GUI modifications to incorporate RecognTags.

- Enable EditDialog for own Ids.
	- Addition, parsing and removal of Tags in IdEditDialog.
	- Display of Tags (only text) in GxsId Label/Chooser/TreewidgetItem ..

TODO:
	- Add icon sets for RecognTags.
	- display of Tags as Icons.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6855 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-10-20 09:56:12 +00:00
parent fc58861447
commit 2ce92da8ad
8 changed files with 507 additions and 174 deletions

View File

@ -473,8 +473,7 @@ void IdDialog::insertIdDetails(uint32_t token)
mStateHelper->setWidgetEnabled(ui.pushButton_Reputation, false);
// No Delete Ids yet!
mStateHelper->setWidgetEnabled(ui.pushButton_Delete, /*true*/ false);
// No Editing Ids yet!
mStateHelper->setWidgetEnabled(ui.pushButton_EditId, /*true*/ false);
mStateHelper->setWidgetEnabled(ui.pushButton_EditId, true);
}
else
{

View File

@ -61,10 +61,19 @@ IdEditDialog::IdEditDialog(QWidget *parent)
/* Connect signals */
connect(ui.radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui.radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateId()));
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui.plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
connect(ui.pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
connect(ui.toolButton_Tag1, SIGNAL(clicked(bool)), this, SLOT(rmTag1()));
connect(ui.toolButton_Tag2, SIGNAL(clicked(bool)), this, SLOT(rmTag2()));
connect(ui.toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
connect(ui.toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
connect(ui.toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
ui.pushButton_Tag->setEnabled(false);
}
void IdEditDialog::setupNewId(bool pseudo)
@ -89,6 +98,10 @@ void IdEditDialog::setupNewId(bool pseudo)
// force - incase it wasn't triggered.
idTypeToggled(true);
ui.frame_Tags->setHidden(true);
ui.radioButton_GpgId->setEnabled(true);
ui.radioButton_Pseudo->setEnabled(true);
}
void IdEditDialog::idTypeToggled(bool checked)
@ -144,7 +157,6 @@ void IdEditDialog::loadExistingId(uint32_t token)
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
/* get details from libretroshare */
RsGxsIdGroup data;
std::vector<RsGxsIdGroup> datavector;
if (!rsIdentity->getGroupData(token, datavector))
{
@ -166,9 +178,9 @@ void IdEditDialog::loadExistingId(uint32_t token)
return;
}
data = datavector[0];
mEditGroup = datavector[0];
bool realid = (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
if (realid)
{
@ -178,25 +190,28 @@ void IdEditDialog::loadExistingId(uint32_t token)
{
ui.radioButton_Pseudo->setChecked(true);
}
// these are not editable for existing Id.
ui.radioButton_GpgId->setEnabled(false);
ui.radioButton_Pseudo->setEnabled(false);
// DOES THIS TRIGGER ALREADY???
// force - incase it wasn't triggered.
idTypeToggled(true);
ui.lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId));
ui.lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()));
ui.lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId));
if (realid)
{
ui.lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash));
ui.lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash));
if (data.mPgpKnown)
if (mEditGroup.mPgpKnown)
{
RsPeerDetails details;
rsPeers->getGPGDetails(data.mPgpId, details);
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId));
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId));
}
else
{
@ -210,53 +225,209 @@ void IdEditDialog::loadExistingId(uint32_t token)
ui.lineEdit_GpgId->setText(tr("N/A"));
ui.lineEdit_GpgName->setText(tr("N/A"));
}
// RecognTags.
ui.frame_Tags->setHidden(false);
loadRecognTags();
}
void IdEditDialog::updateId()
#define MAX_RECOGN_TAGS 5
void IdEditDialog::checkNewTag()
{
RsGxsIdGroup rid;
// Must set, Nickname, KeyId(if existing), mIdType, GpgId.
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
std::string id = ui.lineEdit_KeyId->text().toStdString();
std::string name = ui.lineEdit_Nickname->text().toUtf8().data();
rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toUtf8().constData();
QString desc;
bool ok = tagDetails(id, name, tag, desc);
ui.label_TagCheck->setText(desc);
if (rid.mMeta.mGroupName.size() < 2)
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
{
std::cerr << "IdEditDialog::updateId() Nickname too short";
ok = false;
}
ui.pushButton_Tag->setEnabled(ok);
}
void IdEditDialog::addRecognTag()
{
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
{
std::cerr << "IdEditDialog::addRecognTag() Too many Tags, delete one first";
std::cerr << std::endl;
}
mEditGroup.mRecognTags.push_back(tag);
loadRecognTags();
}
void IdEditDialog::rmTag1()
{
rmTag(0);
}
void IdEditDialog::rmTag2()
{
rmTag(1);
}
void IdEditDialog::rmTag3()
{
rmTag(2);
}
void IdEditDialog::rmTag4()
{
rmTag(3);
}
void IdEditDialog::rmTag5()
{
rmTag(4);
}
void IdEditDialog::rmTag(int idx)
{
std::list<std::string>::iterator it;
int i = 0;
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end() && (idx < i); it++, i++) ;
if (it != mEditGroup.mRecognTags.end())
{
mEditGroup.mRecognTags.erase(it);
}
loadRecognTags();
}
bool IdEditDialog::tagDetails(const std::string &id, const std::string &name, const std::string &tag, QString &desc)
{
if (tag.empty())
{
desc += "Empty Tag";
return false;
}
/* extract details for each tag */
RsRecognTagDetails tagDetails;
bool ok = false;
if (rsIdentity->parseRecognTag(id, name, tag, tagDetails))
{
desc += QString::number(tagDetails.tag_class);
desc += ":";
desc += QString::number(tagDetails.tag_type);
if (tagDetails.is_valid)
{
ok = true;
desc += " Valid";
}
else
{
desc += " Invalid";
}
if (tagDetails.is_pending)
{
ok = true;
desc += " Pending";
}
}
else
{
desc += "Unparseable";
}
return ok;
}
void IdEditDialog::loadRecognTags()
{
std::cerr << "IdEditDialog::loadRecognTags()";
std::cerr << std::endl;
// delete existing items.
ui.label_Tag1->setHidden(true);
ui.label_Tag2->setHidden(true);
ui.label_Tag3->setHidden(true);
ui.label_Tag4->setHidden(true);
ui.label_Tag5->setHidden(true);
ui.toolButton_Tag1->setHidden(true);
ui.toolButton_Tag2->setHidden(true);
ui.toolButton_Tag3->setHidden(true);
ui.toolButton_Tag4->setHidden(true);
ui.toolButton_Tag5->setHidden(true);
ui.plainTextEdit_Tag->setPlainText("");
int i = 0;
std::list<std::string>::const_iterator it;
for(it = mEditGroup.mRecognTags.begin(); it != mEditGroup.mRecognTags.end(); it++, i++)
{
QString recognTag;
tagDetails(mEditGroup.mMeta.mGroupId, mEditGroup.mMeta.mGroupName, *it, recognTag);
switch(i)
{
default:
case 0:
ui.label_Tag1->setText(recognTag);
ui.label_Tag1->setHidden(false);
ui.toolButton_Tag1->setHidden(false);
break;
case 1:
ui.label_Tag2->setText(recognTag);
ui.label_Tag2->setHidden(false);
ui.toolButton_Tag2->setHidden(false);
break;
case 2:
ui.label_Tag3->setText(recognTag);
ui.label_Tag3->setHidden(false);
ui.toolButton_Tag3->setHidden(false);
break;
case 3:
ui.label_Tag4->setText(recognTag);
ui.label_Tag4->setHidden(false);
ui.toolButton_Tag4->setHidden(false);
break;
case 4:
ui.label_Tag5->setText(recognTag);
ui.label_Tag5->setHidden(false);
ui.toolButton_Tag5->setHidden(false);
break;
}
}
}
void IdEditDialog::submit()
{
if (mIsNew)
{
createId();
}
else
{
updateId();
}
}
void IdEditDialog::createId()
{
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
if (groupname.size() < 2)
{
std::cerr << "IdEditDialog::createId() Nickname too short";
std::cerr << std::endl;
return;
}
//rid.mIdType = RSID_RELATION_YOURSELF;
if (mIsNew)
{
rid.mMeta.mGroupId = "";
}
else
{
rid.mMeta.mGroupId = ui.lineEdit_KeyId->text().toStdString();
}
if (ui.radioButton_GpgId->isChecked())
{
//rid.mIdType |= RSID_TYPE_REALID;
//rid.mGpgId = ui.lineEdit_GpgId->text().toStdString();
rid.mPgpIdHash = ui.lineEdit_GpgHash->text().toStdString();
//rid.mGpgName = ui.lineEdit_GpgName->text().toUtf8().constData();
}
else
{
//rid.mIdType |= RSID_TYPE_PSEUDONYM;
//rid.mGpgId = "";
rid.mPgpIdHash = "";
//rid.mGpgName = "";
//rid.mGpgEmail = "";
}
// Can only create Identities for the moment!
RsIdentityParameters params;
params.nickname = rid.mMeta.mGroupName;
params.nickname = groupname;
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
uint32_t dummyToken = 0;
@ -265,6 +436,30 @@ void IdEditDialog::updateId()
close();
}
void IdEditDialog::updateId()
{
/* submit updated details */
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
if (groupname.size() < 2)
{
std::cerr << "IdEditDialog::updateId() Nickname too short";
std::cerr << std::endl;
return;
}
mEditGroup.mMeta.mGroupName = groupname;
uint32_t dummyToken = 0;
rsIdentity->updateIdentity(dummyToken, mEditGroup);
close();
}
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
{
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;

View File

@ -29,6 +29,7 @@
#include <inttypes.h>
#include "util/TokenQueue.h"
#include <retroshare/rsidentity.h>
class UIStateHelper;
@ -46,16 +47,33 @@ public:
private slots:
void idTypeToggled(bool checked);
void updateId();
void submit();
void addRecognTag();
void checkNewTag();
void rmTag1();
void rmTag2();
void rmTag3();
void rmTag4();
void rmTag5();
private:
void createId();
void updateId();
void updateIdType(bool pseudo);
void loadExistingId(uint32_t token);
void loadRecognTags();
// extract details.
bool tagDetails(const std::string &id, const std::string &name, const std::string &tag, QString &desc);
void rmTag(int idx);
protected:
Ui::IdEditDialog ui;
bool mIsNew;
UIStateHelper *mStateHelper;
RsGxsIdGroup mEditGroup;
TokenQueue *mIdQueue;
};

