author | llornkcor <llornkcor> | 2002-04-24 12:24:16 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-24 12:24:16 (UTC) |
commit | 997b7685dcc48cc36737240ca53331f83b66dbeb (patch) (unidiff) | |
tree | 21148b19266eea39859646c249d0e04f3f40fd9a | |
parent | 8f67324fd1a60c165ae7043b9457f911b9690e43 (diff) | |
download | opie-997b7685dcc48cc36737240ca53331f83b66dbeb.zip opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.gz opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.bz2 |
fixed requested mimetype- for now.. still needs work
-rw-r--r-- | libopie/ofileselector.cc | 135 | ||||
-rw-r--r-- | libopie/ofileselector.h | 4 |
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 | |||
@@ -83,13 +83,14 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
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; |
@@ -183,46 +184,42 @@ void OFileSelector::delItems() | |||
183 | it.deleteCurrent(); | 184 | it.deleteCurrent(); |
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
187 | void OFileSelector::init() | 188 | void 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 | ||
226 | void OFileSelector::setYesCancelVisible( bool show ) | 223 | void OFileSelector::setYesCancelVisible( bool show ) |
227 | { | 224 | { |
228 | if ( show == m_shYesNo ) | 225 | if ( show == m_shYesNo ) |
@@ -413,18 +410,16 @@ bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | |||
413 | return true; | 410 | return true; |
414 | return false; | 411 | return false; |
415 | } | 412 | } |
416 | 413 | ||
417 | void OFileSelector::reparse() | 414 | void 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(); |
@@ -467,56 +462,57 @@ void OFileSelector::reparse() | |||
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 | ||
519 | QString OFileSelector::directory()const | 515 | QString OFileSelector::directory()const |
520 | { | 516 | { |
521 | QDir d( m_currentDir); | 517 | QDir d( m_currentDir); |
522 | return d.absPath(); | 518 | return d.absPath(); |
@@ -583,13 +579,13 @@ void OFileSelector::initializeChooser() | |||
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 &) ), |
@@ -643,87 +639,89 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
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 | ||
677 | void OFileSelector::updateMimes() // lets check which mode is active | 669 | void 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 | ||
696 | void OFileSelector::initializeListView() | 688 | void 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 | ||
@@ -739,25 +737,26 @@ void OFileSelector::initializeListView() | |||
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 |
@@ -780,24 +779,25 @@ void OFileSelector::initializeListView() | |||
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 | ||
794 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ | 794 | void 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; |
@@ -898,23 +898,23 @@ void OFileSelector::slotSelectionChanged() // get the current items | |||
898 | { | 898 | { |
899 | qWarning("selection changed" ); | 899 | qWarning("selection changed" ); |
900 | } | 900 | } |
901 | 901 | ||
902 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) | 902 | void 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 | } |
@@ -925,22 +925,22 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint & | |||
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 { |
@@ -953,19 +953,19 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin | |||
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 | ||
963 | void OFileSelector::slotContextMenu(QListViewItem *item) | 963 | void 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{ |
@@ -1011,13 +1011,13 @@ void OFileSelector::slotContextMenu(QListViewItem *item) | |||
1011 | menu.exec(QCursor::pos() ); | 1011 | menu.exec(QCursor::pos() ); |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool OFileSelector::cd(const QString &str ) | 1015 | bool 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(); |
@@ -1028,16 +1028,19 @@ bool OFileSelector::cd(const QString &str ) | |||
1028 | } | 1028 | } |
1029 | return false; | 1029 | return false; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { | 1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, 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); |
@@ -1072,13 +1075,13 @@ void OFileSelector::slotRename() | |||
1072 | { | 1075 | { |
1073 | // rename inline | 1076 | // rename inline |
1074 | } | 1077 | } |
1075 | 1078 | ||
1076 | void OFileSelector::slotDelete() | 1079 | void 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) ) { |
@@ -1098,28 +1101,19 @@ void OFileSelector::cdUP() | |||
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 | ||
1111 | int 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 | |||
1120 | void OFileSelector::slotHome() | 1114 | void OFileSelector::slotHome() |
1121 | { | 1115 | { |
1122 | cd(QDir::homeDirPath() ); | 1116 | cd(QDir::homeDirPath() ); |
1123 | } | 1117 | } |
1124 | 1118 | ||
1125 | void OFileSelector::slotDoc() | 1119 | void OFileSelector::slotDoc() |
@@ -1133,6 +1127,11 @@ void OFileSelector::slotNavigate() | |||
1133 | } | 1127 | } |
1134 | 1128 | ||
1135 | void OFileSelector::locationComboActivated(const QString & file ) { | 1129 | void 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 | |||
1134 | void 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 | |||
@@ -189,13 +189,13 @@ class OFileSelector : public QWidget { | |||
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 | ||
@@ -208,13 +208,13 @@ class OFileSelector : public QWidget { | |||
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 | ||