From eca160ae5a2dbd5590e4bae22cddde488dbacf74 Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Thu, 19 Dec 2024 10:04:16 +0000 Subject: dolphinview: Update thumbnail on filename change If filename of an item was updated previously, it would modify the model before the file was actually changed. This led to the model calling a signal that would try to run a previewjob, but since the filename is not actually changed yet on disk, it would fail. This patch moves the model updating after copyjob. Copyjob will take care of the file renaming if there is already existing file. We just need to update the model correctly after the job has succeeded. BUG:497555 --- src/kitemviews/kfileitemlistview.h | 1 + src/kitemviews/kfileitemmodelrolesupdater.cpp | 1 + src/kitemviews/kfileitemmodelrolesupdater.h | 3 +++ 3 files changed, 5 insertions(+) (limited to 'src/kitemviews') diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h index 4c48c52ab..d6ffd3d0f 100644 --- a/src/kitemviews/kfileitemlistview.h +++ b/src/kitemviews/kfileitemlistview.h @@ -136,6 +136,7 @@ private: QTimer *m_updateIconSizeTimer; friend class KFileItemListViewTest; // For unit testing + friend class DolphinMainWindowTest; // For unit testing }; #endif diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index ac14ed795..8811401b0 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -575,6 +575,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem &item, const QPi disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); m_model->setData(index, data); connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); + Q_EMIT previewJobFinished(); // For unit testing m_finishedItems.insert(item); } diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index aa9ca5fc0..cba5b21a8 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -178,6 +178,9 @@ public: */ void setHoverSequenceState(const QUrl &itemUrl, int seqIdx); +Q_SIGNALS: + void previewJobFinished(); // For unit testing + private Q_SLOTS: void slotItemsInserted(const KItemRangeList &itemRanges); void slotItemsRemoved(const KItemRangeList &itemRanges); -- cgit v1.3