diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index dea3d7739..5abb8a54c 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -197,6 +197,8 @@ void CallModel::handleCallStateChanged (const shared_ptr &call, if (call != mCall) return; + updateIsInConference(); + switch (state) { case linphone::CallStateError: case linphone::CallStateEnd: @@ -251,6 +253,15 @@ void CallModel::handleCallStateChanged (const shared_ptr &call, // ----------------------------------------------------------------------------- +void CallModel::updateIsInConference () { + if (mIsInConference != !!mCall->getConference()) { + mIsInConference = !mIsInConference; + emit isInConferenceChanged(mIsInConference); + } +} + +// ----------------------------------------------------------------------------- + void CallModel::stopAutoAnswerTimer () const { QTimer *timer = findChild(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly); if (timer) { @@ -259,6 +270,8 @@ void CallModel::stopAutoAnswerTimer () const { } } +// ----------------------------------------------------------------------------- + CallModel::CallStatus CallModel::getStatus () const { switch (mCall->getState()) { case linphone::CallStateConnected: diff --git a/linphone-desktop/src/components/call/CallModel.hpp b/linphone-desktop/src/components/call/CallModel.hpp index ccd325024..2828e7ba1 100644 --- a/linphone-desktop/src/components/call/CallModel.hpp +++ b/linphone-desktop/src/components/call/CallModel.hpp @@ -37,6 +37,8 @@ class CallModel : public QObject { Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT); + Q_PROPERTY(bool isInConference READ isInConference NOTIFY isInConferenceChanged); + Q_PROPERTY(int duration READ getDuration CONSTANT); // Constants but called with a timer in qml. Q_PROPERTY(float quality READ getQuality CONSTANT); Q_PROPERTY(float microVu READ getMicroVu CONSTANT); @@ -94,6 +96,7 @@ public: signals: void callErrorChanged (const QString &callError); + void isInConferenceChanged (bool status); void microMutedChanged (bool status); void recordingChanged (bool status); void statsUpdated (); @@ -106,10 +109,17 @@ private: void stopAutoAnswerTimer () const; CallStatus getStatus () const; + bool isOutgoing () const { return mCall->getDir() == linphone::CallDirOutgoing; } + bool isInConference () const { + return mIsInConference; + } + + void updateIsInConference (); + void acceptWithAutoAnswerDelay (); QString getCallError () const; @@ -139,6 +149,8 @@ private: QString iceStateToString (linphone::IceState state) const; + bool mIsInConference = false; + bool mPausedByRemote = false; bool mPausedByUser = false; bool mRecording = false; diff --git a/linphone-desktop/src/components/calls/CallsListModel.cpp b/linphone-desktop/src/components/calls/CallsListModel.cpp index 84b009016..a8361c38e 100644 --- a/linphone-desktop/src/components/calls/CallsListModel.cpp +++ b/linphone-desktop/src/components/calls/CallsListModel.cpp @@ -37,15 +37,18 @@ using namespace std; // ============================================================================= -inline QList::iterator findCallModel ( - QList &list, - const shared_ptr &call -) { - return find_if( - list.begin(), list.end(), [call](CallModel *callModel) { - return call == callModel->getCall(); - } - ); +inline int findCallIndex (QList &list, const shared_ptr &call) { + auto it = find_if(list.begin(), list.end(), [call](CallModel *callModel) { + return call == callModel->getCall(); + }); + + Q_ASSERT(it != list.end()); + + return static_cast(distance(list.begin(), it)); +} + +inline int findCallIndex (QList &list, const CallModel &callModel) { + return findCallIndex(list, callModel.getCall()); } // ----------------------------------------------------------------------------- @@ -136,7 +139,7 @@ void CallsListModel::handleCallStateChanged (const std::shared_ptr(distance(mList.begin(), findCallModel(mList, call))); + int index = findCallIndex(mList, call); emit callRunning(index, &call->getData("call-model")); } break; @@ -173,11 +176,17 @@ void CallsListModel::addCall (const shared_ptr &call) { App::smartShowWindow(App::getInstance()->getCallsWindow()); CallModel *callModel = new CallModel(call); - qInfo() << QStringLiteral("Add call:") << callModel; - App::getInstance()->getEngine()->setObjectOwnership(callModel, QQmlEngine::CppOwnership); + // This connection is (only) useful for `CallsListProxyModel`. + QObject::connect( + callModel, &CallModel::isInConferenceChanged, this, [this, callModel](bool) { + int id = findCallIndex(mList, *callModel); + emit dataChanged(index(id, 0), index(id, 0)); + } + ); + int row = mList.count(); beginInsertRows(QModelIndex(), row, row); diff --git a/linphone-desktop/src/components/calls/CallsListProxyModel.cpp b/linphone-desktop/src/components/calls/CallsListProxyModel.cpp index acbcfe0c3..29ca35150 100644 --- a/linphone-desktop/src/components/calls/CallsListProxyModel.cpp +++ b/linphone-desktop/src/components/calls/CallsListProxyModel.cpp @@ -45,5 +45,5 @@ bool CallsListProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &so const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent); shared_ptr call = index.data().value()->getCall(); - return call->getConference() != nullptr; + return call->getConference() == nullptr; }