Improvements to enable Edit/Show of GxsGroups.

NB: The actual update doesn't happen yet - mainly just the display of info.
  - Fixed up Constructor, and loading of MetaData via TokenService.
  - Fixed up Enabled / ReadOnly for Show.
  - Updated children to match new functionality.
  - Fixed up Show in Circles Dialog too.
  - removed a few compile errors.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7062 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-01-28 07:57:58 +00:00
parent bb0d02f3dc
commit 3b71e8e140
19 changed files with 506 additions and 172 deletions

View File

@ -65,7 +65,7 @@ CirclesDialog::CirclesDialog(QWidget *parent)
mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_friends, UISTATE_ACTIVE_ENABLED); mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_friends, UISTATE_ACTIVE_ENABLED);
mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_category, UISTATE_ACTIVE_ENABLED); mStateHelper->addWidget(CIRCLESDIALOG_GROUPMETA, ui.treeWidget_category, UISTATE_ACTIVE_ENABLED);
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false); // not implemented mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false);
/* Connect signals */ /* Connect signals */
connect(ui.pushButton_extCircle, SIGNAL(clicked()), this, SLOT(createExternalCircle())); connect(ui.pushButton_extCircle, SIGNAL(clicked()), this, SLOT(createExternalCircle()));
@ -113,12 +113,18 @@ void CirclesDialog::createPersonalCircle()
void CirclesDialog::editExistingCircle() void CirclesDialog::editExistingCircle()
{ {
#if 0 QTreeWidgetItem *item = ui.treeWidget_membership->currentItem();
std::string id; if ((!item) || (!item->parent()))
{
return;
}
QString coltext = item->text(CIRCLEGROUP_CIRCLE_COL_GROUPID);
std::string id = coltext.toStdString();
CreateCircleDialog dlg; CreateCircleDialog dlg;
dlg.editExistingId(id); dlg.editExistingId(id);
dlg.exec(); dlg.exec();
#endif
} }
void CirclesDialog::reloadAll() void CirclesDialog::reloadAll()
@ -349,6 +355,7 @@ void CirclesDialog::circle_selected()
if ((!item) || (!item->parent())) if ((!item) || (!item->parent()))
{ {
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, false);
return; return;
} }
@ -377,6 +384,7 @@ void CirclesDialog::circle_selected()
{ {
set_tree_background(ui.treeWidget_friends, GRAY_BACKGROUND); set_tree_background(ui.treeWidget_friends, GRAY_BACKGROUND);
} }
mStateHelper->setWidgetEnabled(ui.pushButton_editCircle, true);
} }
void CirclesDialog::friend_selected() void CirclesDialog::friend_selected()

View File

