author | llornkcor <llornkcor> | 2002-03-24 14:17:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-24 14:17:21 (UTC) |
commit | 927d5f33cc4c36541d7fb7dde036bdd22f5d7253 (patch) (unidiff) | |
tree | cd846d8b462131c8c06c2ddf5787171449b8521e | |
parent | 807ea39f3ccfbc26e769fc16a79d459327e13437 (diff) | |
download | opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.zip opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.tar.gz opie-927d5f33cc4c36541d7fb7dde036bdd22f5d7253.tar.bz2 |
changed things in filebrowser
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 237 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 30 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
3 files changed, 220 insertions, 51 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 1fdf9d9..c9366e7 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -20,3 +20,5 @@ | |||
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/menubutton.h> | ||
21 | 22 | ||
23 | #include <qdict.h> | ||
22 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
@@ -31,2 +33,3 @@ | |||
31 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qstringlist.h> | ||
32 | 35 | ||
@@ -49,2 +52,6 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
49 | 52 | ||
53 | // channel = new QCopChannel( "QPE/fileDialog", this ); | ||
54 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
55 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | ||
56 | |||
50 | QGridLayout *layout = new QGridLayout( this ); | 57 | QGridLayout *layout = new QGridLayout( this ); |
@@ -53,22 +60,37 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
53 | 60 | ||
61 | dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); | ||
62 | dirPathCombo->setEditable(TRUE); | ||
63 | |||
64 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | ||
65 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | ||
66 | |||
67 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | ||
68 | this, SLOT( dirPathEditPressed( ) ) ); | ||
69 | |||
70 | dirPathStringList << "/"; | ||
71 | // we can get the storage here | ||
72 | |||
73 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | ||
74 | |||
75 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | ||
76 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | ||
77 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | ||
78 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | ||
79 | cdUpButton ->setFlat(TRUE); | ||
80 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | ||
54 | 81 | ||
55 | dirLabel = new QLabel(this, "DirLabel"); | ||
56 | dirLabel->setText(currentDir.canonicalPath()); | ||
57 | dirLabel->setMinimumSize( QSize( 50, 15 ) ); | ||
58 | dirLabel->setMaximumSize( QSize( 250, 15 ) ); | ||
59 | layout->addWidget( dirLabel, 0, 0 ); | ||
60 | 82 | ||
61 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 83 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
62 | docButton->setMinimumSize( QSize( 25, 25 ) ); | 84 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
63 | docButton->setMaximumSize( QSize( 25, 25 ) ); | 85 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
64 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 86 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
65 | docButton->setFlat(TRUE); | 87 | docButton->setFlat(TRUE); |
66 | layout->addWidget( docButton, 0, 1 ); | 88 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
67 | 89 | ||
68 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 90 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
69 | homeButton->setMinimumSize( QSize( 25, 25 ) ); | 91 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
70 | homeButton->setMaximumSize( QSize( 25, 25 ) ); | 92 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
71 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 93 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
72 | homeButton->setFlat(TRUE); | 94 | homeButton->setFlat(TRUE); |
73 | layout->addWidget( homeButton, 0, 2 ); | 95 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
74 | 96 | ||
@@ -76,2 +98,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
76 | 98 | ||
99 | |||
77 | ListView = new QListView( this, "ListView" ); | 100 | ListView = new QListView( this, "ListView" ); |
@@ -84,3 +107,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
84 | ListView->addColumn( "Date",-1); | 107 | ListView->addColumn( "Date",-1); |
85 | // ListView->addColumn( tr( "" ) ); | 108 | |
86 | ListView->setColumnWidthMode(0,QListView::Manual); | 109 | ListView->setColumnWidthMode(0,QListView::Manual); |
@@ -97,4 +120,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
97 | FileStack->addWidget( ListView, get_unique_id() ); | 120 | FileStack->addWidget( ListView, get_unique_id() ); |
98 | 121 | mimeType="text/*"; | |
99 | fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy | 122 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
100 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 123 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
@@ -102,10 +125,11 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
102 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 125 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
103 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 ); | 126 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
104 | 127 | ||
105 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 128 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
106 | SelectionCombo->setMinimumSize( QSize( 200, 25 ) ); | ||
107 | SelectionCombo->insertItem( tr( "Documents" ) ); | 129 | SelectionCombo->insertItem( tr( "Documents" ) ); |
108 | SelectionCombo->insertItem( tr( "All files" ) ); | 130 | SelectionCombo->insertItem( tr( "All files" ) ); |
109 | SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) ); | 131 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
110 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 ); | 132 | // SelectionCombo->setMaximumWidth(120); |
133 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | ||
134 | |||
111 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 135 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
@@ -113,2 +137,9 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
113 | 137 | ||
138 | typemb = new MenuButton(this); | ||
139 | typemb->setLabel(tr("Type: %1")); | ||
140 | typemb->setMinimumWidth(110); | ||
141 | typemb->setFixedHeight(22); | ||
142 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | ||
143 | updateMimeTypeMenu() ; | ||
144 | |||
114 | currentDir.setPath(QDir::currentDirPath()); | 145 | currentDir.setPath(QDir::currentDirPath()); |
@@ -170,3 +201,3 @@ void fileBrowser::populateList() | |||
170 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 201 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
171 | } | 202 | } |
172 | isDir=FALSE; | 203 | isDir=FALSE; |
@@ -174,5 +205,13 @@ void fileBrowser::populateList() | |||
174 | } | 205 | } |
175 | // ListView->setSorting( 2, FALSE); | ||
176 | ListView->setSorting( 3, FALSE); | 206 | ListView->setSorting( 3, FALSE); |
177 | dirLabel->setText(currentDir.canonicalPath()); | 207 | QString currentPath = currentDir.canonicalPath(); |
208 | |||
209 | fillCombo( (const QString &)currentPath); | ||
210 | // dirPathCombo->lineEdit()->setText(currentPath); | ||
211 | |||
212 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | ||
213 | // dirPathCombo->clear(); | ||
214 | // dirPathStringList.prepend(currentPath ); | ||
215 | // dirPathCombo->insertStringList( dirPathStringList,-1); | ||
216 | // } | ||
178 | } | 217 | } |
@@ -181,3 +220,10 @@ void fileBrowser::upDir() | |||
181 | { | 220 | { |
182 | // qDebug(currentDir.canonicalPath()); | 221 | QString current = currentDir.canonicalPath(); |
222 | QDir dir(current); | ||
223 | dir.cdUp(); | ||
224 | current = dir.canonicalPath(); | ||
225 | chdir( current.latin1() ); | ||
226 | currentDir.cd( current, TRUE); | ||
227 | populateList(); | ||
228 | update(); | ||
183 | } | 229 | } |
@@ -242,6 +288,7 @@ void fileBrowser::OnOK() | |||
242 | void fileBrowser::homeButtonPushed() { | 288 | void fileBrowser::homeButtonPushed() { |
243 | chdir( QDir::homeDirPath().latin1() ); | 289 | QString current = QDir::homeDirPath(); |
244 | currentDir.cd( QDir::homeDirPath(), TRUE); | 290 | chdir( current.latin1() ); |
245 | populateList(); | 291 | currentDir.cd( current, TRUE); |
246 | update(); | 292 | populateList(); |
293 | update(); | ||
247 | } | 294 | } |
@@ -249,6 +296,7 @@ void fileBrowser::homeButtonPushed() { | |||
249 | void fileBrowser::docButtonPushed() { | 296 | void fileBrowser::docButtonPushed() { |
250 | chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); | 297 | QString current = QPEApplication::documentDir(); |
251 | currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); | 298 | chdir( current.latin1() ); |
252 | populateList(); | 299 | currentDir.cd( current, TRUE); |
253 | update(); | 300 | populateList(); |
301 | update(); | ||
254 | 302 | ||
@@ -258,11 +306,9 @@ void fileBrowser::selectionChanged( const QString &select ) | |||
258 | { | 306 | { |
259 | if ( select == "Documents") | 307 | if ( select == "Documents") { |
260 | { | ||
261 | FileStack->raiseWidget( fileSelector ); | 308 | FileStack->raiseWidget( fileSelector ); |
262 | dirLabel->hide(); | 309 | dirPathCombo->hide(); |
310 | cdUpButton->hide(); | ||
263 | docButton->hide(); | 311 | docButton->hide(); |
264 | homeButton->hide(); | 312 | homeButton->hide(); |
265 | } | 313 | } else { |
266 | else | ||
267 | { | ||
268 | if ( select == "All files" ) | 314 | if ( select == "All files" ) |
@@ -274,3 +320,4 @@ void fileBrowser::selectionChanged( const QString &select ) | |||
274 | update(); | 320 | update(); |
275 | dirLabel->show(); | 321 | dirPathCombo->show(); |
322 | cdUpButton->show(); | ||
276 | docButton->show(); | 323 | docButton->show(); |
@@ -305,2 +352,3 @@ void fileBrowser::showListMenu(QListViewItem *item) { | |||
305 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 352 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
353 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); | ||
306 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 354 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
@@ -309,3 +357,3 @@ void fileBrowser::showListMenu(QListViewItem *item) { | |||
309 | m.exec( QCursor::pos() ); | 357 | m.exec( QCursor::pos() ); |
310 | 358 | ||
311 | } | 359 | } |
@@ -354,3 +402,3 @@ void fileBrowser::localDelete() { | |||
354 | break; | 402 | break; |
355 | case 1: | 403 | case 1: |
356 | // exit | 404 | // exit |
@@ -358,3 +406,3 @@ void fileBrowser::localDelete() { | |||
358 | }; | 406 | }; |
359 | 407 | ||
360 | } else { | 408 | } else { |
@@ -369,3 +417,3 @@ void fileBrowser::localDelete() { | |||
369 | break; | 417 | break; |
370 | case 1: | 418 | case 1: |
371 | // exit | 419 | // exit |
@@ -374,2 +422,109 @@ void fileBrowser::localDelete() { | |||
374 | } | 422 | } |
423 | } | ||
424 | |||
425 | void fileBrowser::updateMimeTypeMenu() { | ||
426 | |||
427 | disconnect( typemb, SIGNAL(selected(const QString&)), | ||
428 | this, SLOT(showType(const QString&)) ); | ||
429 | |||
430 | QString prev; | ||
431 | |||
432 | // Type filter | ||
433 | QStringList types; | ||
434 | types << tr("All"); | ||
435 | types << "--"; | ||
436 | types += getMimeTypes(); | ||
437 | prev = typemb->currentText(); | ||
438 | typemb->clear(); | ||
439 | typemb->insertItems(types); | ||
440 | // typemb->select(prev); | ||
441 | |||
442 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | ||
443 | } | ||
444 | |||
445 | void fileBrowser::showType(const QString &t) { | ||
446 | |||
447 | qDebug(t); | ||
448 | mimeType = t+"/*"; | ||
449 | // if(fileSelector) { | ||
450 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | ||
451 | // delete fileSelector; | ||
452 | } | ||
453 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | ||
454 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | ||
455 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | ||
456 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | ||
457 | fileSelector->reread(); | ||
458 | repaint(); | ||
459 | // if ( t == tr("All") ) { | ||
460 | // icons->setTypeFilter("",TRUE); | ||
461 | // } else { | ||
462 | // icons->setTypeFilter(t+"/*",TRUE); | ||
463 | // } | ||
464 | |||
465 | } | ||
466 | |||
467 | QStringList fileBrowser::getMimeTypes() { | ||
468 | QStringList r; | ||
469 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | ||
470 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | ||
471 | file.open( IO_WriteOnly|IO_Truncate);//) | ||
472 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | ||
473 | AppLnk* l; | ||
474 | l = it.current(); | ||
475 | QStringList maj = l->mimeTypes(); | ||
476 | QStringList::ConstIterator f; | ||
477 | for ( f = maj.begin(); f != maj.end(); f++ ) { | ||
478 | QString temp = *f; | ||
479 | int sl = temp.find('/'); | ||
480 | if (sl >= 0) { | ||
481 | QString k = temp.left(sl); | ||
482 | if( r.grep(k,TRUE).isEmpty() ) { | ||
483 | r << k; | ||
484 | k+="\n"; | ||
485 | file.writeBlock( k.latin1(), k.length()); | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | r.sort(); | ||
491 | file.close(); | ||
492 | return r; | ||
493 | } | ||
494 | |||
495 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | ||
496 | // QDataStream stream( data, IO_ReadOnly ); | ||
497 | // if (msg == "keyRegister(int key, QString channel, QString message)") | ||
498 | // { | ||
499 | // int k; | ||
500 | // QString c, m; | ||
501 | // stream >> k; | ||
502 | // stream >> c; | ||
503 | // stream >> m; | ||
504 | } | ||
505 | |||
506 | void fileBrowser::dirPathComboActivated( const QString & current) { | ||
507 | chdir( current.latin1() ); | ||
508 | currentDir.cd( current, TRUE); | ||
509 | populateList(); | ||
510 | update(); | ||
511 | } | ||
512 | |||
513 | void fileBrowser::dirPathEditPressed() { | ||
514 | QString current = dirPathCombo->lineEdit()->text(); | ||
515 | chdir( current.latin1() ); | ||
516 | currentDir.cd( current, TRUE); | ||
517 | populateList(); | ||
518 | update(); | ||
519 | } | ||
520 | |||
521 | void fileBrowser::fillCombo(const QString ¤tPath) { | ||
522 | |||
523 | dirPathCombo->lineEdit()->setText(currentPath); | ||
524 | |||
525 | if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | ||
526 | dirPathCombo->clear(); | ||
527 | dirPathStringList.prepend(currentPath ); | ||
528 | dirPathCombo->insertStringList( dirPathStringList,-1); | ||
529 | } | ||
375 | 530 | ||
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 4f765dd..8a98365 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -24,2 +24,3 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com | |||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qdict.h> | ||
25 | 26 | ||
@@ -37,2 +38,5 @@ class FileSelector; | |||
37 | class QPoint; | 38 | class QPoint; |
39 | class MenuButton; | ||
40 | class QRegExp; | ||
41 | |||
38 | 42 | ||
@@ -49,3 +53,3 @@ public: | |||
49 | 53 | ||
50 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; | 54 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; |
51 | QListView* ListView; | 55 | QListView* ListView; |
@@ -56,9 +60,17 @@ public: | |||
56 | QFile file; | 60 | QFile file; |
57 | QStringList fileList; | 61 | QStringList fileList, dirPathStringList; |
58 | QListViewItem * item; | 62 | QListViewItem * item; |
59 | QComboBox *SelectionCombo; | 63 | QComboBox *SelectionCombo, *dirPathCombo; |
64 | MenuButton *typemb; | ||
60 | QWidgetStack *FileStack; | 65 | QWidgetStack *FileStack; |
61 | FileSelector *fileSelector; | 66 | FileSelector *fileSelector; |
62 | 67 | QString mimeType; | |
63 | public slots: | 68 | public slots: |
69 | |||
70 | private: | ||
71 | // QDict<void> mimes; | ||
72 | QRegExp tf; | ||
73 | QStringList getMimeTypes(); | ||
74 | void fillCombo( const QString&); | ||
75 | private slots: | ||
64 | void homeButtonPushed(); | 76 | void homeButtonPushed(); |
@@ -71,5 +83,4 @@ public slots: | |||
71 | void localDelete(); | 83 | void localDelete(); |
72 | private: | 84 | void receive( const QCString &msg, const QByteArray &data ); |
73 | 85 | void dirPathComboActivated( const QString & ); | |
74 | private slots: | ||
75 | void upDir(); | 86 | void upDir(); |
@@ -79,3 +90,6 @@ private slots: | |||
79 | void docOpen( const DocLnk & ); | 90 | void docOpen( const DocLnk & ); |
80 | 91 | void updateMimeTypeMenu(); | |
92 | void showType(const QString &); | ||
93 | void dirPathEditPressed(); | ||
94 | |||
81 | protected slots: | 95 | protected slots: |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 1a1b186..da74893 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -499,4 +499,4 @@ void TextEdit::fileOpen() | |||
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); |