mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
chatlobby id context menu - fix reputation change actions
This commit is contained in:
parent
10ba3a6364
commit
8ae9eff928
@ -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<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||
if (selectedItems.isEmpty())
|
||||
return;
|
||||
QList<QTreeWidgetItem*>::iterator item;
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
|
||||
{
|
||||
RsGxsId nickname;
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*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<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::voteParticipantNeutral()
|
||||
{
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||
if (selectedItems.isEmpty())
|
||||
return;
|
||||
QList<QTreeWidgetItem*>::iterator item;
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
|
||||
{
|
||||
RsGxsId nickname;
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*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<GxsIdRSTreeWidgetItem*>(*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<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
|
||||
|
||||
if (selectedItems.isEmpty()) {
|
||||
if (selectedItems.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QTreeWidgetItem*>::iterator item;
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
|
||||
|
||||
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
|
||||
{
|
||||
RsGxsId nickname;
|
||||
dynamic_cast<GxsIdRSTreeWidgetItem*>(*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<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user