summaryrefslogtreecommitdiff
path: root/libopie
authorllornkcor <llornkcor>2002-04-24 12:24:16 (UTC)
committer llornkcor <llornkcor>2002-04-24 12:24:16 (UTC)
commit997b7685dcc48cc36737240ca53331f83b66dbeb (patch) (unidiff)
tree21148b19266eea39859646c249d0e04f3f40fd9a /libopie
parent8f67324fd1a60c165ae7043b9457f911b9690e43 (diff)
downloadopie-997b7685dcc48cc36737240ca53331f83b66dbeb.zip
opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.gz
opie-997b7685dcc48cc36737240ca53331f83b66dbeb.tar.bz2
fixed requested mimetype- for now.. still needs work
Diffstat (limited to 'libopie') (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
@@ -87,5 +87,6 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
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;
@@ -187,11 +188,9 @@ void OFileSelector::delItems()
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 );
@@ -201,12 +200,10 @@ void OFileSelector::init()
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" );
@@ -214,11 +211,11 @@ void OFileSelector::init()
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}
@@ -417,10 +414,8 @@ bool OFileSelector::compliesMime(const QString &path, const QString &mime )
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
@@ -471,5 +466,5 @@ void OFileSelector::reparse()
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 );
@@ -480,29 +475,29 @@ void OFileSelector::reparse()
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 }
@@ -515,4 +510,5 @@ void OFileSelector::reparse()
515 } 510 }
516 m_View->sort(); 511 m_View->sort();
512// m_View->ensureItemVisible();
517} 513}
518 514
@@ -587,5 +583,5 @@ void OFileSelector::initializeChooser()
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
@@ -647,5 +643,5 @@ void OFileSelector::slotViewCheck(const QString &view ){
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;
@@ -654,12 +650,8 @@ void OFileSelector::slotViewCheck(const QString &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;
@@ -671,5 +663,5 @@ void OFileSelector::slotViewCheck(const QString &view ){
671 initializeListView(); 663 initializeListView();
672 reparse(); 664 reparse();
673 }; 665 }
674} 666}
675 667
@@ -680,5 +672,5 @@ void OFileSelector::updateMimes() // lets check which mode is active
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 );
@@ -688,20 +680,24 @@ void OFileSelector::updateMimes() // lets check which mode is active
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
@@ -714,5 +710,5 @@ void OFileSelector::initializeListView()
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 );
@@ -721,5 +717,7 @@ void OFileSelector::initializeListView()
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");
@@ -743,5 +741,5 @@ void OFileSelector::initializeListView()
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();
@@ -756,4 +754,5 @@ void OFileSelector::initializeListView()
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 );
@@ -784,4 +783,5 @@ void OFileSelector::initializeListView()
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
@@ -793,7 +793,7 @@ void OFileSelector::initializeListView()
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 }
@@ -902,5 +902,5 @@ void OFileSelector::slotSelectionChanged() // get the current items
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;
@@ -909,8 +909,8 @@ void OFileSelector::slotCurrentChanged(QListViewItem *item )
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 }
@@ -929,7 +929,7 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
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
@@ -938,5 +938,5 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
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] );
@@ -957,5 +957,5 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin
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}
@@ -963,5 +963,5 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin
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;
@@ -1015,5 +1015,5 @@ void OFileSelector::slotContextMenu(QListViewItem *item)
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() ){
@@ -1032,8 +1032,11 @@ bool OFileSelector::cd(const QString &str )
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)=="//")
@@ -1076,5 +1079,5 @@ void OFileSelector::slotRename()
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) );
@@ -1102,6 +1105,6 @@ void OFileSelector::cdUP()
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
@@ -1109,13 +1112,4 @@ void OFileSelector::cdUP()
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{
@@ -1137,2 +1131,7 @@ void OFileSelector::locationComboActivated(const QString & file ) {
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
@@ -193,5 +193,5 @@ class OFileSelector : public QWidget {
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();
@@ -212,5 +212,5 @@ class OFileSelector : public QWidget {
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;