summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc36
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
@@ -96,94 +96,96 @@ namespace {
96 }; 96 };
97}; 97};
98 98
99 99
100OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, 100OFileSelector::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
117OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, 117OFileSelector::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
140OFileSelector::~OFileSelector() 140OFileSelector::~OFileSelector()
141{ 141{
142 142
143 143
144} 144}
145 145
146void OFileSelector::setNewVisible( bool visible ) 146void 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}
164void OFileSelector::setCloseVisible( bool visible ) 166void 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}
173void OFileSelector::reread() 175void 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
184const DocLnk *OFileSelector::selected() 186const 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() );
@@ -406,193 +408,199 @@ DocLnk OFileSelector::selectedDocument() const
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}
411QValueList<DocLnk> OFileSelector::selectedDocuments() const 413QValueList<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
421void OFileSelector::slotOk() 423void OFileSelector::slotOk()
422{ 424{
423 emit ok(); 425 emit ok();
424} 426}
425void OFileSelector::slotCancel() 427void OFileSelector::slotCancel()
426{ 428{
427 emit cancel(); 429 emit cancel();
428} 430}
429void OFileSelector::slotViewCheck(const QString &sel) 431void 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.....
460QString OFileSelector::currentMimeType() const{ 464QString 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}
480void OFileSelector::slotMimeCheck(const QString &mime) 484void 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}
518void OFileSelector::slotLocationActivated(const QString &file) 524void 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}
523void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 529void OFileSelector::slotInsertLocationPath(const QString &currentPath, 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}
541void OFileSelector::locationComboChanged() 547void OFileSelector::locationComboChanged()
542{ 548{
543 cd( m_location->lineEdit()->text()); 549 cd( m_location->lineEdit()->text());
544 reparse(); 550 reparse();
545} 551}
546void OFileSelector::init() 552void 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}
594void OFileSelector::updateMimes() 602void 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 );
@@ -845,66 +853,66 @@ void OFileSelector::initializeListView()
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 }
@@ -993,126 +1001,142 @@ bool OFileSelector::compliesMime( const QString& mime ) {
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}
1004void OFileSelector::slotFileSelected( const QString &string ) 1012void 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}
1010void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 1018void 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}
1015void OFileSelector::slotSelectionChanged() 1023void OFileSelector::slotSelectionChanged()
1016{ 1024{
1017 1025
1018} 1026}
1019void OFileSelector::slotCurrentChanged(QListViewItem* item ) 1027void 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}
1031void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) 1048void 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}
1060void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 1081void 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}
1069void OFileSelector::slotContextMenu( QListViewItem *item) 1090void OFileSelector::slotContextMenu( QListViewItem *item)
1070{ 1091{
1071 1092
1072} 1093}
1073void OFileSelector::slotChangedDir() 1094void 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}
1081void OFileSelector::slotOpen() 1102void 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}
1089void OFileSelector::slotRescan() 1113void OFileSelector::slotRescan()
1090{ 1114{
1091 1115
1092} 1116}
1093void OFileSelector::slotRename() 1117void OFileSelector::slotRename()
1094{ 1118{
1095 reparse(); 1119 reparse();
1096} 1120}
1097void OFileSelector::slotDelete() 1121void 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}
1115void OFileSelector::cdUP() 1139void OFileSelector::cdUP()
1116{ 1140{
1117 QDir dir( m_currentDir ); 1141 QDir dir( m_currentDir );
1118 dir.cdUp(); 1142 dir.cdUp();