Diffstat (limited to 'libopie2/opieui/fileselector/ofiledialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opieui/fileselector/ofiledialog.cpp | 33 |
1 files changed, 33 insertions, 0 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 ) if ( qApp->argc() < 1 ) return; Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); cfg.setGroup( key ); QFileInfo inf( file ); + if ( inf.isFile() ) cfg.writeEntry("LastDir", inf.dirPath( true ) ); + else + cfg.writeEntry("LastDir", file ); } }; /** * This constructs a modal dialog * @@ -201,12 +204,42 @@ QString OFileDialog::getSaveFileName(int selector, saveLastDir( "FileDialog-SAVE", ret ); } return ret; } +/** + * This opens up a filedialog in select directory mode + * + * @param selector the Selector Mode + * @param startDir Where to start from + * @param wid the parent + * @param caption of the dialog if QString::null tr("Open") will be used + * @return the directoryName or QString::null + */ +QString OFileDialog::getDirectory(int selector, + const QString &_startDir, + QWidget *wid, + const QString &caption ) +{ + QString ret; + QString startDir = _startDir; + if ( startDir.isEmpty() ) + startDir = lastUsedDir( "FileDialog-SELECTDIR" ); + + OFileDialog dlg( caption.isEmpty() ? tr( "Select Directory" ) : caption, + wid, OFileSelector::DirectorySelector, selector, startDir ); + dlg.showMaximized(); + if ( dlg.exec() ) + { + ret = dlg.fileName(); + saveLastDir( "FileDialog-SELECTDIR", ret ); + } + return ret; +} + void OFileDialog::slotFileSelected(const QString & ) { accept(); } void OFileDialog::slotSelectorOk( ) |