]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Just use KMimeType::extractKnownExtension() instead of the custom implementation...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 10 Jun 2008 17:22:24 +0000 (17:22 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 10 Jun 2008 17:22:24 +0000 (17:22 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=819137

src/CMakeLists.txt
src/renamedialog.cpp
src/renamedialog.h
src/tests/CMakeLists.txt [deleted file]
src/tests/renamedialogtest.cpp [deleted file]
src/tests/renamedialogtest.h [deleted file]

index d138a22903e3ca478bffc1bc0462f0f3d1d9928c..b37494566d697caf47a0ddb052f279a7122e1db3 100644 (file)
@@ -1,6 +1,5 @@
 
 add_subdirectory( pics )
 
 add_subdirectory( pics )
-add_subdirectory( tests )
 
 find_package(QImageBlitz REQUIRED)
 
 
 find_package(QImageBlitz REQUIRED)
 
index 3e9b39327d9907012c92a679180ae2d8054907e2..02dd2e9f6dbfe15fd4a330d9f4a1fdec11f4853c 100644 (file)
@@ -65,8 +65,9 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     }
 
     m_lineEdit = new KLineEdit(page);
     }
 
     m_lineEdit = new KLineEdit(page);
-    QString extension = extensionString(items[0].url().prettyUrl());
+    QString extension = KMimeType::extractKnownExtension(items[0].url().prettyUrl());
     if (extension.length() > 0) {
     if (extension.length() > 0) {
+        extension.insert(0, '.');
         // The first item seems to have a extension (e. g. '.jpg' or '.txt'). Now
         // check whether all other URLs have the same extension. If this is the
         // case, add this extension to the name suggestion.
         // The first item seems to have a extension (e. g. '.jpg' or '.txt'). Now
         // check whether all other URLs have the same extension. If this is the
         // case, add this extension to the name suggestion.
@@ -107,7 +108,8 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
 }
 
 RenameDialog::~RenameDialog()
 }
 
 RenameDialog::~RenameDialog()
-{}
+{
+}
 
 void RenameDialog::slotButtonClicked(int button)
 {
 
 void RenameDialog::slotButtonClicked(int button)
 {
@@ -125,36 +127,4 @@ void RenameDialog::slotButtonClicked(int button)
     KDialog::slotButtonClicked(button);
 }
 
     KDialog::slotButtonClicked(button);
 }
 
-QString RenameDialog::extensionString(const QString& name)
-{
-    QString extension;
-
-    const QStringList strings = name.split('.');
-    const int size = strings.size();
-    for (int i = size - 1; i >= 0; --i) {
-        const QString& str = strings.at(i);
-
-        // 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;
-        }
-
-        // 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;
-}
-
 #include "renamedialog.moc"
 #include "renamedialog.moc"
index 9984757337d676577db1a188dd85f1c3d83b0f8a..931b89cb03029ae0651e91e3e2f50af5d143f859 100644 (file)
@@ -81,22 +81,6 @@ public:
 protected slots:
     virtual void slotButtonClicked(int button);
 
 protected slots:
     virtual void slotButtonClicked(int button);
 
-private:
-    /**
-     * Returns the extension string for a filename, which contains all
-     * file extensions. Version numbers like in "cmake-2.4.5" don't count
-     * as file extension. If the version numbers follow after a valid extension, they
-     * are part of the extension string.
-     *
-     * Examples (name -> extension string):
-     * "Image.gif" -> ".gif"
-     * "package.tar.gz" -> ".tar.gz"
-     * "cmake-2.4.5" -> ""
-     * "Image.1.12.gif" -> ".gif"
-     * "Image.tar.1.12.gz" -> ".tar.1.12.gz"
-     */
-    static QString extensionString(const QString& name);
-
 private:
     bool m_renameOneItem;
     KLineEdit* m_lineEdit;
 private:
     bool m_renameOneItem;
     KLineEdit* m_lineEdit;
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
deleted file mode 100644 (file)
index 5379aac..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
-
-########### renamedialogtest ###############
-
-
-kde4_add_unit_test(renamedialogtest renamedialogtest.cpp)
-
-target_link_libraries(renamedialogtest dolphinprivate ${QT_QTTEST_LIBRARY})
-
-
-  ############################################
-
diff --git a/src/tests/renamedialogtest.cpp b/src/tests/renamedialogtest.cpp
deleted file mode 100644 (file)
index dc2adff..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
- ***************************************************************************/
-
-#include "renamedialogtest.h"
-#include <qtest_kde.h>
-#include <renamedialog.h>
-
-QTEST_KDEMAIN(RenameDialogTest, NoGUI)
-
-void RenameDialogTest::testExtensionString()
-{
-    QString result;
-
-    result = RenameDialog::extensionString("Image.gif");
-    QCOMPARE(result, QString(".gif"));
-
-    result = RenameDialog::extensionString("package.tar.gz");
-    QCOMPARE(result, QString(".tar.gz"));
-
-    result = RenameDialog::extensionString("cmake-2.4.5");
-    QCOMPARE(result, QString());
-
-    result = RenameDialog::extensionString("Image.1.12.gif");
-    QCOMPARE(result, QString(".gif"));
-
-    result = RenameDialog::extensionString("Image.tar.1.12.gz");
-    QCOMPARE(result, QString(".gz"));
-
-    result = RenameDialog::extensionString("Open office.org writer documentation.pdf");
-    QCOMPARE(result, QString(".pdf"));
-
-    result = RenameDialog::extensionString("Test.toolongextension.pdf");
-    QCOMPARE(result, QString(".pdf"));
-
-    result = RenameDialog::extensionString("Test.x x.pdf");
-    QCOMPARE(result, QString(".pdf"));
-}
-
-#include "renamedialogtest.moc"
diff --git a/src/tests/renamedialogtest.h b/src/tests/renamedialogtest.h
deleted file mode 100644 (file)
index 0aabc62..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
- ***************************************************************************/ 
-
-#ifndef RENAMEDIALOGTEST_H
-#define RENAMEDIALOGTEST_H
-
-#include <QObject>
-
-class RenameDialogTest : public QObject
-{
-    Q_OBJECT
-
-private slots:
-    void testExtensionString();
-};
-
-#endif