diff --git a/linphone-desktop/CMakeLists.txt b/linphone-desktop/CMakeLists.txt index 8a5870d10..4671fb0b2 100644 --- a/linphone-desktop/CMakeLists.txt +++ b/linphone-desktop/CMakeLists.txt @@ -106,6 +106,7 @@ set(SOURCES src/components/codecs/AbstractCodecsModel.cpp src/components/codecs/AudioCodecsModel.cpp src/components/codecs/VideoCodecsModel.cpp + src/components/conference/ConferenceHelperModel.cpp src/components/contact/ContactModel.cpp src/components/contact/VcardModel.cpp src/components/contacts/ContactsListModel.cpp @@ -147,6 +148,7 @@ set(HEADERS src/components/codecs/AudioCodecsModel.hpp src/components/codecs/VideoCodecsModel.hpp src/components/Components.hpp + src/components/conference/ConferenceHelperModel.hpp src/components/contact/ContactModel.hpp src/components/contact/VcardModel.hpp src/components/contacts/ContactsListModel.hpp diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index c524be446..392099e19 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -343,6 +343,7 @@ void App::registerTypes () { registerType("CameraPreview"); registerType("ChatModel"); registerType("ChatProxyModel"); + registerType("ConferenceHelperModel"); registerType("ContactsListProxyModel"); registerType("SmartSearchBarModel"); registerType("SoundPlayer"); diff --git a/linphone-desktop/src/components/Components.hpp b/linphone-desktop/src/components/Components.hpp index a3eb68289..58d91f880 100644 --- a/linphone-desktop/src/components/Components.hpp +++ b/linphone-desktop/src/components/Components.hpp @@ -31,6 +31,7 @@ #include "chat/ChatProxyModel.hpp" #include "codecs/AudioCodecsModel.hpp" #include "codecs/VideoCodecsModel.hpp" +#include "conference/ConferenceHelperModel.hpp" #include "contacts/ContactsListProxyModel.hpp" #include "core/CoreManager.hpp" #include "presence/OwnPresenceModel.hpp" diff --git a/linphone-desktop/src/components/conference/ConferenceHelperModel.cpp b/linphone-desktop/src/components/conference/ConferenceHelperModel.cpp new file mode 100644 index 000000000..9c2ad7cea --- /dev/null +++ b/linphone-desktop/src/components/conference/ConferenceHelperModel.cpp @@ -0,0 +1,48 @@ +/* + * ConferenceHelperModel.cpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: May 11, 2017 + * Author: Ronan Abhamon + */ + +#include "../../Utils.hpp" +#include "../core/CoreManager.hpp" + +#include "ConferenceHelperModel.hpp" + +// ============================================================================= + +ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProxyModel(parent) { + setSourceModel(CoreManager::getInstance()->getSipAddressesModel()); + + for (const auto &participant : CoreManager::getInstance()->getCore()->getConference()->getParticipants()) + mInConference << ::Utils::linphoneStringToQString(participant->asStringUriOnly()); +} + +QHash ConferenceHelperModel::roleNames () const { + QHash roles; + roles[Qt::DisplayRole] = "$sipAddress"; + return roles; +} + +bool ConferenceHelperModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const { + const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent); + const QVariantMap &data = index.data().toMap(); + + return !mInConference.contains(data["sipAddress"].toString()); +} diff --git a/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp new file mode 100644 index 000000000..337c9dc3a --- /dev/null +++ b/linphone-desktop/src/components/conference/ConferenceHelperModel.hpp @@ -0,0 +1,41 @@ +/* + * ConferenceHelperModel.hpp + * Copyright (C) 2017 Belledonne Communications, Grenoble, France + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Created on: May 11, 2017 + * Author: Ronan Abhamon + */ + +#include + +// ============================================================================= + +class ConferenceHelperModel : public QSortFilterProxyModel { + Q_OBJECT; + +public: + ConferenceHelperModel (QObject *parent = Q_NULLPTR); + ~ConferenceHelperModel () = default; + + QHash roleNames () const override; + +protected: + bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override; + +private: + QStringList mInConference; +};