View File

@ -6,147 +6,233 @@
<rect>
<x>0</x>
<y>0</y>
<width>557</width>
<height>179</height>
<width>510</width>
<height>595</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Key ID</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>PGP Hash</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_GpgHash">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>PGP Id</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_GpgId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>PGP Name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_GpgId">
<property name="text">
<string>PGP Associated ID</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Pseudo">
<property name="text">
<string>Pseudonym</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Key ID</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>PGP Hash</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_GpgHash">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>PGP Id</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>PGP Name</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_Tags">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_Tag1">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButton_Tag1">
<property name="text">
<string>RM</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_Tag2">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="toolButton_Tag2">
<property name="text">
<string>RM</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Tag3">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="toolButton_Tag3">
<property name="text">
<string>RM</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_Tag4">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="toolButton_Tag4">
<property name="text">
<string>RM</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_Tag5">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QToolButton" name="toolButton_Tag5">
<property name="text">
<string>RM</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPlainTextEdit" name="plainTextEdit_Tag"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_TagCheck">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="pushButton_Tag">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>328</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radioButton_GpgId">
<property name="text">
<string>PGP Associated ID</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Pseudo">
<property name="text">
<string>Pseudonym</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit_Nickname</tabstop>
<tabstop>lineEdit_KeyId</tabstop>
<tabstop>lineEdit_GpgHash</tabstop>
<tabstop>lineEdit_GpgId</tabstop>
<tabstop>lineEdit_GpgName</tabstop>
<tabstop>radioButton_GpgId</tabstop>
<tabstop>radioButton_Pseudo</tabstop>
<tabstop>buttonBox</tabstop>

