From 8ae9eff928cb2ef6e34edbe17c2a91ede4fe6513 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Thu, 12 Jan 2017 16:26:35 +0300 Subject: [PATCH] chatlobby id context menu - fix reputation change actions --- .../src/gui/chat/ChatLobbyDialog.cpp | 75 +++++++++++++------ 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 932baab84..850c7930d 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -110,9 +110,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState())); connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant())); connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage())); - connect(votePositiveAct, SIGNAL(triggered()), this, SLOT(voteParticipant(1))); - connect(voteNeutralAct, SIGNAL(triggered()), this, SLOT(voteParticipant(0))); - connect(banAct, SIGNAL(triggered()), this, SLOT(voteParticipant(-1))); + connect(votePositiveAct, SIGNAL(triggered()), this, SLOT(voteParticipantPositive())); + connect(voteNeutralAct, SIGNAL(triggered()), this, SLOT(voteParticipantNeutral())); + connect(banAct, SIGNAL(triggered()), this, SLOT(voteParticipantNegative())); connect(showinpeopleAct, SIGNAL(triggered()), this, SLOT(showInPeopleTab())); connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants())); @@ -263,37 +263,70 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint) contextMnu.exec(QCursor::pos()); } +void ChatLobbyDialog::voteParticipantPositive() +{ + QList selectedItems = ui.participantsList->selectedItems(); + if (selectedItems.isEmpty()) + return; + QList::iterator item; + for (item = selectedItems.begin(); item != selectedItems.end(); ++item) + { + RsGxsId nickname; + dynamic_cast(*item)->getId(nickname) ; + RsGxsId gxs_id; + rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id); + // This test avoids to mute/ban your own identity + if (gxs_id!=nickname) + { + rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE); + std::cerr << "Giving positive opinion to GXS id " << nickname << std::endl; + dynamic_cast(*item)->forceUpdate(); + } + } +} + +void ChatLobbyDialog::voteParticipantNeutral() +{ + QList selectedItems = ui.participantsList->selectedItems(); + if (selectedItems.isEmpty()) + return; + QList::iterator item; + for (item = selectedItems.begin(); item != selectedItems.end(); ++item) + { + RsGxsId nickname; + dynamic_cast(*item)->getId(nickname) ; + RsGxsId gxs_id; + rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id); + // This test avoids to mute/ban your own identity + if (gxs_id!=nickname) + { + rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEUTRAL); + std::cerr << "Giving neutral opinion to GXS id " << nickname << std::endl; + dynamic_cast(*item)->forceUpdate(); + } + } +} + /** * @brief Called when the "ban" menu is selected. Sets a negative reputation on the selected user. */ -void ChatLobbyDialog::voteParticipant(int vote) +void ChatLobbyDialog::voteParticipantNegative() { QList selectedItems = ui.participantsList->selectedItems(); - - if (selectedItems.isEmpty()) { + if (selectedItems.isEmpty()) return; - } - QList::iterator item; - for (item = selectedItems.begin(); item != selectedItems.end(); ++item) { - - RsGxsId nickname; + for (item = selectedItems.begin(); item != selectedItems.end(); ++item) + { + RsGxsId nickname; dynamic_cast(*item)->getId(nickname) ; - RsGxsId gxs_id; rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id); - // This test avoids to mute/ban your own identity - if (gxs_id!=nickname) { - switch(vote) - { - case 1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE); - case -1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE); - default: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEUTRAL); - } - std::cerr << "Giving " << vote << " opinion to GXS id " << nickname << std::endl; + rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE); + std::cerr << "Giving negative opinion to GXS id " << nickname << std::endl; dynamic_cast(*item)->forceUpdate(); } }