add GXS ID creation option for forum/channel/[...] posting. (Patch from Phenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7437 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-07-06 11:19:58 +00:00
parent e25a8eda97
commit 24ad4b8880
30 changed files with 808 additions and 341 deletions

View file

@ -28,6 +28,7 @@
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
#include "gui/Identity/IdDialog.h"
#include <algorithm>
@ -67,6 +68,8 @@ CreateCircleDialog::CreateCircleDialog()
connect(ui.IdFilter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
/* Add filter actions */
QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
QString headerText = headerItem->text(RSCIRCLEID_COL_NICKNAME);
@ -140,6 +143,7 @@ void CreateCircleDialog::setupForPersonalCircle()
ui.frame_Distribution->hide();
ui.idChooserLabel->hide();
ui.idChooser->hide();
ui.toolButton_NewId->hide();
getPgpIdentities();
}
@ -154,6 +158,7 @@ void CreateCircleDialog::setupForExternalCircle()
ui.frame_Distribution->show();
ui.idChooserLabel->show();
ui.idChooser->show();
ui.toolButton_NewId->show();
requestGxsIdentities();
}
@ -229,90 +234,83 @@ void CreateCircleDialog::createCircle()
std::cerr << std::endl;
QString name = ui.circleName->text();
QString desc;
//QString desc;
if(name.isEmpty())
{ /* error message */
if(name.isEmpty()) {
/* error message */
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Subject!!
}
}//if(name.isEmpty())
RsGxsCircleGroup circle;
circle.mMeta.mGroupName = std::string(name.toUtf8());
RsGxsId authorId;
if (ui.idChooser->getChosenId(authorId))
{
switch (ui.idChooser->getChosenId(authorId)) {
case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId:
circle.mMeta.mAuthorId = authorId;
std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId;
std::cerr << std::endl;
}
else
{
break;
case GxsIdChooser::NoId:
case GxsIdChooser::None:
default:
std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!";
std::cerr << std::endl;
}
}//switch (ui.idChooser->getChosenId(authorId))
/* copy Ids from GUI */
QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount();
for(int i = 0; i < count; i++)
{
for(int i = 0; i < count; i++) {
QTreeWidgetItem *item = tree->topLevelItem(i);
QString keyId = item->text(RSCIRCLEID_COL_KEYID);
/* insert into circle */
if (mIsExternalCircle)
{
if (mIsExternalCircle) {
circle.mInvitedMembers.push_back(RsGxsId(keyId.toStdString()));
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
std::cerr << std::endl;
}
else
{
} else {//if (mIsExternalCircle)
circle.mLocalFriends.push_back(RsPgpId(keyId.toStdString()));
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
std::cerr << std::endl;
}
}//if (mIsExternalCircle)
}
}//for(int i = 0; i < count; i++)
if (mIsExistingCircle)
{
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 (mIsExistingCircle)
if (mIsExternalCircle)
{
if (mIsExternalCircle) {
std::cerr << "CreateCircleDialog::createCircle() External Circle";
std::cerr << std::endl;
// set distribution from GUI.
circle.mMeta.mCircleId.clear() ;
if (ui.radioButton_Public->isChecked())
{
if (ui.radioButton_Public->isChecked()) {
std::cerr << "CreateCircleDialog::createCircle() Public Circle";
std::cerr << std::endl;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
}
else if (ui.radioButton_Self->isChecked())
{
} else if (ui.radioButton_Self->isChecked()) {
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
std::cerr << std::endl;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
}
else if (ui.radioButton_Restricted->isChecked())
{
} else if (ui.radioButton_Restricted->isChecked()) {
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
std::cerr << std::endl;
@ -320,37 +318,31 @@ void CreateCircleDialog::createCircle()
/* grab circle ID from chooser */
RsGxsCircleId chosenId;
if (ui.circleComboBox->getChosenCircle(chosenId))
{
if (ui.circleComboBox->getChosenCircle(chosenId)) {
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
std::cerr << std::endl;
circle.mMeta.mCircleId = chosenId;
}
else
{
} else {//if (ui.circleComboBox->getChosenCircle(chosenId))
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
else
{
}//if (ui.circleComboBox->getChosenCircle(chosenId))
} else { //if (ui.radioButton_Public->isChecked())
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
}
else
{
}//if (ui.radioButton_Public->isChecked())
} else {//if (mIsExternalCircle)
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
std::cerr << std::endl;
// set personal distribution
circle.mMeta.mCircleId.clear() ;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
}
}//if (mIsExternalCircle)
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType;
std::cerr << std::endl;
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId;
@ -674,3 +666,11 @@ void CreateCircleDialog::filterIds()
ui.treeWidget_IdList->filterItems(filterColumn, text);
}
void CreateCircleDialog::createNewGxsId()
{
IdEditDialog dlg(this);
dlg.setupNewId(false);
dlg.exec();
ui.idChooser->setDefaultId(dlg.getLastIdName());
}

View file

@ -53,6 +53,7 @@ private slots:
void createCircle();
void filterChanged(const QString &text);
void createNewGxsId();
private:

View file

@ -258,6 +258,38 @@
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_NewId">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Create new Identity</string>
</property>
<property name="text">
<string>New ID</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/identity/identity_create_32.png</normaloff>:/images/identity/identity_create_32.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -337,6 +369,22 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>RSTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/common/RSTreeWidget.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
@ -347,22 +395,6 @@
<extends>QComboBox</extends>
<header>gui/gxs/GxsCircleChooser.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header>gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>RSTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/common/RSTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>