]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/renamedialog.cpp
[CLAZY] Fixed all level 1 and level 2 warnings with small exceptions
[dolphin.git] / src / views / renamedialog.cpp
index e9fda4a569b71150ca46cdad1a181b01d08a1388..a514ede1e7d5b1a7858dcd2b22a756802037da7a 100644 (file)
 
 #include "renamedialog.h"
 
-#include <KLineEdit>
-#include <KLocale>
+#include <KLocalizedString>
 #include <KJobWidgets>
-#include <KJobUiDelegate>
 #include <KIO/CopyJob>
 #include <KIO/FileUndoManager>
-#include <KStringHandler>
-#include <kstringhandler_deprecated.h> //TODO port to QCollator
-#include <knuminput.h>
-#include <kmimetype.h>
+#include <KJobUiDelegate>
 
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QVBoxLayout>
 #include <QMimeDatabase>
-#include <KConfigGroup>
 #include <QDialogButtonBox>
 #include <QPushButton>
+#include <QLineEdit>
+#include <QSpinBox>
 #include <KGuiItem>
 
 RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
@@ -64,11 +60,11 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     m_okButton = buttonBox->button(QDialogButtonBox::Ok);
     m_okButton->setDefault(true);
     m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
-    connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
-    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+    connect(buttonBox, &QDialogButtonBox::accepted, this, &RenameDialog::slotAccepted);
+    connect(buttonBox, &QDialogButtonBox::rejected, this, &RenameDialog::reject);
     m_okButton->setDefault(true);
 
-    KGuiItem::assign(m_okButton, KGuiItem(i18nc("@action:button", "&Rename"), "dialog-ok-apply"));
+    KGuiItem::assign(m_okButton, KGuiItem(i18nc("@action:button", "&Rename"), QStringLiteral("dialog-ok-apply")));
 
     QWidget* page = new QWidget(this);
     mainLayout->addWidget(page);
@@ -90,9 +86,9 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
                                page);
     }
 
-    m_lineEdit = new KLineEdit(page);
+    m_lineEdit = new QLineEdit(page);
     mainLayout->addWidget(m_lineEdit);
-    connect(m_lineEdit, &KLineEdit::textChanged, this, &RenameDialog::slotTextChanged);
+    connect(m_lineEdit, &QLineEdit::textChanged, this, &RenameDialog::slotTextChanged);
 
     int selectionLength = m_newName.length();
     if (m_renameOneItem) {
@@ -112,7 +108,6 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
 
     m_lineEdit->setText(m_newName);
     m_lineEdit->setSelection(0, selectionLength);
-    m_lineEdit->setFocus();
 
     topLayout->addWidget(editLabel);
     topLayout->addWidget(m_lineEdit);
@@ -133,7 +128,12 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
 
         QLabel* infoLabel = new QLabel(i18nc("@info", "# will be replaced by ascending numbers starting with:"), page);
         mainLayout->addWidget(infoLabel);
-        m_spinBox = new KIntSpinBox(0, 10000, 1, 1, page, 10);
+        m_spinBox = new QSpinBox(page);
+        m_spinBox->setMaximum(10000);
+        m_spinBox->setMinimum(0);
+        m_spinBox->setSingleStep(1);
+        m_spinBox->setValue(1);
+        m_spinBox->setDisplayIntegerBase(10);
 
         QHBoxLayout* horizontalLayout = new QHBoxLayout(page);
         horizontalLayout->setMargin(0);
@@ -161,7 +161,7 @@ void RenameDialog::renameItem(const KFileItem &item, const QString& newName)
 
     KIO::Job * job = KIO::moveAs(oldUrl, newUrl);
     KJobWidgets::setWindow(job, widget);
-    KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, QList<QUrl>() << oldUrl, newUrl, job);
+    KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
     job->ui()->setAutoErrorHandlingEnabled(true);
 }
 
@@ -196,6 +196,13 @@ void RenameDialog::slotTextChanged(const QString& newName)
     m_okButton->setEnabled(enable);
 }
 
+void RenameDialog::showEvent(QShowEvent* event)
+{
+    m_lineEdit->setFocus();
+
+    QDialog::showEvent(event);
+}
+
 void RenameDialog::renameItems()
 {
     // Iterate through all items and rename them...