From 4cd04d03db140686d310c2e9f3c7d3641552763e Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 7 Jan 2016 07:45:56 +0100 Subject: [PATCH] Introduce RootItem class hashCode idea. --- src/gui/feedsview.cpp | 4 ++-- src/services/abstract/rootitem.cpp | 7 +++++++ src/services/abstract/rootitem.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 7b4af6a2c..6fd138292 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -108,7 +108,7 @@ void FeedsView::saveExpandedStates() { // Iterate all categories and save their expand statuses. foreach (RootItem *item, expandable_items) { - QString setting_name = QString::number(item->kind()) + QL1S("-") + QString::number(qHash(item->title())) + QL1S("-") + QString::number(item->id()); + QString setting_name = item->hashCode(); settings->setValue(GROUP(Categories), setting_name, @@ -124,7 +124,7 @@ void FeedsView::loadExpandedStates() { // Iterate all categories and save their expand statuses. foreach (RootItem *item, expandable_items) { - QString setting_name = QString::number(item->kind()) + QL1S("-") + QString::number(qHash(item->title())) + QL1S("-") + QString::number(item->id()); + QString setting_name = item->hashCode(); setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)), settings->value(GROUP(Categories), setting_name, item->childCount() > 0).toBool()); diff --git a/src/services/abstract/rootitem.cpp b/src/services/abstract/rootitem.cpp index f7745907b..4f5e5749f 100755 --- a/src/services/abstract/rootitem.cpp +++ b/src/services/abstract/rootitem.cpp @@ -43,6 +43,13 @@ RootItem::~RootItem() { qDeleteAll(m_childItems); } +QString RootItem::hashCode() const { + return + QString::number(kind()) + QL1S("-") + + QString::number(qHash(title())) + QL1S("-") + + QString::number(id()); +} + QList RootItem::contextMenu() { return QList(); } diff --git a/src/services/abstract/rootitem.h b/src/services/abstract/rootitem.h index 54b9be830..af7e08ebd 100755 --- a/src/services/abstract/rootitem.h +++ b/src/services/abstract/rootitem.h @@ -74,6 +74,8 @@ class RootItem : public QObject { // /* Members to override. ///////////////////////////////////////// + virtual QString hashCode() const; + // Returns list of specific actions which can be done with the item. // Do not include general actions here like actions: Mark as read, Update, ... // NOTE: Ownership of returned actions is not switched to caller, free them when needed.