mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
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:
parent
e25a8eda97
commit
24ad4b8880
@ -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());
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ private slots:
|
||||
|
||||
void createCircle();
|
||||
void filterChanged(const QString &text);
|
||||
void createNewGxsId();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -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"/>
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
//#include <retroshare/rsidentity.h> //On header
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
|
@ -37,6 +37,7 @@ IdEditDialog::IdEditDialog(QWidget *parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
mIsNew = true;
|
||||
mLastIdName="";
|
||||
|
||||
ui.setupUi(this);
|
||||
|
||||
@ -445,6 +446,7 @@ void IdEditDialog::createId()
|
||||
uint32_t dummyToken = 0;
|
||||
rsIdentity->createIdentity(dummyToken, params);
|
||||
|
||||
mLastIdName = groupname;
|
||||
close();
|
||||
}
|
||||
|
||||
@ -465,6 +467,8 @@ void IdEditDialog::updateId()
|
||||
uint32_t dummyToken = 0;
|
||||
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
||||
|
||||
|
||||
mLastIdName = groupname;
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "util/TokenQueue.h"
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
#include <QString>
|
||||
|
||||
class UIStateHelper;
|
||||
|
||||
@ -46,6 +47,8 @@ public:
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
std::string getLastIdName() {return mLastIdName;}
|
||||
|
||||
private slots:
|
||||
void idTypeToggled(bool checked);
|
||||
void submit();
|
||||
@ -77,6 +80,7 @@ protected:
|
||||
RsGxsIdGroup mEditGroup;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
std::string mLastIdName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -107,12 +107,20 @@ const RsPhotoPhoto& PhotoItem::getPhotoDetails()
|
||||
{
|
||||
|
||||
|
||||
if(ui->idChooser->isVisible())
|
||||
{
|
||||
if (ui->idChooser->isVisible()) {
|
||||
RsGxsId id;
|
||||
ui->idChooser->getChosenId(id);
|
||||
switch (ui->idChooser->getChosenId(id)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
mPhotoDetails.mMeta.mAuthorId = id;
|
||||
}
|
||||
|
||||
break;
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
break;
|
||||
}//switch (ui->idChooser->getChosenId(id))
|
||||
}//if (ui->idChooser->isVisible())
|
||||
|
||||
return mPhotoDetails;
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ private:
|
||||
QPixmap getPixmap() { return mThumbNail; }
|
||||
|
||||
bool mSelected;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
PhotoShareItemHolder* mHolder;
|
||||
RsPhotoPhoto mPhotoDetails;
|
||||
|
||||
QLabel *mTitleLabel, *mPhotoGrapherLabel;
|
||||
};
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "PostedUserTypes.h"
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -39,6 +40,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos
|
||||
|
||||
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/images/posted_64.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Submit a new Post"));
|
||||
@ -55,15 +57,20 @@ PostedCreatePostDialog::~PostedCreatePostDialog()
|
||||
void PostedCreatePostDialog::createPost()
|
||||
{
|
||||
RsGxsId authorId;
|
||||
if (!ui->idChooser->getChosenId(authorId))
|
||||
{
|
||||
switch (ui->idChooser->getChosenId(authorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "PostedCreatePostDialog::createPost() ERROR GETTING AuthorId!, Post Failed";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id first"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
}//switch (ui->idChooser->getChosenId(authorId))
|
||||
|
||||
RsPostedPost post;
|
||||
post.mMeta.mGroupId = mGrpId;
|
||||
@ -76,7 +83,7 @@ void PostedCreatePostDialog::createPost()
|
||||
/* error message */
|
||||
QMessageBox::warning(this, "RetroShare", tr("Please add a Title"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return; //Don't add a empty title!!
|
||||
}
|
||||
}//if(ui->titleEdit->text().isEmpty())
|
||||
|
||||
uint32_t token;
|
||||
mPosted->createPost(token, post);
|
||||
@ -84,3 +91,11 @@ void PostedCreatePostDialog::createPost()
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void PostedCreatePostDialog::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui->idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void createPost();
|
||||
void createNewGxsId();
|
||||
|
||||
private:
|
||||
QString mLink;
|
||||
|
@ -185,6 +185,38 @@ p, li { white-space: pre-wrap; }
|
||||
<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 row="3" column="0" colspan="3">
|
||||
@ -243,17 +275,17 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GxsIdChooser</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>gui/gxs/GxsIdChooser.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>
|
||||
<header>gui/gxs/GxsIdChooser.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "PostedDialog.h"
|
||||
#include "PostedItem.h"
|
||||
#include "PostedUserTypes.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -76,6 +77,8 @@ PostedListDialog::PostedListDialog(QWidget *parent)
|
||||
|
||||
connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
|
||||
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
// default sort method.
|
||||
mSortMethod = RsPosted::HotRankType;
|
||||
mLastSortMethod = RsPosted::TopRankType; // to be different.
|
||||
@ -97,6 +100,9 @@ PostedListDialog::PostedListDialog(QWidget *parent)
|
||||
|
||||
ui.hotSortButton->setChecked(true);
|
||||
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
||||
|
||||
connect(ui.submitPostButton, SIGNAL(clicked()), this, SLOT(newPost()));
|
||||
}
|
||||
|
||||
@ -244,15 +250,20 @@ void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
||||
{
|
||||
/* must grab AuthorId from Layout */
|
||||
RsGxsId authorId;
|
||||
if (!ui.idChooser->getChosenId(authorId))
|
||||
{
|
||||
switch (ui.idChooser->getChosenId(authorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "PostedListDialog::createPost() ERROR GETTING AuthorId!, Vote Failed";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
}//switch (ui.idChooser->getChosenId(authorId))
|
||||
|
||||
RsGxsVote vote;
|
||||
|
||||
@ -261,14 +272,11 @@ void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
||||
vote.mMeta.mParentId = msgId.second;
|
||||
vote.mMeta.mAuthorId = authorId;
|
||||
|
||||
if (up)
|
||||
{
|
||||
if (up) {
|
||||
vote.mVoteType = GXS_VOTE_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else { //if (up)
|
||||
vote.mVoteType = GXS_VOTE_DOWN;
|
||||
}
|
||||
}//if (up)
|
||||
|
||||
std::cerr << "PostedListDialog::submitVote()";
|
||||
std::cerr << std::endl;
|
||||
@ -396,6 +404,14 @@ void PostedListDialog::editTopic()
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
void PostedListDialog::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui.idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
||||
void PostedListDialog::showGroupDetails()
|
||||
{
|
||||
if (mCurrTopicId.isNull())
|
||||
@ -422,10 +438,10 @@ void PostedListDialog::requestGroupSummary()
|
||||
uint32_t token;
|
||||
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC);
|
||||
|
||||
/* refresh Id Chooser Too */
|
||||
RsGxsId currentId ;
|
||||
ui.idChooser->getChosenId(currentId);
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId);
|
||||
// /* refresh Id Chooser Too */
|
||||
//RsGxsId currentId ;
|
||||
//ui.idChooser->getChosenId(currentId);
|
||||
//ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId);
|
||||
}
|
||||
|
||||
void PostedListDialog::acknowledgeGroup(const uint32_t &token)
|
||||
|
@ -76,6 +76,8 @@ private slots:
|
||||
void showTopic();
|
||||
void editTopic();
|
||||
|
||||
void createNewGxsId();
|
||||
|
||||
void showGroupDetails();
|
||||
void newPost();
|
||||
|
||||
|
@ -251,6 +251,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 row="2" column="0">
|
||||
@ -263,7 +295,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>711</width>
|
||||
<width>714</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -291,21 +323,21 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GxsIdChooser</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>gui/gxs/GxsIdChooser.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GroupTreeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/common/GroupTreeWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GxsIdChooser</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>gui/gxs/GxsIdChooser.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Posted_images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="Posted_images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -50,7 +50,6 @@
|
||||
#define WET_ROLE_ORIGPAGEID Qt::UserRole
|
||||
#define WET_ROLE_PAGEID Qt::UserRole + 1
|
||||
#define WET_ROLE_PARENTID Qt::UserRole + 2
|
||||
|
||||
#define WET_ROLE_SORT Qt::UserRole + 3
|
||||
|
||||
|
||||
@ -421,7 +420,7 @@ void WikiEditDialog::setNewPage()
|
||||
ui.headerFrame->setHeaderText(tr("Create New Wiki Page"));
|
||||
setWindowTitle(tr("Create New Wiki Page"));
|
||||
|
||||
/* no need for for REQUIRED ID */
|
||||
/* No need for for REQUIRED ID */
|
||||
ui.comboBox_IdChooser->loadIds(0, RsGxsId());
|
||||
|
||||
textReset();
|
||||
@ -433,7 +432,7 @@ void WikiEditDialog::setRepublishMode(RsGxsMessageId &origMsgId)
|
||||
mRepublishMode = true;
|
||||
mRepublishOrigId = origMsgId;
|
||||
ui.pushButton_Submit->setText(tr("Republish"));
|
||||
/* no need for for REQUIRED ID */
|
||||
/* No need for for REQUIRED ID */
|
||||
ui.comboBox_IdChooser->loadIds(0, RsGxsId());
|
||||
}
|
||||
|
||||
@ -447,15 +446,12 @@ void WikiEditDialog::cancelEdit()
|
||||
|
||||
void WikiEditDialog::revertEdit()
|
||||
{
|
||||
if (mNewPage)
|
||||
{
|
||||
if (mNewPage) {
|
||||
mCurrentText = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {//if (mNewPage
|
||||
ui.textEdit->setPlainText(QString::fromStdString(mWikiSnapshot.mPage));
|
||||
mCurrentText = QString::fromUtf8(mWikiSnapshot.mPage.c_str());
|
||||
}
|
||||
}//if (mNewPage
|
||||
redrawPage();
|
||||
textReset();
|
||||
}
|
||||
@ -466,8 +462,23 @@ void WikiEditDialog::submitEdit()
|
||||
std::cerr << "WikiEditDialog::submitEdit()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (mNewPage)
|
||||
{
|
||||
RsGxsId authorId;
|
||||
switch (ui.comboBox_IdChooser->getChosenId(authorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
mWikiSnapshot.mMeta.mAuthorId = authorId;
|
||||
std::cerr << "WikiEditDialog::submitEdit() AuthorId: " << authorId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "WikiEditDialog::submitEdit() ERROR GETTING AuthorId!";
|
||||
std::cerr << std::endl;
|
||||
}//switch (ui.comboBox_IdChooser->getChosenId(authorId))
|
||||
|
||||
if (mNewPage) {
|
||||
mWikiSnapshot.mMeta.mGroupId = mWikiCollection.mMeta.mGroupId;
|
||||
mWikiSnapshot.mMeta.mOrigMsgId.clear() ;
|
||||
mWikiSnapshot.mMeta.mMsgId.clear() ;
|
||||
@ -476,9 +487,7 @@ void WikiEditDialog::submitEdit()
|
||||
|
||||
std::cerr << "WikiEditDialog::submitEdit() Is New Page";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else if (mRepublishMode)
|
||||
{
|
||||
} else if (mRepublishMode) {
|
||||
std::cerr << "WikiEditDialog::submitEdit() In Republish Mode";
|
||||
std::cerr << std::endl;
|
||||
// A New Version of the ThreadHead.
|
||||
@ -487,65 +496,44 @@ void WikiEditDialog::submitEdit()
|
||||
mWikiSnapshot.mMeta.mParentId.clear() ;
|
||||
mWikiSnapshot.mMeta.mThreadId.clear() ;
|
||||
mWikiSnapshot.mMeta.mMsgId.clear() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
std::cerr << "WikiEditDialog::submitEdit() In Child Edit Mode";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// A Child of the current message.
|
||||
bool isFirstChild = false;
|
||||
if (mWikiSnapshot.mMeta.mParentId.isNull())
|
||||
{
|
||||
if (mWikiSnapshot.mMeta.mParentId.isNull()) {
|
||||
isFirstChild = true;
|
||||
}
|
||||
}//if (mWikiSnapshot.mMeta.mParentId.isNull())
|
||||
|
||||
mWikiSnapshot.mMeta.mGroupId = mWikiCollection.mMeta.mGroupId;
|
||||
|
||||
if (isFirstChild)
|
||||
{
|
||||
if (isFirstChild){
|
||||
mWikiSnapshot.mMeta.mThreadId = mWikiSnapshot.mMeta.mOrigMsgId;
|
||||
// Special HACK here... parentId points to specific Msg, rather than OrigMsgId.
|
||||
// This allows versioning to work well.
|
||||
mWikiSnapshot.mMeta.mParentId = mWikiSnapshot.mMeta.mMsgId;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {//if (isFirstChild)
|
||||
// ThreadId is the same.
|
||||
mWikiSnapshot.mMeta.mParentId = mWikiSnapshot.mMeta.mOrigMsgId;
|
||||
}
|
||||
}//if (isFirstChild)
|
||||
|
||||
mWikiSnapshot.mMeta.mMsgId.clear() ;
|
||||
mWikiSnapshot.mMeta.mOrigMsgId.clear() ;
|
||||
}
|
||||
}//if (mNewPage)
|
||||
|
||||
|
||||
mWikiSnapshot.mMeta.mMsgName = ui.lineEdit_Page->text().toStdString();
|
||||
|
||||
if (!mPreviewMode)
|
||||
{
|
||||
if (!mPreviewMode) {
|
||||
/* can just use the current text */
|
||||
mCurrentText = ui.textEdit->toPlainText();
|
||||
}
|
||||
}//if (!mPreviewMode)
|
||||
|
||||
{
|
||||
// complicated way of preserving Utf8 text */
|
||||
{// complicated way of preserving Utf8 text */
|
||||
QByteArray byte_array = mCurrentText.toUtf8();
|
||||
mWikiSnapshot.mPage = std::string(byte_array.data());
|
||||
}
|
||||
|
||||
RsGxsId authorId;
|
||||
if (ui.comboBox_IdChooser->getChosenId(authorId))
|
||||
{
|
||||
mWikiSnapshot.mMeta.mAuthorId = authorId;
|
||||
std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}// complicated way of preserving Utf8 text */
|
||||
|
||||
std::cerr << "WikiEditDialog::submitEdit() PageTitle: " << mWikiSnapshot.mMeta.mMsgName;
|
||||
std::cerr << std::endl;
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "gui/gxs/GxsCommentDialog.h"
|
||||
#include "ui_GxsCommentDialog.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -47,6 +48,7 @@ GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_servic
|
||||
|
||||
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
|
||||
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
|
||||
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
/* force voterId through - first time */
|
||||
voterSelectionChanged( 0 );
|
||||
@ -87,17 +89,20 @@ void GxsCommentDialog::voterSelectionChanged( int index )
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsGxsId voterId;
|
||||
if (ui->idChooser->getChosenId(voterId))
|
||||
{
|
||||
switch (ui->idChooser->getChosenId(voterId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
std::cerr << "GxsCommentDialog::voterSelectionChanged() => " << voterId;
|
||||
std::cerr << std::endl;
|
||||
ui->treeWidget->setVoteId(voterId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "GxsCommentDialog::voterSelectionChanged() ERROR nothing selected";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}//switch (ui->idChooser->getChosenId(voterId))
|
||||
}
|
||||
|
||||
void GxsCommentDialog::setCommentHeader(QWidget *header)
|
||||
@ -138,3 +143,11 @@ void GxsCommentDialog::setCommentHeader(QWidget *header)
|
||||
ui->notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsCommentDialog::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui->idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
private slots:
|
||||
void refresh();
|
||||
void voterSelectionChanged( int index );
|
||||
void createNewGxsId();
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGrpId;
|
||||
|
@ -117,6 +117,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>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="text">
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "GxsCreateCommentDialog.h"
|
||||
#include "ui_GxsCreateCommentDialog.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <iostream>
|
||||
@ -35,6 +36,7 @@ GxsCreateCommentDialog::GxsCreateCommentDialog(TokenQueue *tokQ, RsGxsCommentSer
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createComment()));
|
||||
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
||||
@ -58,14 +60,17 @@ void GxsCreateCommentDialog::createComment()
|
||||
|
||||
|
||||
RsGxsId authorId;
|
||||
if (ui->idChooser->getChosenId(authorId))
|
||||
{
|
||||
switch (ui->idChooser->getChosenId(authorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
comment.mMeta.mAuthorId = authorId;
|
||||
std::cerr << "AuthorId : " << comment.mMeta.mAuthorId << std::endl;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "GxsCreateCommentDialog::createComment() ERROR GETTING AuthorId!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
@ -73,8 +78,9 @@ void GxsCreateCommentDialog::createComment()
|
||||
tr("You need to create an Identity\n"
|
||||
"before you can comment"),
|
||||
QMessageBox::Ok);
|
||||
Q_UNUSED(ret)
|
||||
return;
|
||||
}
|
||||
}//switch (ui->idChooser->getChosenId(authorId))
|
||||
|
||||
uint32_t token;
|
||||
mCommentService->createComment(token, comment);
|
||||
@ -82,6 +88,14 @@ void GxsCreateCommentDialog::createComment()
|
||||
close();
|
||||
}
|
||||
|
||||
void GxsCreateCommentDialog::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui->idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
||||
GxsCreateCommentDialog::~GxsCreateCommentDialog()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
private slots:
|
||||
|
||||
void createComment();
|
||||
void createNewGxsId();
|
||||
|
||||
private:
|
||||
Ui::GxsCreateCommentDialog *ui;
|
||||
|
@ -27,10 +27,7 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="3">
|
||||
<widget class="GxsIdChooser" name="idChooser"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="QTextEdit" name="commentTextEdit"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -53,6 +50,41 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="GxsIdChooser" name="idChooser"/>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<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>
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "util/misc.h"
|
||||
#include "GxsGroupDialog.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -85,6 +86,8 @@ void GxsGroupDialog::init()
|
||||
connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancelDialog()));
|
||||
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
|
||||
|
||||
connect( ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
|
||||
@ -173,6 +176,14 @@ void GxsGroupDialog::initMode()
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupDialog::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui.idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
||||
void GxsGroupDialog::clearForm()
|
||||
{
|
||||
ui.groupName->clear();
|
||||
@ -445,36 +456,44 @@ bool GxsGroupDialog::prepareGroupMetaData(RsGroupMetaData &meta)
|
||||
std::cerr << "GxsGroupDialog::prepareGroupMetaData()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
switch (ui.idChooser->getChosenId(meta.mAuthorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
return false;
|
||||
}//switch (ui.idChooser->getChosenId(meta.mAuthorId))
|
||||
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
if(name.isEmpty())
|
||||
{
|
||||
if(name.isEmpty()) {
|
||||
std::cerr << "GxsGroupDialog::prepareGroupMetaData()";
|
||||
std::cerr << " Invalid GroupName";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
}//if(name.isEmpty())
|
||||
|
||||
// Fill in the MetaData as best we can.
|
||||
meta.mGroupName = std::string(name.toUtf8());
|
||||
|
||||
meta.mGroupFlags = flags;
|
||||
meta.mSignFlags = getGroupSignFlags();
|
||||
|
||||
if (!setCircleParameters(meta))
|
||||
{
|
||||
if (!setCircleParameters(meta)){
|
||||
std::cerr << "GxsGroupDialog::prepareGroupMetaData()";
|
||||
std::cerr << " Invalid Circles";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
}//if (!setCircleParameters(meta))
|
||||
|
||||
std::cerr << "void GxsGroupDialog::prepareGroupMetaData() meta.mCircleType: ";
|
||||
std::cerr << meta.mCircleType << " Internal: " << meta.mInternalCircle;
|
||||
std::cerr << " External: " << meta.mCircleId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
ui.idChooser->getChosenId(meta.mAuthorId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ private:
|
||||
void newGroup();
|
||||
void init();
|
||||
void initMode();
|
||||
void createNewGxsId();
|
||||
|
||||
// Functions that can be overloaded for specific stuff.
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>695</width>
|
||||
<height>524</height>
|
||||
<height>577</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,16 +18,7 @@
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
@ -54,16 +45,7 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -127,16 +109,7 @@
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -167,6 +140,38 @@
|
||||
<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>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pubKeyShare_cb">
|
||||
<property name="toolTip">
|
||||
<string>Key recipients can publish to restricted-type group and can view and publish for private-type channels</string>
|
||||
@ -226,16 +231,7 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
@ -302,16 +298,7 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -354,16 +341,7 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -399,16 +377,7 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "GxsIdChooser.h"
|
||||
#include "GxsIdDetails.h"
|
||||
#include "RsGxsUpdateBroadcastBase.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QSortFilterProxyModel>
|
||||
@ -35,12 +36,26 @@
|
||||
#define MAX_TRY 10 // 5 seconds
|
||||
|
||||
#define ROLE_SORT Qt::UserRole + 1 // Qt::UserRole is reserved for data
|
||||
#define ROLE_TYPE Qt::UserRole + 2 //
|
||||
|
||||
#define TYPE_NO_ID 1
|
||||
#define TYPE_FOUND_ID 2
|
||||
#define TYPE_UNKNOWN_ID 3
|
||||
|
||||
#define IDCHOOSER_REFRESH 1
|
||||
|
||||
/** Constructor */
|
||||
GxsIdChooser::GxsIdChooser(QWidget *parent)
|
||||
: QComboBox(parent), mFlags(IDCHOOSER_ANON_DEFAULT)
|
||||
{
|
||||
mBase = new RsGxsUpdateBroadcastBase(rsIdentity, this);
|
||||
connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)));
|
||||
|
||||
mIdQueue = NULL;
|
||||
mFirstLoad=true;
|
||||
|
||||
mDefaultId.clear() ;
|
||||
mDefaultIdName.clear();
|
||||
mTimer = NULL;
|
||||
mTimerCount = 0;
|
||||
|
||||
@ -51,47 +66,77 @@ GxsIdChooser::GxsIdChooser(QWidget *parent)
|
||||
setModel(proxy);
|
||||
|
||||
proxy->setSortRole(ROLE_SORT);
|
||||
connect(this, SIGNAL(currentIndexChanged(int)),this,SLOT(myCurrentIndexChanged(int)));
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
}
|
||||
|
||||
GxsIdChooser::~GxsIdChooser()
|
||||
{
|
||||
}
|
||||
|
||||
void GxsIdChooser::setUpdateWhenInvisible(bool update)
|
||||
{
|
||||
mBase->setUpdateWhenInvisible(update);
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &GxsIdChooser::getGrpIds()
|
||||
{
|
||||
return mBase->getGrpIds();
|
||||
}
|
||||
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &GxsIdChooser::getMsgIds()
|
||||
{
|
||||
return mBase->getMsgIds();
|
||||
}
|
||||
|
||||
void GxsIdChooser::fillDisplay(bool complete)
|
||||
{
|
||||
updateDisplay(complete);
|
||||
update(); // Qt flush
|
||||
}
|
||||
|
||||
void GxsIdChooser::showEvent(QShowEvent *event)
|
||||
{
|
||||
mBase->showEvent(event);
|
||||
QComboBox::showEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void GxsIdChooser::loadIds(uint32_t chooserFlags, RsGxsId defId)
|
||||
{
|
||||
mFlags = chooserFlags;
|
||||
mDefaultId = defId;
|
||||
clear();
|
||||
loadPrivateIds();
|
||||
mFirstLoad = true;
|
||||
}
|
||||
|
||||
bool GxsIdChooser::MakeIdDesc(const RsGxsId &id, QString &desc)
|
||||
bool GxsIdChooser::makeIdDesc(const RsGxsId &gxsId, QString &desc)
|
||||
{
|
||||
RsIdentityDetails details;
|
||||
|
||||
std::list<QIcon> icons;
|
||||
if (!GxsIdDetails::MakeIdDesc(id, false, desc, icons))
|
||||
{
|
||||
if (mTimerCount > MAX_TRY)
|
||||
{
|
||||
if (!GxsIdDetails::MakeIdDesc(gxsId, false, desc, icons)) {
|
||||
if (mTimerCount > MAX_TRY) {
|
||||
desc = QString("%1 ... [").arg(tr("Not found"));
|
||||
desc += QString::fromStdString(id.toStdString().substr(0,5));
|
||||
desc += QString::fromStdString(gxsId.toStdString().substr(0,5));
|
||||
desc += "...]";
|
||||
}
|
||||
}//if (mTimerCount > MAX_TRY)
|
||||
return false;
|
||||
}
|
||||
}//if (!GxsIdDetails::MakeIdDesc(gxsId, false, desc, icons))
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxsIdChooser::addPrivateId(const RsGxsId &gxsId, bool replace)
|
||||
{
|
||||
QString str;
|
||||
bool found = MakeIdDesc(gxsId, str);
|
||||
if (!found)
|
||||
{
|
||||
bool found = makeIdDesc(gxsId, str);
|
||||
if (!found) {
|
||||
/* Add to pending id's */
|
||||
mPendingId.push_back(gxsId);
|
||||
if (replace && mTimerCount <= MAX_TRY) {
|
||||
/* Retry */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}//if (replace && mTimerCount <= MAX_TRY)
|
||||
}//if (!found)
|
||||
|
||||
QString id = QString::fromStdString(gxsId.toStdString());
|
||||
|
||||
@ -101,71 +146,97 @@ void GxsIdChooser::addPrivateId(const RsGxsId &gxsId, bool replace)
|
||||
if (index >= 0) {
|
||||
setItemText(index, str);
|
||||
setItemData(index, QString("%1_%2").arg(found ? "1" : "2").arg(str), ROLE_SORT);
|
||||
setItemData(index, found ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
||||
model()->sort(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}//if (index >= 0)
|
||||
//If not found create a new item.
|
||||
}//if (replace)
|
||||
|
||||
/* Add new item */
|
||||
addItem(str, id);
|
||||
setItemData(count() - 1, QString("%1_%2").arg(found ? "1" : "2").arg(str), ROLE_SORT);
|
||||
setItemData(count() - 1, found ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
||||
model()->sort(0);
|
||||
}
|
||||
|
||||
void GxsIdChooser::loadPrivateIds()
|
||||
void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
{
|
||||
mPendingId.clear();
|
||||
if (mFirstLoad) { clear();}
|
||||
mTimerCount = 0;
|
||||
if (mTimer) {
|
||||
delete(mTimer);
|
||||
}
|
||||
}//if (mTimer)
|
||||
|
||||
std::list<RsGxsId> ids;
|
||||
rsIdentity->getOwnIds(ids);
|
||||
|
||||
if (ids.empty())
|
||||
{
|
||||
std::cerr << "GxsIdChooser::loadPrivateIds() ERROR no ids";
|
||||
//rsIdentity->getOwnIds(ids);
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!rsIdentity->getGroupData(token, datavector)) {
|
||||
std::cerr << "GxsIdChooser::loadPrivateIds() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
}//if (!rsIdentity->getGroupData(token, datavector))
|
||||
|
||||
for (std::vector<RsGxsIdGroup>::iterator vit = datavector.begin();
|
||||
vit != datavector.end(); ++vit) {
|
||||
RsGxsIdGroup data = (*vit);
|
||||
if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
|
||||
ids.push_back((RsGxsId) data.mMeta.mGroupId);
|
||||
}//if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
||||
|
||||
if (mDefaultIdName == data.mMeta.mGroupName) {
|
||||
mDefaultId=(RsGxsId) data.mMeta.mGroupId;
|
||||
}//if (mDefaultIdName == data.mMeta.mGroupName)
|
||||
}//for (std::vector<RsGxsIdGroup>::iterator vit
|
||||
|
||||
//rsIdentity->getDefaultId(defId);
|
||||
// Prefer to use an application specific default???
|
||||
int def = -1;
|
||||
|
||||
if (!(mFlags & IDCHOOSER_ID_REQUIRED))
|
||||
{
|
||||
if (mFirstLoad) {
|
||||
if (!(mFlags & IDCHOOSER_ID_REQUIRED)) {
|
||||
/* add No Signature option */
|
||||
QString str = tr("No Signature");
|
||||
QString id = "";
|
||||
|
||||
addItem(str, id);
|
||||
setItemData(count() - 1, QString("0_%2").arg(str), ROLE_SORT);
|
||||
if (mFlags & IDCHOOSER_ANON_DEFAULT)
|
||||
{
|
||||
def = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
std::list<RsGxsId>::iterator it;
|
||||
for(it = ids.begin(); it != ids.end(); it++, i++)
|
||||
{
|
||||
setItemData(count() - 1, TYPE_NO_ID, ROLE_TYPE);
|
||||
}//if (!(mFlags & IDCHOOSER_ID_REQUIRED)
|
||||
}//if (mFirstLoad)
|
||||
|
||||
if (!mFirstLoad) {
|
||||
for (int idx=0; idx < count(); idx++) {
|
||||
QVariant type = itemData(idx,ROLE_TYPE);
|
||||
switch (type.toInt()) {
|
||||
case TYPE_NO_ID:
|
||||
break;
|
||||
case TYPE_FOUND_ID:
|
||||
case TYPE_UNKNOWN_ID:
|
||||
default: {
|
||||
QVariant var = itemData(idx);
|
||||
RsGxsId gxsId = RsGxsId(var.toString().toStdString());
|
||||
std::list<RsGxsId>::iterator lit = std::find( ids.begin(), ids.end(), gxsId);
|
||||
if (lit == ids.end()) {
|
||||
removeItem(idx);
|
||||
idx--;
|
||||
}//if (lit == ids.end())
|
||||
}//default:
|
||||
}//switch (type.toInt())
|
||||
}//for (int idx=0; idx < count(); idx++)
|
||||
}//if (!mFirstLoad)
|
||||
|
||||
if (ids.empty()) {
|
||||
std::cerr << "GxsIdChooser::loadPrivateIds() ERROR no ids";
|
||||
std::cerr << std::endl;
|
||||
mFirstLoad = false;
|
||||
return;
|
||||
}//if (ids.empty())
|
||||
|
||||
for(std::list<RsGxsId>::iterator it = ids.begin(); it != ids.end(); it++) {
|
||||
/* add to Chooser */
|
||||
addPrivateId(*it, false);
|
||||
|
||||
if (mDefaultId == *it)
|
||||
{
|
||||
def = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (def >= 0)
|
||||
{
|
||||
setCurrentIndex(def);
|
||||
//ui.comboBox->setCurrentIndex(def);
|
||||
}
|
||||
addPrivateId(*it, !mFirstLoad);
|
||||
}//for(std::list<RsGxsId>::iterator it
|
||||
|
||||
if (!mPendingId.empty()) {
|
||||
/* Create and start timer to load pending id's */
|
||||
@ -175,22 +246,76 @@ void GxsIdChooser::loadPrivateIds()
|
||||
mTimer->setInterval(500);
|
||||
connect(mTimer, SIGNAL(timeout()), this, SLOT(timer()));
|
||||
mTimer->start();
|
||||
}
|
||||
}//if (!mPendingId.empty())
|
||||
|
||||
setDefaultItem();
|
||||
|
||||
mFirstLoad=false;
|
||||
}
|
||||
|
||||
bool GxsIdChooser::getChosenId(RsGxsId &id)
|
||||
void GxsIdChooser::setDefaultItem()
|
||||
{
|
||||
if (count() < 1)
|
||||
int def = -1;
|
||||
|
||||
if ((mFlags & IDCHOOSER_ANON_DEFAULT) && !(mFlags & IDCHOOSER_ID_REQUIRED)) {
|
||||
def = findData(TYPE_NO_ID, ROLE_TYPE);
|
||||
} else {
|
||||
QString id = QString::fromStdString(mDefaultId.toStdString());
|
||||
def = findData(id);
|
||||
}//if ((mFlags & IDCHOOSER_ANON_DEFAULT)
|
||||
|
||||
if (def >= 0) {
|
||||
setCurrentIndex(def);
|
||||
}//if (def >= 0)
|
||||
|
||||
}
|
||||
|
||||
bool GxsIdChooser::setChosenId(RsGxsId &gxsId)
|
||||
{
|
||||
QString id = QString::fromStdString(gxsId.toStdString());
|
||||
|
||||
/* Find text of exisiting item */
|
||||
int index = findData(id);
|
||||
if (index >= 0) {
|
||||
setCurrentIndex(index);
|
||||
return true;
|
||||
}//if (index >= 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
GxsIdChooser::ChosenId_Ret GxsIdChooser::getChosenId(RsGxsId &gxsId)
|
||||
{
|
||||
if (count() < 1) {
|
||||
return None;
|
||||
}//if (count() < 1)
|
||||
|
||||
int idx = currentIndex();
|
||||
|
||||
QVariant var = itemData(idx);
|
||||
id = RsGxsId(var.toString().toStdString());
|
||||
gxsId = RsGxsId(var.toString().toStdString());
|
||||
QVariant type = itemData(idx,ROLE_TYPE);
|
||||
switch (type.toInt()) {
|
||||
case TYPE_NO_ID:
|
||||
return NoId;
|
||||
case TYPE_FOUND_ID:
|
||||
return KnowId;
|
||||
case TYPE_UNKNOWN_ID:
|
||||
return UnKnowId;
|
||||
}//switch (type.toInt())
|
||||
|
||||
return true;
|
||||
return None;
|
||||
}
|
||||
|
||||
void GxsIdChooser::myCurrentIndexChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
QFontMetrics fm = QFontMetrics(font());
|
||||
QString text = currentText();
|
||||
if (width()<fm.boundingRect(text).width()) {
|
||||
setToolTip(text);
|
||||
} else {
|
||||
setToolTip("");
|
||||
}//if (width()<fm.boundingRect(text).width())
|
||||
}
|
||||
|
||||
void GxsIdChooser::timer()
|
||||
@ -206,22 +331,67 @@ void GxsIdChooser::timer()
|
||||
pendingId.pop_front();
|
||||
|
||||
addPrivateId(id, true);
|
||||
}
|
||||
}//while (!pendingId.empty())
|
||||
|
||||
setDefaultItem();
|
||||
|
||||
if (mPendingId.empty()) {
|
||||
/* All pending id's processed */
|
||||
delete(mTimer);
|
||||
mTimer = NULL;
|
||||
mTimerCount = 0;
|
||||
} else {
|
||||
} else {//if (mPendingId.empty())
|
||||
if (mTimerCount <= MAX_TRY) {
|
||||
/* Restart timer */
|
||||
mTimer->start();
|
||||
} else {
|
||||
} else {//if (mTimerCount <= MAX_TRY)
|
||||
delete(mTimer);
|
||||
mTimer = NULL;
|
||||
mTimerCount = 0;
|
||||
mPendingId.clear();
|
||||
}//if (mTimerCount <= MAX_TRY)
|
||||
}//if (mPendingId.empty())
|
||||
}
|
||||
|
||||
void GxsIdChooser::updateDisplay(bool complete)
|
||||
{
|
||||
Q_UNUSED(complete)
|
||||
/* Update identity list */
|
||||
requestIdList();
|
||||
}
|
||||
|
||||
void GxsIdChooser::requestIdList()
|
||||
{
|
||||
if (!mIdQueue) return;
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDCHOOSER_REFRESH);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDCHOOSER_REFRESH);
|
||||
}
|
||||
|
||||
void GxsIdChooser::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
Q_UNUSED(queue)
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
switch(req.mUserType) {
|
||||
case IDCHOOSER_REFRESH:
|
||||
insertIdList(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}//switch(req.mUserType)
|
||||
}
|
||||
|
||||
void GxsIdChooser::insertIdList(uint32_t token)
|
||||
{
|
||||
loadPrivateIds(token);
|
||||
}
|
||||
|
@ -26,36 +26,73 @@
|
||||
#define _GXS_ID_CHOOSER_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include "util/TokenQueue.h"
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
|
||||
// This class implement a basic RS functionality which is that ComboBox displaying Id
|
||||
// should update regularly. They also should update only when visible, to save CPU time.
|
||||
//
|
||||
|
||||
class RsGxsIfaceHelper;
|
||||
class RsGxsUpdateBroadcastBase;
|
||||
|
||||
#define IDCHOOSER_ID_REQUIRED 0x0001
|
||||
#define IDCHOOSER_ANON_DEFAULT 0x0002
|
||||
|
||||
class GxsIdChooser : public QComboBox
|
||||
class GxsIdChooser : public QComboBox, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsIdChooser(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL);
|
||||
GxsIdChooser(QWidget *parent = NULL);
|
||||
virtual ~GxsIdChooser();
|
||||
|
||||
void setUpdateWhenInvisible(bool update);
|
||||
const std::list<RsGxsGroupId> &getGrpIds();
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);//TokenResponse
|
||||
|
||||
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
||||
void loadIds(uint32_t chooserFlags, RsGxsId defId);
|
||||
bool setChosenId(RsGxsId &id);
|
||||
bool getChosenId(RsGxsId &id);
|
||||
void setDefaultId(RsGxsId defId) {mDefaultId=defId;}
|
||||
void setDefaultId(std::string defIdName) {mDefaultIdName=defIdName;}
|
||||
|
||||
bool setChosenId(RsGxsId &gxsId);
|
||||
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
private slots:
|
||||
void fillDisplay(bool complete);
|
||||
void timer();
|
||||
void myCurrentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
void loadPrivateIds();
|
||||
void requestIdList() ;
|
||||
void loadPrivateIds(uint32_t token);
|
||||
void addPrivateId(const RsGxsId &gxsId, bool replace);
|
||||
bool MakeIdDesc(const RsGxsId &id, QString &desc);
|
||||
bool makeIdDesc(const RsGxsId &gxsId, QString &desc);
|
||||
void insertIdList(uint32_t token);
|
||||
void setDefaultItem();
|
||||
|
||||
uint32_t mFlags;
|
||||
RsGxsId mDefaultId;
|
||||
std::string mDefaultIdName;
|
||||
bool mFirstLoad;
|
||||
QPushButton* addNewCxsId;
|
||||
|
||||
QList<RsGxsId> mPendingId;
|
||||
QTimer *mTimer;
|
||||
unsigned int mTimerCount;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@ class RsGxsUpdateBroadcastBase : public QObject
|
||||
{
|
||||
friend class RsGxsUpdateBroadcastPage;
|
||||
friend class RsGxsUpdateBroadcastWidget;
|
||||
friend class GxsIdChooser;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "gui/Identity/IdDialog.h"
|
||||
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/misc.h"
|
||||
@ -89,6 +90,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
|
||||
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
|
||||
connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool)));
|
||||
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
||||
|
||||
setAcceptDrops(true);
|
||||
ui.hashBox->setDropWidget(this);
|
||||
@ -126,10 +128,9 @@ void CreateGxsForumMsg::newMsg()
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG);
|
||||
ui.forumName->setText(tr("No Forum"));
|
||||
return;
|
||||
}
|
||||
}//if ( mForumId.isNull())
|
||||
|
||||
/* request Data */
|
||||
{
|
||||
{/* request Data */
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
@ -143,15 +144,12 @@ void CreateGxsForumMsg::newMsg()
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
||||
}
|
||||
}/* request Data */
|
||||
|
||||
if (mParentId.isNull())
|
||||
{
|
||||
if (mParentId.isNull()) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mParentMsgLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
@ -166,7 +164,7 @@ void CreateGxsForumMsg::newMsg()
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
}
|
||||
}//if (mParentId.isNull())
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadFormInformation()
|
||||
@ -261,21 +259,20 @@ void CreateGxsForumMsg::createMsg()
|
||||
|
||||
RsHtml::optimizeHtml(ui.forumMessage, desc);
|
||||
|
||||
if(name.isEmpty())
|
||||
{ /* error message */
|
||||
if(name.isEmpty()) {
|
||||
/* error message */
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return; //Don't add a empty Subject!!
|
||||
}
|
||||
}//if(name.isEmpty())
|
||||
|
||||
RsGxsForumMsg msg;
|
||||
msg.mMeta.mGroupId = mForumId;
|
||||
msg.mMeta.mParentId = mParentId;
|
||||
msg.mMeta.mMsgId.clear() ;
|
||||
if (mParentMsgLoaded)
|
||||
{
|
||||
if (mParentMsgLoaded) {
|
||||
msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId;
|
||||
}
|
||||
}//if (mParentMsgLoaded)
|
||||
|
||||
msg.mMeta.mMsgName = std::string(name.toUtf8());
|
||||
msg.mMsg = std::string(desc.toUtf8());
|
||||
@ -286,31 +283,31 @@ void CreateGxsForumMsg::createMsg()
|
||||
if ((msg.mMsg == "") && (msg.mMeta.mMsgName == ""))
|
||||
return; /* do nothing */
|
||||
|
||||
if (ui.signBox->isChecked())
|
||||
{
|
||||
if (ui.signBox->isChecked()) {
|
||||
RsGxsId authorId;
|
||||
if (ui.idChooser->getChosenId(authorId))
|
||||
{
|
||||
switch (ui.idChooser->getChosenId(authorId)) {
|
||||
case GxsIdChooser::KnowId:
|
||||
case GxsIdChooser::UnKnowId:
|
||||
msg.mMeta.mAuthorId = authorId;
|
||||
std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
break;
|
||||
case GxsIdChooser::NoId:
|
||||
case GxsIdChooser::None:
|
||||
default:
|
||||
std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!";
|
||||
std::cerr << std::endl;
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}//switch (ui.idChooser->getChosenId(authorId))
|
||||
} else {
|
||||
std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
|
||||
std::cerr << std::endl;
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}//if (ui.signBox->isChecked())
|
||||
|
||||
int generateCount = 0;
|
||||
|
||||
@ -319,8 +316,8 @@ void CreateGxsForumMsg::createMsg()
|
||||
generateCount = ui.generateSpinBox->value();
|
||||
if (QMessageBox::question(this, "Generate mass data", QString("Do you really want to generate %1 messages ?").arg(generateCount), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}//if (QMessageBox::question(this,
|
||||
}//if (ui.generateCheckBox->isChecked())
|
||||
#endif
|
||||
|
||||
uint32_t token;
|
||||
@ -331,15 +328,23 @@ void CreateGxsForumMsg::createMsg()
|
||||
generateMsg.mMeta.mMsgName = QString("%1 %2").arg(QString::fromUtf8(msg.mMeta.mMsgName.c_str())).arg(count + 1, 3, 10, QChar('0')).toUtf8().constData();
|
||||
|
||||
rsGxsForums->createMsg(token, generateMsg);
|
||||
}
|
||||
}//for (int count = 0
|
||||
#endif
|
||||
} else {
|
||||
rsGxsForums->createMsg(token, msg);
|
||||
}
|
||||
}//if (generateCount)
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::createNewGxsId()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
ui.idChooser->setDefaultId(dlg.getLastIdName());
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/)
|
||||
{
|
||||
Settings->saveWidgetInformation(this);
|
||||
|
@ -45,6 +45,7 @@ private slots:
|
||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||
/* actions to take.... */
|
||||
void createMsg();
|
||||
void createNewGxsId();
|
||||
|
||||
void smileyWidgetForums();
|
||||
void addSmileys();
|
||||
|
@ -95,10 +95,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="attachFileButton">
|
||||
<property name="focusPolicy">
|
||||
@ -172,7 +169,46 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GxsIdChooser" name="idChooser"/>
|
||||
<widget class="GxsIdChooser" name="idChooser">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<item>
|
||||
<spacer>
|
||||
@ -202,8 +238,8 @@
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"><br /></span></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user