]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Allow to adjust start-index when renaming a various number of items
authorPeter Penz <peter.penz19@gmail.com>
Mon, 15 Aug 2011 18:34:28 +0000 (20:34 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 15 Aug 2011 18:36:43 +0000 (20:36 +0200)
Review: http://git.reviewboard.kde.org/r/102328/
Thanks to Chirag Anand for the patch!

CCMAIL: anand.chirag@gmail.com

src/views/renamedialog.cpp
src/views/renamedialog.h

index c0c6ad58c1153daed7c15b3f7be661fb39bffb4d..c974465feb1ec14c7bfd9a3d84205631caa100a4 100644 (file)
@@ -23,7 +23,9 @@
 #include <KLocale>
 #include <konq_operations.h>
 #include <KStringHandler>
+#include <knuminput.h>
 
+#include <QHBoxLayout>
 #include <QLabel>
 #include <QVBoxLayout>
 
@@ -41,7 +43,8 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     m_renameOneItem(false),
     m_newName(),
     m_lineEdit(0),
-    m_items(items)
+    m_items(items),
+    m_spinBox(0)
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
@@ -118,8 +121,15 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     topLayout->addWidget(m_lineEdit);
 
     if (!m_renameOneItem) {
-        QLabel* infoLabel = new QLabel(i18nc("@info", "(# will be replaced by ascending numbers)"), page);
-        topLayout->addWidget(infoLabel);
+        QLabel* infoLabel = new QLabel(i18nc("@info", "# will be replaced by ascending numbers starting with:"), page);
+        m_spinBox = new KIntSpinBox(0, 10000, 1, 1, page, 10);
+
+        QHBoxLayout* horizontalLayout = new QHBoxLayout(page);
+        horizontalLayout->setMargin(0);
+        horizontalLayout->addWidget(infoLabel);
+        horizontalLayout->addWidget(m_spinBox);
+
+        topLayout->addLayout(horizontalLayout);
     }
 }
 
@@ -177,7 +187,7 @@ void RenameDialog::renameItems()
     qSort(m_items.begin(), m_items.end(), lessThan);
 
     // Iterate through all items and rename them...
-    int index = 1;
+    int index = m_spinBox->value();
     foreach (const KFileItem& item, m_items) {
         const QString newName = indexedName(m_newName, index, QLatin1Char('#'));
         ++index;
index 8d8b73da56c6675b4e81d94f7467e5a52e440c11..18dca3617990d46560a30279d54cd94d47066267 100644 (file)
@@ -26,6 +26,7 @@
 #include <KFileItem>
 
 class KLineEdit;
+class KIntSpinBox;
 
 #include <QString>
 
@@ -49,7 +50,6 @@ private slots:
 private:
     void renameItems();
 
-
     /**
      * @return Returns the string \p name, where the characters represented by
      *         \p indexPlaceHolder get replaced by the index \p index.
@@ -64,6 +64,7 @@ private:
     QString m_newName;
     KLineEdit* m_lineEdit;
     KFileItemList m_items;
+    KIntSpinBox* m_spinBox;
 };
 
 #endif