diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp index 44b89a849..dd2ba6b6a 100644 --- a/src/gui/activitylistmodel.cpp +++ b/src/gui/activitylistmodel.cpp @@ -46,6 +46,8 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const return QVariant(); a = _finalList.at(index.row()); + qDebug() << "Adding activity/notification: " << a._subject; + qDebug() << "Adding activity/notification: " << a._message; AccountStatePtr ast = AccountManager::instance()->account(a._accName); if (!ast) return QVariant(); @@ -173,6 +175,25 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st combineActivityLists(); } +void ActivityListModel::addToActivityList(AccountState *ast, ActivityList list) { + _activityLists[ast].append(list); + //endInsertRows(); + ActivityList resultList; + + foreach (ActivityList list, _activityLists.values()) { + resultList.append(list); + } + + std::sort(resultList.begin(), resultList.end()); + + beginResetModel(); + _finalList.clear(); + endResetModel(); + + beginInsertRows(QModelIndex(), 0, resultList.count()); + _finalList = resultList; + endInsertRows(); +} void ActivityListModel::combineActivityLists() { diff --git a/src/gui/activitylistmodel.h b/src/gui/activitylistmodel.h index ad5574d27..4108ab5d2 100644 --- a/src/gui/activitylistmodel.h +++ b/src/gui/activitylistmodel.h @@ -47,6 +47,7 @@ public: void fetchMore(const QModelIndex &) Q_DECL_OVERRIDE; ActivityList activityList() { return _finalList; } + void addToActivityList(AccountState *ast, ActivityList list); public slots: void slotRefreshActivity(AccountState *ast); diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp index 37e37b44b..e682219ee 100644 --- a/src/gui/activitywidget.cpp +++ b/src/gui/activitywidget.cpp @@ -314,8 +314,12 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list) emit guiLog(activity._subject, activity._accName); } } + _newNotifications.append(activity); } + i++; } + //_model->addToActivityList(AccountManager::instance()->account(listAccountName).data(), _newNotifications); + _model->addToActivityList(AccountManager::instance()->account(listAccountName).data(), list); // check if there are widgets that have no corresponding activity from // the server any more. Collect them in a list diff --git a/src/gui/activitywidget.h b/src/gui/activitywidget.h index 1195e7ffb..b1e899ed9 100644 --- a/src/gui/activitywidget.h +++ b/src/gui/activitywidget.h @@ -105,6 +105,7 @@ private: QMap _widgetForNotifId; QElapsedTimer _guiLogTimer; QSet _guiLoggedNotifications; + ActivityList _newNotifications; ActivityList _blacklistedNotifications; QHash _widgetsToRemove;