diff --git a/src/contactadapter.cpp b/src/contactadapter.cpp index 514c64c9b0c55e7a6413c76090f9f99958730441..3ddc0c59cb12d8b7d1086712684df11bcb0dc7ed 100644 --- a/src/contactadapter.cpp +++ b/src/contactadapter.cpp @@ -31,9 +31,7 @@ ContactAdapter::ContactAdapter(QObject* parent, LRCInstance* instance) QVariant ContactAdapter::getContactSelectableModel(int type) { - /* - * Called from qml every time contact picker refreshes. - */ + // Called from qml every time contact picker refreshes. listModeltype_ = static_cast<SmartListModel::Type>(type); if (listModeltype_ == SmartListModel::Type::CONVERSATION) { @@ -46,9 +44,7 @@ ContactAdapter::getContactSelectableModel(int type) } selectableProxyModel_->setSourceModel(smartListModel_.get()); - /* - * Adjust filter. - */ + // Adjust filter. switch (listModeltype_) { case SmartListModel::Type::CONVERSATION: selectableProxyModel_->setPredicate([this](const QModelIndex& index, const QRegExp&) { @@ -63,16 +59,21 @@ ContactAdapter::getContactSelectableModel(int type) break; case SmartListModel::Type::TRANSFER: selectableProxyModel_->setPredicate([this](const QModelIndex& index, const QRegExp& regexp) { - /* - * Regex to remove current callee. - */ - QRegExp matchExcept = QRegExp(QString("\\b(?!" + calleeDisplayName_ + "\\b)\\w+")); - bool match = false; - bool match_non_self = matchExcept.indexIn( - index.data(SmartListModel::Role::DisplayName).toString()) - != -1; - if (match_non_self) { - match = regexp.indexIn(index.data(SmartListModel::Role::DisplayName).toString()) + // Exclude current sip callee and filtered contact. + bool match = true; + const auto& conv = lrcInstance_->getConversationFromConvUid( + lrcInstance_->getCurrentConvUid()); + if (!conv.participants.isEmpty()) { + QString calleeDisplayId = lrcInstance_->getAccountInfo(lrcInstance_->getCurrAccId()) + .contactModel->bestIdForContact(conv.participants[0]); + + QRegExp matchExcept = QRegExp(QString("\\b(?!" + calleeDisplayId + "\\b)\\w+")); + match = matchExcept.indexIn(index.data(SmartListModel::Role::DisplayID).toString()) + != -1; + } + + if (match) { + match = regexp.indexIn(index.data(SmartListModel::Role::DisplayID).toString()) != -1; } return match && !index.parent().isValid(); @@ -112,9 +113,7 @@ ContactAdapter::contactSelected(int index) if (contactIndex.isValid()) { switch (listModeltype_) { case SmartListModel::Type::CONFERENCE: { - /* - * Conference. - */ + // Conference. const auto sectionName = contactIndex.data(SmartListModel::Role::SectionName) .value<QString>(); if (!sectionName.isEmpty()) { @@ -143,9 +142,7 @@ ContactAdapter::contactSelected(int index) } } break; case SmartListModel::Type::TRANSFER: { - /* - * SIP Transfer. - */ + // SIP Transfer. const auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>(); if (convInfo.uid.isEmpty()) { @@ -156,19 +153,16 @@ ContactAdapter::contactSelected(int index) QString destCallId; try { - /* - * Check if the call exist - (check non-finished calls). - */ + // Check if the call exist - (check non-finished calls). const auto callInfo = callModel->getCallFromURI(contactUri, true); destCallId = callInfo.id; } catch (std::exception& e) { qDebug().noquote() << e.what(); destCallId = ""; } - /* - * If no second call -> blind transfer. - * If there is a second call -> attended transfer. - */ + + // If no second call -> blind transfer. + // If there is a second call -> attended transfer. if (destCallId.size() == 0) { callModel->transfer(callId, "sip:" + contactUri); callModel->hangUp(callId); @@ -195,9 +189,3 @@ ContactAdapter::contactSelected(int index) } } } - -void -ContactAdapter::setCalleeDisplayName(const QString& name) -{ - calleeDisplayName_ = name; -} diff --git a/src/contactadapter.h b/src/contactadapter.h index 46cf92afe6a64b030a93e6038069d4c2dd1bdf10..f0e77294267fd6cefb5a16881aea9f8032f97aed 100644 --- a/src/contactadapter.h +++ b/src/contactadapter.h @@ -81,14 +81,10 @@ protected: Q_INVOKABLE QVariant getContactSelectableModel(int type); Q_INVOKABLE void setSearchFilter(const QString& filter); Q_INVOKABLE void contactSelected(int index); - Q_INVOKABLE void setCalleeDisplayName(const QString& name); private: SmartListModel::Type listModeltype_; - // For sip call transfer, to exclude current sip callee. - QString calleeDisplayName_; - // SmartListModel is the source model of SelectableProxyModel. std::unique_ptr<SmartListModel> smartListModel_; std::unique_ptr<SelectableProxyModel> selectableProxyModel_; diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml index e246506f6f7cd4d68f34082a86f4459a041e65bf..e2e61062d8c9a0ed26399ea334140e22a44b7867 100644 --- a/src/mainview/components/VideoCallPage.qml +++ b/src/mainview/components/VideoCallPage.qml @@ -344,9 +344,5 @@ Rectangle { } } - onBestNameChanged: { - ContactAdapter.setCalleeDisplayName(bestName) - } - color: "black" }