@ -68,7 +68,7 @@ CreateCircleDialog::CreateCircleDialog()
mIsExternalCircle = true; mIsExternalCircle = true;
ui.idChooser->loadIds(0,""); ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL); ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, "");
} }
CreateCircleDialog::~CreateCircleDialog() CreateCircleDialog::~CreateCircleDialog()
@ -81,22 +81,10 @@ void CreateCircleDialog::editExistingId(std::string circleId)
{ {
/* load this circle */ /* load this circle */
mIsExistingCircle = true; mIsExistingCircle = true;
requestCircle(circleId);
/* setup personal or external circle */
bool isExternal = false;
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
/* lock stuff they cannot edit */
} }
void CreateCircleDialog::editNewId(bool isExternal) void CreateCircleDialog::editNewId(bool isExternal)
{ {
/* load this circle */ /* load this circle */
@ -164,7 +152,15 @@ void CreateCircleDialog::addMember()
} }
/* check that its not there already */ /* check that its not there already */
QString keyId = item->text(RSCIRCLEID_COL_KEYID); QString keyId = item->text(RSCIRCLEID_COL_KEYID);
QString idtype = item->text(RSCIRCLEID_COL_IDTYPE);
QString nickname = item->text(RSCIRCLEID_COL_NICKNAME);
addMember(keyId, idtype, nickname);
}
void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname )
{
QTreeWidget *tree = ui.treeWidget_membership; QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount(); int count = tree->topLevelItemCount();
@ -180,9 +176,9 @@ void CreateCircleDialog::addMember()
} }
QTreeWidgetItem *member = new QTreeWidgetItem(); QTreeWidgetItem *member = new QTreeWidgetItem();
member->setText(RSCIRCLEID_COL_NICKNAME, item->text(RSCIRCLEID_COL_NICKNAME)); member->setText(RSCIRCLEID_COL_NICKNAME, nickname);
member->setText(RSCIRCLEID_COL_KEYID, item->text(RSCIRCLEID_COL_KEYID)); member->setText(RSCIRCLEID_COL_KEYID, keyId);
member->setText(RSCIRCLEID_COL_IDTYPE, item->text(RSCIRCLEID_COL_IDTYPE)); member->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(member); tree->addTopLevelItem(member);
} }
@ -337,6 +333,58 @@ void CreateCircleDialog::createCircle()
close(); close();
} }
void CreateCircleDialog::updateCircleGUI()
{
std::cerr << "CreateCircleDialog::updateCircleGUI()";
std::cerr << std::endl;
ui.circleName->setText(QString::fromUtf8(mCircleGroup.mMeta.mGroupName.c_str()));
bool isExternal = true;
switch(mCircleGroup.mMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_LOCAL:
isExternal = false;
break;
case GXS_CIRCLE_TYPE_PUBLIC:
ui.radioButton_Public->setChecked(true);
break;
case GXS_CIRCLE_TYPE_EXT_SELF:
case GXS_CIRCLE_TYPE_EXTERNAL:
if (mCircleGroup.mMeta.mCircleId == mCircleGroup.mMeta.mGroupId)
{
ui.radioButton_Self->setChecked(true);
}
else
{
ui.radioButton_Restricted->setChecked(true);
}
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mCircleGroup.mMeta.mCircleId);
break;
default:
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
std::cerr << std::endl;
break;
}
// set preferredId.
ui.idChooser->loadIds(0,mCircleGroup.mMeta.mAuthorId);
/* setup personal or external circle */
if (isExternal)
{
setupForExternalCircle();
}
else
{
setupForPersonalCircle();
}
}
void CreateCircleDialog::requestCircle(const RsGxsGroupId &groupId) void CreateCircleDialog::requestCircle(const RsGxsGroupId &groupId)
{ {
RsTokReqOptions opts; RsTokReqOptions opts;
@ -382,7 +430,8 @@ void CreateCircleDialog::loadCircle(uint32_t token)
std::cerr << "CreateCircleDialog::loadCircle() Unfinished Loading"; std::cerr << "CreateCircleDialog::loadCircle() Unfinished Loading";
std::cerr << std::endl; std::cerr << std::endl;
//mCircleGroup = groups[0]; mCircleGroup = groups[0];
updateCircleGUI();
} }
void CreateCircleDialog::getPgpIdentities() void CreateCircleDialog::getPgpIdentities()
@ -393,24 +442,38 @@ void CreateCircleDialog::getPgpIdentities()
QTreeWidget *tree = ui.treeWidget_IdList; QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear(); tree->clear();
std::list<std::string> ids; std::list<std::string> ids;
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
rsPeers->getGPGAcceptedList(ids); rsPeers->getGPGAcceptedList(ids);
for(it = ids.begin(); it != ids.end(); it++) for(it = ids.begin(); it != ids.end(); it++)
{ {
QTreeWidgetItem *item = new QTreeWidgetItem();
RsPeerDetails details; RsPeerDetails details;
rsPeers->getGPGDetails(*it, details); rsPeers->getGPGDetails(*it, details);
item->setText(RSCIRCLEID_COL_IDTYPE, "PGP Identity"); QString keyId = QString::fromStdString(details.gpg_id);
item->setText(RSCIRCLEID_COL_NICKNAME, QString::fromUtf8(details.name.c_str())); QString nickname = QString::fromUtf8(details.name.c_str());
item->setText(RSCIRCLEID_COL_KEYID, QString::fromStdString(details.gpg_id)); QString idtype = tr("PGP Identity");
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item); tree->addTopLevelItem(item);
// Local Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
std::list<RsPgpId>::const_iterator it;
it = std::find(mCircleGroup.mLocalFriends.begin(), mCircleGroup.mLocalFriends.end(), details.gpg_id);
if (it != mCircleGroup.mLocalFriends.end())
{
/* found it */
addMember(keyId, idtype, nickname);
}
}
} }
} }
@ -477,27 +540,44 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
continue; continue;
} }
QTreeWidgetItem *item = new QTreeWidgetItem(); QString keyId = QString::fromStdString(data.mMeta.mGroupId);
item->setText(RSCIRCLEID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str())); QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str());
item->setText(RSCIRCLEID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId)); QString idtype = tr("Anon Id");
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{ {
if (data.mPgpKnown) if (data.mPgpKnown)
{ {
RsPeerDetails details; RsPeerDetails details;
rsPeers->getGPGDetails(data.mPgpId, details); rsPeers->getGPGDetails(data.mPgpId, details);
item->setText(RSCIRCLEID_COL_IDTYPE, QString::fromUtf8(details.name.c_str())); idtype = QString::fromUtf8(details.name.c_str());
} }
else else
{ {
item->setText(RSCIRCLEID_COL_IDTYPE, "PGP Linked Id"); idtype = tr("PGP Linked Id");
} }
} }
else
{ QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(RSCIRCLEID_COL_IDTYPE, "Anon Id"); item->setText(RSCIRCLEID_COL_NICKNAME, nickname);
} item->setText(RSCIRCLEID_COL_KEYID, keyId);
item->setText(RSCIRCLEID_COL_IDTYPE, idtype);
tree->addTopLevelItem(item); tree->addTopLevelItem(item);
// External Circle.
if (mIsExistingCircle)
{
// check if its in the circle.
std::list<RsGxsId>::const_iterator it;
it = std::find(mCircleGroup.mInvitedMembers.begin(),
mCircleGroup.mInvitedMembers.end(), data.mMeta.mGroupId);
if (it != mCircleGroup.mInvitedMembers.end())
{
/* found it */
addMember(keyId, idtype, nickname);
}
}
} }
} }

