diff --git a/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp b/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp index 66d8acd4d..c04049833 100644 --- a/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp +++ b/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp @@ -23,6 +23,7 @@ #include "components/contact/ContactModel.hpp" #include "components/contact/VcardModel.hpp" #include "components/core/CoreManager.hpp" +#include "components/participant/ParticipantListModel.hpp" #include "components/sip-addresses/SipAddressesModel.hpp" #include "components/sip-addresses/SipAddressesSorter.hpp" @@ -35,6 +36,7 @@ // ----------------------------------------------------------------------------- SearchSipAddressesProxyModel::SearchSipAddressesProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { + mParticipantListModel = nullptr; setSourceModel(new SearchSipAddressesModel(this)); sort(0); } @@ -45,11 +47,22 @@ SearchSipAddressesModel * SearchSipAddressesProxyModel::getModel(){ return qobject_cast(sourceModel()); } +ParticipantListModel * SearchSipAddressesProxyModel::getParticipantListModel() const{ + return mParticipantListModel; +} + void SearchSipAddressesProxyModel::setFilter (const QString &pattern){ mFilter = pattern; getModel()->setFilter(pattern); } +void SearchSipAddressesProxyModel::setParticipantListModel(ParticipantListModel * model){ + if(mParticipantListModel != model){ + mParticipantListModel = model; + emit participantListModelChanged(); + } +} + void SearchSipAddressesProxyModel::addAddressToIgnore(const QString& address){ std::shared_ptr a = Utils::interpretUrl(address); if(a) { @@ -79,7 +92,9 @@ bool SearchSipAddressesProxyModel::filterAcceptsRow (int sourceRow, const QModel const SearchResultModel * model = sourceModel()->data(index).value(); if(!model) return false; - else + else if(mParticipantListModel){ + return !mParticipantListModel->contains(Utils::coreStringToAppString(model->getAddress()->asStringUriOnly())); + }else return !mResultsToIgnore.contains(Utils::coreStringToAppString(model->getAddress()->asStringUriOnly())); } diff --git a/linphone-app/src/components/search/SearchSipAddressesProxyModel.hpp b/linphone-app/src/components/search/SearchSipAddressesProxyModel.hpp index 8e88118a1..664fb6c26 100644 --- a/linphone-app/src/components/search/SearchSipAddressesProxyModel.hpp +++ b/linphone-app/src/components/search/SearchSipAddressesProxyModel.hpp @@ -23,6 +23,7 @@ #include +class ParticipantListModel; class SearchSipAddressesModel; // ============================================================================= @@ -34,18 +35,22 @@ public: SearchSipAddressesProxyModel (QObject *parent = Q_NULLPTR); Q_PROPERTY(SearchSipAddressesModel * model READ getModel CONSTANT) + Q_PROPERTY(ParticipantListModel *participantListModel READ getParticipantListModel WRITE setParticipantListModel NOTIFY participantListModelChanged) Q_INVOKABLE void addAddressToIgnore(const QString& address); Q_INVOKABLE void removeAddressToIgnore(const QString& address); Q_INVOKABLE bool isIgnored(const QString& address) const; SearchSipAddressesModel * getModel(); + ParticipantListModel * getParticipantListModel() const; Q_INVOKABLE void setFilter (const QString &pattern); void setResultExceptions(QAbstractListModel* exceptionList); + void setParticipantListModel( ParticipantListModel *model); signals: + void participantListModelChanged(); void resultExceptionsChanged(); protected: @@ -55,7 +60,7 @@ protected: private: QMap mResultsToIgnore; QString mFilter; - + ParticipantListModel *mParticipantListModel = nullptr; }; #endif diff --git a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml index fc4f80177..d6f036745 100644 --- a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml +++ b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml @@ -21,6 +21,8 @@ SearchBox { property string previousText: text onTextChanged: if( text != '') previousText = text; + property alias participantListModel : searchModel.participantListModel + function addAddressToIgnore(entry){ searchModel.addAddressToIgnore(entry) } diff --git a/linphone-app/ui/modules/Linphone/View/ParticipantsListView.qml b/linphone-app/ui/modules/Linphone/View/ParticipantsListView.qml index 190502e15..8f91af51c 100644 --- a/linphone-app/ui/modules/Linphone/View/ParticipantsListView.qml +++ b/linphone-app/ui/modules/Linphone/View/ParticipantsListView.qml @@ -54,6 +54,7 @@ ColumnLayout { selectedParticipants.addAddress(entry.sipAddress) }, }] + participantListModel: selectedParticipants.participantListModel onEntryClicked: { selectedParticipants.addAddress(entry.sipAddress)