From d840e72956f4cd6bf79306b3095eadcac25f7664 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 16 Mar 2022 10:34:06 +0100 Subject: [PATCH] Fix showing call history button and timeline filter buttons from data context. --- .../src/components/chat-events/ChatCallModel.cpp | 1 + .../src/components/chat-room/ChatRoomModel.cpp | 3 +++ linphone-app/src/components/core/CoreHandlers.cpp | 4 ++++ linphone-app/src/components/core/CoreHandlers.hpp | 3 +++ linphone-app/src/components/core/CoreManager.cpp | 5 +++++ linphone-app/src/components/core/CoreManager.hpp | 3 +++ linphone-app/src/components/history/HistoryModel.cpp | 2 ++ linphone-app/ui/modules/Linphone/Timeline/Timeline.qml | 10 ++++++++-- 8 files changed, 29 insertions(+), 2 deletions(-) diff --git a/linphone-app/src/components/chat-events/ChatCallModel.cpp b/linphone-app/src/components/chat-events/ChatCallModel.cpp index 2c995a25a..e1f91ced5 100644 --- a/linphone-app/src/components/chat-events/ChatCallModel.cpp +++ b/linphone-app/src/components/chat-events/ChatCallModel.cpp @@ -84,4 +84,5 @@ void ChatCallModel::update(){ void ChatCallModel::deleteEvent(){ CoreManager::getInstance()->getCore()->removeCallLog(mCallLog); + emit CoreManager::getInstance()->callLogsCountChanged(); } \ No newline at end of file diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index 7790deb65..f76825b0d 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -337,8 +337,11 @@ void ChatRoomModel::removeAllEntries () { ( !standardChatEnabled || !isSecure()) ) { auto callLogs = CallsListModel::getCallHistory(getParticipantAddress(), Utils::coreStringToAppString(mChatRoom->getLocalAddress()->asStringUriOnly())); + bool haveLogs = callLogs.size() > 0; for(auto callLog : callLogs) core->removeCallLog(callLog); + if(haveLogs) + emit CoreManager::getInstance()->callLogsCountChanged(); } endResetModel(); emit allEntriesRemoved(mSelf.lock()); diff --git a/linphone-app/src/components/core/CoreHandlers.cpp b/linphone-app/src/components/core/CoreHandlers.cpp index 5efb6a8fd..d5e35dad7 100644 --- a/linphone-app/src/components/core/CoreHandlers.cpp +++ b/linphone-app/src/components/core/CoreHandlers.cpp @@ -80,6 +80,10 @@ void CoreHandlers::onCallEncryptionChanged ( emit callEncryptionChanged(call); } +void CoreHandlers::onCallLogUpdated(const std::shared_ptr & core, const std::shared_ptr & callLog){ + emit callLogUpdated(callLog); +} + void CoreHandlers::onCallStateChanged ( const shared_ptr &, const shared_ptr &call, diff --git a/linphone-app/src/components/core/CoreHandlers.hpp b/linphone-app/src/components/core/CoreHandlers.hpp index 298af4df0..bc80ebd1d 100644 --- a/linphone-app/src/components/core/CoreHandlers.hpp +++ b/linphone-app/src/components/core/CoreHandlers.hpp @@ -41,6 +41,7 @@ public: signals: void authenticationRequested (const std::shared_ptr &authInfo); void callEncryptionChanged (const std::shared_ptr &call); + void callLogUpdated(const std::shared_ptr &call); void callStateChanged (const std::shared_ptr &call, linphone::Call::State state); void callTransferFailed (const std::shared_ptr &call); void callTransferSucceeded (const std::shared_ptr &call); @@ -76,6 +77,8 @@ private: bool on, const std::string &authenticationToken ) override; + + void onCallLogUpdated(const std::shared_ptr & core, const std::shared_ptr & callLog) override; void onCallStateChanged ( const std::shared_ptr &core, diff --git a/linphone-app/src/components/core/CoreManager.cpp b/linphone-app/src/components/core/CoreManager.cpp index 9b6be783c..b4e309c7c 100644 --- a/linphone-app/src/components/core/CoreManager.cpp +++ b/linphone-app/src/components/core/CoreManager.cpp @@ -76,6 +76,8 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, &CoreManager::initCoreManager, Qt::QueuedConnection); QObject::connect(coreHandlers, &CoreHandlers::coreStopped, this, &CoreManager::stopIterate, Qt::QueuedConnection); QObject::connect(coreHandlers, &CoreHandlers::logsUploadStateChanged, this, &CoreManager::handleLogsUploadStateChanged); + QObject::connect(coreHandlers, &CoreHandlers::callLogUpdated, this, &CoreManager::callLogsCountChanged); + QTimer::singleShot(10, [this, configPath](){// Delay the creation in order to have the CoreManager instance set before createLinphoneCore(configPath); }); @@ -354,6 +356,9 @@ QString CoreManager::getVersion () const { int CoreManager::getEventCount () const { return mEventCountNotifier ? mEventCountNotifier->getEventCount() : 0; } +int CoreManager::getCallLogsCount() const{ + return mCore->getCallLogs().size(); +} int CoreManager::getMissedCallCount(const QString &peerAddress, const QString &localAddress)const{ return mEventCountNotifier ? mEventCountNotifier->getMissedCallCount(peerAddress, localAddress) : 0; } diff --git a/linphone-app/src/components/core/CoreManager.hpp b/linphone-app/src/components/core/CoreManager.hpp index c219588d6..fed449ed6 100644 --- a/linphone-app/src/components/core/CoreManager.hpp +++ b/linphone-app/src/components/core/CoreManager.hpp @@ -56,6 +56,7 @@ class CoreManager : public QObject { Q_PROPERTY(QString version READ getVersion CONSTANT) Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT) Q_PROPERTY(int eventCount READ getEventCount NOTIFY eventCountChanged) + Q_PROPERTY(int callLogsCount READ getCallLogsCount NOTIFY callLogsCountChanged) public: bool started () const { @@ -166,6 +167,7 @@ public: Q_INVOKABLE void sendLogs () const; Q_INVOKABLE void cleanLogs () const; + int getCallLogsCount() const; int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines) int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines) @@ -193,6 +195,7 @@ signals: void logsUploaded (const QString &url); void eventCountChanged (); + void callLogsCountChanged(); private: CoreManager (QObject *parent, const QString &configPath); diff --git a/linphone-app/src/components/history/HistoryModel.cpp b/linphone-app/src/components/history/HistoryModel.cpp index 182a3b4a4..ed5c32248 100644 --- a/linphone-app/src/components/history/HistoryModel.cpp +++ b/linphone-app/src/components/history/HistoryModel.cpp @@ -133,6 +133,7 @@ bool HistoryModel::removeRows (int row, int count, const QModelIndex &parent) { emit allEntriesRemoved(); else if (limit == mEntries.count()) emit lastEntryRemoved(); + emit CoreManager::getInstance()->callLogsCountChanged(); emit focused();// Removing rows is like having focus. Don't wait asynchronous events. return true; } @@ -174,6 +175,7 @@ void HistoryModel::removeAllEntries () { endResetModel(); emit allEntriesRemoved(); + emit CoreManager::getInstance()->callLogsCountChanged(); emit focused();// Removing all entries is like having focus. Don't wait asynchronous events. } diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index 0bfc21755..11a1568a9 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -20,9 +20,10 @@ Rectangle { property alias model: view.model property string _selectedSipAddress - property bool showHistoryButton : true + property bool showHistoryButton : CoreManager.callLogsCount property bool updateSelectionModels : true property bool isFilterVisible: searchView.visible || showFilterView + property bool showFiltersButtons: view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0 // --------------------------------------------------------------------------- @@ -62,11 +63,13 @@ Rectangle { Layout.preferredHeight: TimelineStyle.legend.height Layout.alignment: Qt.AlignTop color: showHistory.containsMouse?TimelineStyle.legend.backgroundColor.hovered:TimelineStyle.legend.backgroundColor.normal - visible:view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0 + visible: showHistoryButton || showFiltersButtons + //visible:view.count > 0 || timeline.isFilterVisible || timeline.model.filterFlags > 0 || CoreManager.eventCount > 0 MouseArea{// no more showing history id:showHistory anchors.fill:parent + visible: showFiltersButtons onClicked: { timeline.showFilterView = !timeline.showFilterView } @@ -78,6 +81,7 @@ Rectangle { Layout.preferredHeight: parent.height Layout.fillWidth: true Layout.leftMargin: TimelineStyle.legend.leftMargin + visible: showFiltersButtons color: TimelineStyle.legend.color font.pointSize: TimelineStyle.legend.pointSize //: A title for filtering mode. @@ -96,6 +100,7 @@ Rectangle { icon: 'filter_params_custom' iconSize: TimelineStyle.legend.iconSize overwriteColor: TimelineStyle.legend.color + visible: showFiltersButtons MouseArea{ anchors.fill:parent onClicked:{ @@ -107,6 +112,7 @@ Rectangle { Layout.alignment: Qt.AlignRight Layout.fillHeight: true Layout.preferredWidth: TimelineStyle.legend.iconSize + visible: showFiltersButtons onClicked:{ searchView.visible = !searchView.visible }