View File

@ -54,6 +54,10 @@ private slots:
void createCircle(); void createCircle();
private: private:
void updateCircleGUI();
void addMember(const QString& keyId, const QString& idtype, const QString& nickname );
void setupForPersonalCircle(); void setupForPersonalCircle();
void setupForExternalCircle(); void setupForExternalCircle();
@ -70,6 +74,8 @@ private:
TokenQueue *mCircleQueue; TokenQueue *mCircleQueue;
TokenQueue *mIdQueue; TokenQueue *mIdQueue;
RsGxsCircleGroup mCircleGroup; // for editting existing Circles.
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::CreateCircleDialog ui; Ui::CreateCircleDialog ui;
}; };

View File

@ -26,7 +26,9 @@
#include <retroshare/rswiki.h> #include <retroshare/rswiki.h>
#include <iostream> #include <iostream>
const uint32_t PostedCreateEnabledFlags = ( // GXS_GROUP_FLAGS_ICON | const uint32_t PostedCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION | GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -52,13 +54,16 @@ uint32_t PostedCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_COMMENTS_NO | GXS_GROUP_DEFAULTS_COMMENTS_NO |
0); 0);
uint32_t PostedEditEnabledFlags = PostedCreateEnabledFlags;
uint32_t PostedEditDefaultsFlags = PostedCreateDefaultsFlags;
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent) PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent) :GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
{ {
} }
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup &group, QWidget *parent) PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
:GxsGroupDialog(group.mMeta, MODE_SHOW, parent) :GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, PostedEditEnabledFlags, PostedEditDefaultsFlags, parent)
{ {
} }
@ -99,3 +104,9 @@ bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaDa
return true; return true;
} }
bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta)
{
return false;
}

View File

@ -33,12 +33,13 @@ class PostedGroupDialog : public GxsGroupDialog
public: public:
PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent); PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
PostedGroupDialog(const RsPostedGroup &topic, QWidget *parent); PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
protected: protected:
virtual void initUi(); virtual void initUi();
virtual QPixmap serviceImage(); virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta);
private: private:
RsPostedGroup mTopic; RsPostedGroup mTopic;

View File

@ -368,8 +368,8 @@ void PostedListDialog::showGroupDetails()
{ {
return; return;
} }
PostedGroupDialog cf(mGroups[mCurrTopicId], this); PostedGroupDialog cf(mPostedQueue, rsPosted->getTokenService(), GxsGroupDialog::MODE_SHOW, mCurrTopicId, this);
cf.exec (); cf.exec ();
} }

View File

@ -331,7 +331,7 @@ void ChatLobbyDialog::updateParticipantsList()
std::list<ChatLobbyInfo>::const_iterator it(lInfos.begin()); std::list<ChatLobbyInfo>::const_iterator it(lInfos.begin());
// Set it to the current ChatLobby // Set it to the current ChatLobby
for (; it!=lInfos.end() && (*it).lobby_id != lobbyId; ++it); for (; it!=lInfos.end() && (*it).lobby_id != lobbyId; ++it) ;
if (it != lInfos.end()) { if (it != lInfos.end()) {
ChatLobbyInfo cliInfo=(*it); ChatLobbyInfo cliInfo=(*it);
@ -482,7 +482,7 @@ bool ChatLobbyDialog::isNicknameInLobby(const QString &nickname) {
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
// Set it to the current ChatLobby // Set it to the current ChatLobby
for (; it!=linfos.end() && (*it).lobby_id != lobbyId; ++it); for (; it!=linfos.end() && (*it).lobby_id != lobbyId; ++it) ;
if (it != linfos.end()) { if (it != linfos.end()) {
for (std::map<std::string,time_t>::const_iterator it2((*it).nick_names.begin()); it2 != (*it).nick_names.end(); ++it2) { for (std::map<std::string,time_t>::const_iterator it2((*it).nick_names.begin()); it2 != (*it).nick_names.end(); ++it2) {

View File

@ -36,9 +36,10 @@ GxsCircleChooser::GxsCircleChooser(QWidget *parent)
return; return;
} }
void GxsCircleChooser::loadCircles(uint32_t chooserFlags) void GxsCircleChooser::loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId)
{ {
mFlags = chooserFlags; mFlags = chooserFlags;
mDefaultCircleId = defaultId;
loadGxsCircles(); loadGxsCircles();
} }
@ -84,7 +85,9 @@ void GxsCircleChooser::loadGxsCircles()
} }
std::list<RsGxsCircleId>::iterator it; std::list<RsGxsCircleId>::iterator it;
for(it = ids.begin(); it != ids.end(); it++) int i = 0;
int def = -1;
for(it = ids.begin(); it != ids.end(); it++, i++)
{ {
/* add to Chooser */ /* add to Chooser */
QString str; QString str;
@ -97,6 +100,16 @@ void GxsCircleChooser::loadGxsCircles()
QString id = QString::fromStdString(*it); QString id = QString::fromStdString(*it);
addItem(str, id); addItem(str, id);
if (mDefaultCircleId == *it)
{
def = i;
}
}
if (def >= 0)
{
setCurrentIndex(def);
} }
} }

