summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-27 22:09:26 (UTC)
committer zecke <zecke>2002-04-27 22:09:26 (UTC)
commit7d741c93b423a3ab721071971b2c345d2d8548e2 (patch) (unidiff)
treec6ae4fc904ccd5f3ab08fb2876f9666358544f4f
parent69e271e44d23befc74a96a98708ddb6ec754a4b6 (diff)
downloadopie-7d741c93b423a3ab721071971b2c345d2d8548e2.zip
opie-7d741c93b423a3ab721071971b2c345d2d8548e2.tar.gz
opie-7d741c93b423a3ab721071971b2c345d2d8548e2.tar.bz2
Fix automime and mime tested with textedit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc89
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
@@ -57,55 +57,56 @@
57#include <stdlib.h> 57#include <stdlib.h>
58#include <sys/stat.h> 58#include <sys/stat.h>
59 59
60#include "ofileselector.h" 60#include "ofileselector.h"
61 61
62QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 62QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
63 63
64namespace { 64namespace {
65 65
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;
73 } 72 }
74 } 73 }
75 return index; 74 return index;
76 } 75 }
77 76
78}; 77};
79 78
80 79
81OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 80OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
82 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) 81 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid )
83{ 82{
84 if(wid!=0) 83 if(wid!=0)
85 resize(wid->width(),wid->height()); 84 resize(wid->width(),wid->height());
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;
103 m_docButton = 0; 104 m_docButton = 0;
104 m_hideButton = 0; 105 m_hideButton = 0;
105 m_ok = 0; 106 m_ok = 0;
106 m_cancel = 0; 107 m_cancel = 0;
107 m_reread = 0; 108 m_reread = 0;
108 m_up = 0; 109 m_up = 0;
109 m_View = 0; 110 m_View = 0;
110 m_select = 0; 111 m_select = 0;
111 m_stack = 0; 112 m_stack = 0;
@@ -180,52 +181,56 @@ void OFileSelector::initPics()
180void OFileSelector::delItems() 181void OFileSelector::delItems()
181{ 182{
182 QLayoutIterator it = m_lay->iterator(); 183 QLayoutIterator it = m_lay->iterator();
183 while ( it.current() != 0 ){ 184 while ( it.current() != 0 ){
184 it.deleteCurrent(); 185 it.deleteCurrent();
185 } 186 }
186} 187}
187 188
188void OFileSelector::init() 189void 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 ){
206 initializeName(); 211 initializeName();
207 } 212 }
208 if(m_shPerm ){ 213 if(m_shPerm ){
209 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 214 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
210 m_checkPerm->setChecked( false ); 215 m_checkPerm->setChecked( false );
211 m_lay->addWidget(m_checkPerm ); 216 m_lay->addWidget(m_checkPerm );
212 } 217 }
213 if( m_shChooser ) 218 if( m_shChooser )
214 initializeChooser(); 219 initializeChooser();
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
223void OFileSelector::setYesCancelVisible( bool show ) 228void OFileSelector::setYesCancelVisible( bool show )
224{ 229{
225 if ( show == m_shYesNo ) 230 if ( show == m_shYesNo )
226 return; 231 return;
227 m_shYesNo = show; 232 m_shYesNo = show;
228 if( !show ){ 233 if( !show ){
229 delete m_ok; 234 delete m_ok;
230 delete m_cancel; 235 delete m_cancel;
231 m_ok = 0; 236 m_ok = 0;
@@ -434,25 +439,28 @@ void OFileSelector::reparse()
434 continue; 439 continue;
435 } 440 }
436 MimeType type(fi->filePath() ); 441 MimeType type(fi->filePath() );
437 if( !m_mimetypes.contains( type.id() ) ) 442 if( !m_mimetypes.contains( type.id() ) )
438 m_mimetypes.append( type.id() ); 443 m_mimetypes.append( type.id() );
439 444
440 ++it; 445 ++it;
441 } 446 }
442 m_mimetypes.prepend("All" ); 447 m_mimetypes.prepend("All" );
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 );
450 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; 458 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
451 if( m_case ) 459 if( m_case )
452 sort = QDir::IgnoreCase; 460 sort = QDir::IgnoreCase;
453 dir.setSorting( sort ); 461 dir.setSorting( sort );
454 462
455 int filter; 463 int filter;
456 /* if( m_dir && !m_files) 464 /* if( m_dir && !m_files)
457 filter |= QDir::Dirs; 465 filter |= QDir::Dirs;
458 else if( !m_dir && m_files ) 466 else if( !m_dir && m_files )
@@ -569,30 +577,30 @@ void OFileSelector::initializeChooser()
569 m_mimeCheck = new QComboBox(this, "mime check"); 577 m_mimeCheck = new QComboBox(this, "mime check");
570 m_viewCheck = new QComboBox(this, "view check"); 578 m_viewCheck = new QComboBox(this, "view check");
571 m_boxView->addWidget(m_viewCheck, 0 ); 579 m_boxView->addWidget(m_viewCheck, 0 );
572 m_boxView->insertSpacing(2, 8 ); 580 m_boxView->insertSpacing(2, 8 );
573 m_boxView->addWidget(m_mimeCheck, 0 ); 581 m_boxView->addWidget(m_mimeCheck, 0 );
574 m_lay->addLayout(m_boxView ); 582 m_lay->addLayout(m_boxView );
575 m_lay->insertSpacing( 4, 8); 583 m_lay->insertSpacing( 4, 8);
576 584
577 m_viewCheck->insertItem(tr("Documents") ); 585 m_viewCheck->insertItem(tr("Documents") );
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 & ) ) );
590 598
591 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 599 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
592 this, SLOT(slotMimeCheck(const QString & ) ) ); 600 this, SLOT(slotMimeCheck(const QString & ) ) );
593} 601}
594 602
595void OFileSelector::slotMimeCheck(const QString &view ){ 603void OFileSelector::slotMimeCheck(const QString &view ){
596 if(m_selector == NORMAL ){ 604 if(m_selector == NORMAL ){
597 delete m_select; 605 delete m_select;
598 m_select = new FileSelector(view == "All" ? QString::null : view 606 m_select = new FileSelector(view == "All" ? QString::null : view
@@ -660,57 +668,58 @@ void OFileSelector::slotViewCheck(const QString &view ){
660 m_View = 0; 668 m_View = 0;
661 669
662 m_selector = EXTENDED_ALL; 670 m_selector = EXTENDED_ALL;
663 initializeListView(); 671 initializeListView();
664 reparse(); 672 reparse();
665 } 673 }
666} 674}
667 675
668 676
669void OFileSelector::updateMimes() // lets check which mode is active 677void 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
688void OFileSelector::initializeListView() 698void OFileSelector::initializeListView()
689{ 699{
690 // in the instance that a developer selected the view to be Files or Entended, 700 // in the instance that a developer selected the view to be Files or Entended,
691 // in the initial initialization, you are deleting objects here 701 // in the initial initialization, you are deleting objects here
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;
708 m_location = 0; 717 m_location = 0;
709 m_up = 0; 718 m_up = 0;
710 m_pseudo = 0; 719 m_pseudo = 0;
711 m_pseudoLayout = 0; 720 m_pseudoLayout = 0;
712 qDebug(" time for the toolbar "); 721 qDebug(" time for the toolbar ");
713 m_pseudo = new QWidget(m_stack, "Pseudo Widget"); 722 m_pseudo = new QWidget(m_stack, "Pseudo Widget");
714 m_pseudoLayout = new QVBoxLayout(m_pseudo ); 723 m_pseudoLayout = new QVBoxLayout(m_pseudo );
715 if(m_shTool ){ 724 if(m_shTool ){
716 m_boxToolbar = new QHBoxLayout( ); 725 m_boxToolbar = new QHBoxLayout( );