Refactored restoring of messages.

This commit is contained in:
Martin Rotter 2015-12-10 13:46:26 +01:00
parent 68a9355223
commit c6576ea799
6 changed files with 17 additions and 17 deletions

View File

@ -439,17 +439,17 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, RootIt
bool MessagesModel::setBatchMessagesRestored(const QModelIndexList &messages) {
QStringList message_ids;
QList<int> message_ids_num;
QList<Message> msgs;
// Obtain IDs of all desired messages.
foreach (const QModelIndex &message, messages) {
int msg_id = messageId(message.row());
Message msg = messageAt(message.row());
message_ids_num.append(msg_id);
message_ids.append(QString::number(msg_id));
msgs.append(msg);
message_ids.append(QString::number(msg.m_id));
}
if (!m_selectedItem->getParentServiceRoot()->onBeforeMessagesRestoredFromBin(m_selectedItem, message_ids_num)) {
if (!m_selectedItem->getParentServiceRoot()->onBeforeMessagesRestoredFromBin(m_selectedItem, msgs)) {
return false;
}
@ -461,7 +461,7 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList &messages) {
if (query_read_msg.exec(sql_delete_query)) {
fetchAllData();
return m_selectedItem->getParentServiceRoot()->onAfterMessagesRestoredFromBin(m_selectedItem, message_ids_num);
return m_selectedItem->getParentServiceRoot()->onAfterMessagesRestoredFromBin(m_selectedItem, msgs);
}
else {
return false;

View File

@ -130,12 +130,12 @@ class ServiceRoot : public RootItem {
// Called BEFORE the list of messages is about to be restored from recycle bin
// by the user from message list.
// Selected item is naturally recycle bin.
virtual bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) = 0;
virtual bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) = 0;
// Called AFTER the list of messages was restored from recycle bin
// by the user from message list.
// Selected item is naturally recycle bin.
virtual bool onAfterMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) = 0;
virtual bool onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) = 0;
/////////////////////////////////////////
// Members to override. */

View File

@ -565,13 +565,13 @@ bool StandardServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const Q
return true;
}
bool StandardServiceRoot::onBeforeMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) {
bool StandardServiceRoot::onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) {
return true;
}
bool StandardServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) {
bool StandardServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) {
Q_UNUSED(selected_item)
Q_UNUSED(message_db_ids)
Q_UNUSED(messages)
updateCounts(true);
itemChanged(getSubTree());

View File

@ -72,8 +72,8 @@ class StandardServiceRoot : public ServiceRoot {
bool onBeforeMessagesDelete(RootItem *selected_item, const QList<Message> &messages);
bool onAfterMessagesDelete(RootItem *selected_item, const QList<Message> &messages);
bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids);
bool onAfterMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids);
bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages);
bool onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages);
// Returns all standard categories which are lying under given root node.
// This does NOT include the root node even if the node is category.

View File

@ -210,11 +210,11 @@ bool TtRssServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const QLis
return false;
}
bool TtRssServiceRoot::onBeforeMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) {
bool TtRssServiceRoot::onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) {
return false;
}
bool TtRssServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids) {
bool TtRssServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages) {
return false;
}

View File

@ -63,8 +63,8 @@ class TtRssServiceRoot : public ServiceRoot {
bool onBeforeMessagesDelete(RootItem *selected_item, const QList<Message> &messages);
bool onAfterMessagesDelete(RootItem *selected_item, const QList<Message> &messages);
bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids);
bool onAfterMessagesRestoredFromBin(RootItem *selected_item, QList<int> message_db_ids);
bool onBeforeMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages);
bool onAfterMessagesRestoredFromBin(RootItem *selected_item, const QList<Message> &messages);
TtRssNetworkFactory *network() const;