Fix removing call history.

Update SDK.
This commit is contained in:
Julien Wadel 2024-12-03 20:27:54 +01:00
parent 550295fbe4
commit 390fc16c0a
9 changed files with 32 additions and 9 deletions

View file

@ -139,5 +139,8 @@ void CallHistoryCore::setDuration(const QString &duration) {
}
void CallHistoryCore::remove() {
mHistoryModelConnection->invokeToModel([this]() { mCallHistoryModel->removeCallHistory(); });
mHistoryModelConnection->invokeToModel([this]() {
mCallHistoryModel->removeCallHistory();
emit removed();
});
}

View file

@ -68,6 +68,7 @@ public:
signals:
void durationChanged(QString duration);
void displayNameChanged();
void removed();
private:
QString mDuration;

View file

@ -67,6 +67,7 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
}
for (auto it : linphoneCallLogs) {
auto model = createCallHistoryCore(it);
toConnect(model.get());
callLogs->push_back(model);
}
mModelConnection->invokeToCore([this, callLogs]() {
@ -88,6 +89,7 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
auto oldLog = std::find_if(mList.begin(), mList.end(), [callLogs](QSharedPointer<QObject> log) {
return (*callLogs)->mCallId == log.objectCast<CallHistoryCore>()->mCallId;
});
toConnect(callLogs->get());
if (oldLog == mList.end()) { // New
prepend(*callLogs);
} else { // Update (status, duration, etc ...)
@ -99,6 +101,10 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
emit lUpdate();
}
void CallHistoryList::toConnect(CallHistoryCore *data) {
connect(data, &CallHistoryCore::removed, this, [this, data]() { ListProxy::remove(data); });
}
void CallHistoryList::removeAllEntries() {
beginResetModel();
for (auto it = mList.rbegin(); it != mList.rend(); ++it) {
@ -110,10 +116,8 @@ void CallHistoryList::removeAllEntries() {
}
void CallHistoryList::remove(const int &row) {
beginRemoveRows(QModelIndex(), row, row);
auto item = mList[row].objectCast<CallHistoryCore>();
item->remove();
endRemoveRows();
if (item) item->remove();
}
QVariant CallHistoryList::data(const QModelIndex &index, int role) const {

View file

@ -41,6 +41,7 @@ public:
~CallHistoryList();
void setSelf(QSharedPointer<CallHistoryList> me);
void toConnect(CallHistoryCore *data);
void removeAllEntries();
void remove(const int &row);
@ -54,7 +55,7 @@ public:
// roles[Qt::DisplayRole + 2] = "date";
// return roles;
// }
//void displayMore();
// void displayMore();
signals:
void lUpdate();

View file

@ -45,10 +45,14 @@ void CallHistoryProxy::removeEntriesWithFilter() {
itemList[i] = item;
}
for (auto item : itemList) {
mHistoryList->ListProxy::remove(item.get());
item->remove();
}
}
void CallHistoryProxy::reload() {
emit mHistoryList->lUpdate();
}
//------------------------------------------------------------------------------------------
bool CallHistoryProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {

View file

@ -39,6 +39,7 @@ public:
Q_INVOKABLE void removeAllEntries();
Q_INVOKABLE void removeEntriesWithFilter();
Q_INVOKABLE void reload();
protected:
QSharedPointer<CallHistoryList> mHistoryList;

View file

@ -23,6 +23,7 @@
#include <QDebug>
#include "model/core/CoreModel.hpp"
#include "tool/Utils.hpp"
DEFINE_ABSTRACT_OBJECT(CallHistoryModel)
@ -37,5 +38,6 @@ CallHistoryModel::~CallHistoryModel() {
void CallHistoryModel::removeCallHistory() {
mustBeInLinphoneThread(getClassName() + "::removeCallHistory");
qInfo() << "Removing call log: " << Utils::coreStringToAppString(callLog->getCallId());
CoreModel::getInstance()->getCore()->removeCallLog(callLog);
}
}

View file

@ -251,6 +251,7 @@ AbstractMainPage {
onFilterTextChanged: maxDisplayItems = initialDisplayItems
initialDisplayItems: historyListView.height / (56 * DefaultStyle.dp) + 5
displayItemsStep: initialDisplayItems / 2
}
cacheBuffer: contentHeight>0 ? contentHeight : 0// cache all items
flickDeceleration: 10000
@ -273,7 +274,13 @@ AbstractMainPage {
function onAccepted() {
historyListView.model.removeAllEntries()
}
}
}
Connections{
target: mainItem
function onListViewUpdated(){
callHistoryProxy.reload()
}
}
onAtYEndChanged: if(atYEnd) callHistoryProxy.displayMore()
delegate: FocusScope {
width:historyListView.width

@ -1 +1 @@
Subproject commit ec80377f302c9282b983fdbeebeaadb0a693986f
Subproject commit 477e178da43fcd9e73eedff50d83164e523e9232