summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-06 15:40:28 (UTC)
committer zecke <zecke>2002-10-06 15:40:28 (UTC)
commit8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f (patch) (unidiff)
treefb73b4dd7035b56fd7271a689e80bc2c2067c719
parent24393565a48df6bb65516c25c124280724af9a75 (diff)
downloadopie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.zip
opie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.tar.gz
opie-8d3e63d01c9a37dfd27f3b6bd9429c8a0274d90f.tar.bz2
As promised here is the switching
It's working as expected I'll clean up it a bit fix some UI bugs and then put it into the libopie.pro
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.cpp102
-rw-r--r--libopie/ofileselector/ofileselector.h8
2 files changed, 95 insertions, 15 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 91a510f..7f38f5b 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -354,39 +354,33 @@ QValueList<DocLnk> OFileSelector::selectedDocuments() const
354} 354}
355 355
356 356
357// slots internal 357// slots internal
358 358
359void OFileSelector::slotOk() 359void OFileSelector::slotOk()
360{ 360{
361 emit ok(); 361 emit ok();
362} 362}
363void OFileSelector::slotCancel() 363void OFileSelector::slotCancel()
364{ 364{
365 emit cancel(); 365 emit cancel();
366} 366}
367/* switch the views */ 367/* switch the views */
368void OFileSelector::slotViewCheck(const QString &sel) 368void OFileSelector::slotViewCheck(const QString &sel)
369{ 369{
370 if( sel == tr("Documents" ) ){ 370 setView( sel );
371 initializeOldSelector();
372 m_selector = Normal;
373
374 }else {
375;
376 }
377} 371}
378 372
379QString OFileSelector::currentMimeType() const{ 373QString OFileSelector::currentMimeType() const{
380 QString mime; 374 QString mime;
381 QString currentText; 375 QString currentText;
382 if (m_shChooser && m_mimeCheck ) 376 if (m_shChooser && m_mimeCheck )
383 currentText = m_mimeCheck->currentText(); 377 currentText = m_mimeCheck->currentText();
384 378
385 qWarning("CurrentText" + currentText ); 379 qWarning("CurrentText" + currentText );
386 if (tr("All") == currentText ) return QString::null; 380 if (tr("All") == currentText ) return QString::null;
387 else if (currentText.isEmpty() ) { 381 else if (currentText.isEmpty() ) {
388 ; 382 ;
389 }else { 383 }else {
390 QMap<QString, QStringList>::ConstIterator it; 384 QMap<QString, QStringList>::ConstIterator it;
391 it = m_mimetypes.find( currentText ); 385 it = m_mimetypes.find( currentText );
392 if ( it != m_mimetypes.end() ) { 386 if ( it != m_mimetypes.end() ) {
@@ -461,33 +455,32 @@ void OFileSelector::locationComboChanged()
461 cd(info.dirPath(TRUE) ); //absolute path 455 cd(info.dirPath(TRUE) ); //absolute path
462 else 456 else
463 cd( m_location->lineEdit()->text() ); 457 cd( m_location->lineEdit()->text() );
464 458
465 reparse(); 459 reparse();
466} 460}
467void OFileSelector::init() 461void OFileSelector::init()
468{ 462{
469 initFactory(); 463 initFactory();
470 m_lay = new QVBoxLayout( this ); 464 m_lay = new QVBoxLayout( this );
471 m_lay->setSpacing(0 ); 465 m_lay->setSpacing(0 );
472 466
473 /* take care of the main view... */ 467 /* take care of the main view... */
474 initToolbar(); 468 initToolbar();
475 469
476 /* initialize the file lister */ 470 /* initialize the file lister */
477 initLister();
478 if( m_selector == Normal ){ 471 if( m_selector == Normal ){
479 QString mime; 472 QString mime;
480 if (!m_autoMime) { 473 if (!m_autoMime) {
481 if (!m_mimetypes.isEmpty() ) { 474 if (!m_mimetypes.isEmpty() ) {
482 QMap<QString, QStringList>::Iterator it; 475 QMap<QString, QStringList>::Iterator it;
483 it = m_mimetypes.begin(); // cause we're in the init 476 it = m_mimetypes.begin(); // cause we're in the init
484 mime = it.data().join(";"); 477 mime = it.data().join(";");
485 } 478 }
486 } 479 }
487 initializeOldSelector(); 480 initializeOldSelector();
488 }else{ 481 }else{
489 initializeView(); 482 initializeView();
490 } 483 }
491 484
492 if( m_shLne ) // the LineEdit with the current FileName 485 if( m_shLne ) // the LineEdit with the current FileName
493 initializeName(); 486 initializeName();
@@ -635,32 +628,33 @@ void OFileSelector::updateMimeCheck() {
635 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 628 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
636 m_mimeCheck->insertItem( it.key() ); 629 m_mimeCheck->insertItem( it.key() );
637 } 630 }
638} 631}
639 632
640void OFileSelector::initializeChooser() 633void OFileSelector::initializeChooser()
641{ 634{
642 if( m_boxView == 0 ){ 635 if( m_boxView == 0 ){
643 m_boxView = new QHBox( this ); 636 m_boxView = new QHBox( this );
644 m_viewCheck = new QComboBox( m_boxView, "view check"); 637 m_viewCheck = new QComboBox( m_boxView, "view check");
645 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 638 m_mimeCheck = new QComboBox( m_boxView, "mime check");
646 m_boxView->setSpacing( 8 ); 639 m_boxView->setSpacing( 8 );
647 m_lay->addWidget(m_boxView, 0 ); 640 m_lay->addWidget(m_boxView, 0 );
648 641
649 642
650 updateMimeCheck(); 643 updateMimeCheck();
644 fillList();
651 645
652 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 646 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
653 this, SLOT( slotViewCheck(const QString & ) ) ); 647 this, SLOT( slotViewCheck(const QString & ) ) );
654 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 648 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
655 this, SLOT( slotMimeCheck( const QString & ) ) ); 649 this, SLOT( slotMimeCheck( const QString & ) ) );
656 } 650 }
657} 651}
658/* generate the buttons for the toolbar */ 652/* generate the buttons for the toolbar */
659void OFileSelector::initToolbar() { 653void OFileSelector::initToolbar() {
660 m_mainView = new OFileSelectorMain( this ); 654 m_mainView = new OFileSelectorMain( this );
661 655
662 /* now generate the tool bar */ 656 /* now generate the tool bar */
663 qWarning( "toolbar" ); 657 qWarning( "toolbar" );
664 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); 658 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
665 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 659 m_pseudoLayout = new QVBoxLayout( m_pseudo );
666 660
@@ -710,36 +704,32 @@ void OFileSelector::initToolbar() {
710 704
711 /* init the locations */ 705 /* init the locations */
712 initLocations(); 706 initLocations();
713 707
714 if( !m_shTool ){ 708 if( !m_shTool ){
715 m_location->hide( ); 709 m_location->hide( );
716 m_up->hide( ); 710 m_up->hide( );
717 m_homeButton->hide( ); 711 m_homeButton->hide( );
718 m_docButton->hide( ); 712 m_docButton->hide( );
719 } 713 }
720 if(!m_shClose ) 714 if(!m_shClose )
721 m_close->hide(); 715 m_close->hide();
722 716
723 m_mainView->setToolbar( m_pseudo ); 717 m_mainView->setToolbar( m_pseudo );
724 m_lay->addWidget( m_mainView, 100 ); 718 m_lay->addWidget( m_mainView, 100 );
725} 719}
726/* initialize the OLocalLister */
727void OFileSelector::initLister() {
728 m_lister = new OLocalLister(this);
729}
730/* put default locations into the bar */ 720/* put default locations into the bar */
731void OFileSelector::initLocations () { 721void OFileSelector::initLocations () {
732 722
733 // let;s fill the Location ComboBox 723 // let;s fill the Location ComboBox
734 StorageInfo storage; 724 StorageInfo storage;
735 const QList<FileSystem> &fs = storage.fileSystems(); 725 const QList<FileSystem> &fs = storage.fileSystems();
736 QListIterator<FileSystem> it ( fs ); 726 QListIterator<FileSystem> it ( fs );
737 for( ; it.current(); ++it ){ 727 for( ; it.current(); ++it ){
738 const QString disk = (*it)->name(); 728 const QString disk = (*it)->name();
739 const QString path = (*it)->path(); 729 const QString path = (*it)->path();
740 m_location->insertItem(path+ "<-"+disk ); 730 m_location->insertItem(path+ "<-"+disk );
741 } 731 }
742 int count = m_location->count(); 732 int count = m_location->count();
743 m_location->insertItem( m_currentDir ); 733 m_location->insertItem( m_currentDir );
744 m_location->setCurrentItem( count ); 734 m_location->setCurrentItem( count );
745 735
@@ -926,43 +916,111 @@ void OFileSelector::reparse()
926 currentMimeType = m_mimeCheck->currentText(); 916 currentMimeType = m_mimeCheck->currentText();
927 917
928 } 918 }
929 // now we got our mimetypes we can add the files 919 // now we got our mimetypes we can add the files
930 920
931 currentLister()->reparse( m_currentDir ); 921 currentLister()->reparse( m_currentDir );
932 /* we're done with adding let's sort */ 922 /* we're done with adding let's sort */
933 currentView()->sort(); 923 currentView()->sort();
934 924
935 925
936 if( m_shTool ){ 926 if( m_shTool ){
937 m_location->insertItem( m_currentDir ); 927 m_location->insertItem( m_currentDir );
938 928
939 } 929 }
940 // reenable painting and updates 930 // reenable painting and updates
941} 931}
942 932/* switch lister to @param lister */
933void OFileSelector::setLister(const QString& lister) {
934 QStringList listerList = factory()->lister();
935
936 if (listerList.contains(lister) ) {
937 delete (OLister*) m_lister;
938 m_lister = factory()->lister( lister, this );
939 }else if (!m_lister ) {
940 /*
941 * if we do not have a lister
942 * we need to take the default one
943 */
944 m_lister = new OLocalLister(this);
945 }
946 m_listerName = lister;
947}
948void OFileSelector::setView( const QString& lis ) {
949 qWarning("setView ");
950 fillList();
951 if ( lis == tr("Documents") ) {
952 m_selector = Normal;
953 delete m_lister;
954 delete m_fileView;
955 m_lister = 0l;
956 m_fileView = 0l;
957 initializeOldSelector();
958 }else {
959 QString list;
960
961 delete m_lister;
962 delete m_fileView;
963 delete m_select;
964 m_lister =0l;
965 m_fileView = 0l;
966 m_select = 0l;
967 if ( lis.startsWith("All") ) {
968 m_selector = ExtendedAll;
969 list = lis.mid(4 ).stripWhiteSpace();
970 } else{
971 list = lis;
972 m_selector = Extended;
973 }
974 setLister(m_listerName);
975 m_fileView = factory()->view( list, this, m_mainView );
976 m_mainView->setWidget( m_fileView->widget() );
977 reparse();
978 }
979}
943/* 980/*
944 * the factory 981 * the factory
945 */ 982 */
946void OFileSelector::initFactory() { 983void OFileSelector::initFactory() {
947 m_fileFactory = new OFileFactory(); 984 m_fileFactory = new OFileFactory();
948 m_fileFactory->addLister(tr("Files"), newLocalLister ); 985 m_fileFactory->addLister(tr("Files"), newLocalLister );
949 m_fileFactory->addView(tr("List View"), newFileListView ); 986 m_fileFactory->addView(tr("List View"), newFileListView );
950 /* the factory is just a dummy */ 987 /* the factory is just a dummy */
951 m_fileFactory->addView(tr("Documents"), newFileListView ); 988 m_fileFactory->addView(tr("Documents"), newFileListView );
952} 989}
990void OFileSelector::fillList() {
991 qWarning("fill list");
992 if (!m_viewCheck )
993 return;
994
995 m_viewCheck->clear();
996 QStringList list = factory()->views();
997 qWarning("views: " + list.join(";") );
998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
999 qWarning( (*it) );
1000 if ( (*it) == tr("Documents") ) {
1001 m_viewCheck->insertItem( (*it) );
1002 }else{
1003 m_viewCheck->insertItem( (*it) );
1004 m_viewCheck->insertItem( tr("All ") + (*it) );
1005 }
1006 }
1007}
1008OFileFactory* OFileSelector::factory() {
1009 return m_fileFactory;
1010}
953 1011
954 1012
955OFileView* OFileSelector::currentView() { 1013OFileView* OFileSelector::currentView() {
956 return m_fileView; 1014 return m_fileView;
957} 1015}
958OFileView* OFileSelector::currentView() const{ 1016OFileView* OFileSelector::currentView() const{
959 return m_fileView; 1017 return m_fileView;
960} 1018}
961int OFileSelector::filter() { 1019int OFileSelector::filter() {
962 int filter; 1020 int filter;
963 if ( m_selector == ExtendedAll ) 1021 if ( m_selector == ExtendedAll )
964 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1022 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
965 else 1023 else
966 filter = QDir::Files | QDir::Dirs | QDir::All ; 1024 filter = QDir::Files | QDir::Dirs | QDir::All ;
967 1025
968 return filter; 1026 return filter;
@@ -1009,16 +1067,34 @@ void OFileSelector::initializeOldSelector() {
1009 /* we default not to show close and new buttons */ 1067 /* we default not to show close and new buttons */
1010 QString mime = currentMimeType(); 1068 QString mime = currentMimeType();
1011 qWarning("MimeType " + mime ); 1069 qWarning("MimeType " + mime );
1012 m_select = new FileSelector( mime , 1070 m_select = new FileSelector( mime ,
1013 m_mainView, "fileselector", 1071 m_mainView, "fileselector",
1014 FALSE, FALSE); 1072 FALSE, FALSE);
1015 m_select->setCategorySelectVisible( FALSE ); 1073 m_select->setCategorySelectVisible( FALSE );
1016 m_select->setTypeComboVisible( FALSE ); 1074 m_select->setTypeComboVisible( FALSE );
1017 1075
1018 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1019 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1020 connect(m_select, SIGNAL(closeMe() ), 1078 connect(m_select, SIGNAL(closeMe() ),
1021 this, SIGNAL(closeMe() ) ); 1079 this, SIGNAL(closeMe() ) );
1022 //connect to close me and other signals as well 1080 //connect to close me and other signals as well
1023 m_mainView->setWidget( m_select ); 1081 m_mainView->setWidget( m_select );
1024} 1082}
1083/*
1084 * initialize the listview
1085 * we will call fillList
1086 * setLister
1087 * with QString::null to get the default
1088 * setView with either Files or All Files
1089 * depending on Extended
1090 */
1091void OFileSelector::initializeView() {
1092 setLister(QString::null);
1093 fillList();
1094 if (m_selector == Extended ) {
1095 setView( tr("Files") );
1096 }else{
1097 setView( tr("All Files") );
1098 }
1099}
1100
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
index 3e834fb..76c3ced 100644
--- a/libopie/ofileselector/ofileselector.h
+++ b/libopie/ofileselector/ofileselector.h
@@ -24,32 +24,33 @@
24�: � � = �...= . :.=- 24�: � � = �...= . :.=-
25�-. � .:....=;==+<; You should have received a copy of the GNU 25�-. � .:....=;==+<; You should have received a copy of the GNU
26� -_. . . � )=. �= Library General Public License along with 26� -_. . . � )=. �= Library General Public License along with
27� � -- � � � �:-=` this library; see the file COPYING.LIB. 27� � -- � � � �:-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef opiefileselector_h 34#ifndef opiefileselector_h
35#define opiefileselector_h 35#define opiefileselector_h
36 36
37#include <qpe/fileselector.h> 37#include <qpe/fileselector.h>
38 38
39#include <qdir.h> 39#include <qdir.h>
40#include <qguardedptr.h>
40#include <qwidget.h> 41#include <qwidget.h>
41#include <qstring.h> 42#include <qstring.h>
42#include <qpixmap.h> 43#include <qpixmap.h>
43#include <qstringlist.h> 44#include <qstringlist.h>
44#include <qmap.h> 45#include <qmap.h>
45#include <qvaluelist.h> 46#include <qvaluelist.h>
46 47
47#include <qpe/applnk.h> 48#include <qpe/applnk.h>
48#include <qlistview.h> 49#include <qlistview.h>
49 50
50/** This is OPIEs FileDialog Widget. You can use it 51/** This is OPIEs FileDialog Widget. You can use it
51 * as a dropin replacement of the fileselector and 52 * as a dropin replacement of the fileselector and
52 * or use any of the new features. 53 * or use any of the new features.
53 * This is also a complete FileSave and FileLoad widget 54 * This is also a complete FileSave and FileLoad widget
54 * If you look for a Dialog check OFileDialog 55 * If you look for a Dialog check OFileDialog
55 * 56 *
@@ -218,32 +219,34 @@ class OFileSelector : public QWidget {
218 219
219 /** 220 /**
220 * setPermission 221 * setPermission
221 */ 222 */
222 bool setPermission() const; 223 bool setPermission() const;
223 224
224 /** 225 /**
225 * set ther permission to bool 226 * set ther permission to bool
226 */ 227 */
227 void setPermissionChecked( bool check ); 228 void setPermissionChecked( bool check );
228 229
229 /** 230 /**
230 * set the Selector Mode 231 * set the Selector Mode
231 */ 232 */
232 void setMode( int ); 233 void setMode( int );
233 234
235 void setLister( const QString& name );
236 void setView( const QString& all );
234 /** 237 /**
235 * whether or not to show dirs 238 * whether or not to show dirs
236 */ 239 */
237 bool showDirs()const { return m_dir; } 240 bool showDirs()const { return m_dir; }
238 241
239 /** 242 /**
240 * setShowDirs 243 * setShowDirs
241 */ 244 */
242 void setShowDirs(bool ); 245 void setShowDirs(bool );
243 246
244 /** 247 /**
245 * set CaseSensetive 248 * set CaseSensetive
246 */ 249 */
247 bool isCaseSensetive()const { return m_case; } 250 bool isCaseSensetive()const { return m_case; }
248 251
249 /** 252 /**
@@ -364,32 +367,33 @@ class OFileSelector : public QWidget {
364 void slotViewCheck(const QString & ); 367 void slotViewCheck(const QString & );
365 void slotMimeCheck(const QString & ); 368 void slotMimeCheck(const QString & );
366 void slotLocationActivated(const QString & ); 369 void slotLocationActivated(const QString & );
367 void slotInsertLocationPath(const QString &, int); 370 void slotInsertLocationPath(const QString &, int);
368 void locationComboChanged(); 371 void locationComboChanged();
369 372
370 private: 373 private:
371 void init(); 374 void init();
372 void updateMimes(); 375 void updateMimes();
373 376
374 377
375 private: 378 private:
376 379
377 OFileFactory* m_fileFactory; 380 OFileFactory* m_fileFactory;
378 OFileSelectorMain* m_mainView; 381 OFileSelectorMain* m_mainView;
379 OLister* m_lister; 382 OLister* m_lister;
383 QString m_listerName;
380 OFileView* m_fileView; 384 OFileView* m_fileView;
381 FileSelector* m_select; 385 FileSelector* m_select;
382 int m_mode, m_selector; 386 int m_mode, m_selector;
383 QComboBox *m_location, 387 QComboBox *m_location,
384 *m_mimeCheck, 388 *m_mimeCheck,
385 *m_viewCheck; 389 *m_viewCheck;
386 390
387 QPushButton *m_homeButton, 391 QPushButton *m_homeButton,
388 *m_docButton, 392 *m_docButton,
389 *m_hideButton, 393 *m_hideButton,
390 *m_ok, *m_cancel; 394 *m_ok, *m_cancel;
391 QPushButton *m_reread, 395 QPushButton *m_reread,
392 *m_up, 396 *m_up,
393 *m_new, 397 *m_new,
394 *m_close; 398 *m_close;
395 QListView *m_View; 399 QListView *m_View;
@@ -433,36 +437,36 @@ class OFileSelector : public QWidget {
433 437
434 void delItems(); 438 void delItems();
435 void initializeName(); 439 void initializeName();
436 void initializeYes(); 440 void initializeYes();
437 void initializeChooser(); 441 void initializeChooser();
438 void initializePerm(); 442 void initializePerm();
439 void initPics(); 443 void initPics();
440 bool compliesMime(const QString &path, 444 bool compliesMime(const QString &path,
441 const QString &mime); 445 const QString &mime);
442 bool compliesMime(const QString& mime ); 446 bool compliesMime(const QString& mime );
443 /** 447 /**
444 * Updates the QComboBox with the current mimetypes 448 * Updates the QComboBox with the current mimetypes
445 */ 449 */
446 void updateMimeCheck(); 450 void updateMimeCheck();
447 451
448 void initializeOldSelector(); 452 void initializeOldSelector();
449 void initLister();
450 void initToolbar(); 453 void initToolbar();
451 void initLocations(); 454 void initLocations();
452 void initializeView() {}; // FIXME 455 void initializeView(); // FIXME
456 void fillList();
453 void initFactory(); 457 void initFactory();
454 /** 458 /**
455 * Returns the current mimetype 459 * Returns the current mimetype
456 */ 460 */
457 QString currentMimeType()const; 461 QString currentMimeType()const;
458 class OFileSelectorPrivate; 462 class OFileSelectorPrivate;
459 OFileSelectorPrivate *d; 463 OFileSelectorPrivate *d;
460 static QMap<QString,QPixmap> *m_pixmaps; 464 static QMap<QString,QPixmap> *m_pixmaps;
461 465
462private slots: 466private slots:
463 void slotFileSelected(const QString & ); // not really meant to be a slot 467 void slotFileSelected(const QString & ); // not really meant to be a slot
464 void slotFileBridgeSelected( const DocLnk & ); 468 void slotFileBridgeSelected( const DocLnk & );
465 // listview above 469 // listview above
466 // popup below 470 // popup below
467 virtual void slotDelete(); 471 virtual void slotDelete();
468 virtual void cdUP(); 472 virtual void cdUP();