From b943d4233ea210310515240cd8f5c360f1203275 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 19 May 2017 10:43:31 +0200 Subject: [PATCH] feat(ui/views/App/Calls/ConferenceManager): in progress --- .../src/components/call/CallModel.cpp | 2 +- .../conference/ConferenceAddModel.cpp | 37 +++++++++++++++++-- .../conference/ConferenceAddModel.hpp | 6 +++ .../conference/ConferenceHelperModel.hpp | 2 +- .../sip-addresses/SipAddressesModel.cpp | 7 ++++ .../sip-addresses/SipAddressesModel.hpp | 1 + 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 011e07c8e..dea3d7739 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -193,7 +193,7 @@ void CallModel::stopRecording () { // ----------------------------------------------------------------------------- -void CallModel::handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state) { +void CallModel::handleCallStateChanged (const shared_ptr &call, linphone::CallState state) { if (call != mCall) return; diff --git a/linphone-desktop/src/components/conference/ConferenceAddModel.cpp b/linphone-desktop/src/components/conference/ConferenceAddModel.cpp index 85cdfba8d..e343ca864 100644 --- a/linphone-desktop/src/components/conference/ConferenceAddModel.cpp +++ b/linphone-desktop/src/components/conference/ConferenceAddModel.cpp @@ -33,7 +33,14 @@ ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent) mConferenceHelperModel = qobject_cast(parent); Q_ASSERT(mConferenceHelperModel != nullptr); - for (auto &participant : CoreManager::getInstance()->getCore()->getConference()->getParticipants()) + CoreManager *coreManager = CoreManager::getInstance(); + + QObject::connect( + coreManager->getSipAddressesModel(), &SipAddressesModel::dataChanged, + this, &ConferenceAddModel::handleDataChanged + ); + + for (auto &participant : coreManager->getCore()->getConference()->getParticipants()) addToConference(participant); } @@ -118,9 +125,9 @@ void ConferenceHelperModel::ConferenceAddModel::update () { // ----------------------------------------------------------------------------- -void ConferenceHelperModel::ConferenceAddModel::addToConference (const std::shared_ptr &linphoneAddress) { +void ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr &linphoneAddress) { QString sipAddress = ::Utils::linphoneStringToQString(linphoneAddress->asStringUriOnly()); - QVariantMap map; + QVariantMap map = CoreManager::getInstance()->getSipAddressesModel()->find(sipAddress); map["sipAddress"] = sipAddress; map["__linphoneAddress"] = QVariant::fromValue(linphoneAddress); @@ -128,3 +135,27 @@ void ConferenceHelperModel::ConferenceAddModel::addToConference (const std::shar mSipAddresses[sipAddress] = map; mRefs << &mSipAddresses[sipAddress]; } + +// ----------------------------------------------------------------------------- + +void ConferenceHelperModel::ConferenceAddModel::handleDataChanged ( + const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector & +) { + SipAddressesModel *sipAddressesModel = CoreManager::getInstance()->getSipAddressesModel(); + + int limit = bottomRight.row(); + for (int row = topLeft.row(); row <= limit; ++row) { + const QVariantMap &map = sipAddressesModel->data(sipAddressesModel->index(row, 0)).toMap(); + + auto it = mSipAddresses.find(map["sipAddress"].toString()); + if (it != mSipAddresses.end()) { + (*it)["contact"] = map.value("contact"); + + int row = mRefs.indexOf(&(*it)); + Q_ASSERT(row != -1); + emit dataChanged(index(row, 0), index(row, 0)); + } + } +} diff --git a/linphone-desktop/src/components/conference/ConferenceAddModel.hpp b/linphone-desktop/src/components/conference/ConferenceAddModel.hpp index 854d62ff6..6cbda05a8 100644 --- a/linphone-desktop/src/components/conference/ConferenceAddModel.hpp +++ b/linphone-desktop/src/components/conference/ConferenceAddModel.hpp @@ -57,6 +57,12 @@ public: private: void addToConference (const std::shared_ptr &linphoneAddress); + void handleDataChanged ( + const QModelIndex &topLeft, + const QModelIndex &bottomRight, + const QVector &roles = QVector() + ); + QHash mSipAddresses; QList mRefs; diff --git a/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp index 2eca70ae0..a5fc37461 100644 --- a/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp +++ b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp @@ -39,7 +39,7 @@ namespace linphone { class ConferenceHelperModel : public QSortFilterProxyModel { Q_OBJECT; - Q_PROPERTY(ConferenceAddModel * toAdd READ getConferenceAddModel CONSTANT); + Q_PROPERTY(ConferenceHelperModel::ConferenceAddModel * toAdd READ getConferenceAddModel CONSTANT); public: class ConferenceAddModel; diff --git a/linphone-desktop/src/components/sip-addresses/SipAddressesModel.cpp b/linphone-desktop/src/components/sip-addresses/SipAddressesModel.cpp index d1678bb30..0d8d7960e 100644 --- a/linphone-desktop/src/components/sip-addresses/SipAddressesModel.cpp +++ b/linphone-desktop/src/components/sip-addresses/SipAddressesModel.cpp @@ -93,6 +93,13 @@ void SipAddressesModel::connectToChatModel (ChatModel *chatModel) { // ----------------------------------------------------------------------------- +QVariantMap SipAddressesModel::find (const QString &sipAddress) const { + auto it = mSipAddresses.find(sipAddress); + return it == mSipAddresses.end() ? QVariantMap() : *it; +} + +// ----------------------------------------------------------------------------- + ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sipAddress) const { auto it = mSipAddresses.find(sipAddress); if (it == mSipAddresses.end()) diff --git a/linphone-desktop/src/components/sip-addresses/SipAddressesModel.hpp b/linphone-desktop/src/components/sip-addresses/SipAddressesModel.hpp index 94ece33a3..f73acd479 100644 --- a/linphone-desktop/src/components/sip-addresses/SipAddressesModel.hpp +++ b/linphone-desktop/src/components/sip-addresses/SipAddressesModel.hpp @@ -47,6 +47,7 @@ public: void connectToChatModel (ChatModel *chatModel); + Q_INVOKABLE QVariantMap find (const QString &sipAddress) const; Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sipAddress) const; Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sipAddress);