-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 | |||
@@ -104,78 +104,80 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | |||
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 | } |
@@ -414,51 +416,53 @@ QValueList<DocLnk> OFileSelector::selectedDocuments() const | |||
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(); |
@@ -473,52 +477,54 @@ QString OFileSelector::currentMimeType() const{ | |||
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 | { |
@@ -539,52 +545,54 @@ void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count | |||
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 | ||
@@ -853,50 +861,50 @@ void OFileSelector::initializeListView() | |||
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) ), |
@@ -1001,110 +1009,126 @@ bool OFileSelector::compliesMime( const QString& mime ) { | |||
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] ); |