mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
fixed up People context menu so as to handle actions for multiple persons at once
This commit is contained in:
parent
1edfcf9731
commit
39e6a9b61a
@ -162,7 +162,7 @@ bool RsGxsIntegrityCheck::check()
|
|||||||
std::cerr << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
|
std::cerr << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(rsReputations==NULL || !rsReputations->isIdentityBanned(grp->metaData->mAuthorId))
|
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(grp->metaData->mAuthorId))
|
||||||
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
|
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ bool RsGxsIntegrityCheck::check()
|
|||||||
#ifdef GXSUTIL_DEBUG
|
#ifdef GXSUTIL_DEBUG
|
||||||
std::cerr << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
std::cerr << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
if(rsReputations==NULL || !rsReputations->isIdentityBanned(msg->metaData->mAuthorId))
|
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(msg->metaData->mAuthorId))
|
||||||
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
|
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,105 +949,133 @@ void IdDialog::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req
|
|||||||
|
|
||||||
void IdDialog::IdListCustomPopupMenu( QPoint )
|
void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||||
{
|
{
|
||||||
QMenu contextMnu( this );
|
QMenu contextMnu( this );
|
||||||
|
|
||||||
|
|
||||||
std::list<RsGxsId> own_identities ;
|
std::list<RsGxsId> own_identities ;
|
||||||
rsIdentity->getOwnIds(own_identities) ;
|
rsIdentity->getOwnIds(own_identities) ;
|
||||||
|
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
// make some stats about what's selected. If the same value is used for all selected items, it can be switched.
|
||||||
|
|
||||||
if(item != allItem && item != contactsItem) {
|
|
||||||
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
|
||||||
|
|
||||||
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
{
|
|
||||||
if(own_identities.size() <= 1)
|
|
||||||
{
|
|
||||||
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
|
||||||
|
|
||||||
if(own_identities.empty())
|
bool root_node_present = false ;
|
||||||
action->setEnabled(false) ;
|
bool one_item_owned_by_you = false ;
|
||||||
else
|
uint32_t n_positive_reputations = 0 ;
|
||||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
uint32_t n_negative_reputations = 0 ;
|
||||||
}
|
uint32_t n_neutral_reputations = 0 ;
|
||||||
else
|
uint32_t n_is_a_contact = 0 ;
|
||||||
{
|
uint32_t n_is_not_a_contact = 0 ;
|
||||||
QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
uint32_t n_selected_items =0 ;
|
||||||
|
|
||||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
{
|
{
|
||||||
RsIdentityDetails idd ;
|
if(*it == allItem || *it == contactsItem)
|
||||||
rsIdentity->getIdDetails(*it,idd) ;
|
{
|
||||||
|
root_node_present = true ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap pixmap ;
|
uint32_t item_flags = (*it)->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
||||||
|
|
||||||
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
if(item_flags & RSID_FILTER_OWNED_BY_YOU)
|
||||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
one_item_owned_by_you = true ;
|
||||||
|
|
||||||
|
std::cerr << " item flags = " << item_flags << std::endl;
|
||||||
|
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
|
||||||
|
|
||||||
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
RsReputations::ReputationInfo info ;
|
||||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
rsReputations->getReputationInfo(keyId,info) ;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
|
switch(info.mOwnOpinion)
|
||||||
|
{
|
||||||
contextMnu.addSeparator();
|
case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case RsReputations::OPINION_POSITIVE: ++n_positive_reputations ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case RsReputations::OPINION_NEUTRAL: ++n_neutral_reputations ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
RsIdentityDetails details;
|
++n_selected_items ;
|
||||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
|
||||||
|
|
||||||
rsIdentity->getIdDetails(RsGxsId(keyId), details);
|
if(rsIdentity->isARegularContact(keyId))
|
||||||
|
++n_is_a_contact ;
|
||||||
QAction *addContact = contextMnu.addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
|
else
|
||||||
QAction *removeContact = contextMnu.addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
|
++n_is_not_a_contact ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(root_node_present) // don't show menu if some of the root nodes are present
|
||||||
if(details.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
|
return ;
|
||||||
{
|
|
||||||
addContact->setVisible(false);
|
|
||||||
removeContact->setVisible(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addContact->setVisible(true);
|
|
||||||
removeContact->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
|
|
||||||
RsReputations::ReputationInfo info ;
|
if(!one_item_owned_by_you)
|
||||||
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
{
|
||||||
rsReputations->getReputationInfo(RsGxsId(Id),info) ;
|
if(n_selected_items == 1) // if only one item is selected, allow to chat with this item
|
||||||
|
if(own_identities.size() <= 1)
|
||||||
|
{
|
||||||
|
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
||||||
|
|
||||||
QAction *banaction = contextMnu.addAction(QIcon(":/images/denied16.png"), tr("Ban this person"), this, SLOT(banPerson()));
|
if(own_identities.empty())
|
||||||
QAction *unbanaction = contextMnu.addAction(QIcon(), tr("Unban this person"), this, SLOT(unbanPerson()));
|
action->setEnabled(false) ;
|
||||||
|
else
|
||||||
|
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
||||||
|
|
||||||
|
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||||
|
{
|
||||||
|
RsIdentityDetails idd ;
|
||||||
|
rsIdentity->getIdDetails(*it,idd) ;
|
||||||
|
|
||||||
|
QPixmap pixmap ;
|
||||||
|
|
||||||
|
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
||||||
|
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||||
|
|
||||||
|
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
||||||
|
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// always allow to send messages
|
||||||
|
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg()));
|
||||||
|
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
|
if(n_is_a_contact == 0)
|
||||||
|
contextMnu.addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
|
||||||
|
|
||||||
|
if(n_is_not_a_contact == 0)
|
||||||
|
contextMnu.addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
|
||||||
|
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
|
if(n_positive_reputations == 0) // only unban when all items are banned
|
||||||
|
contextMnu.addAction(QIcon(), tr("Set positive opinion"), this, SLOT(positivePerson()));
|
||||||
|
|
||||||
|
if(n_neutral_reputations == 0) // only unban when all items are banned
|
||||||
|
contextMnu.addAction(QIcon(), tr("Set neutral opinion"), this, SLOT(neutralPerson()));
|
||||||
|
|
||||||
|
if(n_negative_reputations == 0)
|
||||||
|
contextMnu.addAction(QIcon(":/images/denied16.png"), tr("Set negative opinion"), this, SLOT(negativePerson()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(one_item_owned_by_you && n_selected_items==1)
|
||||||
|
{
|
||||||
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
|
contextMnu.addAction(ui->editIdentity);
|
||||||
|
contextMnu.addAction(ui->removeIdentity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(info.mAssessment == RsReputations::ASSESSMENT_BAD)
|
|
||||||
{
|
|
||||||
banaction->setVisible(false);
|
|
||||||
unbanaction->setVisible(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
banaction->setVisible(true);
|
|
||||||
unbanaction->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
contextMnu.addAction(ui->editIdentity);
|
contextMnu.exec(QCursor::pos());
|
||||||
contextMnu.addAction(ui->removeIdentity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
|
|
||||||
contextMnu.exec(QCursor::pos());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::chatIdentity()
|
void IdDialog::chatIdentity()
|
||||||
@ -1076,25 +1104,27 @@ void IdDialog::chatIdentity()
|
|||||||
|
|
||||||
void IdDialog::sendMsg()
|
void IdDialog::sendMsg()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
if (!item)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
if(selected_items.empty())
|
||||||
if (nMsgDialog == NULL) {
|
return ;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
||||||
|
if (nMsgDialog == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(keyId));
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
nMsgDialog->show();
|
{
|
||||||
nMsgDialog->activateWindow();
|
QTreeWidgetItem *item = *it ;
|
||||||
|
|
||||||
|
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
|
nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(keyId));
|
||||||
|
}
|
||||||
|
nMsgDialog->show();
|
||||||
|
nMsgDialog->activateWindow();
|
||||||
|
|
||||||
/* window will destroy itself! */
|
/* window will destroy itself! */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IdDialog::inviteMessage()
|
QString IdDialog::inviteMessage()
|
||||||
@ -1133,33 +1163,48 @@ void IdDialog::sendInvite()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::banPerson()
|
void IdDialog::negativePerson()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
if (!item)
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
{
|
{
|
||||||
return;
|
QTreeWidgetItem *item = *it ;
|
||||||
}
|
|
||||||
|
|
||||||
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEGATIVE) ;
|
rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEGATIVE) ;
|
||||||
|
}
|
||||||
|
|
||||||
requestIdDetails();
|
requestIdDetails();
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::unbanPerson()
|
void IdDialog::neutralPerson()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
if (!item)
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
{
|
{
|
||||||
return;
|
QTreeWidgetItem *item = *it ;
|
||||||
}
|
|
||||||
|
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
|
rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEUTRAL) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
requestIdDetails();
|
||||||
|
requestIdList();
|
||||||
|
}
|
||||||
|
void IdDialog::positivePerson()
|
||||||
|
{
|
||||||
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = *it ;
|
||||||
|
|
||||||
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_POSITIVE) ;
|
rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_POSITIVE) ;
|
||||||
|
}
|
||||||
|
|
||||||
requestIdDetails();
|
requestIdDetails();
|
||||||
requestIdList();
|
requestIdList();
|
||||||
@ -1167,30 +1212,28 @@ void IdDialog::unbanPerson()
|
|||||||
|
|
||||||
void IdDialog::addtoContacts()
|
void IdDialog::addtoContacts()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
if (!item)
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
{
|
{
|
||||||
return;
|
QTreeWidgetItem *item = *it ;
|
||||||
}
|
|
||||||
|
|
||||||
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
|
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
|
||||||
|
}
|
||||||
|
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::removefromContacts()
|
void IdDialog::removefromContacts()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||||
if (!item)
|
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||||
{
|
{
|
||||||
return;
|
QTreeWidgetItem *item = *it ;
|
||||||
}
|
|
||||||
|
|
||||||
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
std::string Id = item->text(RSID_COL_KEYID).toStdString();
|
||||||
|
|
||||||
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
|
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
|
||||||
|
}
|
||||||
|
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,9 @@ private slots:
|
|||||||
void addtoContacts();
|
void addtoContacts();
|
||||||
void removefromContacts();
|
void removefromContacts();
|
||||||
|
|
||||||
void banPerson();
|
void negativePerson();
|
||||||
void unbanPerson();
|
void positivePerson();
|
||||||
|
void neutralPerson();
|
||||||
|
|
||||||
static QString inviteMessage();
|
static QString inviteMessage();
|
||||||
void sendInvite();
|
void sendInvite();
|
||||||
|
Loading…
Reference in New Issue
Block a user