┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/renamedialog.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-02-23 11:59:57 +0000
committerPeter Penz <[email protected]>2008-02-23 11:59:57 +0000
commit3db4843c35b7380cdb2072e9df3ac5811db87e48 (patch)
treecf15d1874c1ad9519cc596d6e5f1ca6311b0625d /src/renamedialog.cpp
parenteaefe4250c3af559d259ed954a322a463f55ede5 (diff)
fixed issue that when renaming "Open office.org writer documentation.pdf" that only "Open office" is selected and ".org writer documentation" is handled as extension
BUG: 158228 svn path=/trunk/KDE/kdebase/apps/; revision=778329
Diffstat (limited to 'src/renamedialog.cpp')
-rw-r--r--src/renamedialog.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/renamedialog.cpp b/src/renamedialog.cpp
index fa5bf60e0..3e9b39327 100644
--- a/src/renamedialog.cpp
+++ b/src/renamedialog.cpp
@@ -128,24 +128,30 @@ void RenameDialog::slotButtonClicked(int button)
QString RenameDialog::extensionString(const QString& name)
{
QString extension;
- bool foundExtension = false; // true if at least one valid file extension
- // like "gif", "txt", ... has been found
- QStringList strings = name.split('.');
+ const QStringList strings = name.split('.');
const int size = strings.size();
- for (int i = 1; i < size; ++i) {
+ for (int i = size - 1; i >= 0; --i) {
const QString& str = strings.at(i);
- if (!foundExtension) {
- // Sub strings like "9", "12", "99", ... which contain only
- // numbers don't count as extension. Usually they are version
- // numbers like in "cmake-2.4.5".
- bool ok = false;
- str.toInt(&ok);
- foundExtension = !ok;
+
+ // Sub strings like "9", "12", "99", ... which contain only
+ // numbers don't count as extension. Usually they are version
+ // numbers like in "cmake-2.4.5".
+ bool isNumeric = false;
+ str.toInt(&isNumeric);
+ if (isNumeric) {
+ break;
}
- if (foundExtension) {
- extension += '.' + str;
+
+ // Extensions may not contain a space and the maximum length
+ // should not exceed 4 characters. This prevents that strings like
+ // "Open office.org writer documentation.pdf" get ".org writer documentation.pdf"
+ // as extension.
+ if (str.contains(' ') || (str.length() > 4)) {
+ break;
}
+
+ extension.insert(0, '.' + str);
}
return extension;