mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-01 09:57:28 +01:00
Refactoring, common code moved to superclasses.
This commit is contained in:
parent
e758511cc2
commit
39f73a0d02
@ -66,3 +66,7 @@ void Category::updateCounts(bool including_total_count) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Category::cleanMessages(bool clean_read_only) {
|
||||
return getParentServiceRoot()->cleanFeeds(getSubTreeFeeds(), clean_read_only);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class Category : public RootItem {
|
||||
virtual ~Category();
|
||||
|
||||
void updateCounts(bool including_total_count);
|
||||
bool cleanMessages(bool clean_read_only);
|
||||
};
|
||||
|
||||
#endif // CATEGORY_H
|
||||
|
@ -214,6 +214,10 @@ void Feed::run() {
|
||||
emit messagesObtained(msgs, error_during_obtaining);
|
||||
}
|
||||
|
||||
bool Feed::cleanMessages(bool clean_read_only) {
|
||||
return getParentServiceRoot()->cleanFeeds(QList<Feed*>() << this, clean_read_only);
|
||||
}
|
||||
|
||||
int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtaining) {
|
||||
QList<RootItem*> items_to_update;
|
||||
int updated_messages = 0;
|
||||
|
@ -82,6 +82,8 @@ class Feed : public RootItem, public QRunnable {
|
||||
// Runs update in thread (thread pooled).
|
||||
void run();
|
||||
|
||||
bool cleanMessages(bool clean_read_only);
|
||||
|
||||
public slots:
|
||||
void updateCounts(bool including_total_count);
|
||||
int updateMessages(const QList<Message>& messages, bool error_during_obtaining);
|
||||
|
@ -73,8 +73,7 @@ class RootItem;
|
||||
|
||||
class OwnCloudGetFeedsCategoriesResponse {
|
||||
public:
|
||||
explicit OwnCloudGetFeedsCategoriesResponse(const QString& raw_categories = QString(),
|
||||
const QString& raw_feeds = QString());
|
||||
explicit OwnCloudGetFeedsCategoriesResponse(const QString& raw_categories = QString(), const QString& raw_feeds = QString());
|
||||
virtual ~OwnCloudGetFeedsCategoriesResponse();
|
||||
|
||||
// Returns tree of feeds/categories.
|
||||
|
@ -91,10 +91,6 @@ bool OwnCloudFeed::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
return getParentServiceRoot()->markFeedsReadUnread(QList<Feed*>() << this, status);
|
||||
}
|
||||
|
||||
bool OwnCloudFeed::cleanMessages(bool clear_only_read) {
|
||||
return getParentServiceRoot()->cleanFeeds(QList<Feed*>() << this, clear_only_read);
|
||||
}
|
||||
|
||||
OwnCloudServiceRoot* OwnCloudFeed::serviceRoot() const {
|
||||
return qobject_cast<OwnCloudServiceRoot*>(getParentServiceRoot());
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ class OwnCloudFeed : public Feed {
|
||||
bool removeItself();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clear_only_read);
|
||||
|
||||
OwnCloudServiceRoot* serviceRoot() const;
|
||||
|
||||
|
@ -116,10 +116,6 @@ bool StandardCategory::markAsReadUnread(ReadStatus status) {
|
||||
return serviceRoot()->markFeedsReadUnread(getSubTreeFeeds(), status);
|
||||
}
|
||||
|
||||
bool StandardCategory::cleanMessages(bool clean_read_only) {
|
||||
return serviceRoot()->cleanFeeds(getSubTreeFeeds(), clean_read_only);
|
||||
}
|
||||
|
||||
bool StandardCategory::removeItself() {
|
||||
bool children_removed = true;
|
||||
|
||||
|
@ -60,7 +60,6 @@ class StandardCategory : public Category {
|
||||
bool deleteViaGui();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clean_read_only);
|
||||
|
||||
// Removes category and all its children from persistent
|
||||
// database.
|
||||
|
@ -110,10 +110,6 @@ bool StandardFeed::markAsReadUnread(ReadStatus status) {
|
||||
return serviceRoot()->markFeedsReadUnread(QList<Feed*>() << this, status);
|
||||
}
|
||||
|
||||
bool StandardFeed::cleanMessages(bool clean_read_only) {
|
||||
return serviceRoot()->cleanFeeds(QList<Feed*>() << this, clean_read_only);
|
||||
}
|
||||
|
||||
QVariant StandardFeed::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
|
@ -70,7 +70,6 @@ class StandardFeed : public Feed {
|
||||
bool deleteViaGui();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clean_read_only);
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
|
||||
|
@ -45,20 +45,6 @@ TtRssServiceRoot* TtRssCategory::serviceRoot() const {
|
||||
}
|
||||
|
||||
bool TtRssCategory::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
const QStringList ids = serviceRoot()->customIDSOfMessagesForItem(this);
|
||||
TtRssUpdateArticleResponse response = serviceRoot()->network()->updateArticles(ids, UpdateArticle::Unread,
|
||||
status == RootItem::Unread ?
|
||||
UpdateArticle::SetToTrue :
|
||||
UpdateArticle::SetToFalse);
|
||||
|
||||
if (serviceRoot()->network()->lastError() != QNetworkReply::NoError || response.updateStatus() != STATUS_OK) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return serviceRoot()->markFeedsReadUnread(getSubTreeFeeds(), status);
|
||||
}
|
||||
}
|
||||
|
||||
bool TtRssCategory::cleanMessages(bool clear_only_read) {
|
||||
return serviceRoot()->cleanFeeds(getSubTreeFeeds(), clear_only_read);
|
||||
serviceRoot()->addMessageStatesToCache(serviceRoot()->customIDSOfMessagesForItem(this), status);
|
||||
return true;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class TtRssCategory : public Category {
|
||||
TtRssServiceRoot* serviceRoot() const;
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clear_only_read);
|
||||
};
|
||||
|
||||
#endif // TTRSSCATEGORY_H
|
||||
|
@ -83,10 +83,6 @@ bool TtRssFeed::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
return getParentServiceRoot()->markFeedsReadUnread(QList<Feed*>() << this, status);
|
||||
}
|
||||
|
||||
bool TtRssFeed::cleanMessages(bool clear_only_read) {
|
||||
return getParentServiceRoot()->cleanFeeds(QList<Feed*>() << this, clear_only_read);
|
||||
}
|
||||
|
||||
bool TtRssFeed::editItself(TtRssFeed* new_feed_data) {
|
||||
QSqlDatabase database = qApp->database()->connection("aa", DatabaseFactory::FromSettings);
|
||||
|
||||
|
@ -41,7 +41,6 @@ class TtRssFeed : public Feed {
|
||||
bool deleteViaGui();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clear_only_read);
|
||||
|
||||
bool editItself(TtRssFeed* new_feed_data);
|
||||
bool removeItself();
|
||||
|
Loading…
x
Reference in New Issue
Block a user