When renaming a file, if its new name causes it to scroll out of view,
Dolphin will not scroll to the location of the new file.
This patch aims to address that. This affects all view modes.
CCBUG: 354330
Test Plan:
1. Have many files in a directory (or several files, just zoom in a lot)
2. Rename a file so that it will move out of view
Differential Revision: https://phabricator.kde.org/D6312
this, &DolphinView::slotRoleEditingFinished);
} else {
RenameDialog* dialog = new RenameDialog(this, items);
this, &DolphinView::slotRoleEditingFinished);
} else {
RenameDialog* dialog = new RenameDialog(this, items);
+
+ connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished);
+
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
dialog->raise();
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
dialog->raise();
void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
- clearSelection();
- markUrlAsCurrent(url);
- markUrlsAsSelected({url});
+ forceUrlsSelection(url, {url});
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
+ forceUrlsSelection(newUrl, {newUrl});
+
if (!newNameExistsAlready) {
// Only connect the result signal if there is no item with the new name
// in the model yet, see bug 328262.
if (!newNameExistsAlready) {
// Only connect the result signal if there is no item with the new name
// in the model yet, see bug 328262.
url.setPath(m_viewPropertiesContext);
return url;
}
url.setPath(m_viewPropertiesContext);
return url;
}
+
+void DolphinView::slotRenameDialogRenamingFinished(const QList<QUrl>& urls)
+{
+ forceUrlsSelection(urls.first(), urls);
+}
+
+void DolphinView::forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected)
+{
+ clearSelection();
+ m_clearSelectionBeforeSelectingNewItems = true;
+ markUrlAsCurrent(current);
+ markUrlsAsSelected(selected);
+}
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
+ void slotRenameDialogRenamingFinished(const QList<QUrl>& urls);
/*
* Is called when new items get pasted or dropped.
/*
* Is called when new items get pasted or dropped.
*/
QUrl viewPropertiesUrl() const;
*/
QUrl viewPropertiesUrl() const;
+ /**
+ * Clears the selection and updates current item and selection according to the parameters
+ *
+ * @param current URL to be set as current
+ * @param selected list of selected items
+ */
+ void forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected);
+
private:
void updatePalette();
private:
void updatePalette();
KIO::Job * job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo);
KJobWidgets::setWindow(job, widget);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
KIO::Job * job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo);
KJobWidgets::setWindow(job, widget);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+
+ if (!job->error()) {
+ m_renamedItems << newUrl;
+ }
+
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
renameItem(item, newName);
}
}
renameItem(item, newName);
}
}
+
+ if (!m_items.empty()) {
+ emit renamingFinished(m_renamedItems);
+ }
}
QString RenameDialog::indexedName(const QString& name, int index, const QChar& indexPlaceHolder)
}
QString RenameDialog::indexedName(const QString& name, int index, const QChar& indexPlaceHolder)
explicit RenameDialog(QWidget* parent, const KFileItemList& items);
virtual ~RenameDialog();
explicit RenameDialog(QWidget* parent, const KFileItemList& items);
virtual ~RenameDialog();
+signals:
+ void renamingFinished(const QList<QUrl>& urls);
+
private slots:
void slotAccepted();
void slotTextChanged(const QString& newName);
private slots:
void slotAccepted();
void slotTextChanged(const QString& newName);
private:
bool m_renameOneItem;
private:
bool m_renameOneItem;
+ QList<QUrl> m_renamedItems;
QString m_newName;
QLineEdit* m_lineEdit;
KFileItemList m_items;
QString m_newName;
QLineEdit* m_lineEdit;
KFileItemList m_items;