summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofiledialog.cpp
authorar <ar>2004-08-14 19:17:39 (UTC)
committer ar <ar>2004-08-14 19:17:39 (UTC)
commitb7e50e77e0b22b3dd0feee43b15d0152d9ca8abb (patch) (side-by-side diff)
tree8b1812fe843ecde7b7b12f8697ca4cf8f7444c0b /libopie2/opieui/fileselector/ofiledialog.cpp
parent74363a9e1d5688d65286e7fea156227b68a28002 (diff)
downloadopie-b7e50e77e0b22b3dd0feee43b15d0152d9ca8abb.zip
opie-b7e50e77e0b22b3dd0feee43b15d0152d9ca8abb.tar.gz
opie-b7e50e77e0b22b3dd0feee43b15d0152d9ca8abb.tar.bz2
- add OFileDialog::getDirectory()
this function open a file dialog to select a directory. it can show Directories and All Directories. the first one is without and the second is with hidden directories.
Diffstat (limited to 'libopie2/opieui/fileselector/ofiledialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp35
1 files changed, 34 insertions, 1 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
@@ -70,7 +70,10 @@ void saveLastDir( const QString& key, const QString& file )
Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
cfg.setGroup( key );
QFileInfo inf( file );
- cfg.writeEntry("LastDir", inf.dirPath( true ) );
+ if ( inf.isFile() )
+ cfg.writeEntry("LastDir", inf.dirPath( true ) );
+ else
+ cfg.writeEntry("LastDir", file );
}
};
@@ -204,6 +207,36 @@ QString OFileDialog::getSaveFileName(int selector,
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();