Handle CallLog updates

This commit is contained in:
Christophe Deschamps 2024-11-14 21:11:39 +01:00
parent 6f08430661
commit 2fdddf942f
2 changed files with 17 additions and 6 deletions

View file

@ -90,12 +90,8 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
});
if (oldLog == mList.end()) { // New
prepend(*callLogs);
} else { // Update
qWarning() << log()
.arg("LinphoneCore::onCallLogUpdated has been call for an existant log which "
"should not be the "
"case. Check with the SDK. CallID=%1")
.arg((*callLogs)->mCallId);
} else { // Update (status, duration, etc ...)
replace(oldLog->objectCast<CallHistoryCore>(), *callLogs);
}
delete[] callLogs;
});

View file

@ -116,6 +116,21 @@ public:
virtual bool remove(QSharedPointer<QObject> itemToRemove) {
return remove(itemToRemove.get());
}
template <class T>
void replace(QSharedPointer<T> itemToReplace, QSharedPointer<T> replacementItem) {
lInfo() << QStringLiteral("Replacing ") << itemToReplace->metaObject()->className() << QStringLiteral(" : ")
<< itemToReplace << " by " << replacementItem;
int index = mList.indexOf(itemToReplace);
if (index == -1) {
lWarning() << QStringLiteral("Unable to replace ") << itemToReplace->metaObject()->className()
<< QStringLiteral(" : ") << itemToReplace << " not found in list";
return;
}
mList[index] = replacementItem;
QModelIndex modelIndex = createIndex(index, 0);
emit dataChanged(modelIndex, modelIndex, {Qt::DisplayRole});
}
};
#endif