From 982ce7ae203de9142ca3e79e6fdeacd003fb0414 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 21 Mar 2012 12:08:59 +0100 Subject: Prevent flickering when updating items When downloading images from e.g. the camera-IO-slave the files will be downloaded as *.part files and renamed afterwards. The renaming results in an undetermined mimetype and hence the probably already available preview or icon gets replaced by a dummy icon. The patch fixes this by keeping the old values as long until they have been resolved by KFileItemModelRolesUpdater. --- src/kitemviews/kfileitemmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 49c40eda1..7a4323fea 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -783,7 +783,15 @@ void KFileItemModel::slotRefreshItems(const QList >& const int index = m_items.value(oldItem.url(), -1); if (index >= 0) { m_itemData[index]->item = newItem; - m_itemData[index]->values = retrieveData(newItem); + + // Keep old values as long as possible if they could not retrieved synchronously yet. + // The update of the values will be done asynchronously by KFileItemModelRolesUpdater. + QHashIterator it(retrieveData(newItem)); + while (it.hasNext()) { + it.next(); + m_itemData[index]->values.insert(it.key(), it.value()); + } + m_items.remove(oldItem.url()); m_items.insert(newItem.url(), index); indexes.append(index); @@ -1146,7 +1154,6 @@ QHash KFileItemModel::retrieveData(const KFileItem& item) // KFileItem::iconName() can be very expensive if the MIME-type is unknown // and hence will be retrieved asynchronously by KFileItemModelRolesUpdater. QHash data; - data.insert("iconPixmap", QPixmap()); data.insert("url", item.url()); const bool isDir = item.isDir(); -- cgit v1.3