Introduce RootItem class hashCode idea.

This commit is contained in:
Martin Rotter 2016-01-07 07:45:56 +01:00
parent b4b244d634
commit 4cd04d03db
3 changed files with 11 additions and 2 deletions

View File

@ -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());

View File

@ -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<QAction*> RootItem::contextMenu() {
return QList<QAction*>();
}

View File

@ -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.