More efficient marking as read/unread for standard plugin.
This commit is contained in:
parent
46a3f9f57a
commit
7e42e17046
@ -117,6 +117,38 @@ bool StandardServiceRoot::deleteViaGui() {
|
||||
return ServiceRoot::deleteViaGui();
|
||||
}
|
||||
|
||||
bool StandardServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
|
||||
if (!db_handle.transaction()) {
|
||||
qWarning("Starting transaction for feeds read change.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QSqlQuery query_read_msg(db_handle);
|
||||
query_read_msg.setForwardOnly(true);
|
||||
query_read_msg.prepare(QSL("UPDATE Messages SET is_read = :read WHERE is_pdeleted = 0 AND account_id = :account_id;"));
|
||||
|
||||
query_read_msg.bindValue(QSL(":account_id"), accountId());
|
||||
query_read_msg.bindValue(QSL(":read"), status == RootItem::Read ? 1 : 0);
|
||||
|
||||
if (!query_read_msg.exec()) {
|
||||
qDebug("Query execution for feeds read change failed.");
|
||||
db_handle.rollback();
|
||||
}
|
||||
|
||||
// Commit changes.
|
||||
if (db_handle.commit()) {
|
||||
updateCounts(false);
|
||||
itemChanged(getSubTree());
|
||||
requestReloadMessageList(status == RootItem::Read);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return db_handle.rollback();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant StandardServiceRoot::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
@ -172,7 +204,7 @@ bool StandardServiceRoot::markFeedsReadUnread(QList<Feed*> items, ReadStatus rea
|
||||
QList<RootItem*> itemss;
|
||||
|
||||
foreach (Feed *feed, items) {
|
||||
feed->updateCounts(true);
|
||||
feed->updateCounts(false);
|
||||
itemss.append(feed);
|
||||
}
|
||||
|
||||
|
@ -47,17 +47,21 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
bool canBeDeleted();
|
||||
bool deleteViaGui();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
QVariant data(int column, int role) const;
|
||||
Qt::ItemFlags additionalFlags() const;
|
||||
|
||||
// Access to recycle bin.
|
||||
RecycleBin *recycleBin();
|
||||
|
||||
// Return "add feed" and "add category" items.
|
||||
QList<QAction*> addItemMenu();
|
||||
|
||||
// Return menu to be shown in "Services -> service" menu.
|
||||
// Returns menu to be shown in "Services -> service" menu.
|
||||
QList<QAction*> serviceMenu();
|
||||
|
||||
// Returns context menu.
|
||||
QList<QAction*> contextMenu();
|
||||
|
||||
// Message stuff.
|
||||
|
Loading…
x
Reference in New Issue
Block a user