-rw-r--r-- | libopie/ofileselector.cc | 89 |
1 files changed, 49 insertions, 40 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index ce66f51..3a11032 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -66,7 +66,6 @@ namespace { | |||
66 | int indexByString( const QComboBox *box, const QString &str ){ | 66 | int indexByString( const QComboBox *box, const QString &str ){ |
67 | int index= -1; | 67 | int index= -1; |
68 | for(int i= 0; i < box->count(); i++ ){ | 68 | for(int i= 0; i < box->count(); i++ ){ |
69 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | ||
70 | if( str == box->text(i ) ){ | 69 | if( str == box->text(i ) ){ |
71 | index= i; | 70 | index= i; |
72 | break; | 71 | break; |
@@ -86,17 +85,19 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
86 | m_selector = selector; | 85 | m_selector = selector; |
87 | m_currentDir = dirName; | 86 | m_currentDir = dirName; |
88 | m_name = fileName; | 87 | m_name = fileName; |
89 | requestedMimeTypesList = m_mimetypes = mimetypes; | 88 | m_mimetypes = mimetypes; |
90 | 89 | ||
91 | // if( mimetypes.isEmpty() ) | 90 | if( mimetypes.isEmpty() ) |
92 | // m_autoMime = true; | 91 | m_autoMime = true; |
93 | 92 | ||
93 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); | ||
94 | m_mode = mode; | 94 | m_mode = mode; |
95 | m_shTool = true; | 95 | m_shTool = true; |
96 | m_shPerm = true; | 96 | m_shPerm = true; |
97 | m_shLne = true; | 97 | m_shLne = true; |
98 | m_shChooser = true; | 98 | m_shChooser = true; |
99 | m_shYesNo = true; | 99 | m_shYesNo = true; |
100 | |||
100 | // for FILESELECTOR only view is interesting | 101 | // for FILESELECTOR only view is interesting |
101 | m_location = 0; | 102 | m_location = 0; |
102 | m_homeButton = 0; | 103 | m_homeButton = 0; |
@@ -189,17 +190,21 @@ void OFileSelector::init() | |||
189 | { | 190 | { |
190 | // qDebug("init"); | 191 | // qDebug("init"); |
191 | m_stack = new QWidgetStack(this, "wstack" ); | 192 | m_stack = new QWidgetStack(this, "wstack" ); |
193 | if( m_selector == NORMAL ){ | ||
192 | QString currMime; | 194 | QString currMime; |
193 | if( m_mimeCheck != 0 ) | 195 | if( m_mimeCheck != 0 ) |
194 | currMime = m_mimeCheck->currentText(); | 196 | currMime = m_mimeCheck->currentText(); |
195 | updateMimes(); | 197 | updateMimes(); |
196 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 198 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , |
199 | m_stack, "fileselector", FALSE, FALSE ); | ||
197 | m_stack->addWidget(m_select, NORMAL ); | 200 | m_stack->addWidget(m_select, NORMAL ); |
198 | m_lay->addWidget(m_stack ); | 201 | m_lay->addWidget(m_stack ); |
199 | m_stack->raiseWidget(NORMAL ); | 202 | m_stack->raiseWidget(NORMAL ); |
200 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 203 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), |
204 | this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | ||
201 | m_pseudoLayout = 0l; | 205 | m_pseudoLayout = 0l; |
202 | if( m_selector != NORMAL ) { | 206 | |
207 | } else { | ||
203 | initializeListView(); | 208 | initializeListView(); |
204 | } | 209 | } |
205 | if(m_shLne ){ | 210 | if(m_shLne ){ |
@@ -215,8 +220,8 @@ void OFileSelector::init() | |||
215 | if(m_shYesNo ) | 220 | if(m_shYesNo ) |
216 | initializeYes(); | 221 | initializeYes(); |
217 | 222 | ||
218 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); | 223 | // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); |
219 | reparse(); | 224 | // reparse(); |
220 | 225 | ||
221 | } | 226 | } |
222 | 227 | ||
@@ -443,7 +448,10 @@ void OFileSelector::reparse() | |||
443 | m_mimeCheck->insertStringList(m_mimetypes ); | 448 | m_mimeCheck->insertStringList(m_mimetypes ); |
444 | // set it to the current mimetype | 449 | // set it to the current mimetype |
445 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 450 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
446 | }; | 451 | }else{ |
452 | m_mimeCheck->clear(); | ||
453 | m_mimeCheck->insertItem( m_mimetypes.join(";") ); | ||
454 | } | ||
447 | 455 | ||
448 | QDir dir( m_currentDir ); | 456 | QDir dir( m_currentDir ); |
449 | //dir.setFilter(-1 ); | 457 | //dir.setFilter(-1 ); |
@@ -578,12 +586,12 @@ void OFileSelector::initializeChooser() | |||
578 | m_viewCheck->insertItem(tr("Files") ); | 586 | m_viewCheck->insertItem(tr("Files") ); |
579 | m_viewCheck->insertItem(tr("All Files") ); | 587 | m_viewCheck->insertItem(tr("All Files") ); |
580 | 588 | ||
581 | // if(!m_autoMime ) | 589 | if(!m_autoMime ) |
582 | // m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 590 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
583 | // else{ // check | 591 | else{ // check |
584 | updateMimes(); | 592 | updateMimes(); |
585 | m_mimeCheck->insertStringList( m_mimetypes ); | 593 | m_mimeCheck->insertStringList( m_mimetypes ); |
586 | // } | 594 | } |
587 | 595 | ||
588 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 596 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
589 | this, SLOT(slotViewCheck(const QString & ) ) ); | 597 | this, SLOT(slotViewCheck(const QString & ) ) ); |
@@ -669,20 +677,22 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
669 | void OFileSelector::updateMimes() // lets check which mode is active | 677 | void OFileSelector::updateMimes() // lets check which mode is active |
670 | // check the current dir for items then | 678 | // check the current dir for items then |
671 | { | 679 | { |
672 | m_mimetypes.clear(); | 680 | if( m_autoMime ){ |
673 | m_mimetypes.append("All" ); | 681 | m_mimetypes.clear(); |
674 | // if( m_selector == NORMAL ){ | 682 | m_mimetypes.append("All" ); |
675 | DocLnkSet set; | 683 | if( m_selector == NORMAL ){ |
676 | Global::findDocuments(&set, QString::null ); | 684 | DocLnkSet set; |
677 | QListIterator<DocLnk> dit( set.children() ); | 685 | Global::findDocuments(&set, QString::null ); |
678 | for ( ; dit.current(); ++dit ) { | 686 | QListIterator<DocLnk> dit( set.children() ); |
679 | if( !m_mimetypes.contains((*dit)->type() ) ) | 687 | for ( ; dit.current(); ++dit ) { |
680 | m_mimetypes.append( (*dit)->type() ); | 688 | if( !m_mimetypes.contains((*dit)->type() ) ) |
681 | } | 689 | m_mimetypes.append( (*dit)->type() ); |
682 | // }else{ | 690 | } |
683 | // should be allreday updatet | 691 | }else{ |
684 | // ; | 692 | // should be allreday updatet |
685 | // } | 693 | ; |
694 | } | ||
695 | } | ||
686 | } | 696 | } |
687 | 697 | ||
688 | void OFileSelector::initializeListView() | 698 | void OFileSelector::initializeListView() |
@@ -692,16 +702,15 @@ void OFileSelector::initializeListView() | |||
692 | // that aren't even existing yet. | 702 | // that aren't even existing yet. |
693 | 703 | ||
694 | // just to make sure but clean it up better FIXME | 704 | // just to make sure but clean it up better FIXME |
695 | // if( m_View) delete m_View; | 705 | delete m_View; |
696 | // m_View = 0; | 706 | m_View = 0; |
697 | // if(m_boxToolbar) delete m_boxToolbar; | 707 | delete m_boxToolbar; |
698 | // if(m_homeButton) delete m_homeButton; | 708 | delete m_homeButton; |
699 | // if(m_docButton) delete m_docButton; | 709 | delete m_docButton; |
700 | // if( m_location) delete m_location; | 710 | delete m_location; |
701 | // if(m_up) delete m_up; | 711 | delete m_up; |
702 | //delete m_pseudo; | 712 | delete m_pseudo; |
703 | //if(m_pseudoLayout!=0 ) // why did you overload malloc | 713 | |
704 | //delete m_pseudoLayout; | ||
705 | m_boxToolbar = 0; | 714 | m_boxToolbar = 0; |
706 | m_homeButton = 0; | 715 | m_homeButton = 0; |
707 | m_docButton = 0; | 716 | m_docButton = 0; |