author | llornkcor <llornkcor> | 2002-04-19 12:09:05 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-19 12:09:05 (UTC) |
commit | 9233f285e5f3366ca5e1d44892e0797d7ef0608c (patch) (unidiff) | |
tree | f4599e33492b04d7d8a9250d662e8bb814313bdf | |
parent | 6ffbfe7daee3b01b8dce2afa9036b70b187a8fc7 (diff) | |
download | opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.zip opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.gz opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.bz2 |
fixed a slight bugy
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 59 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
3 files changed, 77 insertions, 59 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index f322513..fced326 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,102 +1,108 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 | 3 | ** Created: Fri Dec 14 08:16:46 2001 |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
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 | #define QTOPIA_INTERNAL_MIMEEXT |
15 | #include "fileBrowser.h" | 15 | #include "fileBrowser.h" |
16 | //#include "inputDialog.h" | 16 | //#include "inputDialog.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/fileselector.h> | 20 | #include <qpe/fileselector.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/menubutton.h> | 22 | #include <qpe/menubutton.h> |
23 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
24 | 24 | ||
25 | #include <qdict.h> | 25 | #include <qdict.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qcombo.h> | 28 | #include <qcombo.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | 40 | ||
41 | static int u_id = 1; | 41 | static int u_id = 1; |
42 | static int get_unique_id() | 42 | static int get_unique_id() |
43 | { | 43 | { |
44 | return u_id++; | 44 | return u_id++; |
45 | } | 45 | } |
46 | 46 | ||
47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) | 47 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) |
48 | : QDialog( parent, name, modal, fl ) | 48 | : QDialog( parent, name, modal, fl ) |
49 | { | 49 | { |
50 | if ( !name ) | 50 | if ( !name ) |
51 | setName( "fileBrowser" ); | 51 | setName( "fileBrowser" ); |
52 | setCaption(tr( name ) ); | 52 | setCaption(tr( name ) ); |
53 | // mimeType = mimeFilter; | ||
54 | // MimeType mt( mimeType); | ||
55 | // if( mt.extension().isEmpty()) | ||
56 | // QStringList filterList; | ||
57 | // filterList=QStringList::split(";",mimeFilter,FALSE); | ||
58 | // for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
59 | // printf( "%s \n", (*it).latin1() ); | ||
60 | // } | ||
61 | 53 | ||
62 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | 54 | // getMimeTypes(); |
55 | |||
56 | mimeType = mimeFilter; | ||
57 | MimeType mt( mimeType); | ||
58 | |||
59 | if( mt.extension().isEmpty()) { | ||
60 | |||
61 | QStringList filterList; | ||
62 | filterList=QStringList::split(";",mimeFilter,FALSE); | ||
63 | |||
64 | for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { | ||
65 | printf( "%s \n", (*it).latin1() ); | ||
66 | } | ||
67 | |||
68 | filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*"; | ||
63 | 69 | ||
64 | qDebug(filterStr); | 70 | qDebug(filterStr); |
65 | // else | 71 | } else { |
66 | // filterStr = "*."+ mt.extension(); | 72 | filterStr = "*."+ mt.extension(); |
67 | // qDebug("description "+mt.description()); | 73 | // qDebug("description "+mt.description()); |
68 | // qDebug( "id "+mt.id()); | 74 | // qDebug( "id "+mt.id()); |
69 | // qDebug("extension "+mt.extension()); | 75 | // qDebug("extension "+mt.extension()); |
70 | 76 | } | |
71 | // channel = new QCopChannel( "QPE/fileDialog", this ); | 77 | // channel = new QCopChannel( "QPE/fileDialog", this ); |
72 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 78 | // connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
73 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 79 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); |
74 | 80 | ||
75 | QGridLayout *layout = new QGridLayout( this ); | 81 | QGridLayout *layout = new QGridLayout( this ); |
76 | layout->setSpacing( 4 ); | 82 | layout->setSpacing( 4 ); |
77 | layout->setMargin( 4 ); | 83 | layout->setMargin( 4 ); |
78 | 84 | ||
79 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); | 85 | dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); |
80 | dirPathCombo->setEditable(TRUE); | 86 | dirPathCombo->setEditable(TRUE); |
81 | 87 | ||
82 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), | 88 | connect( dirPathCombo, SIGNAL( activated( const QString & ) ), |
83 | this, SLOT( dirPathComboActivated( const QString & ) ) ); | 89 | this, SLOT( dirPathComboActivated( const QString & ) ) ); |
84 | 90 | ||
85 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), | 91 | connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), |
86 | this, SLOT( dirPathEditPressed( ) ) ); | 92 | this, SLOT( dirPathEditPressed( ) ) ); |
87 | 93 | ||
88 | dirPathStringList << "/"; | 94 | dirPathStringList << "/"; |
89 | // we can get the storage here | 95 | // we can get the storage here |
90 | 96 | ||
91 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); | 97 | layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); |
92 | 98 | ||
93 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 99 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
94 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); | 100 | cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); |
95 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); | 101 | cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); |
96 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 102 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
97 | cdUpButton ->setFlat(TRUE); | 103 | cdUpButton ->setFlat(TRUE); |
98 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); | 104 | layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); |
99 | 105 | ||
100 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 106 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
101 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 107 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
102 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 108 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
@@ -205,65 +211,65 @@ void fileBrowser::populateList() | |||
205 | fileL.sprintf( "%s",fi->fileName().data() ); | 211 | fileL.sprintf( "%s",fi->fileName().data() ); |
206 | fileDate= fi->lastModified().toString(); | 212 | fileDate= fi->lastModified().toString(); |
207 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 213 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
208 | fileL+="/"; | 214 | fileL+="/"; |
209 | isDir=TRUE; | 215 | isDir=TRUE; |
210 | // qDebug( fileL); | 216 | // qDebug( fileL); |
211 | } | 217 | } |
212 | } | 218 | } |
213 | if(fileL !="./" && fi->exists()) { | 219 | if(fileL !="./" && fi->exists()) { |
214 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 220 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
215 | QPixmap pm; | 221 | QPixmap pm; |
216 | 222 | ||
217 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 223 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
218 | if( !QDir( fi->filePath() ).isReadable()) | 224 | if( !QDir( fi->filePath() ).isReadable()) |
219 | pm = Resource::loadPixmap( "lockedfolder" ); | 225 | pm = Resource::loadPixmap( "lockedfolder" ); |
220 | else | 226 | else |
221 | pm= Resource::loadPixmap( "folder" ); | 227 | pm= Resource::loadPixmap( "folder" ); |
222 | item->setPixmap( 0,pm ); | 228 | item->setPixmap( 0,pm ); |
223 | } else { | 229 | } else { |
224 | if( !fi->isReadable() ) | 230 | if( !fi->isReadable() ) |
225 | pm = Resource::loadPixmap( "locked" ); | 231 | pm = Resource::loadPixmap( "locked" ); |
226 | else { | 232 | else { |
227 | MimeType mt(fi->filePath()); | 233 | MimeType mt(fi->filePath()); |
228 | pm=mt.pixmap();// sets the pixmap for the mimetype | 234 | pm=mt.pixmap();// sets the pixmap for the mimetype |
229 | if(pm.isNull()) | 235 | if(pm.isNull()) |
230 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 236 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
231 | item->setPixmap( 0,pm); | 237 | item->setPixmap( 0,pm); |
232 | } | 238 | } |
233 | } | 239 | } |
234 | if( fileL.find("->",0,TRUE) != -1) { | 240 | if( fileL.find("->",0,TRUE) != -1) { |
235 | // overlay link image | 241 | // overlay link image |
236 | pm= Resource::loadPixmap( "folder" ); | 242 | pm= Resource::loadPixmap( "folder" ); |
237 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 243 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
238 | QPainter painter( &pm ); | 244 | QPainter painter( &pm ); |
239 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 245 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
240 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 246 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
241 | item->setPixmap( 0, pm); | 247 | item->setPixmap( 0, pm); |
242 | } | 248 | } |
243 | } | 249 | } |
244 | isDir=FALSE; | 250 | isDir=FALSE; |
245 | ++it; | 251 | ++it; |
246 | // } | 252 | // } |
247 | } | 253 | } |
248 | ListView->setSorting( 3, FALSE); | 254 | ListView->setSorting( 3, FALSE); |
249 | QString currentPath = currentDir.canonicalPath(); | 255 | QString currentPath = currentDir.canonicalPath(); |
250 | 256 | ||
251 | fillCombo( (const QString &)currentPath); | 257 | fillCombo( (const QString &)currentPath); |
252 | // dirPathCombo->lineEdit()->setText(currentPath); | 258 | // dirPathCombo->lineEdit()->setText(currentPath); |
253 | 259 | ||
254 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 260 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
255 | // dirPathCombo->clear(); | 261 | // dirPathCombo->clear(); |
256 | // dirPathStringList.prepend(currentPath ); | 262 | // dirPathStringList.prepend(currentPath ); |
257 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 263 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
258 | // } | 264 | // } |
259 | } | 265 | } |
260 | 266 | ||
261 | void fileBrowser::upDir() | 267 | void fileBrowser::upDir() |
262 | { | 268 | { |
263 | QString current = currentDir.canonicalPath(); | 269 | QString current = currentDir.canonicalPath(); |
264 | QDir dir(current); | 270 | QDir dir(current); |
265 | dir.cdUp(); | 271 | dir.cdUp(); |
266 | current = dir.canonicalPath(); | 272 | current = dir.canonicalPath(); |
267 | chdir( current.latin1() ); | 273 | chdir( current.latin1() ); |
268 | currentDir.cd( current, TRUE); | 274 | currentDir.cd( current, TRUE); |
269 | populateList(); | 275 | populateList(); |
@@ -463,122 +469,125 @@ void fileBrowser::localDelete() { | |||
463 | populateList(); | 469 | populateList(); |
464 | } | 470 | } |
465 | break; | 471 | break; |
466 | case 1: | 472 | case 1: |
467 | // exit | 473 | // exit |
468 | break; | 474 | break; |
469 | }; | 475 | }; |
470 | } | 476 | } |
471 | } | 477 | } |
472 | 478 | ||
473 | void fileBrowser::updateMimeTypeMenu() { | 479 | void fileBrowser::updateMimeTypeMenu() { |
474 | 480 | ||
475 | disconnect( typemb, SIGNAL(selected(const QString&)), | 481 | disconnect( typemb, SIGNAL(selected(const QString&)), |
476 | this, SLOT(showType(const QString&)) ); | 482 | this, SLOT(showType(const QString&)) ); |
477 | 483 | ||
478 | QString prev; | 484 | QString prev; |
479 | 485 | ||
480 | // Type filter | 486 | // Type filter |
481 | QStringList types; | 487 | QStringList types; |
482 | types << tr("All"); | 488 | types << tr("All"); |
483 | types << "--"; | 489 | types << "--"; |
484 | types += getMimeTypes(); | 490 | types += getMimeTypes(); |
485 | prev = typemb->currentText(); | 491 | prev = typemb->currentText(); |
486 | typemb->clear(); | 492 | typemb->clear(); |
487 | typemb->insertItems(types); | 493 | typemb->insertItems(types); |
488 | // typemb->select(prev); | 494 | // typemb->select(prev); |
489 | 495 | ||
490 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | 496 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); |
491 | } | 497 | } |
492 | 498 | ||
493 | void fileBrowser::showType(const QString &t) { | 499 | void fileBrowser::showType(const QString &t) { |
494 | 500 | ||
495 | qDebug(t); | 501 | // qDebug("Show type "+t); |
496 | if(t.find("All",0,TRUE) != -1) { | 502 | if(t.find("All",0,TRUE) != -1) { |
497 | filterStr = "*"; | 503 | filterStr = "*"; |
498 | } else { | 504 | } else { |
499 | QStringList list = mimetypes.grep( t,TRUE); | 505 | QStringList list = mimetypes.grep( t,TRUE); |
500 | QString ext; | 506 | QString ext; |
501 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 507 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
502 | mimeType =(*it); | 508 | mimeType =(*it); |
503 | MimeType mt( mimeType); | 509 | MimeType mt(mimeType); |
504 | // qDebug("mime "+mimeType); | 510 | |
505 | // qDebug("description "+mt.description()); | 511 | // qDebug("mime "+mimeType); |
506 | // qDebug( "id "+mt.id()); | 512 | // qDebug("description "+mt.description()); |
507 | // qDebug("extension "+mt.extension()); | 513 | // qDebug( "id "+mt.id()); |
508 | // if( mt.extension().isEmpty()) | 514 | // qDebug("extension "+mt.extension()); |
515 | |||
516 | if( mt.extension().isEmpty()) | ||
509 | filterStr = "*"; | 517 | filterStr = "*"; |
510 | // else | 518 | else |
511 | // filterStr = "*."+ mt.extension()+" "; | 519 | filterStr = "*."+ mt.extension()+" "; |
512 | // printf( "%s \n", (*it).latin1() ); | 520 | // printf( "%s \n", (*it).latin1() ); |
513 | } | 521 | } |
514 | } | 522 | } |
515 | currentDir.setNameFilter(filterStr); | 523 | currentDir.setNameFilter(filterStr); |
516 | 524 | ||
517 | populateList(); | 525 | populateList(); |
518 | update(); | 526 | update(); |
519 | // if(fileSelector) { | 527 | // if(fileSelector) { |
520 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 528 | // disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
521 | // delete fileSelector; | 529 | // delete fileSelector; |
522 | // } | 530 | // } |
523 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 531 | // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
524 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 532 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
525 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 533 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
526 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 534 | // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
527 | // fileSelector->reread(); | 535 | // fileSelector->reread(); |
528 | // if ( t == tr("All") ) { | 536 | // if ( t == tr("All") ) { |
529 | // icons->setTypeFilter("",TRUE); | 537 | // icons->setTypeFilter("",TRUE); |
530 | // } else { | 538 | // } else { |
531 | // icons->setTypeFilter(t+"/*",TRUE); | 539 | // icons->setTypeFilter(t+"/*",TRUE); |
532 | // } | 540 | // } |
533 | 541 | ||
534 | } | 542 | } |
535 | 543 | ||
536 | QStringList fileBrowser::getMimeTypes() { | 544 | QStringList fileBrowser::getMimeTypes() { |
537 | 545 | ||
538 | QStringList r; | 546 | QStringList r; |
539 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); | 547 | AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); |
540 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); | 548 | QFile file( QPEApplication::qpeDir()+"etc/available.mime"); |
541 | file.open( IO_WriteOnly|IO_Truncate);//) | 549 | file.open( IO_WriteOnly|IO_Truncate);//) |
542 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { | 550 | for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { |
543 | AppLnk* l; | 551 | AppLnk* l; |
544 | l = it.current(); | 552 | l = it.current(); |
545 | QStringList maj = l->mimeTypes(); | 553 | QStringList maj = l->mimeTypes(); |
546 | QStringList::ConstIterator f; | 554 | QStringList::ConstIterator f; |
547 | for ( f = maj.begin(); f != maj.end(); f++ ) { | 555 | for ( f = maj.begin(); f != maj.end(); f++ ) { |
548 | QString temp = *f; | 556 | QString temp = *f; |
557 | qDebug("type "+temp); | ||
549 | mimetypes << temp; | 558 | mimetypes << temp; |
550 | int sl = temp.find('/'); | 559 | int sl = temp.find('/'); |
551 | if (sl >= 0) { | 560 | if (sl >= 0) { |
552 | QString k = temp.left(sl); | 561 | QString k = temp;//.left(sl); |
553 | if( r.grep(k,TRUE).isEmpty() ) { | 562 | if( r.grep(k,TRUE).isEmpty() ) { |
554 | r << k; | 563 | r << k; |
555 | k+="\n"; | 564 | k+="\n"; |
556 | file.writeBlock( k.latin1(), k.length()); | 565 | file.writeBlock( k.latin1(), k.length()); |
557 | } | 566 | } |
558 | } | 567 | } |
559 | } | 568 | } |
560 | } | 569 | } |
561 | r.sort(); | 570 | r.sort(); |
562 | file.close(); | 571 | file.close(); |
563 | return r; | 572 | return r; |
564 | } | 573 | } |
565 | 574 | ||
566 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { | 575 | void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { |
567 | // QDataStream stream( data, IO_ReadOnly ); | 576 | // QDataStream stream( data, IO_ReadOnly ); |
568 | // if (msg == "keyRegister(int key, QString channel, QString message)") | 577 | // if (msg == "keyRegister(int key, QString channel, QString message)") |
569 | // { | 578 | // { |
570 | // int k; | 579 | // int k; |
571 | // QString c, m; | 580 | // QString c, m; |
572 | // stream >> k; | 581 | // stream >> k; |
573 | // stream >> c; | 582 | // stream >> c; |
574 | // stream >> m; | 583 | // stream >> m; |
575 | } | 584 | } |
576 | 585 | ||
577 | void fileBrowser::dirPathComboActivated( const QString & current) { | 586 | void fileBrowser::dirPathComboActivated( const QString & current) { |
578 | chdir( current.latin1() ); | 587 | chdir( current.latin1() ); |
579 | currentDir.cd( current, TRUE); | 588 | currentDir.cd( current, TRUE); |
580 | populateList(); | 589 | populateList(); |
581 | update(); | 590 | update(); |
582 | } | 591 | } |
583 | 592 | ||
584 | void fileBrowser::dirPathEditPressed() { | 593 | void fileBrowser::dirPathEditPressed() { |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 18402d4..84888c1 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -472,97 +472,106 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up) | |||
472 | 472 | ||
473 | void TextEdit::setBold(bool y) | 473 | void TextEdit::setBold(bool y) |
474 | { | 474 | { |
475 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
476 | f.setBold(y); | 476 | f.setBold(y); |
477 | editor->setFont(f); | 477 | editor->setFont(f); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::setItalic(bool y) | 480 | void TextEdit::setItalic(bool y) |
481 | { | 481 | { |
482 | QFont f = editor->font(); | 482 | QFont f = editor->font(); |
483 | f.setItalic(y); | 483 | f.setItalic(y); |
484 | editor->setFont(f); | 484 | editor->setFont(f); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TextEdit::setWordWrap(bool y) | 487 | void TextEdit::setWordWrap(bool y) |
488 | { | 488 | { |
489 | bool state = editor->edited(); | 489 | bool state = editor->edited(); |
490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 490 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
491 | editor->setEdited( state ); | 491 | editor->setEdited( state ); |
492 | } | 492 | } |
493 | 493 | ||
494 | void TextEdit::fileNew() | 494 | void TextEdit::fileNew() |
495 | { | 495 | { |
496 | // if( !bFromDocView ) { | 496 | // if( !bFromDocView ) { |
497 | // saveAs(); | 497 | // saveAs(); |
498 | // } | 498 | // } |
499 | newFile(DocLnk()); | 499 | newFile(DocLnk()); |
500 | } | 500 | } |
501 | 501 | ||
502 | void TextEdit::fileOpen() | 502 | void TextEdit::fileOpen() |
503 | { | 503 | { |
504 | QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this ); | 504 | Config cfg("TextEdit"); |
505 | if(!str.isEmpty() ) | 505 | cfg.setGroup("View"); |
506 | openFile( str ); | 506 | bool b=FALSE; |
507 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // | 507 | if(cfg.readEntry("useOldFileDialog") == "TRUE") |
508 | // browseForFiles->setFileView( viewSelection ); | 508 | b=TRUE; |
509 | // browseForFiles->showMaximized(); | 509 | if(!b) { |
510 | // // if( result != -1 ) | 510 | QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); |
511 | 511 | if(!str.isEmpty() ) | |
512 | // if( browseForFiles->exec() != -1 ) { | 512 | openFile( str ); |
513 | // QString selFile = browseForFiles->selectedFileName; | 513 | } else { |
514 | // QStringList fileList = browseForFiles->fileList; | 514 | QString str; |
515 | // qDebug(selFile); | 515 | browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // |
516 | // QStringList::ConstIterator f; | 516 | browseForFiles->setFileView( viewSelection ); |
517 | // QString fileTemp; | 517 | browseForFiles->showMaximized(); |
518 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 518 | // if( result != -1 ) |
519 | // fileTemp = *f; | 519 | |
520 | // fileTemp.right( fileTemp.length()-5); | 520 | if( browseForFiles->exec() != -1 ) { |
521 | // QString fileName = fileTemp; | 521 | QString selFile = browseForFiles->selectedFileName; |
522 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 522 | QStringList fileList = browseForFiles->fileList; |
523 | // currentFileName = fileName; | 523 | qDebug(selFile); |
524 | // qDebug("please open "+currentFileName); | 524 | QStringList::ConstIterator f; |
525 | // openFile(str ); | 525 | QString fileTemp; |
526 | // } | 526 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
527 | // } | 527 | fileTemp = *f; |
528 | // viewSelection = browseForFiles->SelectionCombo->currentItem(); | 528 | fileTemp.right( fileTemp.length()-5); |
529 | // } | 529 | QString fileName = fileTemp; |
530 | // delete browseForFiles; | 530 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
531 | // editor->setEdited( FALSE); | 531 | currentFileName = fileName; |
532 | // edited1=FALSE; | 532 | qDebug("please open "+currentFileName); |
533 | // edited=FALSE; | 533 | openFile(str ); |
534 | // if(caption().left(1)=="*") | 534 | } |
535 | // setCaption(caption().right(caption().length()-1)); | 535 | } |
536 | // doSearchBar(); | 536 | viewSelection = browseForFiles->SelectionCombo->currentItem(); |
537 | } | ||
538 | delete browseForFiles; | ||
539 | editor->setEdited( FALSE); | ||
540 | edited1=FALSE; | ||
541 | edited=FALSE; | ||
542 | if(caption().left(1)=="*") | ||
543 | setCaption(caption().right(caption().length()-1)); | ||
544 | doSearchBar(); | ||
545 | } | ||
537 | } | 546 | } |
538 | 547 | ||
539 | void TextEdit::doSearchBar() | 548 | void TextEdit::doSearchBar() |
540 | { | 549 | { |
541 | Config cfg("TextEdit"); | 550 | Config cfg("TextEdit"); |
542 | cfg.setGroup("View"); | 551 | cfg.setGroup("View"); |
543 | if(cfg.readEntry("SearchBar","Closed") != "Opened") | 552 | if(cfg.readEntry("SearchBar","Closed") != "Opened") |
544 | searchBar->hide(); | 553 | searchBar->hide(); |
545 | } | 554 | } |
546 | 555 | ||
547 | #if 0 | 556 | #if 0 |
548 | void TextEdit::slotFind() | 557 | void TextEdit::slotFind() |
549 | { | 558 | { |
550 | FindDialog frmFind( tr("Text Editor"), this ); | 559 | FindDialog frmFind( tr("Text Editor"), this ); |
551 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 560 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
552 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 561 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
553 | 562 | ||
554 | //case sensitive, backwards, [category] | 563 | //case sensitive, backwards, [category] |
555 | 564 | ||
556 | connect( editor, SIGNAL(notFound()), | 565 | connect( editor, SIGNAL(notFound()), |
557 | &frmFind, SLOT(slotNotFound()) ); | 566 | &frmFind, SLOT(slotNotFound()) ); |
558 | connect( editor, SIGNAL(searchWrapped()), | 567 | connect( editor, SIGNAL(searchWrapped()), |
559 | &frmFind, SLOT(slotWrapAround()) ); | 568 | &frmFind, SLOT(slotWrapAround()) ); |
560 | 569 | ||
561 | frmFind.exec(); | 570 | frmFind.exec(); |
562 | 571 | ||
563 | 572 | ||
564 | } | 573 | } |
565 | #endif | 574 | #endif |
566 | 575 | ||
567 | void TextEdit::fileRevert() | 576 | void TextEdit::fileRevert() |
568 | { | 577 | { |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 61fa2a0..edc6fe3 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -28,65 +28,65 @@ | |||
28 | #include "fileSaver.h" | 28 | #include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <opie/ofileselector.h> | 33 | #include <opie/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | 50 | ||
51 | class TextEdit : public QMainWindow | 51 | class TextEdit : public QMainWindow |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 57 | ~TextEdit(); |
58 | 58 | ||
59 | QPopupMenu *font; | 59 | QPopupMenu *font; |
60 | QAction *nStart; | 60 | QAction *nStart, *nFileDlgOpt; |
61 | bool edited, edited1; | 61 | bool edited, edited1; |
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |
65 | void editorChanged(); | 65 | void editorChanged(); |
66 | void receive(const QCString&, const QByteArray&); | 66 | void receive(const QCString&, const QByteArray&); |
67 | protected: | 67 | protected: |
68 | void closeEvent( QCloseEvent *e ); | 68 | void closeEvent( QCloseEvent *e ); |
69 | void doSearchBar(); | 69 | void doSearchBar(); |
70 | private slots: | 70 | private slots: |
71 | void setDocument(const QString&); | 71 | void setDocument(const QString&); |
72 | void changeFont(); | 72 | void changeFont(); |
73 | void fileNew(); | 73 | void fileNew(); |
74 | void fileRevert(); | 74 | void fileRevert(); |
75 | void fileOpen(); | 75 | void fileOpen(); |
76 | void changeStartConfig(bool); | 76 | void changeStartConfig(bool); |
77 | bool save(); | 77 | bool save(); |
78 | bool saveAs(); | 78 | bool saveAs(); |
79 | void cleanUp(); | 79 | void cleanUp(); |
80 | 80 | ||
81 | 81 | ||
82 | void editCut(); | 82 | void editCut(); |
83 | void editCopy(); | 83 | void editCopy(); |
84 | void editPaste(); | 84 | void editPaste(); |
85 | void editFind(); | 85 | void editFind(); |
86 | void editDelete(); | 86 | void editDelete(); |
87 | 87 | ||
88 | void findNext(); | 88 | void findNext(); |
89 | void findClose(); | 89 | void findClose(); |
90 | 90 | ||
91 | void search(); | 91 | void search(); |
92 | void accept(); | 92 | void accept(); |