diff --git a/src/core/message.cpp b/src/core/message.cpp index a0a6d4448..a8e5b22ce 100755 --- a/src/core/message.cpp +++ b/src/core/message.cpp @@ -63,5 +63,6 @@ QString Enclosures::encodeEnclosuresToString(const QList &enclosures) Message::Message() { m_title = m_url = m_author = m_contents = m_feedId = m_customId = ""; m_enclosures = QList(); + m_accountId = 0; m_isRead = m_isImportant = false; } diff --git a/src/core/message.h b/src/core/message.h index eab142d15..7459eb0be 100755 --- a/src/core/message.h +++ b/src/core/message.h @@ -50,6 +50,7 @@ class Message { QString m_contents; QDateTime m_created; QString m_feedId; + int m_accountId; QString m_customId; bool m_isRead; diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index ba0968bbe..cedbd2ebd 100755 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -140,6 +140,7 @@ Message MessagesModel::messageAt(int row_index) const { message.m_title = rec.value(MSG_DB_TITLE_INDEX).toString(); message.m_url = rec.value(MSG_DB_URL_INDEX).toString(); message.m_feedId = rec.value(MSG_DB_FEED_INDEX).toString(); + message.m_accountId = rec.value(MSG_DB_ACCOUNT_ID_INDEX).toInt(); message.m_customId = rec.value(MSG_DB_CUSTOM_ID_INDEX).toString(); message.m_created = TextFactory::parseDateTime(rec.value(MSG_DB_DCREATED_INDEX).value()).toLocalTime(); diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 2e33f9f57..321884f87 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -154,6 +154,7 @@ QList StandardFeed::undeletedMessages() const { message.m_author = query_read_msg.value(2).toString(); message.m_created = TextFactory::parseDateTime(query_read_msg.value(3).value()); message.m_contents = query_read_msg.value(4).toString(); + message.m_accountId = const_cast(this)->serviceRoot()->accountId(); message.m_enclosures = Enclosures::decodeEnclosuresFromString(query_read_msg.value(5).toString()); messages.append(message); diff --git a/src/services/tt-rss/ttrssfeed.cpp b/src/services/tt-rss/ttrssfeed.cpp index 51cf0ef78..0579cf0fb 100755 --- a/src/services/tt-rss/ttrssfeed.cpp +++ b/src/services/tt-rss/ttrssfeed.cpp @@ -116,12 +116,13 @@ QList TtRssFeed::undeletedMessages() const { int account_id = const_cast(this)->serviceRoot()->accountId(); QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlQuery query_read_msg(database); + query_read_msg.setForwardOnly(true); query_read_msg.prepare("SELECT title, url, author, date_created, contents, enclosures, custom_id " "FROM Messages " "WHERE is_deleted = 0 AND feed = :feed AND account_id = :account_id;"); - query_read_msg.bindValue(QSL(":feed"), id()); + query_read_msg.bindValue(QSL(":feed"), customId()); query_read_msg.bindValue(QSL(":account_id"), account_id); // FIXME: Fix those const functions, this is fucking ugly. @@ -130,13 +131,14 @@ QList TtRssFeed::undeletedMessages() const { while (query_read_msg.next()) { Message message; - message.m_feedId = QString::number(account_id); + message.m_feedId = QString::number(customId()); message.m_title = query_read_msg.value(0).toString(); message.m_url = query_read_msg.value(1).toString(); message.m_author = query_read_msg.value(2).toString(); message.m_created = TextFactory::parseDateTime(query_read_msg.value(3).value()); message.m_contents = query_read_msg.value(4).toString(); message.m_enclosures = Enclosures::decodeEnclosuresFromString(query_read_msg.value(5).toString()); + message.m_accountId = account_id; message.m_customId = query_read_msg.value(6).toString(); messages.append(message); diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 6b50a7ad4..e076a2b43 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -146,11 +146,25 @@ QList TtRssServiceRoot::contextMenu() { } bool TtRssServiceRoot::onBeforeSetMessagesRead(RootItem *selected_item, QList message_db_ids, RootItem::ReadStatus read) { + // TODO: misto čísel primarnich zprav, vracet cele objekty zprav + // tedy včetně custom ID, nemusi se tak znova tahat z DB asi?s + + // OK, update the messages status online. + + // First obtain, custom IDs of messages. + return false; } bool TtRssServiceRoot::onAfterSetMessagesRead(RootItem *selected_item, QList message_db_ids, RootItem::ReadStatus read) { - return false; + Q_UNUSED(message_db_ids) + Q_UNUSED(read) + + selected_item->updateCounts(false); + + itemChanged(QList() << selected_item); + requestFeedReadFilterReload(); + return true; } bool TtRssServiceRoot::onBeforeSwitchMessageImportance(RootItem *selected_item, QList > changes) { diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index 35efa1173..96d424b06 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -76,7 +76,7 @@ class TtRssServiceRoot : public ServiceRoot { public slots: void syncIn(); - private: + private: // Returns converted ids of given feeds // which are suitable as IN clause for SQL queries. QStringList textualFeedIds(const QList &feeds);