diff --git a/src/librssguard/services/abstract/labelsnode.cpp b/src/librssguard/services/abstract/labelsnode.cpp index 1359cdb5d..32376c7d3 100755 --- a/src/librssguard/services/abstract/labelsnode.cpp +++ b/src/librssguard/services/abstract/labelsnode.cpp @@ -6,7 +6,7 @@ #include "miscellaneous/iconfactory.h" #include "services/abstract/serviceroot.h" -LabelsNode::LabelsNode(RootItem* parent_item) : RootItem(parent_item) { +LabelsNode::LabelsNode(RootItem* parent_item) : RootItem(parent_item), m_actLabelNew(nullptr) { setKind(RootItem::Kind::Labels); setId(ID_LABELS); setIcon(qApp->icons()->fromTheme(QSL("mail-mark-important"))); @@ -14,3 +14,14 @@ LabelsNode::LabelsNode(RootItem* parent_item) : RootItem(parent_item) { setDescription(tr("You can see all your labels (tags) here.")); setCreationDate(QDateTime::currentDateTime()); } + +QList LabelsNode::contextMenuFeedsList() { + if (m_actLabelNew == nullptr) { + // Initialize it all. + m_actLabelNew = new QAction(qApp->icons()->fromTheme("tag-new"), tr("New label"), this); + } + + return QList { + m_actLabelNew + }; +} diff --git a/src/librssguard/services/abstract/labelsnode.h b/src/librssguard/services/abstract/labelsnode.h index db91fda09..8f8e399eb 100755 --- a/src/librssguard/services/abstract/labelsnode.h +++ b/src/librssguard/services/abstract/labelsnode.h @@ -10,6 +10,11 @@ class LabelsNode : public RootItem { public: explicit LabelsNode(RootItem* parent_item = nullptr); + + virtual QList contextMenuFeedsList(); + + private: + QAction* m_actLabelNew; }; #endif // LABELSNODE_H diff --git a/src/librssguard/services/abstract/rootitem.h b/src/librssguard/services/abstract/rootitem.h index 70f75b9f4..fd1a406ed 100644 --- a/src/librssguard/services/abstract/rootitem.h +++ b/src/librssguard/services/abstract/rootitem.h @@ -99,48 +99,20 @@ class RSSGUARD_DLLSPEC RootItem : public QObject { virtual int countOfUnreadMessages() const; virtual int countOfAllMessages() const; - inline RootItem* parent() const { - return m_parentItem; - } - - inline void setParent(RootItem* parent_item) { - m_parentItem = parent_item; - } - - inline RootItem* child(int row) { - return m_childItems.value(row); - } - - inline int childCount() const { - return m_childItems.size(); - } - - inline void appendChild(RootItem* child) { - if (child != nullptr) { - m_childItems.append(child); - child->setParent(this); - } - } + RootItem* parent() const; + void setParent(RootItem* parent_item); // Access to children. - inline QList childItems() const { - return m_childItems; - } - - // Removes all children from this item. - // NOTE: Children are NOT freed from the memory. - inline void clearChildren() { - m_childItems.clear(); - } - - inline void setChildItems(const QList& child_items) { - m_childItems = child_items; - } + RootItem* child(int row); + int childCount() const; + void appendChild(RootItem* child); + QList childItems() const; + void clearChildren(); + void setChildItems(const QList& child_items); // Removes particular child at given index. // NOTE: Child is NOT freed from the memory. bool removeChild(int index); - bool removeChild(RootItem* child); // Checks whether "this" object is child (direct or indirect) @@ -219,6 +191,41 @@ class RSSGUARD_DLLSPEC RootItem : public QObject { RootItem* m_parentItem; }; +inline RootItem* RootItem::parent() const { + return m_parentItem; +} + +inline void RootItem::setParent(RootItem* parent_item) { + m_parentItem = parent_item; +} + +inline RootItem* RootItem::child(int row) { + return m_childItems.value(row); +} + +inline int RootItem::childCount() const { + return m_childItems.size(); +} + +inline void RootItem::appendChild(RootItem* child) { + if (child != nullptr) { + m_childItems.append(child); + child->setParent(this); + } +} + +inline QList RootItem::childItems() const { + return m_childItems; +} + +inline void RootItem::clearChildren() { + m_childItems.clear(); +} + +inline void RootItem::setChildItems(const QList& child_items) { + m_childItems = child_items; +} + RootItem::Kind operator|(RootItem::Kind a, RootItem::Kind b); RootItem::Kind operator&(RootItem::Kind a, RootItem::Kind b); diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp index 51abbe4a3..6fbdb8c4f 100644 --- a/src/librssguard/services/abstract/serviceroot.cpp +++ b/src/librssguard/services/abstract/serviceroot.cpp @@ -196,24 +196,24 @@ bool ServiceRoot::cleanFeeds(QList items, bool clean_read_only) { } void ServiceRoot::storeNewFeedTree(RootItem* root) { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); + DatabaseQueries::storeAccountTree(qApp->database()->connection(metaObject()->className()), root, accountId()); - if (DatabaseQueries::storeAccountTree(database, root, accountId())) { - RecycleBin* bin = recycleBin(); + /*if (DatabaseQueries::storeAccountTree(database, root, accountId())) { + RecycleBin* bin = recycleBin(); - if (bin != nullptr && !childItems().contains(bin)) { + if (bin != nullptr && !childItems().contains(bin)) { // As the last item, add recycle bin, which is needed. appendChild(bin); bin->updateCounts(true); - } + } - ImportantNode* imp = importantNode(); + ImportantNode* imp = importantNode(); - if (imp != nullptr && !childItems().contains(imp)) { + if (imp != nullptr && !childItems().contains(imp)) { appendChild(imp); imp->updateCounts(true); - } - } + } + }*/ } void ServiceRoot::removeLeftOverMessages() { @@ -271,7 +271,9 @@ void ServiceRoot::addNewFeed(RootItem* selected_item, const QString& url) { Q_UNUSED(url) } -void ServiceRoot::addNewCategory(RootItem* selected_item) {} +void ServiceRoot::addNewCategory(RootItem* selected_item) { + Q_UNUSED(selected_item) +} QMap ServiceRoot::storeCustomFeedsData() { QMap custom_data; diff --git a/src/librssguard/services/abstract/serviceroot.h b/src/librssguard/services/abstract/serviceroot.h index 26c360da8..80da64c97 100644 --- a/src/librssguard/services/abstract/serviceroot.h +++ b/src/librssguard/services/abstract/serviceroot.h @@ -164,8 +164,7 @@ class ServiceRoot : public RootItem { protected: - // This method should obtain new tree of feed/messages/etc to perform - // sync in. + // This method should obtain new tree of feed/categories/whatever to perform sync in. virtual RootItem* obtainNewTreeForSyncIn() const; // Removes all messages/categories/feeds which are diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp index 4a2590683..a0a53de9a 100644 --- a/src/librssguard/services/standard/standardserviceroot.cpp +++ b/src/librssguard/services/standard/standardserviceroot.cpp @@ -12,6 +12,7 @@ #include "miscellaneous/mutex.h" #include "miscellaneous/settings.h" #include "services/abstract/importantnode.h" +#include "services/abstract/labelsnode.h" #include "services/abstract/recyclebin.h" #include "services/standard/gui/formstandardcategorydetails.h" #include "services/standard/gui/formstandardfeeddetails.h"