From 90efb8fc0e822e43d3b4b746f0711d8cc7aadbe9 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sun, 21 Feb 2016 18:41:13 +0100 Subject: [PATCH] ID shit, custom ID now same is ID for standard acc. --- src/core/feedsmodel.cpp | 1 - src/services/abstract/category.cpp | 10 +--------- src/services/abstract/category.h | 6 ------ src/services/abstract/feed.cpp | 10 +--------- src/services/abstract/feed.h | 4 ---- src/services/abstract/rootitem.cpp | 9 +++++++++ src/services/abstract/rootitem.h | 4 ++++ src/services/standard/standardcategory.cpp | 3 +++ src/services/standard/standardfeed.cpp | 3 +++ src/services/standard/standardserviceentrypoint.cpp | 2 -- 10 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 7f28bf18f..e62826a37 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -53,7 +53,6 @@ FeedsModel::FeedsModel(QObject *parent) // Create root item. m_rootItem = new RootItem(); - m_rootItem->setId(NO_PARENT_CATEGORY); //: Name of root item of feed list which can be seen in feed add/edit dialog. m_rootItem->setTitle(tr("Root")); diff --git a/src/services/abstract/category.cpp b/src/services/abstract/category.cpp index 6108d0558..e3ad1296a 100755 --- a/src/services/abstract/category.cpp +++ b/src/services/abstract/category.cpp @@ -18,17 +18,9 @@ #include "services/abstract/category.h" -Category::Category(RootItem *parent) : RootItem(parent), m_customId(NO_PARENT_CATEGORY) { +Category::Category(RootItem *parent) : RootItem(parent) { setKind(RootItemKind::Category); } Category::~Category() { } - -int Category::customId() const { - return m_customId; -} - -void Category::setCustomId(int custom_id) { - m_customId = custom_id; -} diff --git a/src/services/abstract/category.h b/src/services/abstract/category.h index 54ddf388d..0e43c2edf 100755 --- a/src/services/abstract/category.h +++ b/src/services/abstract/category.h @@ -27,12 +27,6 @@ class Category : public RootItem { public: explicit Category(RootItem *parent = NULL); virtual ~Category(); - - int customId() const; - void setCustomId(int custom_id); - - private: - int m_customId; }; #endif // CATEGORY_H diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp index 5f4d5393b..877f1131e 100755 --- a/src/services/abstract/feed.cpp +++ b/src/services/abstract/feed.cpp @@ -23,21 +23,13 @@ Feed::Feed(RootItem *parent) : RootItem(parent), m_url(QString()), m_status(Normal), m_autoUpdateType(DefaultAutoUpdate), m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), - m_totalCount(0), m_unreadCount(0), m_customId(NO_PARENT_CATEGORY) { + m_totalCount(0), m_unreadCount(0) { setKind(RootItemKind::Feed); } Feed::~Feed() { } -int Feed::customId() const { - return m_customId; -} - -void Feed::setCustomId(int custom_id) { - m_customId = custom_id; -} - QVariant Feed::data(int column, int role) const { switch (role) { case Qt::ForegroundRole: diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h index 9f3e347c0..bf2d90242 100755 --- a/src/services/abstract/feed.h +++ b/src/services/abstract/feed.h @@ -100,9 +100,6 @@ class Feed : public RootItem { m_url = url; } - int customId() const; - void setCustomId(int custom_id); - virtual int messageForeignKeyId() const = 0; private: @@ -113,7 +110,6 @@ class Feed : public RootItem { int m_autoUpdateRemainingInterval; int m_totalCount; int m_unreadCount; - int m_customId; }; #endif // FEED_H diff --git a/src/services/abstract/rootitem.cpp b/src/services/abstract/rootitem.cpp index 88eb8005e..a1dbe9448 100755 --- a/src/services/abstract/rootitem.cpp +++ b/src/services/abstract/rootitem.cpp @@ -30,6 +30,7 @@ RootItem::RootItem(RootItem *parent_item) : QObject(NULL), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), + m_customId(NO_PARENT_CATEGORY), m_title(QString()), m_description(QString()), m_icon(QIcon()), @@ -357,6 +358,14 @@ bool RootItem::removeChild(RootItem *child) { return m_childItems.removeOne(child); } +int RootItem::customId() const { + return m_customId; +} + +void RootItem::setCustomId(int custom_id) { + m_customId = custom_id; +} + Category *RootItem::toCategory() const { return static_cast(const_cast(this)); } diff --git a/src/services/abstract/rootitem.h b/src/services/abstract/rootitem.h index b48fb60d0..bb7e1fbdc 100755 --- a/src/services/abstract/rootitem.h +++ b/src/services/abstract/rootitem.h @@ -255,6 +255,9 @@ class RootItem : public QObject { m_boldFont = bold_font; } + int customId() const; + void setCustomId(int custom_id); + // Converters Category *toCategory() const; Feed *toFeed() const; @@ -265,6 +268,7 @@ class RootItem : public QObject { RootItemKind::Kind m_kind; int m_id; + int m_customId; QString m_title; QString m_description; QIcon m_icon; diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index c876a42e5..c13833eae 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -42,6 +42,7 @@ StandardCategory::StandardCategory(RootItem *parent_item) : Category(parent_item StandardCategory::StandardCategory(const StandardCategory &other) : Category(NULL) { setId(other.id()); + setCustomId(other.customId()); setTitle(other.title()); setDescription(other.description()); setIcon(other.icon()); @@ -179,6 +180,7 @@ bool StandardCategory::addItself(RootItem *parent) { } setId(query_add.lastInsertId().toInt()); + setCustomId(id()); return true; } @@ -214,6 +216,7 @@ bool StandardCategory::editItself(StandardCategory *new_category_data) { StandardCategory::StandardCategory(const QSqlRecord &record) : Category(NULL) { setId(record.value(CAT_DB_ID_INDEX).toInt()); + setCustomId(id()); setTitle(record.value(CAT_DB_TITLE_INDEX).toString()); setDescription(record.value(CAT_DB_DESCRIPTION_INDEX).toString()); setCreationDate(TextFactory::parseDateTime(record.value(CAT_DB_DCREATED_INDEX).value()).toLocalTime()); diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index d9cd02dcd..7cb247081 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -75,6 +75,7 @@ StandardFeed::StandardFeed(const StandardFeed &other) setTitle(other.title()); setId(other.id()); + setCustomId(other.customId()); setIcon(other.icon()); setChildItems(other.childItems()); setParent(other.parent()); @@ -547,6 +548,7 @@ bool StandardFeed::addItself(RootItem *parent) { // New feed was added, fetch is primary id from the database. setId(query_add_feed.lastInsertId().toInt()); + setCustomId(id()); return true; } @@ -770,6 +772,7 @@ QNetworkReply::NetworkError StandardFeed::networkError() const { StandardFeed::StandardFeed(const QSqlRecord &record) : Feed(NULL) { setTitle(record.value(FDS_DB_TITLE_INDEX).toString()); setId(record.value(FDS_DB_ID_INDEX).toInt()); + setCustomId(id()); setDescription(record.value(FDS_DB_DESCRIPTION_INDEX).toString()); setCreationDate(TextFactory::parseDateTime(record.value(FDS_DB_DCREATED_INDEX).value()).toLocalTime()); setIcon(qApp->icons()->fromByteArray(record.value(FDS_DB_ICON_INDEX).toByteArray())); diff --git a/src/services/standard/standardserviceentrypoint.cpp b/src/services/standard/standardserviceentrypoint.cpp index 3779c6bdb..1b5824f4e 100755 --- a/src/services/standard/standardserviceentrypoint.cpp +++ b/src/services/standard/standardserviceentrypoint.cpp @@ -77,7 +77,6 @@ ServiceRoot *StandardServiceEntryPoint::createNewRoot() const { if (query.exec()) { StandardServiceRoot *root = new StandardServiceRoot(); - root->setId(NO_PARENT_CATEGORY); root->setAccountId(id_to_assign); return root; } @@ -99,7 +98,6 @@ QList StandardServiceEntryPoint::initializeSubtree() const { if (query.exec()) { while (query.next()) { StandardServiceRoot *root = new StandardServiceRoot(); - root->setId(NO_PARENT_CATEGORY); root->setAccountId(query.value(0).toInt()); roots.append(root); }