mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-03 02:37:46 +01:00
Made some improvements in total/unread counts
This commit is contained in:
parent
4f5be1023a
commit
c911133066
@ -22,7 +22,8 @@
|
||||
|
||||
Feed::Feed(RootItem *parent)
|
||||
: RootItem(parent), m_url(QString()), m_status(Normal), m_autoUpdateType(DefaultAutoUpdate),
|
||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL) {
|
||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||
m_totalCount(0), m_unreadCount(0) {
|
||||
setKind(RootItemKind::Feed);
|
||||
}
|
||||
|
||||
@ -52,6 +53,22 @@ int Feed::autoUpdateInitialInterval() const {
|
||||
return m_autoUpdateInitialInterval;
|
||||
}
|
||||
|
||||
int Feed::countOfAllMessages() const {
|
||||
return m_totalCount;
|
||||
}
|
||||
|
||||
int Feed::countOfUnreadMessages() const {
|
||||
return m_unreadCount;
|
||||
}
|
||||
|
||||
void Feed::setCountOfAllMessages(int count_all_messages) {
|
||||
m_totalCount = count_all_messages;
|
||||
}
|
||||
|
||||
void Feed::setCountOfUnreadMessages(int count_unread_messages) {
|
||||
m_unreadCount = count_unread_messages;
|
||||
}
|
||||
|
||||
void Feed::setAutoUpdateInitialInterval(int auto_update_interval) {
|
||||
// If new initial auto-update interval is set, then
|
||||
// we should reset time that remains to the next auto-update.
|
||||
|
@ -52,6 +52,12 @@ class Feed : public RootItem {
|
||||
explicit Feed(RootItem *parent = NULL);
|
||||
virtual ~Feed();
|
||||
|
||||
int countOfAllMessages() const;
|
||||
int countOfUnreadMessages() const;
|
||||
|
||||
void setCountOfAllMessages(int count_all_messages);
|
||||
void setCountOfUnreadMessages(int count_unread_messages);
|
||||
|
||||
/////////////////////////////////////////
|
||||
// /* Members to override.
|
||||
/////////////////////////////////////////
|
||||
@ -100,6 +106,8 @@ class Feed : public RootItem {
|
||||
AutoUpdateType m_autoUpdateType;
|
||||
int m_autoUpdateInitialInterval;
|
||||
int m_autoUpdateRemainingInterval;
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
};
|
||||
|
||||
#endif // FEED_H
|
||||
|
@ -52,8 +52,6 @@ StandardFeed::StandardFeed(RootItem *parent_item)
|
||||
m_password = QString();
|
||||
m_networkError = QNetworkReply::NoError;
|
||||
m_type = Rss0X;
|
||||
m_totalCount = 0;
|
||||
m_unreadCount = 0;
|
||||
m_encoding = QString();
|
||||
}
|
||||
|
||||
@ -64,10 +62,11 @@ StandardFeed::StandardFeed(const StandardFeed &other)
|
||||
m_password = other.password();
|
||||
m_networkError = other.networkError();
|
||||
m_type = other.type();
|
||||
m_totalCount = other.countOfAllMessages();
|
||||
m_unreadCount = other.countOfUnreadMessages();
|
||||
m_encoding = other.encoding();
|
||||
|
||||
setCountOfAllMessages(other.countOfAllMessages());
|
||||
setCountOfUnreadMessages(other.countOfUnreadMessages());
|
||||
|
||||
setUrl(other.url());
|
||||
setStatus(other.status());
|
||||
setAutoUpdateType(other.autoUpdateType());
|
||||
@ -87,14 +86,6 @@ StandardFeed::~StandardFeed() {
|
||||
qDebug("Destroying Feed instance.");
|
||||
}
|
||||
|
||||
int StandardFeed::countOfAllMessages() const {
|
||||
return m_totalCount;
|
||||
}
|
||||
|
||||
int StandardFeed::countOfUnreadMessages() const {
|
||||
return m_unreadCount;
|
||||
}
|
||||
|
||||
QList<QAction*> StandardFeed::contextMenu() {
|
||||
return serviceRoot()->getContextMenuForFeed(this);
|
||||
}
|
||||
@ -233,7 +224,7 @@ void StandardFeed::updateCounts(bool including_total_count) {
|
||||
query.bindValue(QSL(":account_id"), serviceRoot()->accountId());
|
||||
|
||||
if (query.exec() && query.next()) {
|
||||
m_totalCount = query.value(0).toInt();
|
||||
setCountOfAllMessages(query.value(0).toInt());
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,11 +236,11 @@ void StandardFeed::updateCounts(bool including_total_count) {
|
||||
if (query.exec() && query.next()) {
|
||||
int new_unread_count = query.value(0).toInt();
|
||||
|
||||
if (status() == NewMessages && new_unread_count < m_unreadCount) {
|
||||
if (status() == NewMessages && new_unread_count < countOfUnreadMessages()) {
|
||||
setStatus(Normal);
|
||||
}
|
||||
|
||||
m_unreadCount = new_unread_count;
|
||||
setCountOfUnreadMessages(new_unread_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,6 @@ class StandardFeed : public Feed {
|
||||
virtual ~StandardFeed();
|
||||
|
||||
StandardServiceRoot *serviceRoot() const;
|
||||
|
||||
// Getters/setters for count of messages.
|
||||
// NOTE: For feeds, counts are stored internally
|
||||
// and can be updated from the database.
|
||||
int countOfAllMessages() const;
|
||||
int countOfUnreadMessages() const;
|
||||
|
||||
QList<QAction*> contextMenu();
|
||||
|
||||
bool canBeEdited() const {
|
||||
@ -169,9 +162,6 @@ class StandardFeed : public Feed {
|
||||
|
||||
Type m_type;
|
||||
QNetworkReply::NetworkError m_networkError;
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
|
||||
QString m_encoding;
|
||||
};
|
||||
|
||||
|
@ -35,10 +35,10 @@
|
||||
|
||||
|
||||
TtRssFeed::TtRssFeed(RootItem *parent)
|
||||
: Feed(parent), m_customId(NO_PARENT_CATEGORY), m_totalCount(0), m_unreadCount(0) {
|
||||
: Feed(parent), m_customId(NO_PARENT_CATEGORY) {
|
||||
}
|
||||
|
||||
TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL), m_totalCount(0), m_unreadCount(0) {
|
||||
TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL) {
|
||||
setTitle(record.value(FDS_DB_TITLE_INDEX).toString());
|
||||
setId(record.value(FDS_DB_ID_INDEX).toInt());
|
||||
setIcon(qApp->icons()->fromByteArray(record.value(FDS_DB_ICON_INDEX).toByteArray()));
|
||||
@ -117,7 +117,7 @@ void TtRssFeed::updateCounts(bool including_total_count) {
|
||||
query_all.bindValue(QSL(":account_id"), serviceRoot()->accountId());
|
||||
|
||||
if (query_all.exec() && query_all.next()) {
|
||||
m_totalCount = query_all.value(0).toInt();
|
||||
setCountOfAllMessages(query_all.value(0).toInt());
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +130,11 @@ void TtRssFeed::updateCounts(bool including_total_count) {
|
||||
if (query_all.exec() && query_all.next()) {
|
||||
int new_unread_count = query_all.value(0).toInt();
|
||||
|
||||
if (status() == NewMessages && new_unread_count < m_unreadCount) {
|
||||
if (status() == NewMessages && new_unread_count < countOfUnreadMessages()) {
|
||||
setStatus(Normal);
|
||||
}
|
||||
|
||||
m_unreadCount = new_unread_count;
|
||||
setCountOfUnreadMessages(new_unread_count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,14 +164,6 @@ bool TtRssFeed::deleteViaGui() {
|
||||
}
|
||||
}
|
||||
|
||||
int TtRssFeed::countOfAllMessages() const {
|
||||
return m_totalCount;
|
||||
}
|
||||
|
||||
int TtRssFeed::countOfUnreadMessages() const {
|
||||
return m_unreadCount;
|
||||
}
|
||||
|
||||
int TtRssFeed::update() {
|
||||
QList<Message> messages;
|
||||
int newly_added_messages = 0;
|
||||
|
@ -47,9 +47,6 @@ class TtRssFeed : public Feed {
|
||||
bool canBeDeleted() const;
|
||||
bool deleteViaGui();
|
||||
|
||||
int countOfAllMessages() const;
|
||||
int countOfUnreadMessages() const;
|
||||
|
||||
int update();
|
||||
QList<Message> undeletedMessages() const;
|
||||
|
||||
@ -67,8 +64,6 @@ class TtRssFeed : public Feed {
|
||||
int updateMessages(const QList<Message> &messages);
|
||||
|
||||
int m_customId;
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
};
|
||||
|
||||
#endif // TTRSSFEED_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user