Unified hashCode() implementation.

This commit is contained in:
Martin Rotter 2016-02-16 07:29:56 +01:00
parent d76e5eb345
commit 57110063d6
5 changed files with 7 additions and 26 deletions

View File

@ -44,7 +44,13 @@ RootItem::~RootItem() {
} }
QString RootItem::hashCode() const { QString RootItem::hashCode() const {
return QString::number(kind()) + QL1S("-") + QString::number(id()); ServiceRoot *root = getParentServiceRoot();
int acc_id = root == NULL ? 0 : root->accountId();
return
QString::number(acc_id) + QL1S("-") +
QString::number(kind()) + QL1S("-") +
QString::number(id());
} }
QList<QAction*> RootItem::contextMenu() { QList<QAction*> RootItem::contextMenu() {

View File

@ -41,13 +41,6 @@ TtRssCategory::TtRssCategory(const QSqlRecord &record) : Category(NULL) {
TtRssCategory::~TtRssCategory() { TtRssCategory::~TtRssCategory() {
} }
QString TtRssCategory::hashCode() const {
return
QString::number(kind()) + QL1S("-") +
QString::number(getParentServiceRoot()->accountId()) + QL1S("-") +
QString::number(customId());
}
TtRssServiceRoot *TtRssCategory::serviceRoot() const { TtRssServiceRoot *TtRssCategory::serviceRoot() const {
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot()); return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
} }

View File

@ -33,10 +33,7 @@ class TtRssCategory : public Category {
explicit TtRssCategory(const QSqlRecord &record); explicit TtRssCategory(const QSqlRecord &record);
virtual ~TtRssCategory(); virtual ~TtRssCategory();
QString hashCode() const;
TtRssServiceRoot *serviceRoot() const; TtRssServiceRoot *serviceRoot() const;
bool markAsReadUnread(ReadStatus status); bool markAsReadUnread(ReadStatus status);
bool cleanMessages(bool clear_only_read); bool cleanMessages(bool clear_only_read);

View File

@ -50,13 +50,6 @@ TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL) {
TtRssFeed::~TtRssFeed() { TtRssFeed::~TtRssFeed() {
} }
QString TtRssFeed::hashCode() const {
return
QString::number(kind()) + QL1S("-") +
QString::number(getParentServiceRoot()->accountId()) + QL1S("-") +
QString::number(customId());
}
int TtRssFeed::messageForeignKeyId() const { int TtRssFeed::messageForeignKeyId() const {
return customId(); return customId();
} }

View File

@ -33,25 +33,17 @@ class TtRssFeed : public Feed {
explicit TtRssFeed(const QSqlRecord &record); explicit TtRssFeed(const QSqlRecord &record);
virtual ~TtRssFeed(); virtual ~TtRssFeed();
QString hashCode() const;
int messageForeignKeyId() const; int messageForeignKeyId() const;
TtRssServiceRoot *serviceRoot() const; TtRssServiceRoot *serviceRoot() const;
QVariant data(int column, int role) const; QVariant data(int column, int role) const;
void updateCounts(bool including_total_count); void updateCounts(bool including_total_count);
bool canBeEdited() const; bool canBeEdited() const;
bool editViaGui(); bool editViaGui();
bool canBeDeleted() const; bool canBeDeleted() const;
bool deleteViaGui(); bool deleteViaGui();
int update(); int update();
QList<Message> undeletedMessages() const; QList<Message> undeletedMessages() const;
bool markAsReadUnread(ReadStatus status); bool markAsReadUnread(ReadStatus status);
bool cleanMessages(bool clear_only_read); bool cleanMessages(bool clear_only_read);
bool editItself(TtRssFeed *new_feed_data); bool editItself(TtRssFeed *new_feed_data);