author | zecke <zecke> | 2002-06-26 20:41:06 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-26 20:41:06 (UTC) |
commit | a078163b38383870dd5a659c1f0964e1238867b3 (patch) (unidiff) | |
tree | 68a517f1adc23cc0fa70b979fe772bcaa53790ab /libopie | |
parent | c229565c40d478555a9ed0aa4910b9ab8181884c (diff) | |
download | opie-a078163b38383870dd5a659c1f0964e1238867b3.zip opie-a078163b38383870dd5a659c1f0964e1238867b3.tar.gz opie-a078163b38383870dd5a659c1f0964e1238867b3.tar.bz2 |
OFileSelector is now a complete drop in replacement
of the QPE fileselector
-rw-r--r-- | libopie/ofileselector.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 98290e0..824acf2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -64,158 +64,160 @@ namespace { | |||
64 | return mLocked; | 64 | return mLocked; |
65 | } | 65 | } |
66 | QString directory()const{ | 66 | QString directory()const{ |
67 | return m_dir; | 67 | return m_dir; |
68 | } | 68 | } |
69 | bool isDir()const{ | 69 | bool isDir()const{ |
70 | return dir; | 70 | return dir; |
71 | } | 71 | } |
72 | QString path()const{ | 72 | QString path()const{ |
73 | return text(1 ); | 73 | return text(1 ); |
74 | } | 74 | } |
75 | QString key(int id, bool )const { | 75 | QString key(int id, bool )const { |
76 | QString ke; | 76 | QString ke; |
77 | if( id == 0 || id == 1 ){ // name | 77 | if( id == 0 || id == 1 ){ // name |
78 | if( dir ){ | 78 | if( dir ){ |
79 | ke.append("0" ); | 79 | ke.append("0" ); |
80 | ke.append( text(1) ); | 80 | ke.append( text(1) ); |
81 | }else{ | 81 | }else{ |
82 | ke.append("1" ); | 82 | ke.append("1" ); |
83 | ke.append( text(1) ); | 83 | ke.append( text(1) ); |
84 | } | 84 | } |
85 | }else if( id == 2 ){ // size | 85 | }else if( id == 2 ){ // size |
86 | return text(2); | 86 | return text(2); |
87 | }else if( id == 3 ){ // date | 87 | }else if( id == 3 ){ // date |
88 | return text(3); | 88 | return text(3); |
89 | } | 89 | } |
90 | return ke; | 90 | return ke; |
91 | }; | 91 | }; |
92 | private: | 92 | private: |
93 | bool mLocked:1; | 93 | bool mLocked:1; |
94 | bool dir:1; | 94 | bool dir:1; |
95 | QString m_dir; | 95 | QString m_dir; |
96 | }; | 96 | }; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
101 | const QString &dirName, | 101 | const QString &dirName, |
102 | const QString &fileName, | 102 | const QString &fileName, |
103 | const QMap<QString,QStringList>& mimeTypes) | 103 | const QMap<QString,QStringList>& mimeTypes) |
104 | : QWidget( wid, "OFileSelector") | 104 | : QWidget( wid, "OFileSelector") |
105 | { | 105 | { |
106 | m_mimetypes = mimeTypes; | 106 | m_mimetypes = mimeTypes; |
107 | if (mode == SAVE ) | 107 | if (mode == SAVE ) |
108 | m_name = fileName; | 108 | m_name = fileName; |
109 | initVars(); | 109 | initVars(); |
110 | m_mode = mode; | 110 | m_mode = mode; |
111 | m_selector = selector; | 111 | m_selector = selector; |
112 | m_currentDir = dirName; | 112 | m_currentDir = dirName; |
113 | init(); | 113 | init(); |
114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | 114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); |
115 | } | 115 | } |
116 | 116 | ||
117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
118 | const char *name, bool newVisible, | 118 | const char *name, bool newVisible, |
119 | bool closeVisible ) | 119 | bool closeVisible ) |
120 | : QWidget( parent, name ) | 120 | : QWidget( parent, name ) |
121 | { | 121 | { |
122 | if (!mimeFilter.isEmpty() ) { | 122 | if (!mimeFilter.isEmpty() ) { |
123 | QStringList list = QStringList::split(";", mimeFilter ); | 123 | QStringList list = QStringList::split(";", mimeFilter ); |
124 | m_mimetypes.insert(mimeFilter, list ); | 124 | m_mimetypes.insert(mimeFilter, list ); |
125 | } | 125 | } |
126 | initVars(); | 126 | initVars(); |
127 | m_currentDir = QPEApplication::documentDir(); | 127 | m_currentDir = QPEApplication::documentDir(); |
128 | m_mode = OPEN; | 128 | m_mode = FILESELECTOR; |
129 | m_selector = NORMAL; | 129 | m_selector = NORMAL; |
130 | m_shClose = closeVisible; | 130 | m_shClose = closeVisible; |
131 | m_shNew = newVisible; | 131 | m_shNew = newVisible; |
132 | m_shLne = false; | 132 | m_shLne = false; |
133 | m_shPerm = false; | 133 | m_shPerm = false; |
134 | m_shYesNo = false; | 134 | m_shYesNo = false; |
135 | init(); | 135 | init(); |
136 | 136 | ||
137 | 137 | ||
138 | } | 138 | } |
139 | 139 | ||
140 | OFileSelector::~OFileSelector() | 140 | OFileSelector::~OFileSelector() |
141 | { | 141 | { |
142 | 142 | ||
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void OFileSelector::setNewVisible( bool visible ) | 146 | void OFileSelector::setNewVisible( bool visible ) |
147 | { | 147 | { |
148 | m_shNew = visible; | 148 | m_shNew = visible; |
149 | if( m_selector == NORMAL ){ | 149 | if( m_selector == NORMAL ){ |
150 | delete m_select; | 150 | delete m_select; |
151 | // we need to initialize but keep the selected mimetype | 151 | // we need to initialize but keep the selected mimetype |
152 | QString mime = currentMimeType(); | 152 | QString mime = currentMimeType(); |
153 | m_select = new FileSelector( mime , | 153 | m_select = new FileSelector( mime , |
154 | m_stack, "fileselector", | 154 | m_stack, "fileselector", |
155 | m_shNew, m_shClose); | 155 | m_shNew, m_shClose); |
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
158 | connect(m_select, SIGNAL(closeMe() ), | ||
159 | this, SIGNAL(closeMe() ) ); | ||
158 | //connect to close me and other signals as well | 160 | //connect to close me and other signals as well |
159 | m_stack->addWidget( m_select, NORMAL ); | 161 | m_stack->addWidget( m_select, NORMAL ); |
160 | }else{ | 162 | }else{ |
161 | m_new->show(); | 163 | m_new->show(); |
162 | } | 164 | } |
163 | } | 165 | } |
164 | void OFileSelector::setCloseVisible( bool visible ) | 166 | void OFileSelector::setCloseVisible( bool visible ) |
165 | { | 167 | { |
166 | m_shClose = visible; | 168 | m_shClose = visible; |
167 | if( m_selector == NORMAL ){ | 169 | if( m_selector == NORMAL ){ |
168 | setNewVisible( m_shNew ); // yeah baby | 170 | setNewVisible( m_shNew ); // yeah baby |
169 | }else{ | 171 | }else{ |
170 | m_close->show(); | 172 | m_close->show(); |
171 | } | 173 | } |
172 | } | 174 | } |
173 | void OFileSelector::reread() | 175 | void OFileSelector::reread() |
174 | { | 176 | { |
175 | if( m_selector == NORMAL ){ | 177 | if( m_selector == NORMAL ){ |
176 | setNewVisible( m_shNew ); // make it a initializeSelector | 178 | setNewVisible( m_shNew ); // make it a initializeSelector |
177 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
178 | reparse(); | 180 | reparse(); |
179 | //}else{ | 181 | //}else{ |
180 | //; | 182 | //; |
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | const DocLnk *OFileSelector::selected() | 186 | const DocLnk *OFileSelector::selected() |
185 | { | 187 | { |
186 | if( m_selector == NORMAL ){ | 188 | if( m_selector == NORMAL ){ |
187 | return m_select->selected(); | 189 | return m_select->selected(); |
188 | }else{ | 190 | }else{ |
189 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 191 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
190 | return lnk; | 192 | return lnk; |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | void OFileSelector::setYesCancelVisible( bool show ) | 196 | void OFileSelector::setYesCancelVisible( bool show ) |
195 | { | 197 | { |
196 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 198 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
197 | m_shYesNo = show; | 199 | m_shYesNo = show; |
198 | if( m_shYesNo ) | 200 | if( m_shYesNo ) |
199 | m_boxOk->show(); | 201 | m_boxOk->show(); |
200 | else | 202 | else |
201 | m_boxOk->hide(); | 203 | m_boxOk->hide(); |
202 | 204 | ||
203 | } | 205 | } |
204 | void OFileSelector::setToolbarVisible( bool show ) | 206 | void OFileSelector::setToolbarVisible( bool show ) |
205 | { | 207 | { |
206 | m_shTool = show; | 208 | m_shTool = show; |
207 | initializeListView(); // FIXME see above waste of memory | 209 | initializeListView(); // FIXME see above waste of memory |
208 | if(!m_shTool ){ | 210 | if(!m_shTool ){ |
209 | m_location->hide(); | 211 | m_location->hide(); |
210 | m_up->hide(); | 212 | m_up->hide(); |
211 | m_homeButton->hide(); | 213 | m_homeButton->hide(); |
212 | m_docButton->hide(); | 214 | m_docButton->hide(); |
213 | }else{ | 215 | }else{ |
214 | m_location->show(); | 216 | m_location->show(); |
215 | m_up->show(); | 217 | m_up->show(); |
216 | m_homeButton->show(); | 218 | m_homeButton->show(); |
217 | m_docButton->show(); | 219 | m_docButton->show(); |
218 | } | 220 | } |
219 | } | 221 | } |
220 | void OFileSelector::setPermissionBarVisible( bool show ) | 222 | void OFileSelector::setPermissionBarVisible( bool show ) |
221 | { | 223 | { |
@@ -374,257 +376,263 @@ QString OFileSelector::directory()const | |||
374 | return QDir(m_currentDir).absPath(); | 376 | return QDir(m_currentDir).absPath(); |
375 | } | 377 | } |
376 | 378 | ||
377 | int OFileSelector::fileCount() | 379 | int OFileSelector::fileCount() |
378 | { | 380 | { |
379 | int count; | 381 | int count; |
380 | switch( m_selector ){ | 382 | switch( m_selector ){ |
381 | case NORMAL: | 383 | case NORMAL: |
382 | count = m_select->fileCount(); | 384 | count = m_select->fileCount(); |
383 | break; | 385 | break; |
384 | //case CUSTOM: | 386 | //case CUSTOM: |
385 | case EXTENDED: | 387 | case EXTENDED: |
386 | case EXTENDED_ALL: | 388 | case EXTENDED_ALL: |
387 | default: | 389 | default: |
388 | count = m_View->childCount(); | 390 | count = m_View->childCount(); |
389 | break; | 391 | break; |
390 | } | 392 | } |
391 | return count; | 393 | return count; |
392 | } | 394 | } |
393 | DocLnk OFileSelector::selectedDocument() const | 395 | DocLnk OFileSelector::selectedDocument() const |
394 | { | 396 | { |
395 | DocLnk lnk; | 397 | DocLnk lnk; |
396 | switch( m_selector ){ | 398 | switch( m_selector ){ |
397 | case NORMAL:{ | 399 | case NORMAL:{ |
398 | const DocLnk *lnk2 = m_select->selected(); | 400 | const DocLnk *lnk2 = m_select->selected(); |
399 | lnk = DocLnk(*lnk2 ); // copy | 401 | lnk = DocLnk(*lnk2 ); // copy |
400 | delete lnk2; | 402 | delete lnk2; |
401 | break; | 403 | break; |
402 | } | 404 | } |
403 | case EXTENDED: | 405 | case EXTENDED: |
404 | case EXTENDED_ALL: | 406 | case EXTENDED_ALL: |
405 | default: | 407 | default: |
406 | lnk = DocLnk( selectedName() ); // new DocLnk | 408 | lnk = DocLnk( selectedName() ); // new DocLnk |
407 | break; | 409 | break; |
408 | } | 410 | } |
409 | return lnk; | 411 | return lnk; |
410 | } | 412 | } |
411 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 413 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
412 | { | 414 | { |
413 | QValueList<DocLnk> docs; | 415 | QValueList<DocLnk> docs; |
414 | docs.append( selectedDocument() ); | 416 | docs.append( selectedDocument() ); |
415 | return docs; | 417 | return docs; |
416 | } | 418 | } |
417 | 419 | ||
418 | 420 | ||
419 | // slots internal | 421 | // slots internal |
420 | 422 | ||
421 | void OFileSelector::slotOk() | 423 | void OFileSelector::slotOk() |
422 | { | 424 | { |
423 | emit ok(); | 425 | emit ok(); |
424 | } | 426 | } |
425 | void OFileSelector::slotCancel() | 427 | void OFileSelector::slotCancel() |
426 | { | 428 | { |
427 | emit cancel(); | 429 | emit cancel(); |
428 | } | 430 | } |
429 | void OFileSelector::slotViewCheck(const QString &sel) | 431 | void OFileSelector::slotViewCheck(const QString &sel) |
430 | { | 432 | { |
431 | if( sel == tr("Documents" ) ){ | 433 | if( sel == tr("Documents" ) ){ |
432 | if( m_select == 0 ){ | 434 | if( m_select == 0 ){ |
433 | // autMime? fix cause now we use All and not the current | 435 | // autMime? fix cause now we use All and not the current |
434 | // yes currentMime fixes that for us | 436 | // yes currentMime fixes that for us |
435 | QString mime = currentMimeType(); | 437 | QString mime = currentMimeType(); |
436 | m_select = new FileSelector(mime, | 438 | m_select = new FileSelector(mime, |
437 | m_stack, "fileselector", | 439 | m_stack, "fileselector", |
438 | FALSE, FALSE); | 440 | m_shNew, m_shClose); |
439 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 441 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
440 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 442 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
443 | connect(m_select, SIGNAL(closeMe() ), | ||
444 | this, SIGNAL(closeMe() ) ); | ||
441 | //connect to close me and other signals as well | 445 | //connect to close me and other signals as well |
442 | 446 | ||
443 | m_stack->addWidget( m_select, NORMAL ); | 447 | m_stack->addWidget( m_select, NORMAL ); |
444 | } | 448 | } |
445 | m_stack->raiseWidget( NORMAL ); | 449 | m_stack->raiseWidget( NORMAL ); |
446 | m_selector = NORMAL; | 450 | m_selector = NORMAL; |
447 | }else if( sel == tr("Files") ){ | 451 | }else if( sel == tr("Files") ){ |
448 | m_selector = EXTENDED; | 452 | m_selector = EXTENDED; |
449 | initializeListView(); | 453 | initializeListView(); |
450 | reparse(); | 454 | reparse(); |
451 | m_stack->raiseWidget( EXTENDED ); | 455 | m_stack->raiseWidget( EXTENDED ); |
452 | }else if( sel == tr("All Files") ){ | 456 | }else if( sel == tr("All Files") ){ |
453 | m_selector = EXTENDED_ALL; | 457 | m_selector = EXTENDED_ALL; |
454 | initializeListView(); | 458 | initializeListView(); |
455 | reparse(); | 459 | reparse(); |
456 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | 460 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter |
457 | } | 461 | } |
458 | } | 462 | } |
459 | // not yet finished..... | 463 | // not yet finished..... |
460 | QString OFileSelector::currentMimeType() const{ | 464 | QString OFileSelector::currentMimeType() const{ |
461 | QString mime; | 465 | QString mime; |
462 | QString currentText; | 466 | QString currentText; |
463 | if (m_shChooser ) | 467 | if (m_shChooser ) |
464 | currentText = m_mimeCheck->currentText(); | 468 | currentText = m_mimeCheck->currentText(); |
465 | 469 | ||
466 | if (tr("All") == currentText ) return QString::null; | 470 | if (tr("All") == currentText ) return QString::null; |
467 | else if (currentText.isEmpty() ) { | 471 | else if (currentText.isEmpty() ) { |
468 | ; | 472 | ; |
469 | }else { | 473 | }else { |
470 | QMap<QString, QStringList>::ConstIterator it; | 474 | QMap<QString, QStringList>::ConstIterator it; |
471 | it = m_mimetypes.find( currentText ); | 475 | it = m_mimetypes.find( currentText ); |
472 | if ( it == m_mimetypes.end() ) { | 476 | if ( it == m_mimetypes.end() ) { |
473 | mime = it.data().join(";"); | 477 | mime = it.data().join(";"); |
474 | }else{ | 478 | }else{ |
475 | mime = currentText; | 479 | mime = currentText; |
476 | } | 480 | } |
477 | } | 481 | } |
478 | return mime; | 482 | return mime; |
479 | } | 483 | } |
480 | void OFileSelector::slotMimeCheck(const QString &mime) | 484 | void OFileSelector::slotMimeCheck(const QString &mime) |
481 | { | 485 | { |
482 | if( m_selector == NORMAL ){ | 486 | if( m_selector == NORMAL ){ |
483 | //if( m_autoMime ){ | 487 | //if( m_autoMime ){ |
484 | QString newMimeType; | 488 | QString newMimeType; |
485 | if (mime != tr("All") ) { | 489 | if (mime != tr("All") ) { |
486 | QMap<QString, QStringList>::Iterator it; | 490 | QMap<QString, QStringList>::Iterator it; |
487 | it = m_mimetypes.find(mime); | 491 | it = m_mimetypes.find(mime); |
488 | if ( it != m_mimetypes.end() ) { | 492 | if ( it != m_mimetypes.end() ) { |
489 | newMimeType = it.data().join(";"); | 493 | newMimeType = it.data().join(";"); |
490 | }else{ | 494 | }else{ |
491 | newMimeType = mime; | 495 | newMimeType = mime; |
492 | } | 496 | } |
493 | } | 497 | } |
494 | delete m_select; | 498 | delete m_select; |
495 | m_select = new FileSelector( newMimeType, | 499 | m_select = new FileSelector( newMimeType, |
496 | m_stack, "fileselector", | 500 | m_stack, "fileselector", |
497 | FALSE, FALSE); | 501 | m_shNew, m_shClose); |
498 | 502 | ||
499 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 503 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
500 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 504 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
505 | connect(m_select, SIGNAL(closeMe() ), | ||
506 | this, SIGNAL(closeMe() ) ); | ||
501 | //connect to close me and other signals as well | 507 | //connect to close me and other signals as well |
502 | m_stack->addWidget( m_select, NORMAL ); | 508 | m_stack->addWidget( m_select, NORMAL ); |
503 | m_stack->raiseWidget( NORMAL ); | 509 | m_stack->raiseWidget( NORMAL ); |
504 | updateMimes(); | 510 | updateMimes(); |
505 | updateMimeCheck(); | 511 | updateMimeCheck(); |
506 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 512 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
507 | //} | 513 | //} |
508 | }else{ // others | 514 | }else{ // others |
509 | qWarning("Mime %s", mime.latin1() ); | 515 | qWarning("Mime %s", mime.latin1() ); |
510 | if(m_shChooser ){ | 516 | if(m_shChooser ){ |
511 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 517 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
512 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 518 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
513 | } | 519 | } |
514 | reparse(); | 520 | reparse(); |
515 | } | 521 | } |
516 | 522 | ||
517 | } | 523 | } |
518 | void OFileSelector::slotLocationActivated(const QString &file) | 524 | void OFileSelector::slotLocationActivated(const QString &file) |
519 | { | 525 | { |
520 | cd(file.left(file.find("<-",0,TRUE))); | 526 | cd(file.left(file.find("<-",0,TRUE))); |
521 | reparse(); | 527 | reparse(); |
522 | } | 528 | } |
523 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 529 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
524 | { | 530 | { |
525 | QStringList pathList; | 531 | QStringList pathList; |
526 | bool underDog = FALSE; | 532 | bool underDog = FALSE; |
527 | for(int i=0;i<count;i++) { | 533 | for(int i=0;i<count;i++) { |
528 | pathList << m_location->text(i); | 534 | pathList << m_location->text(i); |
529 | if( m_location->text(i) == currentPath) | 535 | if( m_location->text(i) == currentPath) |
530 | underDog = TRUE; | 536 | underDog = TRUE; |
531 | } | 537 | } |
532 | if( !underDog) { | 538 | if( !underDog) { |
533 | m_location->clear(); | 539 | m_location->clear(); |
534 | if( currentPath.left(2)=="//") | 540 | if( currentPath.left(2)=="//") |
535 | pathList.append( currentPath.right(currentPath.length()-1) ); | 541 | pathList.append( currentPath.right(currentPath.length()-1) ); |
536 | else | 542 | else |
537 | pathList.append( currentPath ); | 543 | pathList.append( currentPath ); |
538 | m_location->insertStringList( pathList,-1); | 544 | m_location->insertStringList( pathList,-1); |
539 | } | 545 | } |
540 | } | 546 | } |
541 | void OFileSelector::locationComboChanged() | 547 | void OFileSelector::locationComboChanged() |
542 | { | 548 | { |
543 | cd( m_location->lineEdit()->text()); | 549 | cd( m_location->lineEdit()->text()); |
544 | reparse(); | 550 | reparse(); |
545 | } | 551 | } |
546 | void OFileSelector::init() | 552 | void OFileSelector::init() |
547 | { | 553 | { |
548 | m_lay = new QVBoxLayout( this ); | 554 | m_lay = new QVBoxLayout( this ); |
549 | m_lay->setSpacing(0 ); | 555 | m_lay->setSpacing(0 ); |
550 | 556 | ||
551 | m_stack = new QWidgetStack( this ); | 557 | m_stack = new QWidgetStack( this ); |
552 | if( m_selector == NORMAL ){ | 558 | if( m_selector == NORMAL ){ |
553 | QString mime; | 559 | QString mime; |
554 | if (!m_autoMime) { | 560 | if (!m_autoMime) { |
555 | if (!m_mimetypes.isEmpty() ) { | 561 | if (!m_mimetypes.isEmpty() ) { |
556 | QMap<QString, QStringList>::Iterator it; | 562 | QMap<QString, QStringList>::Iterator it; |
557 | it = m_mimetypes.begin(); // cause we're in the init | 563 | it = m_mimetypes.begin(); // cause we're in the init |
558 | mime = it.data().join(";"); | 564 | mime = it.data().join(";"); |
559 | } | 565 | } |
560 | } | 566 | } |
561 | m_select = new FileSelector(mime, | 567 | m_select = new FileSelector(mime, |
562 | m_stack, "fileselector", | 568 | m_stack, "fileselector", |
563 | FALSE, FALSE); | 569 | m_shNew, m_shClose); |
564 | 570 | ||
565 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 571 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
566 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 572 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
573 | connect(m_select, SIGNAL(closeMe() ), | ||
574 | this, SIGNAL( closeMe() ) ); | ||
567 | //connect to close me and other signals as well | 575 | //connect to close me and other signals as well |
568 | 576 | ||
569 | m_stack->addWidget( m_select, NORMAL ); | 577 | m_stack->addWidget( m_select, NORMAL ); |
570 | m_stack->raiseWidget( NORMAL ); | 578 | m_stack->raiseWidget( NORMAL ); |
571 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | 579 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL |
572 | // and initializeListview will take care of those | 580 | // and initializeListview will take care of those |
573 | // toolbar get's generade in initializeListView | 581 | // toolbar get's generade in initializeListView |
574 | initializeListView( ); // will raise the widget as well | 582 | initializeListView( ); // will raise the widget as well |
575 | m_stack->raiseWidget( EXTENDED ); | 583 | m_stack->raiseWidget( EXTENDED ); |
576 | } | 584 | } |
577 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | 585 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch |
578 | 586 | ||
579 | if( m_shLne ) // the LineEdit with the current FileName | 587 | if( m_shLne ) // the LineEdit with the current FileName |
580 | initializeName(); | 588 | initializeName(); |
581 | 589 | ||
582 | if( m_shPerm ) // the Permission QCheckBox | 590 | if( m_shPerm ) // the Permission QCheckBox |
583 | initializePerm(); | 591 | initializePerm(); |
584 | 592 | ||
585 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 593 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
586 | initializeChooser(); | 594 | initializeChooser(); |
587 | 595 | ||
588 | if( m_shYesNo ) // the Yes No button row | 596 | if( m_shYesNo ) // the Yes No button row |
589 | initializeYes( ); | 597 | initializeYes( ); |
590 | 598 | ||
591 | if (m_selector != NORMAL ) | 599 | if (m_selector != NORMAL ) |
592 | reparse(); | 600 | reparse(); |
593 | } | 601 | } |
594 | void OFileSelector::updateMimes() | 602 | void OFileSelector::updateMimes() |
595 | { | 603 | { |
596 | if( m_autoMime ){ | 604 | if( m_autoMime ){ |
597 | m_mimetypes.clear(); | 605 | m_mimetypes.clear(); |
598 | m_mimetypes.insert( tr("All"), QString::null ); | 606 | m_mimetypes.insert( tr("All"), QString::null ); |
599 | if( m_selector == NORMAL ){ | 607 | if( m_selector == NORMAL ){ |
600 | DocLnkSet set; | 608 | DocLnkSet set; |
601 | Global::findDocuments(&set, QString::null ); | 609 | Global::findDocuments(&set, QString::null ); |
602 | QListIterator<DocLnk> dit( set.children() ); | 610 | QListIterator<DocLnk> dit( set.children() ); |
603 | for( ; dit.current(); ++dit ){ | 611 | for( ; dit.current(); ++dit ){ |
604 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 612 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
605 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 613 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
606 | } | 614 | } |
607 | }// else done in reparse | 615 | }// else done in reparse |
608 | } | 616 | } |
609 | } | 617 | } |
610 | void OFileSelector::initVars() | 618 | void OFileSelector::initVars() |
611 | { | 619 | { |
612 | if( m_mimetypes.isEmpty() ) | 620 | if( m_mimetypes.isEmpty() ) |
613 | m_autoMime = true; | 621 | m_autoMime = true; |
614 | else | 622 | else |
615 | m_autoMime = false; | 623 | m_autoMime = false; |
616 | m_shClose = false; | 624 | m_shClose = false; |
617 | m_shNew = false; | 625 | m_shNew = false; |
618 | m_shTool = true; | 626 | m_shTool = true; |
619 | m_shPerm = false; | 627 | m_shPerm = false; |
620 | m_shLne = true; | 628 | m_shLne = true; |
621 | m_shChooser = true; | 629 | m_shChooser = true; |
622 | m_shYesNo = true; | 630 | m_shYesNo = true; |
623 | m_case = false; | 631 | m_case = false; |
624 | m_dir = true; | 632 | m_dir = true; |
625 | m_files = true; | 633 | m_files = true; |
626 | m_showPopup = false; | 634 | m_showPopup = false; |
627 | if(m_pixmaps == 0 ) // init the pixmaps | 635 | if(m_pixmaps == 0 ) // init the pixmaps |
628 | initPics(); | 636 | initPics(); |
629 | 637 | ||
630 | // pointers | 638 | // pointers |
@@ -813,130 +821,130 @@ void OFileSelector::initializeListView() | |||
813 | // toolbar | 821 | // toolbar |
814 | m_boxToolbar = new QHBox( m_pseudo ); | 822 | m_boxToolbar = new QHBox( m_pseudo ); |
815 | m_boxToolbar->setSpacing(0 ); // next to each other please | 823 | m_boxToolbar->setSpacing(0 ); // next to each other please |
816 | 824 | ||
817 | // toolbar members | 825 | // toolbar members |
818 | { | 826 | { |
819 | // location QComboBox | 827 | // location QComboBox |
820 | m_location = new QComboBox( m_boxToolbar ); | 828 | m_location = new QComboBox( m_boxToolbar ); |
821 | m_location->setEditable( TRUE ); | 829 | m_location->setEditable( TRUE ); |
822 | m_location->setDuplicatesEnabled( FALSE ); | 830 | m_location->setDuplicatesEnabled( FALSE ); |
823 | connect( m_location, SIGNAL(activated(const QString &) ), | 831 | connect( m_location, SIGNAL(activated(const QString &) ), |
824 | this, SLOT( slotLocationActivated(const QString &) ) ); | 832 | this, SLOT( slotLocationActivated(const QString &) ) ); |
825 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | 833 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), |
826 | this, SLOT(locationComboChanged() ) ); | 834 | this, SLOT(locationComboChanged() ) ); |
827 | // UP Button | 835 | // UP Button |
828 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | 836 | m_up = new QPushButton(Resource::loadIconSet("up"),"", |
829 | m_boxToolbar,"cdUpButton"); | 837 | m_boxToolbar,"cdUpButton"); |
830 | m_up->setFixedSize( QSize( 20, 20 ) ); | 838 | m_up->setFixedSize( QSize( 20, 20 ) ); |
831 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 839 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
832 | m_up->setFlat(TRUE); | 840 | m_up->setFlat(TRUE); |
833 | 841 | ||
834 | // Home Button | 842 | // Home Button |
835 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | 843 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , |
836 | "", m_boxToolbar); | 844 | "", m_boxToolbar); |
837 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 845 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
838 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 846 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
839 | m_homeButton->setFlat(TRUE); | 847 | m_homeButton->setFlat(TRUE); |
840 | // Documents Button | 848 | // Documents Button |
841 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | 849 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", |
842 | m_boxToolbar,"docsButton"); | 850 | m_boxToolbar,"docsButton"); |
843 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 851 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
844 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 852 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
845 | m_docButton->setFlat(TRUE); | 853 | m_docButton->setFlat(TRUE); |
846 | 854 | ||
847 | // Close button | 855 | // Close button |
848 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 856 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
849 | m_boxToolbar ); | 857 | m_boxToolbar ); |
850 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 858 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
851 | m_close->setFixedSize( 20, 20 ); | 859 | m_close->setFixedSize( 20, 20 ); |
852 | 860 | ||
853 | m_boxToolbar->setFixedHeight( 20 ); | 861 | m_boxToolbar->setFixedHeight( 20 ); |
854 | m_pseudoLayout->addWidget(m_boxToolbar ); | 862 | m_pseudoLayout->addWidget(m_boxToolbar ); |
855 | 863 | ||
856 | // let;s fill the Location ComboBox | 864 | // let;s fill the Location ComboBox |
857 | StorageInfo storage; | 865 | StorageInfo storage; |
858 | const QList<FileSystem> &fs = storage.fileSystems(); | 866 | const QList<FileSystem> &fs = storage.fileSystems(); |
859 | QListIterator<FileSystem> it ( fs ); | 867 | QListIterator<FileSystem> it ( fs ); |
860 | for( ; it.current(); ++it ){ | 868 | for( ; it.current(); ++it ){ |
861 | const QString disk = (*it)->name(); | 869 | const QString disk = (*it)->name(); |
862 | const QString path = (*it)->path(); | 870 | const QString path = (*it)->path(); |
863 | m_location->insertItem(path+ "<-"+disk ); | 871 | m_location->insertItem(path+ "<-"+disk ); |
864 | } | 872 | } |
865 | int count = m_location->count(); | 873 | int count = m_location->count(); |
866 | m_location->insertItem( m_currentDir ); | 874 | m_location->insertItem( m_currentDir ); |
867 | m_location->setCurrentItem( count ); | 875 | m_location->setCurrentItem( count ); |
868 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | 876 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it |
869 | if( !m_shTool ){ | 877 | if( !m_shTool ){ |
870 | m_location->hide( ); | 878 | m_location->hide( ); |
871 | m_up->hide( ); | 879 | m_up->hide( ); |
872 | m_homeButton->hide( ); | 880 | m_homeButton->hide( ); |
873 | m_docButton->hide( ); | 881 | m_docButton->hide( ); |
874 | } | 882 | } |
875 | if(!m_shClose ) | 883 | if(!m_shClose ) |
876 | m_close->hide(); | 884 | m_close->hide(); |
877 | if(!m_shNew) | 885 | //if(!m_shNew) |
878 | m_close->hide(); | 886 | //m_close->hide(); |
879 | 887 | ||
880 | } // off toolbar | 888 | } // off toolbar |
881 | // the Main ListView | 889 | // the Main ListView |
882 | // make a QWidgetStack first so Views can share the Toolbar | 890 | // make a QWidgetStack first so Views can share the Toolbar |
883 | m_View = new QListView( m_pseudo, "Extended view"); | 891 | m_View = new QListView( m_pseudo, "Extended view"); |
884 | QPEApplication::setStylusOperation( m_View->viewport(), | 892 | QPEApplication::setStylusOperation( m_View->viewport(), |
885 | QPEApplication::RightOnHold); | 893 | QPEApplication::RightOnHold); |
886 | m_View->addColumn(" " ); | 894 | m_View->addColumn(" " ); |
887 | m_View->addColumn(tr("Name"), 135 ); | 895 | m_View->addColumn(tr("Name"), 135 ); |
888 | m_View->addColumn(tr("Size"), -1 ); | 896 | m_View->addColumn(tr("Size"), -1 ); |
889 | m_View->addColumn(tr("Date"), 60 ); | 897 | m_View->addColumn(tr("Date"), 60 ); |
890 | m_View->addColumn(tr("Mime Type"), -1 ); | 898 | m_View->addColumn(tr("Mime Type"), -1 ); |
891 | QHeader *header = m_View->header(); | 899 | QHeader *header = m_View->header(); |
892 | header->hide(); | 900 | header->hide(); |
893 | m_View->setSorting( 1 ); | 901 | m_View->setSorting( 1 ); |
894 | m_View->setAllColumnsShowFocus( TRUE ); | 902 | m_View->setAllColumnsShowFocus( TRUE ); |
895 | 903 | ||
896 | connect(m_View, SIGNAL(selectionChanged() ), | 904 | connect(m_View, SIGNAL(selectionChanged() ), |
897 | this, SLOT(slotSelectionChanged() ) ); | 905 | this, SLOT(slotSelectionChanged() ) ); |
898 | 906 | ||
899 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | 907 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), |
900 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 908 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
901 | 909 | ||
902 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 910 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
903 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 911 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
904 | 912 | ||
905 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 913 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
906 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 914 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
907 | 915 | ||
908 | m_pseudoLayout->addWidget( m_View, 288 ); | 916 | m_pseudoLayout->addWidget( m_View, 288 ); |
909 | m_stack->addWidget( m_pseudo, EXTENDED ); | 917 | m_stack->addWidget( m_pseudo, EXTENDED ); |
910 | } | 918 | } |
911 | } | 919 | } |
912 | void OFileSelector::initializePerm() | 920 | void OFileSelector::initializePerm() |
913 | { | 921 | { |
914 | if( m_checkPerm == 0 ){ | 922 | if( m_checkPerm == 0 ){ |
915 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | 923 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); |
916 | m_checkPerm->setChecked( false ); | 924 | m_checkPerm->setChecked( false ); |
917 | m_lay->addWidget( m_checkPerm ); | 925 | m_lay->addWidget( m_checkPerm ); |
918 | 926 | ||
919 | } | 927 | } |
920 | } | 928 | } |
921 | void OFileSelector::initPics() | 929 | void OFileSelector::initPics() |
922 | { | 930 | { |
923 | m_pixmaps = new QMap<QString,QPixmap>; | 931 | m_pixmaps = new QMap<QString,QPixmap>; |
924 | QPixmap pm = Resource::loadPixmap( "folder" ); | 932 | QPixmap pm = Resource::loadPixmap( "folder" ); |
925 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 933 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
926 | QPainter painter( &pm ); | 934 | QPainter painter( &pm ); |
927 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 935 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
928 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 936 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
929 | m_pixmaps->insert("dirsymlink", pm ); | 937 | m_pixmaps->insert("dirsymlink", pm ); |
930 | 938 | ||
931 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 939 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
932 | QPainter pen(&pm2 ); | 940 | QPainter pen(&pm2 ); |
933 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 941 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
934 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 942 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
935 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 943 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
936 | } | 944 | } |
937 | // if a mime complies with the m_mimeCheck->currentItem | 945 | // if a mime complies with the m_mimeCheck->currentItem |
938 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 946 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
939 | { | 947 | { |
940 | if( mime == "All" ) | 948 | if( mime == "All" ) |
941 | return true; | 949 | return true; |
942 | MimeType type( path ); | 950 | MimeType type( path ); |
@@ -961,190 +969,206 @@ bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | |||
961 | * if it's contained return true | 969 | * if it's contained return true |
962 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 970 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
963 | * is contained in the mimefilter and then we will | 971 | * is contained in the mimefilter and then we will |
964 | * look if both are equal until the '/' | 972 | * look if both are equal until the '/' |
965 | */ | 973 | */ |
966 | bool OFileSelector::compliesMime( const QString& mime ) { | 974 | bool OFileSelector::compliesMime( const QString& mime ) { |
967 | qWarning("mimetype is %s", mime.latin1() ); | 975 | qWarning("mimetype is %s", mime.latin1() ); |
968 | QString currentText; | 976 | QString currentText; |
969 | if (m_shChooser ) | 977 | if (m_shChooser ) |
970 | currentText = m_mimeCheck->currentText(); | 978 | currentText = m_mimeCheck->currentText(); |
971 | 979 | ||
972 | qWarning("current text is %s", currentText.latin1() ); | 980 | qWarning("current text is %s", currentText.latin1() ); |
973 | QMap<QString, QStringList>::Iterator it; | 981 | QMap<QString, QStringList>::Iterator it; |
974 | QStringList list; | 982 | QStringList list; |
975 | if ( currentText == tr("All") ) return true; | 983 | if ( currentText == tr("All") ) return true; |
976 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | 984 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { |
977 | it = m_mimetypes.begin(); | 985 | it = m_mimetypes.begin(); |
978 | list = it.data(); | 986 | list = it.data(); |
979 | }else if ( currentText.isEmpty() ) return true; | 987 | }else if ( currentText.isEmpty() ) return true; |
980 | else{ | 988 | else{ |
981 | it = m_mimetypes.find(currentText ); | 989 | it = m_mimetypes.find(currentText ); |
982 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 990 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
983 | else qWarning("found"), list = it.data(); | 991 | else qWarning("found"), list = it.data(); |
984 | } | 992 | } |
985 | // dump it now | 993 | // dump it now |
986 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 994 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
987 | // qWarning( "%s", (*it).latin1() ); | 995 | // qWarning( "%s", (*it).latin1() ); |
988 | //} | 996 | //} |
989 | 997 | ||
990 | 998 | ||
991 | if ( list.contains(mime) ) return true; | 999 | if ( list.contains(mime) ) return true; |
992 | qWarning("list doesn't contain it "); | 1000 | qWarning("list doesn't contain it "); |
993 | QStringList::Iterator it2; | 1001 | QStringList::Iterator it2; |
994 | int pos; | 1002 | int pos; |
995 | int pos2; | 1003 | int pos2; |
996 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | 1004 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { |
997 | pos = (*it2).findRev("/*"); | 1005 | pos = (*it2).findRev("/*"); |
998 | if ( pos >= 0 ) { | 1006 | if ( pos >= 0 ) { |
999 | if ( mime.contains( (*it2).left(pos) ) ) return true; | 1007 | if ( mime.contains( (*it2).left(pos) ) ) return true; |
1000 | } | 1008 | } |
1001 | } | 1009 | } |
1002 | return false; | 1010 | return false; |
1003 | } | 1011 | } |
1004 | void OFileSelector::slotFileSelected( const QString &string ) | 1012 | void OFileSelector::slotFileSelected( const QString &string ) |
1005 | { | 1013 | { |
1006 | if( m_shLne ) | 1014 | if( m_shLne ) |
1007 | m_edit->setText( string ); | 1015 | m_edit->setText( string ); |
1008 | emit fileSelected( string ); | 1016 | emit fileSelected( string ); |
1009 | } | 1017 | } |
1010 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 1018 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
1011 | { | 1019 | { |
1012 | slotFileSelected( lnk.name() ); | 1020 | slotFileSelected( lnk.name() ); |
1013 | // emit fileSelected( lnk ); | 1021 | // emit fileSelected( lnk ); |
1014 | } | 1022 | } |
1015 | void OFileSelector::slotSelectionChanged() | 1023 | void OFileSelector::slotSelectionChanged() |
1016 | { | 1024 | { |
1017 | 1025 | ||
1018 | } | 1026 | } |
1019 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | 1027 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) |
1020 | { | 1028 | { |
1021 | if( item == 0 ) | 1029 | if( item == 0 ) |
1022 | return; | 1030 | return; |
1023 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 1031 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
1024 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | 1032 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) |
1033 | qWarning("current changed"); | ||
1025 | if(!sel->isDir() ){ | 1034 | if(!sel->isDir() ){ |
1026 | if( m_shLne ) | 1035 | if( m_shLne ) |
1027 | m_edit->setText( sel->text(1) ); | 1036 | m_edit->setText( sel->text(1) ); |
1037 | |||
1038 | if (m_mode == FILESELECTOR ) { | ||
1039 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1040 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
1041 | emit fileSelected(path ); | ||
1042 | DocLnk lnk( path ); | ||
1043 | emit fileSelected(lnk ); | ||
1044 | } | ||
1028 | } | 1045 | } |
1029 | } | 1046 | } |
1030 | } | 1047 | } |
1031 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | 1048 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) |
1032 | { | 1049 | { |
1033 | if ( item == 0 ) | 1050 | if ( item == 0 ) |
1034 | return; | 1051 | return; |
1035 | 1052 | ||
1036 | if( button != Qt::LeftButton ) | 1053 | if( button != Qt::LeftButton ) |
1037 | return; | 1054 | return; |
1038 | 1055 | ||
1039 | switch( m_selector ){ | 1056 | switch( m_selector ){ |
1040 | default: | 1057 | default: |
1041 | break; | 1058 | break; |
1042 | case EXTENDED: // fall through | 1059 | case EXTENDED: // fall through |
1043 | case EXTENDED_ALL:{ | 1060 | case EXTENDED_ALL:{ |
1044 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 1061 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
1045 | if(!sel->isLocked() ){ | 1062 | if(!sel->isLocked() ){ |
1046 | QStringList str = QStringList::split("->", sel->text(1) ); | 1063 | QStringList str = QStringList::split("->", sel->text(1) ); |
1047 | if( sel->isDir() ){ | 1064 | if( sel->isDir() ){ |
1048 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1065 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1049 | // if MODE Dir m_shLne set the Text | 1066 | // if MODE Dir m_shLne set the Text |
1050 | }else{ | 1067 | }else{ |
1051 | if( m_shLne ) | 1068 | if( m_shLne ) |
1052 | m_edit->setText( str[0].stripWhiteSpace() ); | 1069 | m_edit->setText( str[0].stripWhiteSpace() ); |
1070 | qWarning("selected here in slot clicked"); | ||
1053 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1071 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1072 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1073 | qWarning("file selected"); | ||
1074 | emit fileSelected( lnk ); | ||
1054 | } | 1075 | } |
1055 | } | 1076 | } |
1056 | break; | 1077 | break; |
1057 | } | 1078 | } |
1058 | } | 1079 | } |
1059 | } | 1080 | } |
1060 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 1081 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
1061 | { | 1082 | { |
1062 | if( item == 0 ) | 1083 | if( item == 0 ) |
1063 | return; | 1084 | return; |
1064 | 1085 | ||
1065 | if( button != Qt::RightButton ) | 1086 | if( button != Qt::RightButton ) |
1066 | return; | 1087 | return; |
1067 | slotContextMenu( item ); | 1088 | slotContextMenu( item ); |
1068 | } | 1089 | } |
1069 | void OFileSelector::slotContextMenu( QListViewItem *item) | 1090 | void OFileSelector::slotContextMenu( QListViewItem *item) |
1070 | { | 1091 | { |
1071 | 1092 | ||
1072 | } | 1093 | } |
1073 | void OFileSelector::slotChangedDir() | 1094 | void OFileSelector::slotChangedDir() |
1074 | { | 1095 | { |
1075 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1096 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1076 | if(sel->isDir() ){ | 1097 | if(sel->isDir() ){ |
1077 | QStringList str = QStringList::split("->", sel->text(1) ); | 1098 | QStringList str = QStringList::split("->", sel->text(1) ); |
1078 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1099 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1079 | } | 1100 | } |
1080 | } | 1101 | } |
1081 | void OFileSelector::slotOpen() | 1102 | void OFileSelector::slotOpen() |
1082 | { | 1103 | { |
1083 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1104 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1084 | if(!sel->isDir() ){ | 1105 | if(!sel->isDir() ){ |
1085 | QStringList str = QStringList::split("->", sel->text(1) ); | 1106 | QStringList str = QStringList::split("->", sel->text(1) ); |
1086 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | 1107 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); |
1108 | qWarning("slot open"); | ||
1109 | // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1110 | //emit fileSelected( lnk ); | ||
1087 | } | 1111 | } |
1088 | } | 1112 | } |
1089 | void OFileSelector::slotRescan() | 1113 | void OFileSelector::slotRescan() |
1090 | { | 1114 | { |
1091 | 1115 | ||
1092 | } | 1116 | } |
1093 | void OFileSelector::slotRename() | 1117 | void OFileSelector::slotRename() |
1094 | { | 1118 | { |
1095 | reparse(); | 1119 | reparse(); |
1096 | } | 1120 | } |
1097 | void OFileSelector::slotDelete() | 1121 | void OFileSelector::slotDelete() |
1098 | { | 1122 | { |
1099 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1123 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1100 | QStringList list = QStringList::split("->", sel->text(1) ); | 1124 | QStringList list = QStringList::split("->", sel->text(1) ); |
1101 | if( sel->isDir() ){ | 1125 | if( sel->isDir() ){ |
1102 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 1126 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
1103 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 1127 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
1104 | tr("Yes"),tr("No"),0,1,1) ) { | 1128 | tr("Yes"),tr("No"),0,1,1) ) { |
1105 | case 0: | 1129 | case 0: |
1106 | ::system(str.utf8().data() ); | 1130 | ::system(str.utf8().data() ); |
1107 | break; | 1131 | break; |
1108 | } | 1132 | } |
1109 | } else { | 1133 | } else { |
1110 | QFile::remove( list[0] ); | 1134 | QFile::remove( list[0] ); |
1111 | } | 1135 | } |
1112 | m_View->takeItem( sel ); | 1136 | m_View->takeItem( sel ); |
1113 | delete sel; | 1137 | delete sel; |
1114 | } | 1138 | } |
1115 | void OFileSelector::cdUP() | 1139 | void OFileSelector::cdUP() |
1116 | { | 1140 | { |
1117 | QDir dir( m_currentDir ); | 1141 | QDir dir( m_currentDir ); |
1118 | dir.cdUp(); | 1142 | dir.cdUp(); |
1119 | if(dir.exists() ){ | 1143 | if(dir.exists() ){ |
1120 | m_currentDir = dir.absPath(); | 1144 | m_currentDir = dir.absPath(); |
1121 | reparse(); | 1145 | reparse(); |
1122 | int count = m_location->count(); | 1146 | int count = m_location->count(); |
1123 | slotInsertLocationPath( m_currentDir, count); | 1147 | slotInsertLocationPath( m_currentDir, count); |
1124 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 1148 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
1125 | //this wont work in all instances | 1149 | //this wont work in all instances |
1126 | // FIXME | 1150 | // FIXME |
1127 | } | 1151 | } |
1128 | } | 1152 | } |
1129 | void OFileSelector::slotHome() | 1153 | void OFileSelector::slotHome() |
1130 | { | 1154 | { |
1131 | cd(QDir::homeDirPath() ); | 1155 | cd(QDir::homeDirPath() ); |
1132 | } | 1156 | } |
1133 | void OFileSelector::slotDoc() | 1157 | void OFileSelector::slotDoc() |
1134 | { | 1158 | { |
1135 | cd(QPEApplication::documentDir() ); | 1159 | cd(QPEApplication::documentDir() ); |
1136 | } | 1160 | } |
1137 | void OFileSelector::slotNavigate( ) | 1161 | void OFileSelector::slotNavigate( ) |
1138 | { | 1162 | { |
1139 | 1163 | ||
1140 | } | 1164 | } |
1141 | // fill the View with life | 1165 | // fill the View with life |
1142 | void OFileSelector::reparse() | 1166 | void OFileSelector::reparse() |
1143 | { | 1167 | { |
1144 | if( m_selector == NORMAL ) | 1168 | if( m_selector == NORMAL ) |
1145 | return; | 1169 | return; |
1146 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | 1170 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) |
1147 | m_View->clear(); | 1171 | m_View->clear(); |
1148 | else // custom view | 1172 | else // custom view |
1149 | ; // currentView()->clear(); | 1173 | ; // currentView()->clear(); |
1150 | if( m_shChooser) | 1174 | if( m_shChooser) |