improved Circle editor ID selection list

This commit is contained in:
csoler 2020-03-01 11:35:24 +01:00
parent 8be92f24b6
commit d96ce490d4
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
2 changed files with 44 additions and 56 deletions

View file

@ -41,8 +41,8 @@
#define CREATECIRCLEDIALOG_IDINFO 3 #define CREATECIRCLEDIALOG_IDINFO 3
#define RSCIRCLEID_COL_NICKNAME 0 #define RSCIRCLEID_COL_NICKNAME 0
#define RSCIRCLEID_COL_KEYID 1 #define RSCIRCLEID_COL_IDTYPE 1
#define RSCIRCLEID_COL_IDTYPE 2 #define RSCIRCLEID_COL_KEYID 2
/** Constructor */ /** Constructor */
CreateCircleDialog::CreateCircleDialog() CreateCircleDialog::CreateCircleDialog()
@ -84,7 +84,7 @@ CreateCircleDialog::CreateCircleDialog()
QObject::connect(ui.radioButton_ListAll, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ; QObject::connect(ui.radioButton_ListAll, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ; QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_ListKnownPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ; QObject::connect(ui.radioButton_ListFriendPGP, SIGNAL(toggled(bool)), this, SLOT(idTypeChanged())) ;
QObject::connect(ui.radioButton_Public, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ; QObject::connect(ui.radioButton_Public, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Self, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ; QObject::connect(ui.radioButton_Self, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
@ -99,6 +99,8 @@ CreateCircleDialog::CreateCircleDialog()
ui.circleName->setPlaceholderText(QApplication::translate("CreateCircleDialog", "Circle name", 0)); ui.circleName->setPlaceholderText(QApplication::translate("CreateCircleDialog", "Circle name", 0));
#endif #endif
ui.treeWidget_IdList->setColumnHidden(RSCIRCLEID_COL_KEYID,true); // no need to show this. the tooltip will do it.
//ui.idChooser->loadIds(0,RsGxsId()); //ui.idChooser->loadIds(0,RsGxsId());
ui.circleComboBox->loadCircles(RsGxsCircleId()); ui.circleComboBox->loadCircles(RsGxsCircleId());
} }
@ -263,7 +265,7 @@ void CreateCircleDialog::addMember(const RsGxsIdGroup &idGroup)
{ {
QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString()); QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString());
QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str()); QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id"); QString idtype = tr("[Anonymous Id]");
QPixmap pixmap ; QPixmap pixmap ;
@ -324,7 +326,7 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails)
QString keyId = QString::fromStdString(gxs_id.toStdString()); QString keyId = QString::fromStdString(gxs_id.toStdString());
QString nickname = QString::fromUtf8(gxs_details.mNickname.c_str()); QString nickname = QString::fromUtf8(gxs_details.mNickname.c_str());
QString idtype = tr("Anon Id"); QString idtype = tr("[Anonymous Id]");
QPixmap pixmap ; QPixmap pixmap ;
@ -333,8 +335,8 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails)
addMember(keyId, idtype, nickname, QIcon(pixmap)); addMember(keyId, idtype, nickname, QIcon(pixmap));
}//if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details)) }
}//for (itUnknownPeers it = cirDetails.mUnknownPeers.begin() }
typedef std::set<RsPgpId>::const_iterator itAllowedPeers; typedef std::set<RsPgpId>::const_iterator itAllowedPeers;
for (itAllowedPeers it = cirDetails.mAllowedNodes.begin() ; it != cirDetails.mAllowedNodes.end() ; ++it ) for (itAllowedPeers it = cirDetails.mAllowedNodes.begin() ; it != cirDetails.mAllowedNodes.end() ; ++it )
@ -352,8 +354,8 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails)
addMember(keyId, idtype, nickname, QIcon(avatar)); addMember(keyId, idtype, nickname, QIcon(avatar));
}//if(!gpg_id.isNull() && rsPeers->getGPGDetails(gpg_id,details)) }
}//for (itAllowedPeers it = cirDetails.mAllowedPeers.begin() }
} }
void CreateCircleDialog::removeMember() void CreateCircleDialog::removeMember()
@ -385,7 +387,7 @@ void CreateCircleDialog::createCircle()
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Subject!! return; //Don't add a empty Subject!!
}//if(name.isEmpty()) }
RsGxsCircleGroup circle = mCircleGroup; // init with loaded group RsGxsCircleGroup circle = mCircleGroup; // init with loaded group
@ -459,16 +461,6 @@ void CreateCircleDialog::createCircle()
} }
// if (mIsExistingCircle)
// {
// std::cerr << "CreateCircleDialog::createCircle() Existing Circle TODO";
// std::cerr << std::endl;
//
// // cannot edit these yet.
// QMessageBox::warning(this, tr("RetroShare"),tr("Cannot Edit Existing Circles Yet"), QMessageBox::Ok, QMessageBox::Ok);
// return;
// }
if (mIsExternalCircle) if (mIsExternalCircle)
{ {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
@ -742,22 +734,20 @@ void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_
QTreeWidget *tree = ui.treeWidget_IdList; QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear(); tree->clear();
bool acceptAnonymous = ui.radioButton_ListAll->isChecked(); bool acceptAll = ui.radioButton_ListAll->isChecked();
bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked(); bool acceptOnlySignedIdentities = ui.radioButton_ListAllPGP->isChecked();
//bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked(); bool acceptOnlyIdentitiesSignedByFriend = ui.radioButton_ListFriendPGP->isChecked();
for(const auto& idGroup:id_groups) for(const auto& idGroup:id_groups)
{ {
bool isSigned = !idGroup.mPgpId.isNull();
bool isSignedByFriendNode = isSigned && rsPeers->isPgpFriend(idGroup.mPgpId);
/* do filtering */ /* do filtering */
bool ok = false; bool ok = false;
if (acceptAnonymous)
ok = true;
else if (acceptAllPGP)
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ;
else if (idGroup.mPgpKnown)
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ;
if (!ok) { if(!(acceptAll ||(acceptOnlySignedIdentities && isSigned) ||(acceptOnlyIdentitiesSignedByFriend && isSignedByFriendNode)))
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId; std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId;
std::cerr << std::endl; std::cerr << std::endl;
@ -767,23 +757,21 @@ void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_
QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString()); QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString());
QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str()); QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str());
QString idtype = tr("Anon Id"); QString idtype ;
QPixmap pixmap ; QPixmap pixmap ;
if(idGroup.mImage.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idGroup.mImage.mData, idGroup.mImage.mSize, pixmap, GxsIdDetails::SMALL)) if(idGroup.mImage.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idGroup.mImage.mData, idGroup.mImage.mSize, pixmap, GxsIdDetails::SMALL))
pixmap = GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId),GxsIdDetails::SMALL) ; pixmap = GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId),GxsIdDetails::SMALL) ;
if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) if (!idGroup.mPgpId.isNull())
{ {
if (idGroup.mPgpKnown) {
RsPeerDetails details; RsPeerDetails details;
rsPeers->getGPGDetails(idGroup.mPgpId, details);
idtype = QString::fromUtf8(details.name.c_str());
}
else
idtype = tr("PGP Linked Id");
if(rsPeers->getGPGDetails(idGroup.mPgpId, details))
idtype = QString::fromUtf8(details.name.c_str());
else
idtype = tr("[Unknown]");
} }
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
@ -793,6 +781,11 @@ void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_
item->setText(RSCIRCLEID_COL_IDTYPE, idtype); item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item); tree->addTopLevelItem(item);
RsIdentityDetails det;
if(rsIdentity->getIdDetails(RsGxsId(idGroup.mMeta.mGroupId),det))
item->setToolTip(RSCIRCLEID_COL_NICKNAME,GxsIdDetails::getComment(det));
// External Circle. // External Circle.
if (mIsExistingCircle) if (mIsExistingCircle)
{ {

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>1211</width>
<height>500</height> <height>647</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -161,12 +161,7 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>ID</string> <string>Profile</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property> </property>
</column> </column>
</widget> </widget>
@ -210,9 +205,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButton_ListKnownPGP"> <widget class="QRadioButton" name="radioButton_ListFriendPGP">
<property name="text"> <property name="text">
<string>Signed by known nodes</string> <string>Signed by friend node</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -411,7 +406,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Circles can be restricted to the members of another circle. Only the members of that second circle will be allowed to see the new circle and its content (list of members, etc).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Circles can be restricted to the members of another circle. Only the members of that second circle will be allowed to see the new circle and its content (list of members, etc).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Only visible to members of:</string> <string>Only &amp;visible to members of:</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../icons.qrc"> <iconset resource="../icons.qrc">
@ -455,6 +450,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
<customwidget> <customwidget>
<class>LineEditClear</class> <class>LineEditClear</class>
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
@ -471,11 +471,6 @@
<header>gui/common/HeaderFrame.h</header> <header>gui/common/HeaderFrame.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
<customwidget> <customwidget>
<class>GxsCircleChooser</class> <class>GxsCircleChooser</class>
<extends>QComboBox</extends> <extends>QComboBox</extends>