]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/renamedialog.h
Show elastic band on the column widget
[dolphin.git] / src / renamedialog.h
index c08856f8c8aaac9870a076071e7fb37abbf2af86..9984757337d676577db1a188dd85f1c3d83b0f8a 100644 (file)
 #ifndef RENAMEDIALOG_H
 #define RENAMEDIALOG_H
 
+#include "libdolphin_export.h"
+
 #include <kdialog.h>
 #include <kurl.h>
 
-#include <QString>
 
+class KFileItem;
+class KFileItemList;
 class KLineEdit;
 
 /**
@@ -45,34 +48,62 @@ class KLineEdit;
  * }
  * \endcode
  */
-class RenameDialog : public KDialog
+class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
 {
     Q_OBJECT
 
 public:
-    explicit RenameDialog(const KUrl::List& items);
+    explicit RenameDialog(QWidget *parent, const KFileItemList& items);
     virtual ~RenameDialog();
 
     /**
-     * Returns the new name of the items. If the returned string is not empty,
-     * then it is assured that the string contains exactly one character #,
-     * which should be replaced by ascending numbers. An empty string indicates
-     * that the user has removed the # character.
+     * Returns the new name of the items. If more than one
+     * item should be renamed, then it is assured that the # character
+     * is part of the returned string. If the returned string is empty,
+     * then RenameDialog::errorString() should be used to show the reason
+     * of having an empty string (e. g. if the # character has
+     * been deleted by the user, although more then one item should be
+     * renamed).
      */
-    const QString& newName() const { return m_newName; }
+    const QString& newName() const
+    {
+        return m_newName;
+    }
 
     /**
      * Returns the error string, if Dialog::newName() returned an empty string.
      */
-    const QString& errorString() const { return m_errorString; }
+    const QString& errorString() const
+    {
+        return m_errorString;
+    }
 
 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;
     QString m_newName;
     QString m_errorString;
+
+    friend class RenameDialogTest; // allow access for unit testing
 };
 
 #endif