From 57b77805cb1ff818af997b1bc3ee84827a33f04a Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Tue, 4 Aug 2015 17:48:52 +0200 Subject: [PATCH] Avoid recreating recent item labels when there's no change --- src/searchview.cpp | 16 ++++++++++------ src/searchview.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/searchview.cpp b/src/searchview.cpp index 60cc7a4..f72751b 100644 --- a/src/searchview.cpp +++ b/src/searchview.cpp @@ -214,6 +214,11 @@ void SearchView::disappear() { } void SearchView::updateRecentKeywords() { + // load + QSettings settings; + QStringList keywords = settings.value(recentKeywordsKey).toStringList(); + if (keywords == recentKeywords) return; + recentKeywords = keywords; // cleanup QLayoutItem *item; @@ -222,9 +227,6 @@ void SearchView::updateRecentKeywords() { delete item; } - // load - QSettings settings; - QStringList keywords = settings.value(recentKeywordsKey).toStringList(); recentKeywordsLabel->setVisible(!keywords.isEmpty()); The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty()); @@ -262,6 +264,11 @@ void SearchView::updateRecentKeywords() { } void SearchView::updateRecentChannels() { + // load + QSettings settings; + QStringList keywords = settings.value(recentChannelsKey).toStringList(); + if (keywords == recentChannels) return; + recentChannels = keywords; // cleanup QLayoutItem *item; @@ -270,9 +277,6 @@ void SearchView::updateRecentChannels() { delete item; } - // load - QSettings settings; - QStringList keywords = settings.value(recentChannelsKey).toStringList(); recentChannelsLabel->setVisible(!keywords.isEmpty()); // TODO The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty()); diff --git a/src/searchview.h b/src/searchview.h index 3e81879..e8751a6 100644 --- a/src/searchview.h +++ b/src/searchview.h @@ -74,6 +74,8 @@ private: QLabel *message; QPushButton *watchButton; + QStringList recentKeywords; + QStringList recentChannels; }; #endif // __SEARCHVIEW_H__ -- 2.39.5