Can mark category.

This commit is contained in:
Martin Rotter 2015-12-12 17:53:46 +01:00
parent 23b0f411d6
commit bfa177a32d
2 changed files with 30 additions and 0 deletions

View File

@ -20,6 +20,9 @@
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "services/tt-rss/definitions.h"
#include "services/tt-rss/ttrssserviceroot.h"
#include "services/tt-rss/network/ttrssnetworkfactory.h"
#include <QVariant>
@ -38,6 +41,27 @@ TtRssCategory::TtRssCategory(const QSqlRecord &record) : Category(NULL) {
TtRssCategory::~TtRssCategory() {
}
TtRssServiceRoot *TtRssCategory::serviceRoot() {
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
}
bool TtRssCategory::markAsReadUnread(RootItem::ReadStatus status) {
QNetworkReply::NetworkError error;
QStringList ids = serviceRoot()->customIDSOfMessagesForItem(this);
TtRssUpdateArticleResponse response = serviceRoot()->network()->updateArticles(ids, UpdateArticle::Unread,
status == RootItem::Unread ?
UpdateArticle::SetToTrue :
UpdateArticle::SetToFalse,
error);
if (error != QNetworkReply::NoError || response.updateStatus() != STATUS_OK) {
return false;
}
else {
return serviceRoot()->markFeedsReadUnread(getSubTreeFeeds(), status);
}
}
int TtRssCategory::customId() const {
return m_customId;
}

View File

@ -23,6 +23,8 @@
#include <QSqlRecord>
class TtRssServiceRoot;
class TtRssCategory : public Category {
Q_OBJECT
@ -31,6 +33,10 @@ class TtRssCategory : public Category {
explicit TtRssCategory(const QSqlRecord &record);
virtual ~TtRssCategory();
TtRssServiceRoot *serviceRoot();
bool markAsReadUnread(ReadStatus status);
int customId() const;
void setCustomId(int custom_id);