diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index c4186282f..bba214982 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -51,7 +51,8 @@ CallHistoryCore::CallHistoryCore(const std::shared_ptr &callL mStatus = LinphoneEnums::fromLinphone(callLog->getStatus()); mDate = QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000); mIsOutgoing = callLog->getDir() == linphone::Call::Dir::Outgoing; - mDuration = QString::number(callLog->getDuration()); + mDuration = callLog->getDuration(); + mDurationString = QString::number(mDuration); mIsConference = callLog->wasConference(); mCallId = Utils::coreStringToAppString(callLog->getCallId()); mHasChat = false; @@ -149,16 +150,17 @@ ConferenceInfoGui *CallHistoryCore::getConferenceInfoGui() const { return mConferenceInfo ? new ConferenceInfoGui(mConferenceInfo) : nullptr; } -QString CallHistoryCore::getDuration() const { +int CallHistoryCore::getDuration() const { return mDuration; } -void CallHistoryCore::setDuration(const QString &duration) { +QString CallHistoryCore::getDurationString() const { + return mDurationString; +} + +QDateTime CallHistoryCore::getStartDate() const { mustBeInMainThread(log().arg(Q_FUNC_INFO)); - if (mDuration != duration) { - mDuration = duration; - emit durationChanged(mDuration); - } + return mDate; } std::shared_ptr CallHistoryCore::getModel() const { diff --git a/Linphone/core/call-history/CallHistoryCore.hpp b/Linphone/core/call-history/CallHistoryCore.hpp index ca59fdc0b..9a7525cc1 100644 --- a/Linphone/core/call-history/CallHistoryCore.hpp +++ b/Linphone/core/call-history/CallHistoryCore.hpp @@ -43,7 +43,7 @@ class CallHistoryCore : public QObject, public AbstractObject { Q_PROPERTY(ConferenceInfoGui *conferenceInfo READ getConferenceInfoGui CONSTANT) Q_PROPERTY(QDateTime date MEMBER mDate CONSTANT) Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus CONSTANT) - Q_PROPERTY(QString duration READ getDuration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(int duration READ getDuration NOTIFY durationChanged) public: static QSharedPointer create(const std::shared_ptr &callLogs); @@ -53,8 +53,10 @@ public: void setSelf(QSharedPointer me); ConferenceInfoGui *getConferenceInfoGui() const; - QString getDuration() const; - void setDuration(const QString &duration); + int getDuration() const; + QString getDurationString() const; + + QDateTime getStartDate() const; std::shared_ptr getModel() const; @@ -71,13 +73,15 @@ public: QString mCallId; signals: - void durationChanged(QString duration); + void durationChanged(int duration); + void durationStringChanged(QString duration); void displayNameChanged(); void friendUpdated(); // When a friend is created, this log is linked to it. void removed(); private: - QString mDuration; + int mDuration; + QString mDurationString; QSharedPointer mConferenceInfo = nullptr; bool mHasChat = false; std::shared_ptr mCallHistoryModel; diff --git a/Linphone/core/call-history/CallHistoryList.cpp b/Linphone/core/call-history/CallHistoryList.cpp index 8b02d5184..c9db6ee18 100644 --- a/Linphone/core/call-history/CallHistoryList.cpp +++ b/Linphone/core/call-history/CallHistoryList.cpp @@ -56,11 +56,11 @@ CallHistoryList::~CallHistoryList() { void CallHistoryList::setSelf(QSharedPointer me) { mModelConnection = SafeConnection::create(me, CoreModel::getInstance()); - mModelConnection->makeConnectToCore(&CallHistoryList::lUpdate, [this]() { - clearData(); - emit listAboutToBeReset(); + mModelConnection->makeConnectToCore(&CallHistoryList::lUpdate, [this](bool signalReset) { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); + if (signalReset) emit listAboutToBeReset(); mModelConnection->invokeToModel([this]() { - mustBeInLinphoneThread(getClassName()); + mustBeInLinphoneThread(Q_FUNC_INFO); // Avoid copy to lambdas QList> *callLogs = new QList>(); std::list> linphoneCallLogs; @@ -73,8 +73,13 @@ void CallHistoryList::setSelf(QSharedPointer me) { callLogs->push_front(model); } mModelConnection->invokeToCore([this, callLogs]() { - mustBeInMainThread(getClassName()); - resetData(*callLogs); + mustBeInMainThread(Q_FUNC_INFO); + beginResetModel(); + mList.clear(); + for (auto &item : *callLogs) { + mList.append(item); + } + endResetModel(); delete callLogs; }); }); @@ -84,21 +89,24 @@ void CallHistoryList::setSelf(QSharedPointer me) { mModelConnection->makeConnectToModel( &CoreModel::callLogUpdated, [this](const std::shared_ptr &core, const std::shared_ptr &callLog) { - QSharedPointer *callLogs = new QSharedPointer[1]; - auto model = createCallHistoryCore(callLog); - callLogs[0] = model; - mModelConnection->invokeToCore([this, callLogs]() { - 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 …) - replace(oldLog->objectCast(), *callLogs); - } - delete[] callLogs; - }); + if (!callLog->getLocalAddress()->weakEqual( + CoreModel::getInstance()->getCore()->getDefaultAccount()->getParams()->getIdentityAddress())) { + lInfo() << "call log does not refer to current account, return"; + return; + } + emit lUpdate(false); + // auto callLogCore = createCallHistoryCore(callLog); + // mModelConnection->invokeToCore([this, callLogCore]() { + // auto oldLog = std::find_if(mList.begin(), mList.end(), [callLogCore](QSharedPointer log) { + // return (callLogCore)->mCallId == log.objectCast()->mCallId; + // }); + // toConnect(callLogCore.get()); + // if (oldLog == mList.end()) { // New + // prepend(callLogCore); + // } else { // Update (status, duration, etc …) + // replace(oldLog->objectCast(), callLogCore); + // } + // }); }); mModelConnection->makeConnectToCore(&CallHistoryList::lRemoveEntriesForAddress, [this](QString address) { mModelConnection->invokeToModel([this, address]() { diff --git a/Linphone/core/call-history/CallHistoryList.hpp b/Linphone/core/call-history/CallHistoryList.hpp index e91e233f4..1ef15fff4 100644 --- a/Linphone/core/call-history/CallHistoryList.hpp +++ b/Linphone/core/call-history/CallHistoryList.hpp @@ -59,7 +59,7 @@ public: // void displayMore(); signals: - void lUpdate(); + void lUpdate(bool signalReset = true); void lRemoveEntriesForAddress(QString address); void lRemoveAllEntries(); void listAboutToBeReset(); diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml index b60a14bd7..6592676c3 100644 --- a/Linphone/view/Page/Main/Call/CallPage.qml +++ b/Linphone/view/Page/Main/Call/CallPage.qml @@ -683,9 +683,7 @@ AbstractMainPage { Layout.fillWidth: true } Text { - text: UtilsCpp.formatElapsedTime( - modelData.core.duration, - false) + text: UtilsCpp.formatElapsedTime(modelData.core.duration,false) font { pixelSize: Utils.getSizeWithScreenRatio(12) weight: Utils.getSizeWithScreenRatio(300)