ID shit, custom ID now same is ID for standard acc.

This commit is contained in:
Martin Rotter 2016-02-21 18:41:13 +01:00
parent ad2b02aba3
commit 90efb8fc0e
10 changed files with 21 additions and 31 deletions

View File

@ -53,7 +53,6 @@ FeedsModel::FeedsModel(QObject *parent)
// Create root item. // Create root item.
m_rootItem = new RootItem(); 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. //: Name of root item of feed list which can be seen in feed add/edit dialog.
m_rootItem->setTitle(tr("Root")); m_rootItem->setTitle(tr("Root"));

View File

@ -18,17 +18,9 @@
#include "services/abstract/category.h" #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); setKind(RootItemKind::Category);
} }
Category::~Category() { Category::~Category() {
} }
int Category::customId() const {
return m_customId;
}
void Category::setCustomId(int custom_id) {
m_customId = custom_id;
}

View File

@ -27,12 +27,6 @@ class Category : public RootItem {
public: public:
explicit Category(RootItem *parent = NULL); explicit Category(RootItem *parent = NULL);
virtual ~Category(); virtual ~Category();
int customId() const;
void setCustomId(int custom_id);
private:
int m_customId;
}; };
#endif // CATEGORY_H #endif // CATEGORY_H

View File

@ -23,21 +23,13 @@
Feed::Feed(RootItem *parent) Feed::Feed(RootItem *parent)
: RootItem(parent), m_url(QString()), m_status(Normal), m_autoUpdateType(DefaultAutoUpdate), : RootItem(parent), m_url(QString()), m_status(Normal), m_autoUpdateType(DefaultAutoUpdate),
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL), 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); setKind(RootItemKind::Feed);
} }
Feed::~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 { QVariant Feed::data(int column, int role) const {
switch (role) { switch (role) {
case Qt::ForegroundRole: case Qt::ForegroundRole:

View File

@ -100,9 +100,6 @@ class Feed : public RootItem {
m_url = url; m_url = url;
} }
int customId() const;
void setCustomId(int custom_id);
virtual int messageForeignKeyId() const = 0; virtual int messageForeignKeyId() const = 0;
private: private:
@ -113,7 +110,6 @@ class Feed : public RootItem {
int m_autoUpdateRemainingInterval; int m_autoUpdateRemainingInterval;
int m_totalCount; int m_totalCount;
int m_unreadCount; int m_unreadCount;
int m_customId;
}; };
#endif // FEED_H #endif // FEED_H

View File

@ -30,6 +30,7 @@ RootItem::RootItem(RootItem *parent_item)
: QObject(NULL), : QObject(NULL),
m_kind(RootItemKind::Root), m_kind(RootItemKind::Root),
m_id(NO_PARENT_CATEGORY), m_id(NO_PARENT_CATEGORY),
m_customId(NO_PARENT_CATEGORY),
m_title(QString()), m_title(QString()),
m_description(QString()), m_description(QString()),
m_icon(QIcon()), m_icon(QIcon()),
@ -357,6 +358,14 @@ bool RootItem::removeChild(RootItem *child) {
return m_childItems.removeOne(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 { Category *RootItem::toCategory() const {
return static_cast<Category*>(const_cast<RootItem*>(this)); return static_cast<Category*>(const_cast<RootItem*>(this));
} }

View File

@ -255,6 +255,9 @@ class RootItem : public QObject {
m_boldFont = bold_font; m_boldFont = bold_font;
} }
int customId() const;
void setCustomId(int custom_id);
// Converters // Converters
Category *toCategory() const; Category *toCategory() const;
Feed *toFeed() const; Feed *toFeed() const;
@ -265,6 +268,7 @@ class RootItem : public QObject {
RootItemKind::Kind m_kind; RootItemKind::Kind m_kind;
int m_id; int m_id;
int m_customId;
QString m_title; QString m_title;
QString m_description; QString m_description;
QIcon m_icon; QIcon m_icon;

View File

@ -42,6 +42,7 @@ StandardCategory::StandardCategory(RootItem *parent_item) : Category(parent_item
StandardCategory::StandardCategory(const StandardCategory &other) StandardCategory::StandardCategory(const StandardCategory &other)
: Category(NULL) { : Category(NULL) {
setId(other.id()); setId(other.id());
setCustomId(other.customId());
setTitle(other.title()); setTitle(other.title());
setDescription(other.description()); setDescription(other.description());
setIcon(other.icon()); setIcon(other.icon());
@ -179,6 +180,7 @@ bool StandardCategory::addItself(RootItem *parent) {
} }
setId(query_add.lastInsertId().toInt()); setId(query_add.lastInsertId().toInt());
setCustomId(id());
return true; return true;
} }
@ -214,6 +216,7 @@ bool StandardCategory::editItself(StandardCategory *new_category_data) {
StandardCategory::StandardCategory(const QSqlRecord &record) : Category(NULL) { StandardCategory::StandardCategory(const QSqlRecord &record) : Category(NULL) {
setId(record.value(CAT_DB_ID_INDEX).toInt()); setId(record.value(CAT_DB_ID_INDEX).toInt());
setCustomId(id());
setTitle(record.value(CAT_DB_TITLE_INDEX).toString()); setTitle(record.value(CAT_DB_TITLE_INDEX).toString());
setDescription(record.value(CAT_DB_DESCRIPTION_INDEX).toString()); setDescription(record.value(CAT_DB_DESCRIPTION_INDEX).toString());
setCreationDate(TextFactory::parseDateTime(record.value(CAT_DB_DCREATED_INDEX).value<qint64>()).toLocalTime()); setCreationDate(TextFactory::parseDateTime(record.value(CAT_DB_DCREATED_INDEX).value<qint64>()).toLocalTime());

View File

@ -75,6 +75,7 @@ StandardFeed::StandardFeed(const StandardFeed &other)
setTitle(other.title()); setTitle(other.title());
setId(other.id()); setId(other.id());
setCustomId(other.customId());
setIcon(other.icon()); setIcon(other.icon());
setChildItems(other.childItems()); setChildItems(other.childItems());
setParent(other.parent()); setParent(other.parent());
@ -547,6 +548,7 @@ bool StandardFeed::addItself(RootItem *parent) {
// New feed was added, fetch is primary id from the database. // New feed was added, fetch is primary id from the database.
setId(query_add_feed.lastInsertId().toInt()); setId(query_add_feed.lastInsertId().toInt());
setCustomId(id());
return true; return true;
} }
@ -770,6 +772,7 @@ QNetworkReply::NetworkError StandardFeed::networkError() const {
StandardFeed::StandardFeed(const QSqlRecord &record) : Feed(NULL) { StandardFeed::StandardFeed(const QSqlRecord &record) : Feed(NULL) {
setTitle(record.value(FDS_DB_TITLE_INDEX).toString()); setTitle(record.value(FDS_DB_TITLE_INDEX).toString());
setId(record.value(FDS_DB_ID_INDEX).toInt()); setId(record.value(FDS_DB_ID_INDEX).toInt());
setCustomId(id());
setDescription(record.value(FDS_DB_DESCRIPTION_INDEX).toString()); setDescription(record.value(FDS_DB_DESCRIPTION_INDEX).toString());
setCreationDate(TextFactory::parseDateTime(record.value(FDS_DB_DCREATED_INDEX).value<qint64>()).toLocalTime()); setCreationDate(TextFactory::parseDateTime(record.value(FDS_DB_DCREATED_INDEX).value<qint64>()).toLocalTime());
setIcon(qApp->icons()->fromByteArray(record.value(FDS_DB_ICON_INDEX).toByteArray())); setIcon(qApp->icons()->fromByteArray(record.value(FDS_DB_ICON_INDEX).toByteArray()));

View File

@ -77,7 +77,6 @@ ServiceRoot *StandardServiceEntryPoint::createNewRoot() const {
if (query.exec()) { if (query.exec()) {
StandardServiceRoot *root = new StandardServiceRoot(); StandardServiceRoot *root = new StandardServiceRoot();
root->setId(NO_PARENT_CATEGORY);
root->setAccountId(id_to_assign); root->setAccountId(id_to_assign);
return root; return root;
} }
@ -99,7 +98,6 @@ QList<ServiceRoot*> StandardServiceEntryPoint::initializeSubtree() const {
if (query.exec()) { if (query.exec()) {
while (query.next()) { while (query.next()) {
StandardServiceRoot *root = new StandardServiceRoot(); StandardServiceRoot *root = new StandardServiceRoot();
root->setId(NO_PARENT_CATEGORY);
root->setAccountId(query.value(0).toInt()); root->setAccountId(query.value(0).toInt());
roots.append(root); roots.append(root);
} }