View File

@ -40,12 +40,14 @@ class GxsCircleChooser : public QComboBox
public: public:
GxsCircleChooser(QWidget *parent = NULL); GxsCircleChooser(QWidget *parent = NULL);
void loadCircles(uint32_t chooserFlags); void loadCircles(uint32_t chooserFlags, const RsGxsCircleId &defaultId);
bool getChosenCircle(RsGxsCircleId &id); bool getChosenCircle(RsGxsCircleId &id);
private: private:
void loadGxsCircles(); void loadGxsCircles();
uint32_t mFlags; uint32_t mFlags;
RsGxsCircleId mDefaultCircleId;
}; };
#endif #endif

View File

@ -51,23 +51,30 @@
#define GXSGROUP_NEWGROUPID 1 #define GXSGROUP_NEWGROUPID 1
#define GXSGROUP_LOADGROUP 2 #define GXSGROUP_LOADGROUP 2
#define GXSGROUP_INTERNAL_LOADGROUP 3
/** Constructor */ /** Constructor */
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent) GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
mInternalTokenQueue = NULL;
init(); init();
} }
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidget *parent) GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(NULL), mGrpMeta(grpMeta), mMode(mode), mEnabledFlags(0), mReadonlyFlags(0), mDefaultsFlags(0) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(mode), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
mTokenService = tokenService;
mInternalTokenQueue = new TokenQueue(tokenService, this);
mGrpMeta.mGroupId = groupId;
init(); init();
} }
@ -102,8 +109,8 @@ void GxsGroupDialog::init()
/* Setup Reasonable Defaults */ /* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,""); ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL); ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL,"");
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL); ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL,"");
initMode(); initMode();
} }
@ -134,6 +141,7 @@ void GxsGroupDialog::setUiText(UiType uiType, const QString &text)
void GxsGroupDialog::initMode() void GxsGroupDialog::initMode()
{ {
setAllReadonly();
switch (mode()) switch (mode())
{ {
case MODE_CREATE: case MODE_CREATE:
@ -146,15 +154,18 @@ void GxsGroupDialog::initMode()
case MODE_SHOW: case MODE_SHOW:
{ {
mReadonlyFlags = 0xffffffff; // Force all to readonly.
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close); ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
requestGroup(mGrpMeta.mGroupId);
} }
break; break;
case MODE_EDIT: case MODE_EDIT:
{ {
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes")); ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
} requestGroup(mGrpMeta.mGroupId);
break; }
break;
} }
} }
@ -253,6 +264,9 @@ void GxsGroupDialog::setupDefaults()
void GxsGroupDialog::setupVisibility() void GxsGroupDialog::setupVisibility()
{ {
{
ui.groupName->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_NAME);
}
{ {
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON); ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON); ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
@ -289,14 +303,112 @@ void GxsGroupDialog::setupVisibility()
} }
void GxsGroupDialog::setAllReadonly()
{
uint32_t origReadonlyFlags = mReadonlyFlags;
mReadonlyFlags = 0xffffffff;
setupReadonly();
mReadonlyFlags = origReadonlyFlags;
}
void GxsGroupDialog::setupReadonly()
{
{
ui.groupName->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_NAME));
}
{
ui.groupLogo->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON));
ui.addLogoButton->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON));
}
{
ui.groupDesc->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DESCRIPTION));
ui.groupDescLabel->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DESCRIPTION));
}
{
ui.distribGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
}
{
ui.publishGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_PUBLISHSIGN));
}
{
ui.pubKeyShare_cb->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_SHAREKEYS));
}
{
ui.personalGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_PERSONALSIGN));
}
{
ui.commentGroupBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_COMMENTS));
}
{
ui.extraFrame->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_EXTRA));
}
}
void GxsGroupDialog::newGroup() void GxsGroupDialog::newGroup()
{ {
setupDefaults(); setupDefaults();
setupVisibility(); setupVisibility();
setupReadonly();
clearForm(); clearForm();
} }
void GxsGroupDialog::updateFromExistingMeta()
{
std::cerr << "void GxsGroupDialog::updateFromExistingMeta()";
std::cerr << std::endl;
std::cerr << "void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: ";
std::cerr << mGrpMeta.mCircleType << " Internal: " << mGrpMeta.mInternalCircle;
std::cerr << " External: " << mGrpMeta.mCircleId;
std::cerr << std::endl;
setupDefaults();
setupVisibility();
setupReadonly();
clearForm();
/* setup name */
ui.groupName->setText(QString::fromUtf8(mGrpMeta.mGroupName.c_str()));
bool isExternal = true;
switch(mGrpMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_YOUREYESONLY:
ui.typeLocal->setChecked(true);
ui.localComboBox->loadCircles(GXS_CIRCLE_CHOOSER_PERSONAL, mGrpMeta.mInternalCircle);
break;
case GXS_CIRCLE_TYPE_PUBLIC:
ui.typePublic->setChecked(true);
break;
case GXS_CIRCLE_TYPE_EXTERNAL:
ui.typeGroup->setChecked(true);
ui.circleComboBox->loadCircles(GXS_CIRCLE_CHOOSER_EXTERNAL, mGrpMeta.mCircleId);
break;
default:
std::cerr << "CreateCircleDialog::updateCircleGUI() INVALID mCircleType";
std::cerr << std::endl;
break;
}
ui.idChooser->loadIds(0, mGrpMeta.mAuthorId);
updateCircleOptions();
}
void GxsGroupDialog::submitGroup() void GxsGroupDialog::submitGroup()
{ {
std::cerr << "GxsGroupDialog::submitGroup()"; std::cerr << "GxsGroupDialog::submitGroup()";
@ -320,9 +432,9 @@ void GxsGroupDialog::submitGroup()
break; break;
case MODE_EDIT: case MODE_EDIT:
{ {
editGroup(); editGroup();
} }
break; break;
} }
@ -337,21 +449,24 @@ void GxsGroupDialog::editGroup()
if(name.isEmpty()) if(name.isEmpty())
{ {
/* error message */ /* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!! return; //Don't add a empty name!!
} }
std::cerr << "GxsGroupDialog::editGroup() Unfinished" << std::endl;
#if 0
uint32_t token; uint32_t token;
RsGxsGroupUpdateMeta updateMeta(mGrpMeta.mGroupId); RsGxsGroupUpdateMeta updateMeta(mGrpMeta.mGroupId);
updateMeta.setMetaUpdate(RsGxsGroupUpdateMeta::NAME, std::string(name.toUtf8())); updateMeta.setMetaUpdate(RsGxsGroupUpdateMeta::NAME, std::string(name.toUtf8()));
if (service_EditGroup(token, updateMeta)) if (service_EditGroup(token, updateMeta))
{ {
// get the Queue to handle response. // get the Queue to handle response.
if(mTokenQueue != NULL) if(mExternalTokenQueue != NULL)
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID); mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
} }
#endif
close(); close();
} }
@ -387,14 +502,18 @@ void GxsGroupDialog::createGroup()
return; //Don't add with invalid circle. return; //Don't add with invalid circle.
} }
std::cerr << "void GxsGroupDialog::createGroup() meta.mCircleType: ";
std::cerr << meta.mCircleType << " Internal: " << meta.mInternalCircle;
std::cerr << " External: " << meta.mCircleId;
std::cerr << std::endl;
ui.idChooser->getChosenId(meta.mAuthorId); ui.idChooser->getChosenId(meta.mAuthorId);
if (service_CreateGroup(token, meta)) if (service_CreateGroup(token, meta))
{ {
// get the Queue to handle response. // get the Queue to handle response.
if(mTokenQueue != NULL) if(mExternalTokenQueue != NULL)
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID); mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
} }
close(); close();
@ -473,7 +592,7 @@ void GxsGroupDialog::updateCircleOptions()
{ {
if (ui.typeGroup->isChecked()) if (ui.typeGroup->isChecked())
{ {
ui.circleComboBox->setEnabled(true); ui.circleComboBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
ui.circleComboBox->setVisible(true); ui.circleComboBox->setVisible(true);
} }
else else
@ -484,7 +603,7 @@ void GxsGroupDialog::updateCircleOptions()
if (ui.typeLocal->isChecked()) if (ui.typeLocal->isChecked())
{ {
ui.localComboBox->setEnabled(true); ui.circleComboBox->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
ui.localComboBox->setVisible(true); ui.localComboBox->setVisible(true);
} }
else else
@ -585,3 +704,69 @@ void GxsGroupDialog::setShareList()
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
} }
} }
/***********************************************************************************
Loading Group.
***********************************************************************************/
void GxsGroupDialog::requestGroup(const RsGxsGroupId &groupId)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(groupId);
std::cerr << "GxsGroupDialog::requestGroup() Requesting Group Summary(" << groupId << ")";
std::cerr << std::endl;
uint32_t token;
mInternalTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, GXSGROUP_INTERNAL_LOADGROUP);
}
void GxsGroupDialog::loadGroup(uint32_t token)
{
std::cerr << "GxsGroupDialog::loadGroup(" << token << ")";
std::cerr << std::endl;
if (service_loadGroup(token, mMode, mGrpMeta))
{
updateFromExistingMeta();
}
}
bool GxsGroupDialog::service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData)
{
std::cerr << "GxsGroupDialog::service_loadGroup(" << token << ") NOT IMPLEMENTED";
std::cerr << std::endl;
return false;
}
void GxsGroupDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "GxsGroupDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
if (queue == mInternalTokenQueue)
{
/* now switch on req */
switch(req.mUserType)
{
case GXSGROUP_INTERNAL_LOADGROUP:
loadGroup(req.mToken);
break;
default:
std::cerr << "GxsGroupDialog::loadGroup() UNKNOWN UserType ";
std::cerr << std::endl;
break;
}
}
}

