]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
ViewProperties: Store view properties in extended file attributes
[dolphin.git] / src / views / dolphinview.cpp
index 17023ae5f445d7d8e556ffaf8d4f0d25684b9553..0c5ebb1df72a2a82e0372751d8183cf40ed119ec 100644 (file)
@@ -375,9 +375,8 @@ void DolphinView::setGroupedSorting(bool grouped)
 
     ViewProperties props(viewPropertiesUrl());
     props.setGroupedSorting(grouped);
-    props.save();
 
-    m_container->controller()->model()->setGroupedSorting(grouped);
+    m_model->setGroupedSorting(grouped);
 
     Q_EMIT groupedSortingChanged(grouped);
 }
@@ -757,7 +756,20 @@ void DolphinView::renameSelectedItems()
 
     } else {
         KIO::RenameFileDialog *dialog = new KIO::RenameFileDialog(items, this);
-        connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished);
+        connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, [this, items](const QList<QUrl> &urls) {
+            // The model may have already been updated, so it's possible that we don't find the old items.
+            for (int i = 0; i < items.count(); ++i) {
+                const int index = m_model->index(items[i]);
+                if (index >= 0) {
+                    QHash<QByteArray, QVariant> data;
+                    data.insert("text", urls[i].fileName());
+                    m_model->setData(index, data);
+                }
+            }
+
+            forceUrlsSelection(urls.first(), urls);
+            updateSelectionState();
+        });
         connect(dialog, &KIO::RenameFileDialog::error, this, [this](KJob *job) {
             KMessageBox::error(this, job->errorString());
         });
@@ -2032,6 +2044,7 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray &role, con
 
             if (!newNameExistsAlready) {
                 forceUrlsSelection(newUrl, {newUrl});
+                updateSelectionState();
 
                 // Only connect the result signal if there is no item with the new name
                 // in the model yet, see bug 328262.
@@ -2275,11 +2288,6 @@ QUrl DolphinView::viewPropertiesUrl() const
     return url;
 }
 
-void DolphinView::slotRenameDialogRenamingFinished(const QList<QUrl> &urls)
-{
-    forceUrlsSelection(urls.first(), urls);
-}
-
 void DolphinView::forceUrlsSelection(const QUrl &current, const QList<QUrl> &selected)
 {
     clearSelection();