Adds notifications to the Activities list.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2018-03-25 23:44:32 +02:00 committed by Roeland Jago Douma
parent 30a4f1edd7
commit 908870ccde
No known key found for this signature in database
GPG key ID: F941078878347C0C
4 changed files with 27 additions and 0 deletions

View file

@ -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()
{

View file

@ -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);

View file

@ -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

View file

@ -105,6 +105,7 @@ private:
QMap<Activity::Identifier, NotificationWidget *> _widgetForNotifId;
QElapsedTimer _guiLogTimer;
QSet<int> _guiLoggedNotifications;
ActivityList _newNotifications;
ActivityList _blacklistedNotifications;
QHash<NotificationWidget *, QDateTime> _widgetsToRemove;