summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofiledialog.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opieui/fileselector/ofiledialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp33
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
@@ -72,3 +72,6 @@ void saveLastDir( const QString& key, const QString& file )
QFileInfo inf( file );
+ if ( inf.isFile() )
cfg.writeEntry("LastDir", inf.dirPath( true ) );
+ else
+ cfg.writeEntry("LastDir", file );
}
@@ -206,2 +209,32 @@ QString OFileDialog::getSaveFileName(int selector,
+/**
+ * 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 & )