From c7272df5c17c804fd379e4bac2758850f03695da Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 9 Sep 2011 20:34:55 +0200 Subject: Improve cache handling in KItemListWidget Provide a hook for derived KItemListWidget where the cache can be updated. --- src/views/dolphinfileitemlistwidget.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'src/views/dolphinfileitemlistwidget.cpp') diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp index a3fac7b2e..d39d58cd0 100644 --- a/src/views/dolphinfileitemlistwidget.cpp +++ b/src/views/dolphinfileitemlistwidget.cpp @@ -34,16 +34,14 @@ DolphinFileItemListWidget::~DolphinFileItemListWidget() { } -void DolphinFileItemListWidget::dataChanged(const QHash& current, const QSet& roles) +void DolphinFileItemListWidget::refreshCache() { - KFileItemListWidget::dataChanged(current, roles); - QColor color; - QPixmap overlay; - if (roles.contains("version")) { + const QHash values = data(); + if (values.contains("version")) { // The item is under version control. Apply the text color corresponding // to its version state. - const KVersionControlPlugin::VersionState version = static_cast(current.value("version").toInt()); + const KVersionControlPlugin::VersionState version = static_cast(values.value("version").toInt()); const QColor textColor = styleOption().palette.text().color(); QColor tintColor = textColor; @@ -68,22 +66,12 @@ void DolphinFileItemListWidget::dataChanged(const QHash& c (tintColor.blue() + textColor.blue()) / 2, (tintColor.alpha() + textColor.alpha()) / 2); - overlay = overlayForState(version, styleOption().iconSize); + setOverlay(overlayForState(version, styleOption().iconSize)); + } else if (!overlay().isNull()) { + setOverlay(QPixmap()); } setTextColor(color); - setOverlay(overlay); -} - -void DolphinFileItemListWidget::styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) -{ - KFileItemListWidget::styleOptionChanged(current, previous); - - if (!overlay().isNull() && current.iconSize != previous.iconSize) { - const KVersionControlPlugin::VersionState version = static_cast(data().value("version").toInt()); - const QPixmap newOverlay = overlayForState(version, current.iconSize); - setOverlay(newOverlay); - } } QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::VersionState version, int size) -- cgit v1.3