summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp35
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.h5
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp66
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h3
4 files changed, 89 insertions, 20 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index beb4d6c..ebce0ef 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -67,13 +67,16 @@ void saveLastDir( const QString& key, const QString& file )
67 if ( qApp->argc() < 1 ) 67 if ( qApp->argc() < 1 )
68 return; 68 return;
69 69
70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); 70 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
71 cfg.setGroup( key ); 71 cfg.setGroup( key );
72 QFileInfo inf( file ); 72 QFileInfo inf( file );
73 cfg.writeEntry("LastDir", inf.dirPath( true ) ); 73 if ( inf.isFile() )
74 cfg.writeEntry("LastDir", inf.dirPath( true ) );
75 else
76 cfg.writeEntry("LastDir", file );
74} 77}
75}; 78};
76 79
77/** 80/**
78 * This constructs a modal dialog 81 * This constructs a modal dialog
79 * 82 *
@@ -201,12 +204,42 @@ QString OFileDialog::getSaveFileName(int selector,
201 saveLastDir( "FileDialog-SAVE", ret ); 204 saveLastDir( "FileDialog-SAVE", ret );
202 } 205 }
203 206
204 return ret; 207 return ret;
205} 208}
206 209
210/**
211 * This opens up a filedialog in select directory mode
212 *
213 * @param selector the Selector Mode
214 * @param startDir Where to start from
215 * @param wid the parent
216 * @param caption of the dialog if QString::null tr("Open") will be used
217 * @return the directoryName or QString::null
218 */
219QString OFileDialog::getDirectory(int selector,
220 const QString &_startDir,
221 QWidget *wid,
222 const QString &caption )
223{
224 QString ret;
225 QString startDir = _startDir;
226 if ( startDir.isEmpty() )
227 startDir = lastUsedDir( "FileDialog-SELECTDIR" );
228
229 OFileDialog dlg( caption.isEmpty() ? tr( "Select Directory" ) : caption,
230 wid, OFileSelector::DirectorySelector, selector, startDir );
231 dlg.showMaximized();
232 if ( dlg.exec() )
233 {
234 ret = dlg.fileName();
235 saveLastDir( "FileDialog-SELECTDIR", ret );
236 }
237 return ret;
238}
239
207void OFileDialog::slotFileSelected(const QString & ) 240void OFileDialog::slotFileSelected(const QString & )
208{ 241{
209 accept(); 242 accept();
210} 243}
211 244
212void OFileDialog::slotSelectorOk( ) 245void OFileDialog::slotSelectorOk( )
diff --git a/libopie2/opieui/fileselector/ofiledialog.h b/libopie2/opieui/fileselector/ofiledialog.h
index dfecf3d..569f45c 100644
--- a/libopie2/opieui/fileselector/ofiledialog.h
+++ b/libopie2/opieui/fileselector/ofiledialog.h
@@ -86,12 +86,17 @@ public:
86 const QString& startDir = QString::null, 86 const QString& startDir = QString::null,
87 const QString& fileName = QString::null, 87 const QString& fileName = QString::null,
88 const MimeTypes& mimefilter = MimeTypes(), 88 const MimeTypes& mimefilter = MimeTypes(),
89 QWidget *wid = 0, 89 QWidget *wid = 0,
90 const QString &caption = QString::null ); 90 const QString &caption = QString::null );
91 91
92 static QString getDirectory(int selector,
93 const QString &startDir = QString::null,
94 QWidget *wid = 0,
95 const QString &caption = QString::null );
96
92 //let's OFileSelector catch up first 97 //let's OFileSelector catch up first
93 //static QString getExistingDirectory(const QString& startDir = QString::null, 98 //static QString getExistingDirectory(const QString& startDir = QString::null,
94 //QWidget *parent = 0, const QString& caption = QString::null ); 99 //QWidget *parent = 0, const QString& caption = QString::null );
95 100
96private: 101private:
97 class OFileDialogPrivate; 102 class OFileDialogPrivate;
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index b06defd..346eeae 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -425,16 +425,19 @@ void OFileViewFileListView::reread( bool all )
425 QDir dir( m_currentDir ); 425 QDir dir( m_currentDir );
426 if (!dir.exists() ) 426 if (!dir.exists() )
427 return; 427 return;
428 428
429 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 429 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
430 int filter; 430 int filter;
431 if (m_all ) 431 filter = QDir::Dirs;
432 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 432 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR )
433 else 433 filter = filter | QDir::Files | QDir::All;
434 filter = QDir::Files | QDir::Dirs | QDir::All; 434
435 if ( m_all )
436 filter = filter | QDir::Hidden;
437
435 dir.setFilter( filter ); 438 dir.setFilter( filter );
436 439
437 // now go through all files 440 // now go through all files
438 const QFileInfoList *list = dir.entryInfoList(); 441 const QFileInfoList *list = dir.entryInfoList();
439 if (!list) 442 if (!list)
440 { 443 {
@@ -811,13 +814,13 @@ QWidget* OFileViewFileSystem::widget( QWidget* parent )
811 } 814 }
812 return m_view; 815 return m_view;
813} 816}
814 817
815void OFileViewFileSystem::activate( const QString& str) 818void OFileViewFileSystem::activate( const QString& str)
816{ 819{
817 m_all = (str != QObject::tr("Files") ); 820 m_all = ( str.find( "All" ) != -1 );
818} 821}
819 822
820 823
821} 824}
822/* Selector */ 825/* Selector */
823/** 826/**
@@ -871,22 +874,37 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
871 874
872 QString str; 875 QString str;
873 switch ( m_selector ) 876 switch ( m_selector )
874 { 877 {
875 default: 878 default:
876 case Normal: 879 case Normal:
877 str = QObject::tr("Documents"); 880 if ( m_mode == DIRECTORYSELECTOR )
881 str = QObject::tr("Directories");
882 else
883 str = QObject::tr("Documents");
878 m_cmbView->setCurrentItem( 0 ); 884 m_cmbView->setCurrentItem( 0 );
879 break; 885 break;
880 case Extended: 886 case Extended:
881 str = QObject::tr("Files"); 887 if ( m_mode == DIRECTORYSELECTOR )
882 m_cmbView->setCurrentItem( 1 ); 888 {
889 str = QObject::tr("Directories");
890 m_cmbView->setCurrentItem( 0 );
891 } else {
892 str = QObject::tr("Files");
893 m_cmbView->setCurrentItem( 1 );
894 }
883 break; 895 break;
884 case ExtendedAll: 896 case ExtendedAll:
885 str = QObject::tr("All Files"); 897 if ( m_mode == DIRECTORYSELECTOR )
886 m_cmbView->setCurrentItem( 2 ); 898 {
899 str = QObject::tr("All Directories");
900 m_cmbView->setCurrentItem( 1 );
901 } else {
902 str = QObject::tr("All Files");
903 m_cmbView->setCurrentItem( 2 );
904 }
887 break; 905 break;
888 } 906 }
889 slotViewChange( str ); 907 slotViewChange( str );
890 908
891} 909}
892 910
@@ -982,25 +1000,37 @@ void OFileSelector::initMime()
982 this, SLOT(slotMimeTypeChanged() ) ); 1000 this, SLOT(slotMimeTypeChanged() ) );
983 1001
984} 1002}
985 1003
986void OFileSelector::initViews() 1004void OFileSelector::initViews()
987{ 1005{
988 m_cmbView->insertItem( QObject::tr("Documents") ); 1006 if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
989 m_cmbView->insertItem( QObject::tr("Files") ); 1007 {
990 m_cmbView->insertItem( QObject::tr("All Files") ); 1008 m_cmbView->insertItem( QObject::tr("Directories") );
1009 m_cmbView->insertItem( QObject::tr("All Directories") );
1010 } else {
1011 m_cmbView->insertItem( QObject::tr("Documents") );
1012 m_cmbView->insertItem( QObject::tr("Files") );
1013 m_cmbView->insertItem( QObject::tr("All Files") );
1014 }
1015
991 connect(m_cmbView, SIGNAL(activated(const QString&) ), 1016 connect(m_cmbView, SIGNAL(activated(const QString&) ),
992 this, SLOT(slotViewChange(const QString&) ) ); 1017 this, SLOT(slotViewChange(const QString&) ) );
993 1018
994
995 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
996
997 /* see above why add both */ 1019 /* see above why add both */
998 OFileViewInterface* in = new OFileViewFileSystem( this ); 1020 OFileViewInterface* in = new OFileViewFileSystem( this );
999 m_views.insert( QObject::tr("Files"), in ); 1021
1000 m_views.insert( QObject::tr("All Files"), in ); 1022 if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
1023 {
1024 m_views.insert( QObject::tr("Directories"), in );
1025 m_views.insert( QObject::tr("All Directories"), in );
1026 } else {
1027 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
1028 m_views.insert( QObject::tr("Files"), in );
1029 m_views.insert( QObject::tr("All Files"), in );
1030 }
1001} 1031}
1002 1032
1003void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { 1033void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
1004 m_viewsPtr.append( iface ); 1034 m_viewsPtr.append( iface );
1005} 1035}
1006 1036
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index de2b98a..b1cd405 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -82,14 +82,15 @@ class OFileSelector : public QWidget
82public: 82public:
83 /** 83 /**
84 * The Mode of the Fileselector 84 * The Mode of the Fileselector
85 * Open = Open A File 85 * Open = Open A File
86 * Save = Save a File 86 * Save = Save a File
87 * FILESELECTOR = As A GUI in a screen to select a file 87 * FILESELECTOR = As A GUI in a screen to select a file
88 * SelectDir = Select a Directory
88 */ 89 */
89 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 90 enum Mode { Open = 1, Save = 2, DirectorySelector = 3, FileSelector = 4, OPEN = 1, SAVE = 2, DIRECTORYSELECTOR = 3, FILESELECTOR = 4 };
90 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 91 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
91 /** 92 /**
92 * Normal = The old FileSelector 93 * Normal = The old FileSelector
93 * Extended = Dir View 94 * Extended = Dir View
94 * ExtendedAll = Dir View with all hidden files 95 * ExtendedAll = Dir View with all hidden files
95 * Default = What the vendor considers best 96 * Default = What the vendor considers best