View File

@ -55,13 +55,14 @@ public:
/*** Group flags affect what is visually enabled that gets input into the grpMeta ***/ /*** Group flags affect what is visually enabled that gets input into the grpMeta ***/
#define GXS_GROUP_FLAGS_ICON 0x00000001 #define GXS_GROUP_FLAGS_NAME 0x00000001
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000002 #define GXS_GROUP_FLAGS_ICON 0x00000002
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000004 #define GXS_GROUP_FLAGS_DESCRIPTION 0x00000004
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000008 #define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000008
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000010 #define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000010
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000020 #define GXS_GROUP_FLAGS_SHAREKEYS 0x00000020
#define GXS_GROUP_FLAGS_COMMENTS 0x00000040 #define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000040
#define GXS_GROUP_FLAGS_COMMENTS 0x00000080
#define GXS_GROUP_FLAGS_EXTRA 0x00000100 #define GXS_GROUP_FLAGS_EXTRA 0x00000100
@ -102,7 +103,7 @@ public:
* The long term plan is perhap logic structure (i.e. code) will be moved into each GXS \n * The long term plan is perhap logic structure (i.e. code) will be moved into each GXS \n
* service for better customisation of group creation, or perhaps not! * service for better customisation of group creation, or perhaps not!
*/ */
class GxsGroupDialog : public QDialog class GxsGroupDialog : public QDialog, public TokenResponse
{ {
Q_OBJECT Q_OBJECT
@ -131,7 +132,7 @@ public:
* @param parent The parent dialog * @param parent The parent dialog
* @param mode * @param mode
*/ */
GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent = NULL); GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
/*! /*!
* Contructs a GxsGroupDialog for display a group or editing * Contructs a GxsGroupDialog for display a group or editing
@ -139,10 +140,13 @@ public:
* @param mode This determines whether the dialog starts in show or edit mode (Edit not supported yet) * @param mode This determines whether the dialog starts in show or edit mode (Edit not supported yet)
* @param parent * @param parent
*/ */
GxsGroupDialog(const RsGroupMetaData& grpMeta, Mode mode, QWidget *parent = NULL); GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
uint32_t mode() { return mMode; } uint32_t mode() { return mMode; }
// overloaded from TokenResponse
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private: private:
void newGroup(); void newGroup();
void init(); void init();
@ -172,11 +176,14 @@ protected:
/*! /*!
* It is up to the service to do the actual group editing * It is up to the service to do the actual group editing
* TODO: make pure virtual
* @param token This should be set to the token retrieved * @param token This should be set to the token retrieved
* @param meta The deriving GXS service should set their grp meta to this value * @param meta The deriving GXS service should set their grp meta to this value
*/ */
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta) {} virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta) = 0;
// To be overloaded by users.
// use Token to retrieve from service, fill in metaData.
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData);
/*! /*!
* This returns a group logo from the ui \n * This returns a group logo from the ui \n
@ -206,6 +213,9 @@ private:
void setGroupSignFlags(uint32_t signFlags); void setGroupSignFlags(uint32_t signFlags);
uint32_t getGroupSignFlags(); uint32_t getGroupSignFlags();
void setAllReadonly();
void setupReadonly();
void setupDefaults(); void setupDefaults();
void setupVisibility(); void setupVisibility();
void clearForm(); void clearForm();
@ -214,12 +224,19 @@ private:
void sendShareList(std::string forumId); void sendShareList(std::string forumId);
void loadNewGroupId(const uint32_t &token); void loadNewGroupId(const uint32_t &token);
// loading existing Groups.
void requestGroup(const RsGxsGroupId &groupId);
void loadGroup(uint32_t token);
void updateFromExistingMeta();
std::list<std::string> mShareList; std::list<std::string> mShareList;
QPixmap picture; QPixmap picture;
TokenQueue *mTokenQueue; RsTokenService *mTokenService;
TokenQueue *mExternalTokenQueue;
TokenQueue *mInternalTokenQueue;
RsGroupMetaData mGrpMeta; RsGroupMetaData mGrpMeta;
uint32_t mMode; Mode mMode;
uint32_t mEnabledFlags; uint32_t mEnabledFlags;
uint32_t mReadonlyFlags; uint32_t mReadonlyFlags;
uint32_t mDefaultsFlags; uint32_t mDefaultsFlags;

View File

@ -39,6 +39,7 @@ public:
GxsIdChooser(QWidget *parent = NULL); GxsIdChooser(QWidget *parent = NULL);
void loadIds(uint32_t chooserFlags, RsGxsId defId); void loadIds(uint32_t chooserFlags, RsGxsId defId);
bool setChosenId(RsGxsId &id);
bool getChosenId(RsGxsId &id); bool getChosenId(RsGxsId &id);
private slots: private slots:

View File

@ -26,7 +26,9 @@
#include <retroshare/rswiki.h> #include <retroshare/rswiki.h>
#include <iostream> #include <iostream>
const uint32_t WikiCreateEnabledFlags = ( // GXS_GROUP_FLAGS_ICON | const uint32_t WikiCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
// GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION | GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -52,71 +54,17 @@ uint32_t WikiCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_COMMENTS_NO | GXS_GROUP_DEFAULTS_COMMENTS_NO |
0); 0);
uint32_t WikiEditDefaultsFlags = WikiCreateDefaultsFlags;
uint32_t WikiEditEnabledFlags = WikiCreateEnabledFlags;
WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent) WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent) :GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent)
{ {
// To start with we only have open forums - with distribution controls.
#if 0
uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS |
// GXS_GROUP_FLAGS_PERSONALSIGN |
// GXS_GROUP_FLAGS_COMMENTS |
0);
uint32_t readonlyFlags = 0;
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
//GXS_GROUP_DEFAULTS_COMMENTS_YES |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
//setFlags(enabledFlags, readonlyFlags, defaultsFlags);
setFlags(enabledFlags, defaultsFlags);
#endif
} }
WikiGroupDialog::WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent) WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
:GxsGroupDialog(collection.mMeta, MODE_SHOW, parent) :GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, WikiEditEnabledFlags, WikiEditDefaultsFlags, parent)
{ {
#if 0
// To start with we only have open forums - with distribution controls.
uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
GXS_GROUP_FLAGS_SHAREKEYS |
0);
uint32_t readonlyFlags = 0;
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
setFlags(enabledFlags, defaultsFlags);
#endif
} }
void WikiGroupDialog::initUi() void WikiGroupDialog::initUi()
@ -156,3 +104,13 @@ bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData
return true; return true;
} }
bool WikiGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta)
{
std::cerr << "WikiGroupDialog::service_EditGroup() UNFINISHED";
std::cerr << std::endl;
return false;
}

View File

@ -34,12 +34,13 @@ class WikiGroupDialog : public GxsGroupDialog
public: public:
WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent); WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent); WikiGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent = NULL);
protected: protected:
virtual void initUi(); virtual void initUi();
virtual QPixmap serviceImage(); virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta);
private: private:

View File

@ -26,7 +26,9 @@
// To start with we only have open forums - with distribution controls. // To start with we only have open forums - with distribution controls.
const uint32_t ChannelCreateEnabledFlags = ( GXS_GROUP_FLAGS_ICON | const uint32_t ChannelCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION | GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -52,13 +54,16 @@ const uint32_t ChannelCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
//GXS_GROUP_DEFAULTS_COMMENTS_NO | //GXS_GROUP_DEFAULTS_COMMENTS_NO |
0); 0);
const uint32_t ChannelEditEnabledFlags = ChannelCreateEnabledFlags;
const uint32_t ChannelEditDefaultsFlags = ChannelCreateDefaultsFlags;
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent) GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent) :GxsGroupDialog(tokenQueue, ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent)
{ {
} }
GxsChannelGroupDialog::GxsChannelGroupDialog(const RsGxsChannelGroup &group, Mode mode, QWidget *parent) GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
:GxsGroupDialog(group.mMeta, mode, parent) :GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, ChannelEditEnabledFlags, ChannelEditDefaultsFlags, parent)
{ {
} }
@ -96,3 +101,14 @@ bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMe
rsGxsChannels->createGroup(token, grp); rsGxsChannels->createGroup(token, grp);
return true; return true;
} }
bool GxsChannelGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta)
{
std::cerr << "GxsChannelGroupDialog::service_EditGroup() UNFINISHED";
std::cerr << std::endl;
return false;
}

View File

@ -31,12 +31,14 @@ class GxsChannelGroupDialog : public GxsGroupDialog
public: public:
GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent); GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
GxsChannelGroupDialog(const RsGxsChannelGroup &group, Mode mode, QWidget *parent); GxsChannelGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
protected: protected:
virtual void initUi(); virtual void initUi();
virtual QPixmap serviceImage(); virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta);
}; };
#endif #endif

View File

@ -26,7 +26,9 @@
// To start with we only have open forums - with distribution controls. // To start with we only have open forums - with distribution controls.
const uint32_t ForumCreateEnabledFlags = ( GXS_GROUP_FLAGS_ICON | const uint32_t ForumCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION | GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN | // GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -52,20 +54,16 @@ const uint32_t ForumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
GXS_GROUP_DEFAULTS_COMMENTS_NO | GXS_GROUP_DEFAULTS_COMMENTS_NO |
0); 0);
const uint32_t ForumEditEnabledFlags = ForumCreateEnabledFlags;
const uint32_t ForumEditEnabledFlags = ( GXS_GROUP_FLAGS_ICON | const uint32_t ForumEditDefaultsFlags = ForumCreateDefaultsFlags;
GXS_GROUP_FLAGS_DESCRIPTION |
0);
const uint32_t ForumEditDefaultsFlags = 0;
GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent) GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent) :GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent)
{ {
} }
GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, Mode mode, QWidget *parent) GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
:GxsGroupDialog(group.mMeta, mode, parent) :GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, ForumEditEnabledFlags, ForumEditDefaultsFlags, parent)
{ {
} }
@ -103,9 +101,44 @@ bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMeta
bool GxsForumGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta) bool GxsForumGroupDialog::service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta)
{ {
RsGxsForumGroup grp; std::cerr << "GxsForumGroupDialog::service_EditGroup() UNFINISHED";
grp.mDescription = std::string(ui.groupDesc->toPlainText().toUtf8()); std::cerr << std::endl;
rsGxsForums->updateGroup(token, updateMeta, grp); RsGxsForumGroup grp;
return true; grp.mDescription = std::string(ui.groupDesc->toPlainText().toUtf8());
rsGxsForums->updateGroup(token, updateMeta, grp);
return true;
} }
bool GxsForumGroupDialog::service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData)
{
std::cerr << "GxsForumGroupDialog::service_loadGroup(" << token << ")";
std::cerr << std::endl;
std::vector<RsGxsForumGroup> groups;
if (!rsGxsForums->getGroupData(token, groups))
{
std::cerr << "GxsForumGroupDialog::service_loadGroup() Error getting GroupData";
std::cerr << std::endl;
return false;
}
if (groups.size() != 1)
{
std::cerr << "GxsForumGroupDialog::service_loadGroup() Error Group.size() != 1";
std::cerr << std::endl;
return false;
}
std::cerr << "GxsForumsGroupDialog::service_loadGroup() Unfinished Loading";
std::cerr << std::endl;
groupMetaData = groups[0].mMeta;
return true;
}

View File

@ -31,13 +31,16 @@ class GxsForumGroupDialog : public GxsGroupDialog
public: public:
GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent); GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
GxsForumGroupDialog(const RsGxsForumGroup &group, Mode mode, QWidget *parent); GxsForumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
protected: protected:
virtual void initUi(); virtual void initUi();
virtual QPixmap serviceImage(); virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta); virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta);
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData);
}; };
#endif #endif

View File

@ -546,10 +546,7 @@ void GxsForumsDialog::showForumDetails()
return; return;
} }
RsGxsForumGroup grp; GxsForumGroupDialog cf(mForumQueue, rsGxsForums->getTokenService(), GxsGroupDialog::MODE_SHOW, mForumId, this);
grp.mMeta.mGroupId = mForumId;
GxsForumGroupDialog cf(grp, GxsGroupDialog::MODE_SHOW, this);
cf.exec (); cf.exec ();
} }
@ -562,7 +559,7 @@ void GxsForumsDialog::editForumDetails()
RsGxsForumGroup grp; RsGxsForumGroup grp;
grp.mMeta.mGroupId = mForumId; grp.mMeta.mGroupId = mForumId;
GxsForumGroupDialog cf(grp, GxsGroupDialog::MODE_EDIT, this); GxsForumGroupDialog cf(mForumQueue, rsGxsForums->getTokenService(), GxsGroupDialog::MODE_EDIT, mForumId, this);
cf.exec (); cf.exec ();
} }