202
History::Threads HistoryGroupedThreadsModel::restoreParticipants(const History::Threads &oldThreads, const History::Threads &newThreads)
204
History::Threads updated = newThreads;
205
for(History::Thread &thread : updated) {
206
if (!thread.participants().isEmpty()) {
209
int i = oldThreads.indexOf(thread);
211
thread.addParticipants(oldThreads[i].participants());
202
217
void HistoryGroupedThreadsModel::updateQuery()
204
219
// remove all entries and call the query update
238
254
notifyDataChanged();
257
void HistoryGroupedThreadsModel::onThreadParticipantsChanged(const History::Thread &thread, const History::Participants &added, const History::Participants &removed, const History::Participants &modified)
259
int pos = existingPositionForEntry(thread);
261
HistoryThreadGroup &group = mGroups[pos];
262
if (group.displayedThread == thread) {
263
group.displayedThread.removeParticipants(removed);
264
group.displayedThread.removeParticipants(modified);
265
group.displayedThread.addParticipants(added);
266
group.displayedThread.addParticipants(modified);
269
Q_FOREACH(const History::Thread &existingThread, group.threads) {
270
if (existingThread == thread) {
271
History::Thread modifiedThread = existingThread;
272
group.threads.removeOne(existingThread);
273
modifiedThread.removeParticipants(removed);
274
modifiedThread.removeParticipants(modified);
275
modifiedThread.addParticipants(added);
276
modifiedThread.addParticipants(modified);
277
group.threads.append(modifiedThread);
280
QModelIndex idx = index(pos);
281
Q_EMIT dataChanged(idx, idx);
284
// watch the contact info for the received participants
285
Q_FOREACH(const History::Participant &participant, added) {
286
watchContactInfo(thread.accountId(), participant.identifier(), participant.properties());
288
Q_FOREACH(const History::Participant &participant, modified) {
289
watchContactInfo(thread.accountId(), participant.identifier(), participant.properties());
241
293
void HistoryGroupedThreadsModel::processThreadGrouping(const History::Thread &thread)
243
295
QVariantMap queryProperties;
264
316
HistoryThreadGroup &group = mGroups[pos];
265
group.threads = groupedThread.groupedThreads();
317
group.threads = restoreParticipants(group.threads, groupedThread.groupedThreads());
267
319
updateDisplayedThread(group);
268
320
markGroupAsChanged(group);