summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp22
-rw-r--r--core/apps/textedit/fileBrowser.h5
-rw-r--r--core/apps/textedit/textedit.cpp2
-rw-r--r--core/apps/textedit/textedit.h3
4 files changed, 23 insertions, 9 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index e103bcb..7a3a703 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -8,12 +8,13 @@
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#define QTOPIA_INTERNAL_MIMEEXT
14#include "fileBrowser.h" 15#include "fileBrowser.h"
15//#include "inputDialog.h" 16//#include "inputDialog.h"
16 17
17#include <qpe/config.h> 18#include <qpe/config.h>
18#include <qpe/resource.h> 19#include <qpe/resource.h>
19#include <qpe/fileselector.h> 20#include <qpe/fileselector.h>
@@ -40,19 +41,28 @@
40static int u_id = 1; 41static int u_id = 1;
41static int get_unique_id() 42static int get_unique_id()
42{ 43{
43 return u_id++; 44 return u_id++;
44} 45}
45 46
46fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
47 : QDialog( parent, name, modal, fl ) 48 : QDialog( parent, name, modal, fl )
48{ 49{
49 if ( !name ) 50 if ( !name )
50 setName( "fileBrowser" ); 51 setName( "fileBrowser" );
51 setCaption(tr( name ) ); 52 setCaption(tr( name ) );
52 filterStr = filter; 53 mimeType = mimeFilter;
54 MimeType mt( mimeType);
55 if( mt.extension().isEmpty())
56 filterStr = "*";
57 else
58 filterStr = "*."+ mt.extension();
59// qDebug("description "+mt.description());
60// qDebug( "id "+mt.id());
61// qDebug("extension "+mt.extension());
62
53// channel = new QCopChannel( "QPE/fileDialog", this ); 63// channel = new QCopChannel( "QPE/fileDialog", this );
54// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 64// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
55// this, SLOT(receive(const QCString&, const QByteArray&)) ); 65// this, SLOT(receive(const QCString&, const QByteArray&)) );
56 66
57 QGridLayout *layout = new QGridLayout( this ); 67 QGridLayout *layout = new QGridLayout( this );
58 layout->setSpacing( 4 ); 68 layout->setSpacing( 4 );
@@ -76,13 +86,12 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
76 cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); 86 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
77 cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); 87 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
78 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 88 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
79 cdUpButton ->setFlat(TRUE); 89 cdUpButton ->setFlat(TRUE);
80 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); 90 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
81 91
82
83 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 92 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
84 docButton->setMinimumSize( QSize( 20, 20 ) ); 93 docButton->setMinimumSize( QSize( 20, 20 ) );
85 docButton->setMaximumSize( QSize( 20, 20 ) ); 94 docButton->setMaximumSize( QSize( 20, 20 ) );
86 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 95 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
87 docButton->setFlat(TRUE); 96 docButton->setFlat(TRUE);
88 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 97 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
@@ -93,13 +102,12 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
93 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 102 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
94 homeButton->setFlat(TRUE); 103 homeButton->setFlat(TRUE);
95 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); 104 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
96 105
97 FileStack = new QWidgetStack( this ); 106 FileStack = new QWidgetStack( this );
98 107
99
100 ListView = new QListView( this, "ListView" ); 108 ListView = new QListView( this, "ListView" );
101// ListView->setMinimumSize( QSize( 100, 25 ) ); 109// ListView->setMinimumSize( QSize( 100, 25 ) );
102 ListView->addColumn( tr( "Name" ) ); 110 ListView->addColumn( tr( "Name" ) );
103 ListView->setColumnWidth(0,120); 111 ListView->setColumnWidth(0,120);
104 ListView->setSorting( 2, FALSE); 112 ListView->setSorting( 2, FALSE);
105 ListView->addColumn( tr( "Size" ) ); 113 ListView->addColumn( tr( "Size" ) );
@@ -115,13 +123,13 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
115 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 123 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
116 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 124 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
117 125
118 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 126 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
119 127
120 FileStack->addWidget( ListView, get_unique_id() ); 128 FileStack->addWidget( ListView, get_unique_id() );
121mimeType="text/*"; 129
122 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 130 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
123// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 131// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
124// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 132// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
125 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 133 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
126 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 134 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
127 135
@@ -150,12 +158,16 @@ mimeType="text/*";
150} 158}
151 159
152fileBrowser::~fileBrowser() 160fileBrowser::~fileBrowser()
153{ 161{
154} 162}
155 163
164void fileBrowser::setMimeType(const QString &type) {
165 mimeType = type;
166}
167
156void fileBrowser::setFileView( int selection ) 168void fileBrowser::setFileView( int selection )
157{ 169{
158 SelectionCombo->setCurrentItem( selection ); 170 SelectionCombo->setCurrentItem( selection );
159 selectionChanged( SelectionCombo->currentText() ); 171 selectionChanged( SelectionCombo->currentText() );
160} 172}
161 173
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index 77ac166..1138d80 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -49,25 +49,26 @@ class fileBrowser : public QDialog
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 52 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
53 ~fileBrowser(); 53 ~fileBrowser();
54 54
55 QString selectedFileName, mimeType; 55 QString selectedFileName;
56 QFile file; 56 QFile file;
57 QStringList fileList; 57 QStringList fileList;
58 QComboBox *SelectionCombo; 58 QComboBox *SelectionCombo;
59public slots: 59public slots:
60 void setFileView( int ); 60 void setFileView( int );
61 void setMimeType(const QString &);
61 62
62private: 63private:
63// QDict<void> mimes; 64// QDict<void> mimes;
64 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; 65 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton;
65 QListView* ListView; 66 QListView* ListView;
66 QLabel *dirLabel; 67 QLabel *dirLabel;
67 QString filterStr; 68 QString filterStr, mimeType;
68 QDir currentDir; 69 QDir currentDir;
69 QStringList dirPathStringList; 70 QStringList dirPathStringList;
70 QListViewItem * item; 71 QListViewItem * item;
71 QComboBox *dirPathCombo; 72 QComboBox *dirPathCombo;
72 MenuButton *typemb; 73 MenuButton *typemb;
73 QWidgetStack *FileStack; 74 QWidgetStack *FileStack;
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index ecebe12..d28ece8 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -490,13 +490,13 @@ void TextEdit::fileNew()
490 } 490 }
491 newFile(DocLnk()); 491 newFile(DocLnk());
492} 492}
493 493
494void TextEdit::fileOpen() 494void TextEdit::fileOpen()
495{ 495{
496 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); 496 browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "text/*"); //
497 browseForFiles->setFileView( viewSelection ); 497 browseForFiles->setFileView( viewSelection );
498 browseForFiles->showMaximized(); 498 browseForFiles->showMaximized();
499 if( browseForFiles->exec() != -1 ) { 499 if( browseForFiles->exec() != -1 ) {
500 QString selFile = browseForFiles->selectedFileName; 500 QString selFile = browseForFiles->selectedFileName;
501 QStringList fileList = browseForFiles->fileList; 501 QStringList fileList = browseForFiles->fileList;
502 qDebug(selFile); 502 qDebug(selFile);
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 70cf068..af69518 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -49,13 +49,14 @@ class TextEdit : public QMainWindow
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 53 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
54 ~TextEdit(); 54 ~TextEdit();
55 QPopupMenu *font; 55
56 QPopupMenu *font;
56 QAction *nStart; 57 QAction *nStart;
57 bool edited, edited1; 58 bool edited, edited1;
58 void openFile( const QString & ); 59 void openFile( const QString & );
59public slots: 60public slots:
60 void editorChanged(); 61 void editorChanged();
61 62