From f68e4c1ff276b8fb7acf88fd93c2de6f21558ce4 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 28 Jan 2022 17:23:26 +0100 Subject: [PATCH] - do not show 'me' if not admin in group info --- .../participant/ParticipantModel.cpp | 4 + .../participant/ParticipantModel.hpp | 2 + .../participant/ParticipantProxyModel.cpp | 20 ++- .../participant/ParticipantProxyModel.hpp | 5 + .../modules/Linphone/Private/ThemeEditor.qml | 159 ------------------ .../views/App/Main/Dialogs/InfoChatRoom.qml | 1 + 6 files changed, 31 insertions(+), 160 deletions(-) delete mode 100644 linphone-app/ui/modules/Linphone/Private/ThemeEditor.qml diff --git a/linphone-app/src/components/participant/ParticipantModel.cpp b/linphone-app/src/components/participant/ParticipantModel.cpp index 8c6a7543f..535ebbacc 100644 --- a/linphone-app/src/components/participant/ParticipantModel.cpp +++ b/linphone-app/src/components/participant/ParticipantModel.cpp @@ -64,6 +64,10 @@ bool ParticipantModel::getInviting() const{ return !mParticipant; } +bool ParticipantModel::isMe() const{ + return CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddress()->weakEqual(Utils::interpretUrl(getSipAddress())); +} + QString ParticipantModel::getSipAddress() const{ return (mParticipant ? Utils::coreStringToAppString(mParticipant->getAddress()->asString()) : mSipAddress); } diff --git a/linphone-app/src/components/participant/ParticipantModel.hpp b/linphone-app/src/components/participant/ParticipantModel.hpp index c65b32355..9d1e08b5c 100644 --- a/linphone-app/src/components/participant/ParticipantModel.hpp +++ b/linphone-app/src/components/participant/ParticipantModel.hpp @@ -58,6 +58,8 @@ public: int getDeviceCount(); bool getInviting() const; + bool isMe() const; + void setSipAddress(const QString& address); void setAdminStatus(const bool& status); void setParticipant(std::shared_ptr participant); diff --git a/linphone-app/src/components/participant/ParticipantProxyModel.cpp b/linphone-app/src/components/participant/ParticipantProxyModel.cpp index 021c08c9e..9a7d8a5e1 100644 --- a/linphone-app/src/components/participant/ParticipantProxyModel.cpp +++ b/linphone-app/src/components/participant/ParticipantProxyModel.cpp @@ -65,6 +65,10 @@ int ParticipantProxyModel::getCount() const{ return dynamic_cast(sourceModel())->rowCount(); } +bool ParticipantProxyModel::getShowMe() const{ + return mShowMe; +} + // ----------------------------------------------------------------------------- void ParticipantProxyModel::setChatRoomModel(ChatRoomModel * chatRoomModel){ @@ -83,6 +87,14 @@ void ParticipantProxyModel::setChatRoomModel(ChatRoomModel * chatRoomModel){ } } +void ParticipantProxyModel::setShowMe(const bool& show){ + if(mShowMe != show){ + mShowMe = show; + emit showMeChanged(); + invalidate(); + } +} + void ParticipantProxyModel::addAddress(const QString& address){ ParticipantListModel * participantsModel = dynamic_cast(sourceModel()); if(!participantsModel->contains(address)){ @@ -114,8 +126,14 @@ void ParticipantProxyModel::removeModel(ParticipantModel * participant){ // ----------------------------------------------------------------------------- bool ParticipantProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const { + if( mShowMe) + return true; + else{ + const ParticipantModel* a = sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent)).value(); + return !a->isMe(); + } //const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - return true; + //return true; } bool ParticipantProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { diff --git a/linphone-app/src/components/participant/ParticipantProxyModel.hpp b/linphone-app/src/components/participant/ParticipantProxyModel.hpp index bb24f550d..ab44b52b4 100644 --- a/linphone-app/src/components/participant/ParticipantProxyModel.hpp +++ b/linphone-app/src/components/participant/ParticipantProxyModel.hpp @@ -41,6 +41,7 @@ public: Q_PROPERTY(ChatRoomModel* chatRoomModel READ getChatRoomModel WRITE setChatRoomModel NOTIFY chatRoomModelChanged) Q_PROPERTY(int count READ getCount NOTIFY countChanged) + Q_PROPERTY(bool showMe READ getShowMe WRITE setShowMe NOTIFY showMeChanged) bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; @@ -49,8 +50,10 @@ public: Q_INVOKABLE QStringList getSipAddresses() const; Q_INVOKABLE QVariantList getParticipants() const; Q_INVOKABLE int getCount() const; + bool getShowMe() const; void setChatRoomModel(ChatRoomModel * chatRoomModel); + void setShowMe(const bool& show); Q_INVOKABLE void addAddress(const QString& address); Q_INVOKABLE void removeModel(ParticipantModel * participant); @@ -60,6 +63,7 @@ public: signals: void chatRoomModelChanged(); void countChanged(); + void showMeChanged(); void addressAdded(QString sipAddress); void addressRemoved(QString sipAddress); @@ -70,6 +74,7 @@ private: //std::shared_ptr mParticipantListModel; ChatRoomModel *mChatRoomModel; + bool mShowMe = true; }; #endif // PARTICIPANT_PROXY_MODEL_H_ diff --git a/linphone-app/ui/modules/Linphone/Private/ThemeEditor.qml b/linphone-app/ui/modules/Linphone/Private/ThemeEditor.qml deleted file mode 100644 index 22e71188a..000000000 --- a/linphone-app/ui/modules/Linphone/Private/ThemeEditor.qml +++ /dev/null @@ -1,159 +0,0 @@ -import QtGraphicalEffects 1.0 -import QtQuick 2.7 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.5 -import QtQuick.Dialogs 1.0 - -import Common 1.0 -import Linphone 1.0 - -import App.Styles 1.0 - - -// ============================================================================= -// ThemeEditor{} - -Window { - id: window - - - Component.onCompleted: window.show() - function setHeight (height) { - window.height = (Window.screen && height > Window.screen.desktopAvailableHeight) - ? Window.screen.desktopAvailableHeight - : height - } - - // --------------------------------------------------------------------------- - height:500 - width:500 - minimumHeight: 300 - minimumWidth: 200 - title: 'Theme Editor' - - - // --------------------------------------------------------------------------- - onVisibleChanged: visible=true - //onClosing: Logic.handleClosing(close) - //onDetachedVirtualWindow: Logic.tryToCloseWindow() - - // --------------------------------------------------------------------------- - ColumnLayout{ - anchors.fill:parent - TabBar{ - id: bar - Layout.fillWidth: true - TabButton{ - text: 'Colors' - } - TabButton{ - text: 'Icons' - } - } - StackLayout { - Layout.fillWidth: true - currentIndex: bar.currentIndex - // COLORS - ScrollableListView{ - //anchors.fill:parent - model:ColorProxyModel{ - id:colorProxy - } - delegate: RowLayout{ - TextField{ - id:colorField - Layout.fillHeight: true - Layout.fillWidth: true - text: colorPreview.color - onEditingFinished: modelData.color = text - } - Rectangle{ - id:colorPreview - width:30 - Layout.fillHeight: true - color:modelData.color - } - Slider{ - id:redSlider - from:0 - to:255 - value: colorPreview.color.r*255 - onValueChanged: modelData.color.r = value/255 - } - Slider{ - id:greenSlider - from:0 - to:255 - value: colorPreview.color.g*255 - onValueChanged: modelData.color.g = value/255 - } - Slider{ - id:blueSlider - from:0 - to:255 - value: colorPreview.color.b*255 - onValueChanged: modelData.color.b = value/255 - } - Slider{ - id:alphaSlider - from:0 - to:255 - value: colorPreview.color.a*255 - onValueChanged: modelData.color.a = value/255 - } - - Text{ - text : modelData.description - } - Text{ - text: modelData.name - visible:modelData.description == '' - } - } - } - ScrollableListView{ - //anchors.fill:parent - model:ImageProxyModel{ - id:imageProxy - } - delegate: RowLayout{ - Text{ - text: modelData.id - } - Icon{ - id:iconPreview - width:30 - Layout.fillHeight: true - icon:modelData.id - iconSize:30 - } - Text{ - text: modelData.path - } - Button{ - text:'...' - onClicked: fileDialog.open() - FileDialog { - id: fileDialog - title: "Please choose a file" - folder: shortcuts.home - selectExisting: true - selectFolder: false - selectMultiple: false - defaultSuffix: 'svg' - onAccepted: { - console.log("You chose: " + fileDialog.fileUrls) - modelData.setUrl(fileDialog.fileUrl) - } - onRejected: { - console.log("Canceled") - } - //Component.onCompleted: visible = true - - } - } - } - } - } - } -} \ No newline at end of file diff --git a/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml b/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml index ea30e0823..fdfd49750 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml @@ -172,6 +172,7 @@ DialogPlus { chatRoomModel:dialog.chatRoomModel onAddressAdded: smartSearchBar.addAddressToIgnore(sipAddress) onAddressRemoved: smartSearchBar.removeAddressToIgnore(sipAddress) + showMe: dialog.adminMode }