Diffstat (limited to 'libopie2/opieui/fileselector/ofiledialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/fileselector/ofiledialog.cpp | 35 |
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 | |||
@@ -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 | */ | ||
219 | QString 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 | |||
207 | void OFileDialog::slotFileSelected(const QString & ) | 240 | void OFileDialog::slotFileSelected(const QString & ) |
208 | { | 241 | { |
209 | accept(); | 242 | accept(); |
210 | } | 243 | } |
211 | 244 | ||
212 | void OFileDialog::slotSelectorOk( ) | 245 | void OFileDialog::slotSelectorOk( ) |