Changeset View
Changeset View
Standalone View
Standalone View
src/views/renamedialog.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | |||||
150 | 150 | | |||
151 | void RenameDialog::slotAccepted() | 151 | void RenameDialog::slotAccepted() | ||
152 | { | 152 | { | ||
153 | QWidget* widget = parentWidget(); | 153 | QWidget* widget = parentWidget(); | ||
154 | if (!widget) { | 154 | if (!widget) { | ||
155 | widget = this; | 155 | widget = this; | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | const QList<QUrl> srcList = m_items.urlList(); | ||||
159 | const QString newName = m_lineEdit->text(); | ||||
158 | KIO::FileUndoManager::CommandType cmdType; | 160 | KIO::FileUndoManager::CommandType cmdType; | ||
161 | KIO::Job *job = nullptr; | ||||
159 | if (m_renameOneItem) { | 162 | if (m_renameOneItem) { | ||
160 | Q_ASSERT(m_items.count() == 1); | 163 | Q_ASSERT(m_items.count() == 1); | ||
161 | cmdType = KIO::FileUndoManager::Rename; | 164 | cmdType = KIO::FileUndoManager::Rename; | ||
165 | const QUrl oldUrl = m_items.constFirst().url(); | ||||
166 | QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename); | ||||
167 | newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName)); | ||||
168 | m_renamedItems << newUrl; | ||||
169 | job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo); | ||||
162 | } else { | 170 | } else { | ||
163 | cmdType = KIO::FileUndoManager::BatchRename; | 171 | cmdType = KIO::FileUndoManager::BatchRename; | ||
172 | job = KIO::batchRename(srcList, newName, m_spinBox->value(), QLatin1Char('#')); | ||||
173 | connect(qobject_cast<KIO::BatchRenameJob*>(job), &KIO::BatchRenameJob::fileRenamed, this, &RenameDialog::slotFileRenamed); | ||||
164 | } | 174 | } | ||
165 | 175 | | |||
166 | const QList<QUrl> srcList = m_items.urlList(); | | |||
167 | KIO::BatchRenameJob* job = KIO::batchRename(srcList, m_lineEdit->text(), m_spinBox->value(), QLatin1Char('#')); | | |||
168 | KJobWidgets::setWindow(job, widget); | 176 | KJobWidgets::setWindow(job, widget); | ||
169 | const QUrl parentUrl = srcList.first().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); | 177 | const QUrl parentUrl = srcList.first().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); | ||
170 | KIO::FileUndoManager::self()->recordJob(cmdType, srcList, parentUrl, job); | 178 | KIO::FileUndoManager::self()->recordJob(cmdType, srcList, parentUrl, job); | ||
171 | 179 | | |||
172 | connect(job, &KIO::BatchRenameJob::fileRenamed, this, &RenameDialog::slotFileRenamed); | 180 | connect(job, &KJob::result, this, &RenameDialog::slotResult); | ||
173 | connect(job, &KIO::BatchRenameJob::result, this, &RenameDialog::slotResult); | | |||
174 | 181 | | |||
175 | job->uiDelegate()->setAutoErrorHandlingEnabled(true); | 182 | job->uiDelegate()->setAutoErrorHandlingEnabled(true); | ||
176 | 183 | | |||
177 | accept(); | 184 | accept(); | ||
178 | } | 185 | } | ||
179 | 186 | | |||
180 | void RenameDialog::slotTextChanged(const QString& newName) | 187 | void RenameDialog::slotTextChanged(const QString& newName) | ||
181 | { | 188 | { | ||
Show All 35 Lines |