Enable labels for all accounts.
This commit is contained in:
parent
44e467b9c7
commit
a9b6ecd351
@ -9,14 +9,16 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
LabelsNode::LabelsNode(const QList<Label*>& labels, RootItem* parent_item) : RootItem(parent_item), m_actLabelNew(nullptr) {
|
||||
LabelsNode::LabelsNode(RootItem* parent_item) : RootItem(parent_item), m_actLabelNew(nullptr) {
|
||||
setKind(RootItem::Kind::Labels);
|
||||
setId(ID_LABELS);
|
||||
setIcon(qApp->icons()->fromTheme(QSL("tag-folder")));
|
||||
setTitle(tr("Labels"));
|
||||
setDescription(tr("You can see all your labels (tags) here."));
|
||||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void LabelsNode::loadLabels(const QList<Label*>& labels) {
|
||||
for (Label* lbl : labels) {
|
||||
appendChild(lbl);
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ class LabelsNode : public RootItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LabelsNode(const QList<Label*>& labels, RootItem* parent_item = nullptr);
|
||||
explicit LabelsNode(RootItem* parent_item = nullptr);
|
||||
|
||||
void loadLabels(const QList<Label*>& labels);
|
||||
|
||||
virtual QList<QAction*> contextMenuFeedsList();
|
||||
|
||||
|
@ -12,10 +12,12 @@
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/importantnode.h"
|
||||
#include "services/abstract/labelsnode.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
|
||||
ServiceRoot::ServiceRoot(RootItem* parent)
|
||||
: RootItem(parent), m_recycleBin(new RecycleBin(this)), m_importantNode(new ImportantNode(this)), m_accountId(NO_PARENT_CATEGORY) {
|
||||
: RootItem(parent), m_recycleBin(new RecycleBin(this)), m_importantNode(new ImportantNode(this)),
|
||||
m_labelsNode(new LabelsNode(this)), m_accountId(NO_PARENT_CATEGORY) {
|
||||
setKind(RootItem::Kind::ServiceRoot);
|
||||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
@ -312,6 +314,10 @@ ImportantNode* ServiceRoot::importantNode() const {
|
||||
return m_importantNode;
|
||||
}
|
||||
|
||||
LabelsNode* ServiceRoot::labelsNode() const {
|
||||
return m_labelsNode;
|
||||
}
|
||||
|
||||
void ServiceRoot::setRecycleBin(RecycleBin* recycle_bin) {
|
||||
m_recycleBin = recycle_bin;
|
||||
}
|
||||
@ -356,6 +362,22 @@ void ServiceRoot::syncIn() {
|
||||
itemChanged(getSubTree());
|
||||
}
|
||||
|
||||
void ServiceRoot::performInitialAssembly(const Assignment& categories, const Assignment& feeds, const QList<Label*>& labels) {
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
appendChild(labelsNode());
|
||||
|
||||
labelsNode()->loadLabels(labels);
|
||||
requestItemExpand({ labelsNode() }, true);
|
||||
|
||||
updateCounts(true);
|
||||
}
|
||||
|
||||
RootItem* ServiceRoot::obtainNewTreeForSyncIn() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
class FeedsModel;
|
||||
class RecycleBin;
|
||||
class ImportantNode;
|
||||
class LabelsNode;
|
||||
class Label;
|
||||
class QAction;
|
||||
class MessagesModel;
|
||||
|
||||
@ -39,6 +41,7 @@ class ServiceRoot : public RootItem {
|
||||
void setRecycleBin(RecycleBin* recycle_bin);
|
||||
|
||||
virtual ImportantNode* importantNode() const;
|
||||
virtual LabelsNode* labelsNode() const;
|
||||
virtual bool downloadAttachmentOnMyOwn(const QUrl& url) const;
|
||||
|
||||
QList<Message> undeletedMessages() const;
|
||||
@ -163,6 +166,7 @@ class ServiceRoot : public RootItem {
|
||||
virtual void syncIn();
|
||||
|
||||
protected:
|
||||
void performInitialAssembly(const Assignment& categories, const Assignment& feeds, const QList<Label*>& labels);
|
||||
|
||||
// This method should obtain new tree of feed/categories/whatever to perform sync in.
|
||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||
@ -212,6 +216,7 @@ class ServiceRoot : public RootItem {
|
||||
protected:
|
||||
RecycleBin* m_recycleBin;
|
||||
ImportantNode* m_importantNode;
|
||||
LabelsNode* m_labelsNode;
|
||||
int m_accountId;
|
||||
QAction* m_actionSyncIn;
|
||||
QList<QAction*> m_serviceMenu;
|
||||
|
@ -63,20 +63,15 @@ void GmailServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||
Assignment feeds = DatabaseQueries::getFeeds<GmailFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
performInitialAssembly(categories, feeds, labels);
|
||||
|
||||
for (RootItem* feed : childItems()) {
|
||||
if (feed->customId() == QL1S("INBOX")) {
|
||||
feed->setKeepOnTop(true);
|
||||
}
|
||||
}
|
||||
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
updateCounts(true);
|
||||
}
|
||||
|
||||
void GmailServiceRoot::saveAccountDataToDatabase() {
|
||||
@ -191,7 +186,7 @@ void GmailServiceRoot::start(bool freshly_activated) {
|
||||
loadFromDatabase();
|
||||
loadCacheFromFile(accountId());
|
||||
|
||||
if (childCount() <= 2) {
|
||||
if (childCount() <= 3) {
|
||||
syncIn();
|
||||
}
|
||||
|
||||
|
@ -36,15 +36,9 @@ void InoreaderServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||
Assignment feeds = DatabaseQueries::getFeeds<InoreaderFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
updateCounts(true);
|
||||
performInitialAssembly(categories, feeds, labels);
|
||||
}
|
||||
|
||||
void InoreaderServiceRoot::saveAccountDataToDatabase() {
|
||||
@ -111,7 +105,7 @@ void InoreaderServiceRoot::start(bool freshly_activated) {
|
||||
loadFromDatabase();
|
||||
loadCacheFromFile(accountId());
|
||||
|
||||
if (childCount() <= 2) {
|
||||
if (childCount() <= 3) {
|
||||
syncIn();
|
||||
}
|
||||
else {
|
||||
|
@ -68,7 +68,7 @@ void OwnCloudServiceRoot::start(bool freshly_activated) {
|
||||
loadFromDatabase();
|
||||
loadCacheFromFile(accountId());
|
||||
|
||||
if (childCount() <= 2) {
|
||||
if (childCount() <= 3) {
|
||||
syncIn();
|
||||
}
|
||||
}
|
||||
@ -191,13 +191,7 @@ void OwnCloudServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||
Assignment feeds = DatabaseQueries::getFeeds<OwnCloudFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
updateCounts(true);
|
||||
performInitialAssembly(categories, feeds, labels);
|
||||
}
|
||||
|
@ -134,21 +134,9 @@ void StandardServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
Assignment categories = DatabaseQueries::getCategories<StandardCategory>(database, accountId());
|
||||
Assignment feeds = DatabaseQueries::getFeeds<StandardFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
|
||||
auto* labelss = new LabelsNode(DatabaseQueries::getLabels(database, accountId()), this);
|
||||
|
||||
appendChild(labelss);
|
||||
requestItemExpand({ labelss }, true);
|
||||
|
||||
updateCounts(true);
|
||||
performInitialAssembly(categories, feeds, labels);
|
||||
}
|
||||
|
||||
void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
||||
|
@ -206,15 +206,9 @@ void TtRssServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||
Assignment feeds = DatabaseQueries::getFeeds<TtRssFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||
|
||||
// All data are now obtained, lets create the hierarchy.
|
||||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(recycleBin());
|
||||
appendChild(importantNode());
|
||||
updateCounts(true);
|
||||
performInitialAssembly(categories, feeds, labels);
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::updateTitle() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user