From 931c3df282219342c5de67a08592f885b1fd5171 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 11 Jul 2016 21:33:09 -0400 Subject: [PATCH] fixed display of group node restriction in GxsGroupDialog and info --- .../src/gui/common/GroupChooser.cpp | 18 +- retroshare-gui/src/gui/common/GroupChooser.h | 3 +- retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 156 ++++++++++-------- retroshare-gui/src/gui/gxs/GxsGroupDialog.ui | 9 + .../gui/gxsforums/GxsForumThreadWidget.cpp | 17 +- 5 files changed, 120 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/gui/common/GroupChooser.cpp b/retroshare-gui/src/gui/common/GroupChooser.cpp index c41ed1e8a..02b43fb56 100644 --- a/retroshare-gui/src/gui/common/GroupChooser.cpp +++ b/retroshare-gui/src/gui/common/GroupChooser.cpp @@ -44,14 +44,20 @@ void GroupChooser::loadGroups(uint32_t chooserFlags, const RsNodeGroupId& defaul } -static bool MakeNodeGroupDesc(const RsGroupInfo& info, QString &desc) +bool GroupChooser::makeNodeGroupDesc(const RsGroupInfo& info, QString &desc) { desc.clear(); - desc = QString::fromUtf8(info.name.c_str()); - desc += " (Node group) ["; - desc += QString::fromStdString(info.id.toStdString().substr(0,5)); - desc += "...]"; + if(info.name.empty()) + desc = tr("[Unknown]") ; + else + desc = "\"" + QString::fromUtf8(info.name.c_str()) + "\""; + + desc += " [" ; + desc += QString::fromStdString(info.id.toStdString().substr(0,3)); + desc += "..."; + desc += QString::fromStdString(info.id.toStdString().substr(info.id.toStdString().length()-2,2)); + desc += "]"; return true; } @@ -76,7 +82,7 @@ void GroupChooser::loadGroups() { /* add to Chooser */ QString str; - if (!MakeNodeGroupDesc(*it, str)) + if (!makeNodeGroupDesc(*it, str)) { std::cerr << "GroupChooser::loadGroups() ERROR Desc for Id: " << it->id; std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/common/GroupChooser.h b/retroshare-gui/src/gui/common/GroupChooser.h index 91c06954a..fe7cb553b 100644 --- a/retroshare-gui/src/gui/common/GroupChooser.h +++ b/retroshare-gui/src/gui/common/GroupChooser.h @@ -25,7 +25,7 @@ #pragma once #include -#include +#include class GroupChooser : public QComboBox { @@ -35,6 +35,7 @@ public: void loadGroups(uint32_t chooserFlags, const RsNodeGroupId& defaultId); bool getChosenGroup(RsNodeGroupId& id); + static bool makeNodeGroupDesc(const RsGroupInfo& info, QString &desc); private: void loadGroups(); uint32_t mFlags; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 735d923d3..dce00c020 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -392,87 +392,97 @@ void GxsGroupDialog::newGroup() void GxsGroupDialog::updateFromExistingMeta(const QString &description) { - std::cerr << "void GxsGroupDialog::updateFromExistingMeta()"; - std::cerr << std::endl; + std::cerr << "void GxsGroupDialog::updateFromExistingMeta()"; + std::cerr << std::endl; - std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: "; - std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle; - std::cerr << " External: " << mGrpMeta.mCircleId; - std::cerr << std::endl; + std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: "; + std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle; + std::cerr << " External: " << mGrpMeta.mCircleId; + std::cerr << std::endl; - setupDefaults(); - setupVisibility(); - setupReadonly(); - clearForm(); - setGroupSignFlags(mGrpMeta.mSignFlags) ; + setupDefaults(); + setupVisibility(); + setupReadonly(); + clearForm(); + setGroupSignFlags(mGrpMeta.mSignFlags) ; - /* setup name */ - ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); - - /* Show Mode */ - ui.nameline->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); - ui.popline->setText(QString::number( mGrpMeta.mPop)) ; - ui.postsline->setText(QString::number(mGrpMeta.mVisibleMsgCount)); - ui.lastpostline->setText(DateTime::formatLongDateTime(mGrpMeta.mLastPost)); + /* setup name */ + ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); + + /* Show Mode */ + ui.nameline->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); + ui.popline->setText(QString::number( mGrpMeta.mPop)) ; + ui.postsline->setText(QString::number(mGrpMeta.mVisibleMsgCount)); + ui.lastpostline->setText(DateTime::formatLongDateTime(mGrpMeta.mLastPost)); ui.authorLabel->setId(mGrpMeta.mAuthorId); - ui.IDline->setText(QString::fromStdString(mGrpMeta.mGroupId.toStdString())); - ui.descriptiontextEdit->setPlainText(description); - - switch (mode()) - { - case MODE_CREATE:{ - } - break; - case MODE_SHOW:{ - ui.headerFrame->setHeaderText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); - if (!mPicture.isNull()) - ui.headerFrame->setHeaderImage(mPicture); - } - break; - case MODE_EDIT:{ - } - break; - } - /* set description */ - ui.groupDesc->setPlainText(description); - QString distribution_string = "[Unknown]"; + ui.IDline->setText(QString::fromStdString(mGrpMeta.mGroupId.toStdString())); + ui.descriptiontextEdit->setPlainText(description); - switch(mGrpMeta.mCircleType) - { - case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: - ui.typeLocal->setChecked(true); - distribution_string = tr("Your friends only") ; - ui.localComboBox->loadGroups(0, RsNodeGroupId(mGrpMeta.mInternalCircle)); - ui.distributionCircleComboBox->setVisible(false) ; - ui.localComboBox->setVisible(true) ; - break; - case GXS_CIRCLE_TYPE_PUBLIC: - ui.typePublic->setChecked(true); - distribution_string = tr("Public") ; - ui.distributionCircleComboBox->setVisible(false) ; - ui.localComboBox->setVisible(false) ; - break; - case GXS_CIRCLE_TYPE_EXTERNAL: - ui.typeGroup->setChecked(true); - distribution_string = tr("Restricted to circle:") ; - ui.localComboBox->setVisible(false) ; - ui.distributionCircleComboBox->setVisible(true) ; - ui.distributionCircleComboBox->loadCircles(mGrpMeta.mCircleId); - ui.circleComboBox->loadCircles(mGrpMeta.mCircleId); - break; - default: - std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType"; - std::cerr << std::endl; - break; - } + switch (mode()) + { + case MODE_CREATE:{ + } + break; + case MODE_SHOW:{ + ui.headerFrame->setHeaderText(QString::fromUtf8(mGrpMeta.mGroupName.c_str())); + if (!mPicture.isNull()) + ui.headerFrame->setHeaderImage(mPicture); + } + break; + case MODE_EDIT:{ + } + break; + } + /* set description */ + ui.groupDesc->setPlainText(description); + QString distribution_string = "[Unknown]"; + + switch(mGrpMeta.mCircleType) + { + case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: + { + ui.typeLocal->setChecked(true); + distribution_string = tr("Only friends nodes in group ") ; + + RsGroupInfo ginfo ; + rsPeers->getGroupInfo(RsNodeGroupId(mGrpMeta.mInternalCircle),ginfo) ; + + QString desc; + GroupChooser::makeNodeGroupDesc(ginfo, desc); + distribution_string += desc ; + + ui.localComboBox->loadGroups(0, RsNodeGroupId(mGrpMeta.mInternalCircle)); + ui.distributionCircleComboBox->setVisible(false) ; + ui.localComboBox->setVisible(true) ; + } + break; + case GXS_CIRCLE_TYPE_PUBLIC: + ui.typePublic->setChecked(true); + distribution_string = tr("Public") ; + ui.distributionCircleComboBox->setVisible(false) ; + ui.localComboBox->setVisible(false) ; + break; + case GXS_CIRCLE_TYPE_EXTERNAL: + ui.typeGroup->setChecked(true); + distribution_string = tr("Restricted to circle:") ; + ui.localComboBox->setVisible(false) ; + ui.distributionCircleComboBox->setVisible(true) ; + ui.distributionCircleComboBox->loadCircles(mGrpMeta.mCircleId); + ui.circleComboBox->loadCircles(mGrpMeta.mCircleId); + break; + default: + std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType"; + std::cerr << std::endl; + break; + } ui.distributionValueLabel->setText(distribution_string) ; - ui.idChooser->loadIds(0, mGrpMeta.mAuthorId); - - if(!mGrpMeta.mAuthorId.isNull()) - ui.idChooser->setChosenId(mGrpMeta.mAuthorId) ; + ui.idChooser->loadIds(0, mGrpMeta.mAuthorId); - updateCircleOptions(); + if(!mGrpMeta.mAuthorId.isNull()) + ui.idChooser->setChosenId(mGrpMeta.mAuthorId) ; + + updateCircleOptions(); } void GxsGroupDialog::submitGroup() diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index 861f2d2ae..7eb1f4ef6 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -301,6 +301,9 @@ 0 + + <html><head/><body><p>Messsages will spread way beyond your friend nodes, as long as people subscribe to the channel/forum/posted you're creating.</p></body></html> + Public @@ -326,6 +329,9 @@ 0 + + <html><head/><body><p>Messages will spread among Retroshare nodes that host one of the identities listed as member of the circle and who also subscribe the media. Only these nodes will be able to see that this forum/channel/posted media exists. </p></body></html> + Restricted to Circle @@ -356,6 +362,9 @@ 0 + + <html><head/><body><p>Messages will only be distributed to the selected subset of your friend nodes. They will not forward messages with each other, but only use your own node as a central hub to distribute them.</p></body></html> + Only For Your Friends diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 82ed1e6dd..e76c3185a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -817,9 +817,20 @@ void GxsForumThreadWidget::insertGroupData() distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; } break ; - case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: distrib_string = tr("Your eyes only"); - break ; - case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); + case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY: + { + distrib_string = tr("Only friends nodes in group ") ; + + RsGroupInfo ginfo ; + rsPeers->getGroupInfo(RsNodeGroupId(group.mMeta.mInternalCircle),ginfo) ; + + QString desc; + GroupChooser::makeNodeGroupDesc(ginfo, desc); + distrib_string += desc ; + } + break ; + + case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("Your eyes only"); // this is not yet supported. If you see this, it is a bug! break ; default: std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;