summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Kubo da Costa <kubito@gmail.com>2011-08-11 12:22:15 (GMT)
committerRaphael Kubo da Costa <kubito@gmail.com>2011-08-11 12:22:15 (GMT)
commitc25ff39b48de661b2f64d0211e7e000cec89335d (patch)
tree8aea5aed394e919026bfd3bd54615fe2a7aebca0
parent6421226f30fdcbcdcaf379041a1e9eaeb5c02bb6 (diff)
Account for the case when the only selected file is a directory.
So far we were only calling QFileInfo::baseName(), which returned an empty string for directories. BUG: 279862 FIXED-IN: 4.7.1 svn path=/branches/KDE/4.7/kdeutils/ark/; revision=1246402
-rw-r--r--kerfuffle/adddialog.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/kerfuffle/adddialog.cpp b/kerfuffle/adddialog.cpp
index eebcafd..e690c7a 100644
--- a/kerfuffle/adddialog.cpp
+++ b/kerfuffle/adddialog.cpp
@@ -72,11 +72,14 @@ AddDialog::AddDialog(const QStringList& itemsToAdd,
// Set up a default name if there's only one file to compress
if (itemsToAdd.size() == 1) {
+ const QFileInfo fileInfo(itemsToAdd.first());
+ const QString fileName =
+ fileInfo.isDir() ? fileInfo.dir().dirName() : fileInfo.baseName();
+
// #272914: Add an extension when it is present, otherwise KFileDialog
// will not automatically add it as baseFileName is a file which
// already exists.
- const QString baseFileName = QFileInfo(itemsToAdd.first()).baseName();
- setSelection(baseFileName + currentFilterMimeType()->mainExtension());
+ setSelection(fileName + currentFilterMimeType()->mainExtension());
}
//These extra options will be implemented in a 4.2+ version of