View File

@ -67,6 +67,17 @@ bool GxsIdChooser::MakeIdDesc(const RsGxsId &id, QString &desc)
if (found)
{
desc = QString::fromUtf8(details.mNickname.c_str());
std::list<RsRecognTag>::iterator it;
for(it = details.mRecognTags.begin(); it != details.mRecognTags.end(); it++)
{
desc += " (";
desc += QString::number(it->tag_class);
desc += ":";
desc += QString::number(it->tag_type);
desc += ")";
}
if (details.mPgpLinked)
{
desc += " (PGP) [";

View File

@ -71,6 +71,16 @@ static bool MakeIdDesc(const RsGxsId &id, QString &str)
str = QString::fromUtf8(details.mNickname.c_str());
std::list<RsRecognTag>::iterator it;
for(it = details.mRecognTags.begin(); it != details.mRecognTags.end(); it++)
{
str += " (";
str += QString::number(it->tag_class);
str += ":";
str += QString::number(it->tag_type);
str += ")";
}
bool addCode = true;
if (details.mPgpLinked)
{

View File

@ -45,6 +45,17 @@ static bool MakeIdDesc(const RsGxsId &id, QString &str)
str = QString::fromUtf8(details.mNickname.c_str());
std::list<RsRecognTag>::iterator it;
for(it = details.mRecognTags.begin(); it != details.mRecognTags.end(); it++)
{
str += " (";
str += QString::number(it->tag_class);
str += ":";
str += QString::number(it->tag_type);
str += ")";
}
bool addCode = true;
if (details.mPgpLinked)
{

View File

@ -2,7 +2,7 @@ CONFIG += qt gui uic qrc resources uitools idle bitdht
# Below is for GXS services.
# Should be disabled for releases.
#CONFIG += gxs debug
CONFIG += gxs debug
gxs {
@ -193,7 +193,10 @@ macx {
gxs {
LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a
LIBS += -lsqlite3
LIBS += ../../../lib/libsqlcipher.a
#LIBS += ../../../lib/sqlcipher/.libs/libsqlcipher.a
#LIBS += -lsqlite3
#LIBS += -lsqlcipher
}