diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index 34a63a3a3..495ebedec 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -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(); + }); } diff --git a/Linphone/core/call-history/CallHistoryCore.hpp b/Linphone/core/call-history/CallHistoryCore.hpp index f13b07b35..f8c1c7465 100644 --- a/Linphone/core/call-history/CallHistoryCore.hpp +++ b/Linphone/core/call-history/CallHistoryCore.hpp @@ -68,6 +68,7 @@ public: signals: void durationChanged(QString duration); void displayNameChanged(); + void removed(); private: QString mDuration; diff --git a/Linphone/core/call-history/CallHistoryList.cpp b/Linphone/core/call-history/CallHistoryList.cpp index f2195de64..f553ede82 100644 --- a/Linphone/core/call-history/CallHistoryList.cpp +++ b/Linphone/core/call-history/CallHistoryList.cpp @@ -67,6 +67,7 @@ void CallHistoryList::setSelf(QSharedPointer 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 me) { auto oldLog = std::find_if(mList.begin(), mList.end(), [callLogs](QSharedPointer log) { return (*callLogs)->mCallId == log.objectCast()->mCallId; }); + toConnect(callLogs->get()); if (oldLog == mList.end()) { // New prepend(*callLogs); } else { // Update (status, duration, etc ...) @@ -99,6 +101,10 @@ void CallHistoryList::setSelf(QSharedPointer 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(); - item->remove(); - endRemoveRows(); + if (item) item->remove(); } QVariant CallHistoryList::data(const QModelIndex &index, int role) const { diff --git a/Linphone/core/call-history/CallHistoryList.hpp b/Linphone/core/call-history/CallHistoryList.hpp index 98f686852..bdef270a8 100644 --- a/Linphone/core/call-history/CallHistoryList.hpp +++ b/Linphone/core/call-history/CallHistoryList.hpp @@ -41,6 +41,7 @@ public: ~CallHistoryList(); void setSelf(QSharedPointer 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(); diff --git a/Linphone/core/call-history/CallHistoryProxy.cpp b/Linphone/core/call-history/CallHistoryProxy.cpp index 2712e4c72..bdaae52d6 100644 --- a/Linphone/core/call-history/CallHistoryProxy.cpp +++ b/Linphone/core/call-history/CallHistoryProxy.cpp @@ -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 { diff --git a/Linphone/core/call-history/CallHistoryProxy.hpp b/Linphone/core/call-history/CallHistoryProxy.hpp index afe8fd6e8..b209286f6 100644 --- a/Linphone/core/call-history/CallHistoryProxy.hpp +++ b/Linphone/core/call-history/CallHistoryProxy.hpp @@ -39,6 +39,7 @@ public: Q_INVOKABLE void removeAllEntries(); Q_INVOKABLE void removeEntriesWithFilter(); + Q_INVOKABLE void reload(); protected: QSharedPointer mHistoryList; diff --git a/Linphone/model/call-history/CallHistoryModel.cpp b/Linphone/model/call-history/CallHistoryModel.cpp index a76d34164..78ca0aa0d 100644 --- a/Linphone/model/call-history/CallHistoryModel.cpp +++ b/Linphone/model/call-history/CallHistoryModel.cpp @@ -23,6 +23,7 @@ #include #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); -} \ No newline at end of file +} diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml index 1485ddbfb..8c20402ed 100644 --- a/Linphone/view/Page/Main/Call/CallPage.qml +++ b/Linphone/view/Page/Main/Call/CallPage.qml @@ -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 diff --git a/external/linphone-sdk b/external/linphone-sdk index ec80377f3..477e178da 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit ec80377f302c9282b983fdbeebeaadb0a693986f +Subproject commit 477e178da43fcd9e73eedff50d83164e523e9232