summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-24 12:24:16 (UTC)
committer llornkcor <llornkcor>2002-04-24 12:24:16 (UTC)
commit997b7685dcc48cc36737240ca53331f83b66dbeb (patch) (unidiff)
tree21148b19266eea39859646c249d0e04f3f40fd9a
parent8f67324fd1a60c165ae7043b9457f911b9690e43 (diff)
downloadopie-997b7685dcc48cc36737240ca53331f83b66dbeb.zip
opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.gz
opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.bz2
fixed requested mimetype- for now.. still needs work
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc135
-rw-r--r--libopie/ofileselector.h4
2 files changed, 69 insertions, 70 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index d1f1e1f..ce66f51 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -77,25 +77,26 @@ namespace {
77 77
78}; 78};
79 79
80 80
81OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 81OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
82 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) 82 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid )
83{ 83{
84 if(wid!=0) 84 if(wid!=0)
85 resize(wid->width(),wid->height()); 85 resize(wid->width(),wid->height());
86 m_selector = selector; 86 m_selector = selector;
87 m_currentDir = dirName; 87 m_currentDir = dirName;
88 m_name = fileName; 88 m_name = fileName;
89 m_mimetypes = mimetypes; 89 requestedMimeTypesList = m_mimetypes = mimetypes;
90
90// if( mimetypes.isEmpty() ) 91// if( mimetypes.isEmpty() )
91// m_autoMime = true; 92// m_autoMime = true;
92 93
93 m_mode = mode; 94 m_mode = mode;
94 m_shTool = true; 95 m_shTool = true;
95 m_shPerm = true; 96 m_shPerm = true;
96 m_shLne = true; 97 m_shLne = true;
97 m_shChooser = true; 98 m_shChooser = true;
98 m_shYesNo = true; 99 m_shYesNo = true;
99 // for FILESELECTOR only view is interesting 100 // for FILESELECTOR only view is interesting
100 m_location = 0; 101 m_location = 0;
101 m_homeButton = 0; 102 m_homeButton = 0;
@@ -177,58 +178,54 @@ void OFileSelector::initPics()
177 ____________________ 178 ____________________
178 */ 179 */
179void OFileSelector::delItems() 180void OFileSelector::delItems()
180{ 181{
181 QLayoutIterator it = m_lay->iterator(); 182 QLayoutIterator it = m_lay->iterator();
182 while ( it.current() != 0 ){ 183 while ( it.current() != 0 ){
183 it.deleteCurrent(); 184 it.deleteCurrent();
184 } 185 }
185} 186}
186 187
187void OFileSelector::init() 188void OFileSelector::init()
188{ 189{
189 190// qDebug("init");
190 m_stack = new QWidgetStack(this, "wstack" ); 191 m_stack = new QWidgetStack(this, "wstack" );
191 if( m_selector == NORMAL ){
192 QString currMime; 192 QString currMime;
193 if( m_mimeCheck != 0 ) 193 if( m_mimeCheck != 0 )
194 currMime = m_mimeCheck->currentText(); 194 currMime = m_mimeCheck->currentText();
195
196 updateMimes(); 195 updateMimes();
197 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 196 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
198 m_stack->addWidget(m_select, NORMAL ); 197 m_stack->addWidget(m_select, NORMAL );
199 m_lay->addWidget(m_stack ); 198 m_lay->addWidget(m_stack );
200 m_stack->raiseWidget(NORMAL ); 199 m_stack->raiseWidget(NORMAL );
201 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 200 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
202 m_pseudoLayout = 0l; 201 m_pseudoLayout = 0l;
203 }else { 202 if( m_selector != NORMAL ) {
204 initializeListView(); 203 initializeListView();
205 } 204 }
206
207 if(m_shLne ){ 205 if(m_shLne ){
208 initializeName(); 206 initializeName();
209 } 207 }
210
211 if(m_shPerm ){ 208 if(m_shPerm ){
212 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 209 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
213 m_checkPerm->setChecked( false ); 210 m_checkPerm->setChecked( false );
214 m_lay->addWidget(m_checkPerm ); 211 m_lay->addWidget(m_checkPerm );
215 } 212 }
216
217 if( m_shChooser ) 213 if( m_shChooser )
218 initializeChooser(); 214 initializeChooser();
219
220 if(m_shYesNo ) 215 if(m_shYesNo )
221 initializeYes(); 216 initializeYes();
222 217
218 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) );
219 reparse();
223 220
224} 221}
225 222
226void OFileSelector::setYesCancelVisible( bool show ) 223void OFileSelector::setYesCancelVisible( bool show )
227{ 224{
228 if ( show == m_shYesNo ) 225 if ( show == m_shYesNo )
229 return; 226 return;
230 m_shYesNo = show; 227 m_shYesNo = show;
231 if( !show ){ 228 if( !show ){
232 delete m_ok; 229 delete m_ok;
233 delete m_cancel; 230 delete m_cancel;
234 m_ok = 0; 231 m_ok = 0;
@@ -407,30 +404,28 @@ void OFileSelector::updateLay()
407bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 404bool OFileSelector::compliesMime(const QString &path, const QString &mime )
408{ 405{
409 if( mime == "All" ) 406 if( mime == "All" )
410 return true; 407 return true;
411 MimeType type( path ); 408 MimeType type( path );
412 if( type.id() == mime ) 409 if( type.id() == mime )
413 return true; 410 return true;
414 return false; 411 return false;
415} 412}
416 413
417void OFileSelector::reparse() 414void OFileSelector::reparse()
418{ 415{
416 qDebug("reparse");
419 if(m_View== 0 || m_selector == NORMAL) 417 if(m_View== 0 || m_selector == NORMAL)
420 return; 418 return;
421
422 m_View->clear(); 419 m_View->clear();
423
424
425 QString currMime =m_mimeCheck->currentText(); 420 QString currMime =m_mimeCheck->currentText();
426 // update the mimetype now 421 // update the mimetype now
427 if( m_autoMime ) { 422 if( m_autoMime ) {
428 QDir dir( m_currentDir ); 423 QDir dir( m_currentDir );
429 m_mimetypes.clear(); 424 m_mimetypes.clear();
430 m_mimeCheck->clear(); 425 m_mimeCheck->clear();
431 dir.setFilter( QDir::Files | QDir::Readable ); 426 dir.setFilter( QDir::Files | QDir::Readable );
432 dir.setSorting(QDir::Size ); 427 dir.setSorting(QDir::Size );
433 const QFileInfoList *list = dir.entryInfoList(); 428 const QFileInfoList *list = dir.entryInfoList();
434 QFileInfoListIterator it( *list ); 429 QFileInfoListIterator it( *list );
435 QFileInfo *fi; 430 QFileInfo *fi;
436 while( (fi=it.current()) ){ 431 while( (fi=it.current()) ){
@@ -461,68 +456,69 @@ void OFileSelector::reparse()
461 /* if( m_dir && !m_files) 456 /* if( m_dir && !m_files)
462 filter |= QDir::Dirs; 457 filter |= QDir::Dirs;
463 else if( !m_dir && m_files ) 458 else if( !m_dir && m_files )
464 filter |= QDir::Files; 459 filter |= QDir::Files;
465 else 460 else
466 filter |= QDir::All; 461 filter |= QDir::All;
467 */ 462 */
468 if( m_selector == EXTENDED_ALL ) 463 if( m_selector == EXTENDED_ALL )
469 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 464 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
470 else 465 else
471 filter = QDir::Files | QDir::Dirs | QDir::All; 466 filter = QDir::Files | QDir::Dirs | QDir::All;
472 dir.setFilter( filter ); 467 dir.setFilter( filter );
473 468 qDebug("infoList");
474 const QFileInfoList *list = dir.entryInfoList(); 469 const QFileInfoList *list = dir.entryInfoList();
475 QFileInfoListIterator it( *list ); 470 QFileInfoListIterator it( *list );
476 QFileInfo *fi; 471 QFileInfo *fi;
477 while( (fi=it.current()) ){ 472 while( (fi=it.current()) ){
478 if(fi->fileName() == ".." || fi->fileName() == "." ){ 473 if(fi->fileName() == ".." || fi->fileName() == "." ){
479 ++it; 474 ++it;
480 continue; 475 continue;
481 } 476 }
482 qWarning("Test: %s", fi->fileName().latin1() ); 477// qWarning("Test: %s", fi->fileName().latin1() );
483 if(fi->isSymLink() ){ 478 if(fi->isSymLink() ){
484 qWarning("Symlink %s", fi->fileName().latin1() ); 479// qWarning("Symlink %s", fi->fileName().latin1() );
485 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 480 QString file = fi->dirPath(true)+"/"+ fi->readLink();
486 qWarning("File ->%s", file.latin1() ); 481// qWarning("File ->%s", file.latin1() );
487 for(int i=0; i<=4; i++ ){ // prepend from dos 482 for(int i=0; i<=4; i++ ){ // prepend from dos
488 QFileInfo info( file ); 483 QFileInfo info( file );
489 if( !info.exists() ){ 484 if( !info.exists() ){
490 qWarning("does not exist" ); 485// qWarning("does not exist" );
491 addSymlink(currMime, fi, TRUE ); 486 addSymlink(currMime, fi, TRUE );
492 break; 487 break;
493 }else if( info.isDir() ){ 488 }else if( info.isDir() ){
494 qWarning("isDir" ); 489// qWarning("isDir" );
495 addDir(currMime, fi, TRUE ); 490 addDir(currMime, fi, TRUE );
496 break; 491 break;
497 }else if( info.isFile() ){ 492 }else if( info.isFile() ){
498 qWarning("isFile" ); 493// qWarning("isFile" );
499 addFile(currMime, fi, TRUE ); 494 addFile(currMime, fi, TRUE );
500 break; 495 break;
501 }else if( info.isSymLink() ){ 496 }else if( info.isSymLink() ){
502 file = info.dirPath(true)+ "/"+ info.readLink(); 497 file = info.dirPath(true)+ "/"+ info.readLink();
503 qWarning("isSymlink again %s", file.latin1() ); 498// qWarning("isSymlink again %s", file.latin1() );
504 }else if( i == 4 ){ // just insert it and have the symlink symbol 499 }else if( i == 4 ){ // just insert it and have the symlink symbol
505 addSymlink(currMime, fi ); 500 addSymlink(currMime, fi );
506 qWarning("level too deep" ); 501// qWarning("level too deep" );
507 } 502 }
508 } 503 }
509 }else if( fi->isDir() ){ 504 }else if( fi->isDir() ){
510 addDir(currMime, fi ); 505 addDir(currMime, fi );
511 }else if( fi->isFile() ) { // file ? 506 }else if( fi->isFile() ) { // file ?
512 addFile(currMime, fi ); 507 addFile(currMime, fi );
513 } 508 }
514 ++it; 509 ++it;
515 } 510 }
516 m_View->sort(); 511 m_View->sort();
512// m_View->ensureItemVisible();
517} 513}
518 514
519QString OFileSelector::directory()const 515QString OFileSelector::directory()const
520{ 516{
521 QDir d( m_currentDir); 517 QDir d( m_currentDir);
522 return d.absPath(); 518 return d.absPath();
523} 519}
524 520
525int OFileSelector::fileCount() 521int OFileSelector::fileCount()
526{ 522{
527 return 0; 523 return 0;
528} 524}
@@ -577,25 +573,25 @@ void OFileSelector::initializeChooser()
577 m_boxView->addWidget(m_mimeCheck, 0 ); 573 m_boxView->addWidget(m_mimeCheck, 0 );
578 m_lay->addLayout(m_boxView ); 574 m_lay->addLayout(m_boxView );
579 m_lay->insertSpacing( 4, 8); 575 m_lay->insertSpacing( 4, 8);
580 576
581 m_viewCheck->insertItem(tr("Documents") ); 577 m_viewCheck->insertItem(tr("Documents") );
582 m_viewCheck->insertItem(tr("Files") ); 578 m_viewCheck->insertItem(tr("Files") );
583 m_viewCheck->insertItem(tr("All Files") ); 579 m_viewCheck->insertItem(tr("All Files") );
584 580
585// if(!m_autoMime ) 581// if(!m_autoMime )
586// m_mimeCheck->insertItem(m_mimetypes.join("," ) ); 582// m_mimeCheck->insertItem(m_mimetypes.join("," ) );
587// else{ // check 583// else{ // check
588 updateMimes(); 584 updateMimes();
589 m_mimeCheck->insertStringList( m_mimetypes ); 585 m_mimeCheck->insertStringList( m_mimetypes );
590// } 586// }
591 587
592 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 588 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
593 this, SLOT(slotViewCheck(const QString & ) ) ); 589 this, SLOT(slotViewCheck(const QString & ) ) );
594 590
595 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 591 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
596 this, SLOT(slotMimeCheck(const QString & ) ) ); 592 this, SLOT(slotMimeCheck(const QString & ) ) );
597} 593}
598 594
599void OFileSelector::slotMimeCheck(const QString &view ){ 595void OFileSelector::slotMimeCheck(const QString &view ){
600 if(m_selector == NORMAL ){ 596 if(m_selector == NORMAL ){
601 delete m_select; 597 delete m_select;
@@ -637,133 +633,136 @@ void OFileSelector::slotViewCheck(const QString &view ){
637 633
638 delete m_select; 634 delete m_select;
639 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 635 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
640 m_stack,"fileselector", FALSE, FALSE ); 636 m_stack,"fileselector", FALSE, FALSE );
641 m_stack->addWidget( m_select, NORMAL ); 637 m_stack->addWidget( m_select, NORMAL );
642 m_mimeCheck->clear(); 638 m_mimeCheck->clear();
643 m_selector = NORMAL; 639 m_selector = NORMAL;
644 updateMimes(); 640 updateMimes();
645 m_mimeCheck->insertStringList( m_mimetypes ); 641 m_mimeCheck->insertStringList( m_mimetypes );
646 m_stack->raiseWidget( NORMAL ); 642 m_stack->raiseWidget( NORMAL );
647 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 643 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
648 644
649 }else if(view == QString::fromLatin1("Files") ){ 645 } else if(view == QString::fromLatin1("Files") ){
650 // remove from the stack 646 // remove from the stack
651 delete m_select; 647 delete m_select;
652 m_select = 0; 648 m_select = 0;
653 delete m_View; 649 delete m_View;
654 m_View = 0; 650 m_View = 0;
655 651
656
657
658 m_selector = EXTENDED; 652 m_selector = EXTENDED;
659 // create the ListView or IconView
660 initializeListView(); 653 initializeListView();
661
662 reparse(); 654 reparse();
663 }else if(view == QString::fromLatin1("All Files") ) { 655 } else if(view == QString::fromLatin1("All Files") ) {
664 // remove from the stack 656 // remove from the stack
665 delete m_select; 657 delete m_select;
666 m_select = 0; 658 m_select = 0;
667 delete m_View; 659 delete m_View;
668 m_View = 0; 660 m_View = 0;
669 661
670 m_selector = EXTENDED_ALL; 662 m_selector = EXTENDED_ALL;
671 initializeListView(); 663 initializeListView();
672 reparse(); 664 reparse();
673 }; 665 }
674} 666}
675 667
676 668
677void OFileSelector::updateMimes() // lets check which mode is active 669void OFileSelector::updateMimes() // lets check which mode is active
678 // check the current dir for items then 670 // check the current dir for items then
679{ 671{
680 m_mimetypes.clear(); 672 m_mimetypes.clear();
681 m_mimetypes.append("All" ); 673 m_mimetypes.append("All" );
682 if( m_selector == NORMAL ){ 674// if( m_selector == NORMAL ){
683 DocLnkSet set; 675 DocLnkSet set;
684 Global::findDocuments(&set, QString::null ); 676 Global::findDocuments(&set, QString::null );
685 QListIterator<DocLnk> dit( set.children() ); 677 QListIterator<DocLnk> dit( set.children() );
686 for ( ; dit.current(); ++dit ) { 678 for ( ; dit.current(); ++dit ) {
687 if( !m_mimetypes.contains((*dit)->type() ) ) 679 if( !m_mimetypes.contains((*dit)->type() ) )
688 m_mimetypes.append( (*dit)->type() ); 680 m_mimetypes.append( (*dit)->type() );
689 } 681 }
690 }else{ 682// }else{
691 // should be allreday updatet 683 // should be allreday updatet
692 ; 684 // ;
693 } 685 // }
694} 686}
695 687
696void OFileSelector::initializeListView() 688void OFileSelector::initializeListView()
697{ 689{
690 // in the instance that a developer selected the view to be Files or Entended,
691 // in the initial initialization, you are deleting objects here
692 // that aren't even existing yet.
693
698 // just to make sure but clean it up better FIXME 694 // just to make sure but clean it up better FIXME
699 delete m_View; 695 // if( m_View) delete m_View;
700 m_View = 0; 696// m_View = 0;
701 delete m_boxToolbar; 697// if(m_boxToolbar) delete m_boxToolbar;
702 delete m_homeButton; 698// if(m_homeButton) delete m_homeButton;
703 delete m_docButton; 699// if(m_docButton) delete m_docButton;
704 delete m_location; 700// if( m_location) delete m_location;
705 delete m_up; 701// if(m_up) delete m_up;
706 //delete m_pseudo; 702 //delete m_pseudo;
707 //if(m_pseudoLayout!=0 ) // why did you overload malloc 703 //if(m_pseudoLayout!=0 ) // why did you overload malloc
708 //delete m_pseudoLayout; 704 //delete m_pseudoLayout;
709 m_boxToolbar = 0; 705 m_boxToolbar = 0;
710 m_homeButton = 0; 706 m_homeButton = 0;
711 m_docButton = 0; 707 m_docButton = 0;
712 m_location = 0; 708 m_location = 0;
713 m_up = 0; 709 m_up = 0;
714 m_pseudo = 0; 710 m_pseudo = 0;
715 m_pseudoLayout = 0; 711 m_pseudoLayout = 0;
716 // time for the toolbar 712 qDebug(" time for the toolbar ");
717 m_pseudo = new QWidget(m_stack, "Pseudo Widget"); 713 m_pseudo = new QWidget(m_stack, "Pseudo Widget");
718 m_pseudoLayout = new QVBoxLayout(m_pseudo ); 714 m_pseudoLayout = new QVBoxLayout(m_pseudo );
719 if(m_shTool ){ 715 if(m_shTool ){
720 m_boxToolbar = new QHBoxLayout( ); 716 m_boxToolbar = new QHBoxLayout( );
721 m_boxToolbar->setAutoAdd( true ); 717 m_boxToolbar->setAutoAdd( true );
722 m_location = new QComboBox(m_pseudo ); 718 m_location = new QComboBox(m_pseudo );
719 m_location ->setEditable(TRUE);
723 connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); 720 connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) );
721 connect( m_location->lineEdit(),SIGNAL(returnPressed()), this,SLOT( locationComboChanged()));
724 722
725 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); 723 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton");
726 m_up->setFixedSize( QSize( 20, 20 ) ); 724 m_up->setFixedSize( QSize( 20, 20 ) );
727 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); 725 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
728 m_up->setFlat(TRUE); 726 m_up->setFlat(TRUE);
729 727
730 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); 728 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo);
731 m_homeButton->setFixedSize( QSize( 20, 20 ) ); 729 m_homeButton->setFixedSize( QSize( 20, 20 ) );
732 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); 730 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
733 m_homeButton->setFlat(TRUE); 731 m_homeButton->setFlat(TRUE);
734 732
735 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); 733 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
736 m_docButton->setFixedSize( QSize( 20, 20 ) ); 734 m_docButton->setFixedSize( QSize( 20, 20 ) );
737 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); 735 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
738 m_docButton->setFlat(TRUE); 736 m_docButton->setFlat(TRUE);
739 737
740 m_boxToolbar->addWidget(m_location ); 738 m_boxToolbar->addWidget(m_location );
741 m_boxToolbar->addWidget(m_up ); 739 m_boxToolbar->addWidget(m_up );
742 m_boxToolbar->addWidget(m_homeButton ); 740 m_boxToolbar->addWidget(m_homeButton );
743 m_boxToolbar->addWidget(m_docButton ); 741 m_boxToolbar->addWidget(m_docButton );
744 m_pseudoLayout->addLayout(m_boxToolbar ); 742 m_pseudoLayout->addLayout(m_boxToolbar );
745 // lets fill the combobox 743 qDebug("lets fill the combobox");
746 StorageInfo storage; 744 StorageInfo storage;
747 const QList<FileSystem> &fs = storage.fileSystems(); 745 const QList<FileSystem> &fs = storage.fileSystems();
748 QListIterator<FileSystem> it ( fs ); 746 QListIterator<FileSystem> it ( fs );
749 for( ; it.current(); ++it ){ 747 for( ; it.current(); ++it ){
750 const QString disk = (*it)->name(); 748 const QString disk = (*it)->name();
751 const QString path = (*it)->path(); 749 const QString path = (*it)->path();
752 m_location->insertItem(path+ "<-"+disk ); 750 m_location->insertItem(path+ "<-"+disk );
753 } 751 }
754 int count = m_location->count(); 752 int count = m_location->count();
755 m_location->insertItem(m_currentDir ); 753 m_location->insertItem(m_currentDir );
756 m_location->setCurrentItem( count ); 754 m_location->setCurrentItem( count );
757 }; 755 };
756
758 m_View = new QListView(m_pseudo, "Extended view" ); 757 m_View = new QListView(m_pseudo, "Extended view" );
759 m_stack->addWidget( m_pseudo, EXTENDED ); 758 m_stack->addWidget( m_pseudo, EXTENDED );
760 m_stack->raiseWidget( EXTENDED ); 759 m_stack->raiseWidget( EXTENDED );
761 m_pseudoLayout->addWidget(m_View ); 760 m_pseudoLayout->addWidget(m_View );
762 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); 761 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
763 // set up the stuff 762 // set up the stuff
764 // Pixmap Name Date Size mime 763 // Pixmap Name Date Size mime
765 //(m_View->header() )->hide(); 764 //(m_View->header() )->hide();
766 //m_View->setRootIsDecorated(false); 765 //m_View->setRootIsDecorated(false);
767 m_View->addColumn(" "); 766 m_View->addColumn(" ");
768 m_View->addColumn(tr("Name"),135 ); 767 m_View->addColumn(tr("Name"),135 );
769 m_View->addColumn(tr("Size"),-1 ); 768 m_View->addColumn(tr("Size"),-1 );
@@ -774,36 +773,37 @@ void OFileSelector::initializeListView()
774 m_View->setSorting(1 ); 773 m_View->setSorting(1 );
775 m_View->setAllColumnsShowFocus( TRUE); 774 m_View->setAllColumnsShowFocus( TRUE);
776 // connect now 775 // connect now
777 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); 776 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
778 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 777 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
779 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 778 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
780 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 779 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
781 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 780 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
782 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 781 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
783 782
784 783
785}; 784};
785
786/* If a item is locked depends on the mode 786/* If a item is locked depends on the mode
787 if we're in OPEN !isReadable is locked 787 if we're in OPEN !isReadable is locked
788 if we're in SAVE !isWriteable is locked 788 if we're in SAVE !isWriteable is locked
789 789
790 790
791 */ 791 */
792 792
793 793
794void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ 794void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
795 qWarning("Add Files" ); 795// qWarning("Add Files" );
796 if( !m_files ){ 796 if( !m_files ){
797 qWarning("not mfiles" ); 797// qWarning("not mfiles" );
798 return; 798 return;
799 } 799 }
800 800
801 MimeType type( info->filePath() ); 801 MimeType type( info->filePath() );
802 QString name; 802 QString name;
803 QString dir; 803 QString dir;
804 bool locked= false; 804 bool locked= false;
805 if(mime == "All" ){ 805 if(mime == "All" ){
806 ; 806 ;
807 }else if( type.id() != mime ) { 807 }else if( type.id() != mime ) {
808 return; 808 return;
809 } 809 }
@@ -892,86 +892,86 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
892 slotFileSelected(lnk.name() ); 892 slotFileSelected(lnk.name() );
893 emit fileSelected( lnk ); 893 emit fileSelected( lnk );
894} 894}
895 895
896void OFileSelector::slotSelectionChanged() // get the current items 896void OFileSelector::slotSelectionChanged() // get the current items
897 // fixme 897 // fixme
898{ 898{
899 qWarning("selection changed" ); 899 qWarning("selection changed" );
900} 900}
901 901
902void OFileSelector::slotCurrentChanged(QListViewItem *item ) 902void OFileSelector::slotCurrentChanged(QListViewItem *item )
903{ 903{
904 qWarning("current changed" ); 904// qWarning("current changed" );
905 if( item == 0 ) 905 if( item == 0 )
906 return; 906 return;
907 907
908 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 908 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
909 OFileSelectorItem *sel = (OFileSelectorItem*)item; 909 OFileSelectorItem *sel = (OFileSelectorItem*)item;
910 if(!sel->isDir() ){ 910 if(!sel->isDir() ){
911 qWarning("is not dir" ); 911// qWarning("is not dir" );
912 if(m_shLne ){ 912 if(m_shLne ){
913 m_edit->setText(sel->text(1) ); 913 m_edit->setText(sel->text(1) );
914 qWarning("setTexy" ); 914// qWarning("setTexy" );
915 } 915 }
916 } 916 }
917 }else { 917 }else {
918 qWarning("mode not extended" ); 918 qWarning("mode not extended" );
919 } 919 }
920} 920}
921 921
922// either select or change dir 922// either select or change dir
923void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) 923void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int )
924{ 924{
925 if( item == 0 ) 925 if( item == 0 )
926 return; 926 return;
927 927
928 if( button != Qt::LeftButton ) 928 if( button != Qt::LeftButton )
929 return; 929 return;
930 930
931 qWarning("clicked" ); 931// qWarning("clicked" );
932 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 932 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
933 qWarning("inside" ); 933// qWarning("inside" );
934 OFileSelectorItem *sel = (OFileSelectorItem*)item; 934 OFileSelectorItem *sel = (OFileSelectorItem*)item;
935 if(!sel->isLocked() ){ // not locked either changedir or open 935 if(!sel->isLocked() ){ // not locked either changedir or open
936 QStringList str = QStringList::split("->", sel->text(1) ); 936 QStringList str = QStringList::split("->", sel->text(1) );
937 if(sel->isDir() ){ 937 if(sel->isDir() ){
938 cd( sel->directory() + "/" + str[0] ); 938 cd( sel->directory() + "/" + str[0] );
939 } else { 939 } else {
940 qWarning("file" ); 940// qWarning("file" );
941 if(m_shLne ) 941 if(m_shLne )
942 m_edit->setText(str[0] ); 942 m_edit->setText(str[0] );
943 emit fileSelected(str[0] ); 943 emit fileSelected(str[0] );
944 // emit DocLnk need to do it 944 // emit DocLnk need to do it
945 } 945 }
946 } else { 946 } else {
947 qWarning( "locked" ); 947 qWarning( "locked" );
948 } 948 }
949 }; 949 };
950} 950}
951 951
952void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 952void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
953{ 953{
954 if (item == 0 ) 954 if (item == 0 )
955 return; 955 return;
956 956
957 if( button != Qt::RightButton ) 957 if( button != Qt::RightButton )
958 return; 958 return;
959 qWarning("right button" ); 959// qWarning("right button" );
960 slotContextMenu(item); 960 slotContextMenu(item);
961} 961}
962 962
963void OFileSelector::slotContextMenu(QListViewItem *item) 963void OFileSelector::slotContextMenu(QListViewItem *item)
964{ 964{
965 qWarning("context menu" ); 965// qWarning("context menu" );
966 if( item ==0 || !m_showPopup ) 966 if( item ==0 || !m_showPopup )
967 return; 967 return;
968 968
969 if( m_custom !=0){ 969 if( m_custom !=0){
970 m_custom->exec(); 970 m_custom->exec();
971 }else{ 971 }else{
972 QPopupMenu menu; 972 QPopupMenu menu;
973 QAction up; 973 QAction up;
974 up.setText("cd up"); 974 up.setText("cd up");
975 up.addTo( &menu ); 975 up.addTo( &menu );
976 connect(&up, SIGNAL(activated() ), 976 connect(&up, SIGNAL(activated() ),
977 this, SLOT(cdUP() ) ); 977 this, SLOT(cdUP() ) );
@@ -1005,45 +1005,48 @@ void OFileSelector::slotContextMenu(QListViewItem *item)
1005 QAction delItem; 1005 QAction delItem;
1006 delItem.setText( tr("Delete") ); 1006 delItem.setText( tr("Delete") );
1007 delItem.addTo(&menu ); 1007 delItem.addTo(&menu );
1008 connect(&delItem, SIGNAL(activated() ), 1008 connect(&delItem, SIGNAL(activated() ),
1009 this, SLOT(slotDelete() ) ); 1009 this, SLOT(slotDelete() ) );
1010 1010
1011 menu.exec(QCursor::pos() ); 1011 menu.exec(QCursor::pos() );
1012 } 1012 }
1013} 1013}
1014 1014
1015bool OFileSelector::cd(const QString &str ) 1015bool OFileSelector::cd(const QString &str )
1016{ 1016{
1017 qWarning(" dir %s", str.latin1() ); 1017// qWarning(" dir %s", str.latin1() );
1018 QDir dir( str); 1018 QDir dir( str);
1019 if(dir.exists() ){ 1019 if(dir.exists() ){
1020 m_currentDir = dir.absPath(); 1020 m_currentDir = dir.absPath();
1021 reparse(); 1021 reparse();
1022 if(m_shTool ){ 1022 if(m_shTool ){
1023 int count = m_location->count(); 1023 int count = m_location->count();
1024 insertLocationPath( str ,count ); 1024 insertLocationPath( str ,count );
1025 m_location->setCurrentItem( count ); 1025 m_location->setCurrentItem( count );
1026 } 1026 }
1027 return true; 1027 return true;
1028 } 1028 }
1029 return false; 1029 return false;
1030} 1030}
1031 1031
1032void OFileSelector::insertLocationPath(const QString &currentPath, int count) { 1032void OFileSelector::insertLocationPath(const QString &currentPath, int count) {
1033 QStringList pathList; 1033 QStringList pathList;
1034 bool underDog = FALSE;
1034 for(int i=0;i<count;i++) { 1035 for(int i=0;i<count;i++) {
1035 pathList << m_location->text(i); 1036 pathList << m_location->text(i);
1037 if( m_location->text(i) == currentPath)
1038 underDog = TRUE;
1036 } 1039 }
1037 if( pathList.grep( currentPath,TRUE).isEmpty() ) { 1040 if( !underDog) {
1038 m_location->clear(); 1041 m_location->clear();
1039 if( currentPath.left(2)=="//") 1042 if( currentPath.left(2)=="//")
1040 pathList.append( currentPath.right(currentPath.length()-1) ); 1043 pathList.append( currentPath.right(currentPath.length()-1) );
1041 else 1044 else
1042 pathList.append( currentPath ); 1045 pathList.append( currentPath );
1043 m_location->insertStringList( pathList,-1); 1046 m_location->insertStringList( pathList,-1);
1044 } 1047 }
1045} 1048}
1046 1049
1047void OFileSelector::slotChangedDir() 1050void OFileSelector::slotChangedDir()
1048{ 1051{
1049 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1052 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
@@ -1066,25 +1069,25 @@ void OFileSelector::slotOpen()
1066void OFileSelector::slotRescan() 1069void OFileSelector::slotRescan()
1067{ 1070{
1068 reparse(); 1071 reparse();
1069} 1072}
1070 1073
1071void OFileSelector::slotRename() 1074void OFileSelector::slotRename()
1072{ 1075{
1073 // rename inline 1076 // rename inline
1074} 1077}
1075 1078
1076void OFileSelector::slotDelete() 1079void OFileSelector::slotDelete()
1077{ 1080{
1078 qWarning("delete slot" ); 1081// qWarning("delete slot" );
1079 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1082 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1080 QStringList list = QStringList::split("->", sel->text(1) ); 1083 QStringList list = QStringList::split("->", sel->text(1) );
1081 if( sel->isDir() ){ 1084 if( sel->isDir() ){
1082 QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry 1085 QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry
1083 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 1086 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
1084 tr("Yes"),tr("No"),0,1,1) ) { 1087 tr("Yes"),tr("No"),0,1,1) ) {
1085 case 0: 1088 case 0:
1086 ::system(str.utf8().data() ); 1089 ::system(str.utf8().data() );
1087 break; 1090 break;
1088 } 1091 }
1089 } else { 1092 } else {
1090 QFile::remove( list[0] ); 1093 QFile::remove( list[0] );
@@ -1092,47 +1095,43 @@ void OFileSelector::slotDelete()
1092 m_View->takeItem( sel ); 1095 m_View->takeItem( sel );
1093 delete sel; 1096 delete sel;
1094} 1097}
1095 1098
1096void OFileSelector::cdUP() 1099void OFileSelector::cdUP()
1097{ 1100{
1098 QDir dir( m_currentDir ); 1101 QDir dir( m_currentDir );
1099 dir.cdUp(); 1102 dir.cdUp();
1100 if(dir.exists() ){ 1103 if(dir.exists() ){
1101 m_currentDir = dir.absPath(); 1104 m_currentDir = dir.absPath();
1102 reparse(); 1105 reparse();
1103 int count = m_location->count(); 1106 int count = m_location->count();
1104 insertLocationPath( m_currentDir,count ); 1107 insertLocationPath( m_currentDir, count);
1105 m_location->setCurrentItem( indexFromString(m_currentDir )); 1108 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
1106//this wont work in all instances 1109//this wont work in all instances
1107 // FIXME 1110 // FIXME
1108 } 1111 }
1109} 1112}
1110 1113
1111int OFileSelector::indexFromString(const QString &str) {
1112
1113 for(int i=0;i< m_location->count();i++) {
1114 if(str == m_location->text(i))
1115 return i;
1116 }
1117 return 0;
1118}
1119
1120void OFileSelector::slotHome() 1114void OFileSelector::slotHome()
1121{ 1115{
1122 cd(QDir::homeDirPath() ); 1116 cd(QDir::homeDirPath() );
1123} 1117}
1124 1118
1125void OFileSelector::slotDoc() 1119void OFileSelector::slotDoc()
1126{ 1120{
1127 cd(QDir::homeDirPath() + "/Documents" ); 1121 cd(QDir::homeDirPath() + "/Documents" );
1128} 1122}
1129 1123
1130void OFileSelector::slotNavigate() 1124void OFileSelector::slotNavigate()
1131{ 1125{
1132 1126
1133} 1127}
1134 1128
1135void OFileSelector::locationComboActivated(const QString & file ) { 1129void OFileSelector::locationComboActivated(const QString & file ) {
1136 cd(file.left(file.find("<-",0,TRUE))); 1130 cd(file.left(file.find("<-",0,TRUE)));
1137 reparse(); 1131 reparse();
1138} 1132}
1133
1134void OFileSelector::locationComboChanged() {
1135 cd( m_location->lineEdit()->text());
1136 reparse();
1137}
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 81a9e63..babe09f 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -183,44 +183,44 @@ class OFileSelector : public QWidget {
183 void dirSelected(const QString &dir ); 183 void dirSelected(const QString &dir );
184 void closeMe(); 184 void closeMe();
185 void ok(); 185 void ok();
186 void cancel(); 186 void cancel();
187 187
188 protected slots: 188 protected slots:
189 void slotOk(); 189 void slotOk();
190 void slotCancel(); 190 void slotCancel();
191 void slotViewCheck(const QString & ); 191 void slotViewCheck(const QString & );
192 void slotMimeCheck(const QString & ); 192 void slotMimeCheck(const QString & );
193 void locationComboActivated(const QString & ); 193 void locationComboActivated(const QString & );
194 void insertLocationPath(const QString &, int); 194 void insertLocationPath(const QString &, int);
195 int indexFromString(const QString &); 195 void locationComboChanged();
196 protected: 196 protected:
197 void init(); 197 void init();
198 void updateMimes(); 198 void updateMimes();
199 199
200 protected: 200 protected:
201 201
202 private: 202 private:
203 int m_mode, m_selector; 203 int m_mode, m_selector;
204 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 204 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
205 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 205 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
206 QPushButton *m_reread, *m_up; 206 QPushButton *m_reread, *m_up;
207 QListView *m_View; 207 QListView *m_View;
208 QCheckBox *m_checkPerm; 208 QCheckBox *m_checkPerm;
209 QWidget *m_pseudo; 209 QWidget *m_pseudo;
210 QVBoxLayout *m_pseudoLayout; 210 QVBoxLayout *m_pseudoLayout;
211 211
212 QString m_currentDir; 212 QString m_currentDir;
213 QString m_name; 213 QString m_name;
214 QStringList m_mimetypes; 214 QStringList m_mimetypes, requestedMimeTypesList;
215 215
216 FileSelector *m_select; 216 FileSelector *m_select;
217 QWidgetStack *m_stack; 217 QWidgetStack *m_stack;
218 QVBoxLayout *m_lay; 218 QVBoxLayout *m_lay;
219 QGridLayout *m_Oselector; 219 QGridLayout *m_Oselector;
220 220
221 QHBoxLayout *m_boxToolbar; 221 QHBoxLayout *m_boxToolbar;
222 QHBoxLayout *m_boxOk; 222 QHBoxLayout *m_boxOk;
223 QHBoxLayout *m_boxName; 223 QHBoxLayout *m_boxName;
224 QHBoxLayout *m_boxView; 224 QHBoxLayout *m_boxView;
225 225
226 QPopupMenu *m_custom; 226 QPopupMenu *m_custom;