]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Renaming: Don't select unknown extensions
authorPeter Penz <peter.penz19@gmail.com>
Sat, 16 Jun 2012 20:51:39 +0000 (22:51 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 16 Jun 2012 20:53:32 +0000 (22:53 +0200)
If a file with an unknown extension gets renamed, it is assumed
that the letters after the last point represent the extension and
won't be selected.

BUG: 301893
FIXED-IN: 4.9.0

src/kitemviews/kstandarditemlistwidget.cpp

index acd426cf25d73b3039cfa6b9712a55203be18836..e584c0678ce7e6e3fc04ad3dbeb89c8556d8a51f 100644 (file)
@@ -606,10 +606,17 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
     m_roleEditor->document()->setDefaultTextOption(textOption);
 
     // Select the text without MIME-type extension
+    // TODO: This is file-item-specific and should be moved
+    // into KFileItemListWidget.
     int selectionLength = text.length();
 
     const QString extension = KMimeType::extractKnownExtension(text);
-    if (!extension.isEmpty()) {
+    if (extension.isEmpty()) {
+        // For an unknown extension just exclude the extension after
+        // the last point. This does not work for multiple extensions like
+        // *.tar.gz but usually this is anyhow a known extension.
+        selectionLength = text.lastIndexOf(QLatin1Char('.'));
+    } else {
         selectionLength -= extension.length() + 1;
     }