X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8eb9b508ca87fb1d634d8b8ba62c054ed04466d2..2f0ceedae088158b8af24a5e94500a7d1c0edecb:/src/views/renamedialog.cpp diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index 864cfe270..c974465fe 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -23,7 +23,9 @@ #include #include #include +#include +#include #include #include @@ -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); } } @@ -131,7 +141,16 @@ void RenameDialog::slotButtonClicked(int button) { if (button == KDialog::Ok) { m_newName = m_lineEdit->text(); - renameItems(); + + if (m_renameOneItem) { + Q_ASSERT(m_items.count() == 1); + const KUrl oldUrl = m_items.first().url(); + KUrl newUrl = oldUrl; + newUrl.setFileName(KIO::encodeFileName(m_newName)); + KonqOperations::rename(this, oldUrl, newUrl); + } else { + renameItems(); + } } KDialog::slotButtonClicked(button); @@ -139,7 +158,7 @@ void RenameDialog::slotButtonClicked(int button) void RenameDialog::slotTextChanged(const QString& newName) { - bool enable = !newName.isEmpty(); + bool enable = !newName.isEmpty() && (newName != QLatin1String("..")) && (newName != QLatin1String(".")); if (enable) { if (m_renameOneItem) { enable = enable && (newName != m_newName); @@ -168,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; @@ -176,7 +195,7 @@ void RenameDialog::renameItems() const KUrl oldUrl = item.url(); if (oldUrl.fileName() != newName) { KUrl newUrl = oldUrl; - newUrl.setFileName(newName); + newUrl.setFileName(KIO::encodeFileName(newName)); KonqOperations::rename(this, oldUrl, newUrl); } }