From 4dacd9a54dbad516d1e1b16bf519e53ef507696f Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 19 Nov 2015 19:08:47 +0100 Subject: [PATCH] Added Ban/Unban Context menu actions for People list. --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 55 ++++++++++++++++++++ retroshare-gui/src/gui/Identity/IdDialog.h | 3 ++ 2 files changed, 58 insertions(+) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index e38d29a5e..443620f78 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -950,6 +950,29 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg())); + + contextMnu.addSeparator(); + + RsReputations::ReputationInfo info ; + std::string Id = item->text(RSID_COL_KEYID).toStdString(); + rsReputations->getReputationInfo(RsGxsId(Id),info) ; + + + QAction *banaction = contextMnu.addAction(QIcon(":/images/denied16.png"), tr("Ban this person"), this, SLOT(banPerson())); + QAction *unbanaction = contextMnu.addAction(QIcon(), tr("Unban this person"), this, SLOT(unbanPerson())); + + + if(info.mAssessment == RsReputations::ASSESSMENT_BAD) + { + banaction->setVisible(false); + unbanaction->setVisible(true); + } + else + { + banaction->setVisible(true); + unbanaction->setVisible(false); + } + } } @@ -1008,3 +1031,35 @@ void IdDialog::sendMsg() /* window will destroy itself! */ } + +void IdDialog::banPerson() +{ + QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); + if (!item) + { + return; + } + + std::string Id = item->text(RSID_COL_KEYID).toStdString(); + + rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEGATIVE) ; + + requestIdDetails(); + requestIdList(); +} + +void IdDialog::unbanPerson() +{ + QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); + if (!item) + { + return; + } + + std::string Id = item->text(RSID_COL_KEYID).toStdString(); + + rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_POSITIVE) ; + + requestIdDetails(); + requestIdList(); +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index a46a6ce73..8eb2b748f 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -75,6 +75,9 @@ private slots: /** Create the context popup menu and it's submenus */ void IdListCustomPopupMenu( QPoint point ); + void banPerson(); + void unbanPerson(); + private: void processSettings(bool load);