lobby id dialog - add vote neutral option

This commit is contained in:
unknown 2017-01-09 16:05:23 +03:00
parent bc43cb8cf0
commit cc3b8bde52
2 changed files with 25 additions and 47 deletions

View File

@ -88,7 +88,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
muteAct = new QAction(QIcon(), tr("Mute participant"), this); muteAct = new QAction(QIcon(), tr("Mute participant"), this);
banAct = new QAction(QIcon(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); banAct = new QAction(QIcon(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this);
voteAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this); voteNeutralAct = new QAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this);
votePositiveAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this);
distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this); distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this); sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
@ -107,8 +108,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState())); connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant())); connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage())); connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
connect(banAct, SIGNAL(triggered()), this, SLOT(banParticipant())); connect(votePositiveAct, SIGNAL(triggered()), this, SLOT(voteParticipant(1)));
connect(voteAct, SIGNAL(triggered()), this, SLOT(voteParticipant())); connect(voteNeutralAct, SIGNAL(triggered()), this, SLOT(voteParticipant(0)));
connect(banAct, SIGNAL(triggered()), this, SLOT(voteParticipant(-1)));
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants())); connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants())); connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
@ -223,13 +225,15 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
contextMnu.addAction(actionSortByName); contextMnu.addAction(actionSortByName);
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(muteAct); contextMnu.addAction(muteAct);
contextMnu.addAction(voteAct); contextMnu.addAction(votePositiveAct);
contextMnu.addAction(voteNeutralAct);
contextMnu.addAction(banAct); contextMnu.addAction(banAct);
muteAct->setCheckable(true); muteAct->setCheckable(true);
muteAct->setEnabled(false); muteAct->setEnabled(false);
muteAct->setChecked(false); muteAct->setChecked(false);
voteAct->setEnabled(false); votePositiveAct->setEnabled(false);
voteNeutralAct->setEnabled(false);
banAct->setEnabled(false); banAct->setEnabled(false);
if (selectedItems.size()) if (selectedItems.size())
@ -240,8 +244,9 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName)) if(selectedItems.count()>1 || (RsGxsId(selectedItems.at(0)->text(COLUMN_ID).toStdString())!=nickName))
{ {
muteAct->setEnabled(true); muteAct->setEnabled(true);
votePositiveAct->setEnabled(true);
voteNeutralAct->setEnabled(true);
banAct->setEnabled(true); banAct->setEnabled(true);
voteAct->setEnabled(true);
QList<QTreeWidgetItem*>::iterator item; QList<QTreeWidgetItem*>::iterator item;
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) { for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
@ -263,7 +268,7 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
/** /**
* @brief Called when the "ban" menu is selected. Sets a negative reputation on the selected user. * @brief Called when the "ban" menu is selected. Sets a negative reputation on the selected user.
*/ */
void ChatLobbyDialog::banParticipant() void ChatLobbyDialog::voteParticipant(int vote)
{ {
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems(); QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
@ -284,41 +289,14 @@ void ChatLobbyDialog::banParticipant()
if (gxs_id!=nickname) if (gxs_id!=nickname)
{ {
std::cerr << "Giving negative opinion to GXS id " << nickname << std::endl; switch(vote)
rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_NEGATIVE);
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
}
}
}
void ChatLobbyDialog::voteParticipant()
{
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)
{ {
std::cerr << "Giving negative opinion to GXS id " << nickname << std::endl; case 1: rsReputations->setOwnOpinion(nickname, RsReputations::OPINION_POSITIVE);
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;
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate(); dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->forceUpdate();
} }
} }
} }

View File

@ -80,8 +80,7 @@ protected slots:
void distantChatParticipant(); void distantChatParticipant();
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column); void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
void sendMessage(); void sendMessage();
void banParticipant(); void voteParticipant(int vote);
void voteParticipant();
private: private:
void updateParticipantsList(); void updateParticipantsList();
@ -109,8 +108,9 @@ private:
std::set<RsGxsId> mutedParticipants; std::set<RsGxsId> mutedParticipants;
QAction *muteAct; QAction *muteAct;
QAction *votePositiveAct;
QAction *voteNeutralAct;
QAction *banAct; QAction *banAct;
QAction *voteAct;
QAction *distantChatAct; QAction *distantChatAct;
QAction *actionSortByName; QAction *actionSortByName;
QAction *actionSortByActivity; QAction *actionSortByActivity;