Handle CallLog updates
This commit is contained in:
parent
6f08430661
commit
2fdddf942f
2 changed files with 17 additions and 6 deletions
|
|
@ -90,12 +90,8 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
|
||||||
});
|
});
|
||||||
if (oldLog == mList.end()) { // New
|
if (oldLog == mList.end()) { // New
|
||||||
prepend(*callLogs);
|
prepend(*callLogs);
|
||||||
} else { // Update
|
} else { // Update (status, duration, etc ...)
|
||||||
qWarning() << log()
|
replace(oldLog->objectCast<CallHistoryCore>(), *callLogs);
|
||||||
.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);
|
|
||||||
}
|
}
|
||||||
delete[] callLogs;
|
delete[] callLogs;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,21 @@ public:
|
||||||
virtual bool remove(QSharedPointer<QObject> itemToRemove) {
|
virtual bool remove(QSharedPointer<QObject> itemToRemove) {
|
||||||
return remove(itemToRemove.get());
|
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
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue