mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 09:04:52 +01:00
Message class now includes account ID. Fixed newspaper mode for TT-RSS.
This commit is contained in:
parent
3284d3a1b5
commit
09b023b937
@ -63,5 +63,6 @@ QString Enclosures::encodeEnclosuresToString(const QList<Enclosure> &enclosures)
|
||||
Message::Message() {
|
||||
m_title = m_url = m_author = m_contents = m_feedId = m_customId = "";
|
||||
m_enclosures = QList<Enclosure>();
|
||||
m_accountId = 0;
|
||||
m_isRead = m_isImportant = false;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ class Message {
|
||||
QString m_contents;
|
||||
QDateTime m_created;
|
||||
QString m_feedId;
|
||||
int m_accountId;
|
||||
QString m_customId;
|
||||
|
||||
bool m_isRead;
|
||||
|
@ -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<qint64>()).toLocalTime();
|
||||
|
||||
|
@ -154,6 +154,7 @@ QList<Message> StandardFeed::undeletedMessages() const {
|
||||
message.m_author = query_read_msg.value(2).toString();
|
||||
message.m_created = TextFactory::parseDateTime(query_read_msg.value(3).value<qint64>());
|
||||
message.m_contents = query_read_msg.value(4).toString();
|
||||
message.m_accountId = const_cast<StandardFeed*>(this)->serviceRoot()->accountId();
|
||||
message.m_enclosures = Enclosures::decodeEnclosuresFromString(query_read_msg.value(5).toString());
|
||||
|
||||
messages.append(message);
|
||||
|
@ -116,12 +116,13 @@ QList<Message> TtRssFeed::undeletedMessages() const {
|
||||
int account_id = const_cast<TtRssFeed*>(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<Message> 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<qint64>());
|
||||
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);
|
||||
|
@ -146,11 +146,25 @@ QList<QAction*> TtRssServiceRoot::contextMenu() {
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::onBeforeSetMessagesRead(RootItem *selected_item, QList<int> 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<int> message_db_ids, RootItem::ReadStatus read) {
|
||||
return false;
|
||||
Q_UNUSED(message_db_ids)
|
||||
Q_UNUSED(read)
|
||||
|
||||
selected_item->updateCounts(false);
|
||||
|
||||
itemChanged(QList<RootItem*>() << selected_item);
|
||||
requestFeedReadFilterReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::onBeforeSwitchMessageImportance(RootItem *selected_item, QList<QPair<int, RootItem::Importance> > changes) {
|
||||
|
@ -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<Feed*> &feeds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user