- do not show 'me' if not admin in group info

This commit is contained in:
Julien Wadel 2022-01-28 17:23:26 +01:00
parent 005cceb62b
commit f68e4c1ff2
6 changed files with 31 additions and 160 deletions

View file

@ -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);
}

View file

@ -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<linphone::Participant> participant);

View file

@ -65,6 +65,10 @@ int ParticipantProxyModel::getCount() const{
return dynamic_cast<ParticipantListModel*>(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<ParticipantListModel*>(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<ParticipantModel*>();
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 {

View file

@ -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<ParticipantListModel> mParticipantListModel;
ChatRoomModel *mChatRoomModel;
bool mShowMe = true;
};
#endif // PARTICIPANT_PROXY_MODEL_H_

View file

@ -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
}
}
}
}
}
}
}

View file

@ -172,6 +172,7 @@ DialogPlus {
chatRoomModel:dialog.chatRoomModel
onAddressAdded: smartSearchBar.addAddressToIgnore(sipAddress)
onAddressRemoved: smartSearchBar.removeAddressToIgnore(sipAddress)
showMe: dialog.adminMode
}