Simplify some sync-in logic.
This commit is contained in:
parent
e2198faedc
commit
821192906e
@ -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<QAction*> LabelsNode::contextMenuFeedsList() {
|
||||
if (m_actLabelNew == nullptr) {
|
||||
// Initialize it all.
|
||||
m_actLabelNew = new QAction(qApp->icons()->fromTheme("tag-new"), tr("New label"), this);
|
||||
}
|
||||
|
||||
return QList<QAction*> {
|
||||
m_actLabelNew
|
||||
};
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ class LabelsNode : public RootItem {
|
||||
|
||||
public:
|
||||
explicit LabelsNode(RootItem* parent_item = nullptr);
|
||||
|
||||
virtual QList<QAction*> contextMenuFeedsList();
|
||||
|
||||
private:
|
||||
QAction* m_actLabelNew;
|
||||
};
|
||||
|
||||
#endif // LABELSNODE_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<RootItem*> 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<RootItem*>& child_items) {
|
||||
m_childItems = child_items;
|
||||
}
|
||||
RootItem* child(int row);
|
||||
int childCount() const;
|
||||
void appendChild(RootItem* child);
|
||||
QList<RootItem*> childItems() const;
|
||||
void clearChildren();
|
||||
void setChildItems(const QList<RootItem*>& 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*> RootItem::childItems() const {
|
||||
return m_childItems;
|
||||
}
|
||||
|
||||
inline void RootItem::clearChildren() {
|
||||
m_childItems.clear();
|
||||
}
|
||||
|
||||
inline void RootItem::setChildItems(const QList<RootItem*>& child_items) {
|
||||
m_childItems = child_items;
|
||||
}
|
||||
|
||||
RootItem::Kind operator|(RootItem::Kind a, RootItem::Kind b);
|
||||
RootItem::Kind operator&(RootItem::Kind a, RootItem::Kind b);
|
||||
|
||||
|
@ -196,24 +196,24 @@ bool ServiceRoot::cleanFeeds(QList<Feed*> 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<QString, QVariantMap> ServiceRoot::storeCustomFeedsData() {
|
||||
QMap<QString, QVariantMap> custom_data;
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user