improved circles GUI logic

This commit is contained in:
csoler 2016-03-08 00:02:16 -05:00
parent 9b92f66c61
commit cba4795911
3 changed files with 54 additions and 16 deletions

View File

@ -87,6 +87,10 @@ CreateCircleDialog::CreateCircleDialog()
QObject::connect(ui.radioButton_ListAllPGP, SIGNAL(toggled(bool)), this, SLOT(updateCircleGUI())) ;
QObject::connect(ui.radioButton_ListKnownPGP, SIGNAL(toggled(bool)), this, SLOT(updateCircleGUI())) ;
QObject::connect(ui.radioButton_Public, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Self, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
QObject::connect(ui.radioButton_Restricted, SIGNAL(toggled(bool)), this, SLOT(updateCircleType(bool))) ;
mIsExistingCircle = false;
mIsExternalCircle = true;
mClearList = true;
@ -135,6 +139,28 @@ void CreateCircleDialog::editNewId(bool isExternal)
/* enable stuff that might be locked */
}
void CreateCircleDialog::updateCircleType(bool b)
{
if(!b)
return ; // no need to change when b<-false
if(ui.radioButton_Self->isChecked())
setupForPersonalCircle() ;
else
setupForExternalCircle() ;
if(ui.radioButton_Restricted->isChecked())
{
ui.circleComboBox->setEnabled(true) ;
ui.circleComboBox->show() ;
}
else
{
ui.circleComboBox->setEnabled(false) ;
ui.circleComboBox->hide() ;
}
}
void CreateCircleDialog::setupForPersonalCircle()
{
mIsExternalCircle = false;
@ -143,7 +169,7 @@ void CreateCircleDialog::setupForPersonalCircle()
ui.groupBox_title->setTitle(tr("Circle Details"));
ui.frame_PgpTypes->hide();
ui.frame_Distribution->hide();
//ui.frame_Distribution->hide();
ui.idChooserLabel->hide();
ui.idChooser->hide();
//ui.toolButton_NewId->hide();

View File

@ -46,11 +46,12 @@ public:
void addCircle(const RsGxsCircleDetails &cirDetails);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots:
void addMember();
void removeMember();
void updateCircleType(bool b);
void selectedId(QTreeWidgetItem*, QTreeWidgetItem*);
void selectedMember(QTreeWidgetItem*, QTreeWidgetItem*);

View File

@ -53,8 +53,9 @@
#define IDDIALOG_REPLIST 3
#define IDDIALOG_REFRESH 4
#define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0
#define CIRCLEGROUP_CIRCLE_COL_GROUPID 1
#define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0
#define CIRCLEGROUP_CIRCLE_COL_GROUPID 1
#define CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS 2
#define CIRCLEGROUP_FRIEND_COL_NAME 0
#define CIRCLEGROUP_FRIEND_COL_ID 1
@ -310,18 +311,18 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
//QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem();
//personalCirclesItem->setText(0, tr("Personal Circles"));
//ui->treeWidget_membership->addTopLevelItem(personalCirclesItem);
QTreeWidgetItem *externalAdminCirclesItem = new QTreeWidgetItem();
externalAdminCirclesItem->setText(0, tr("Circles (Admin)"));
ui->treeWidget_membership->addTopLevelItem(externalAdminCirclesItem);
QTreeWidgetItem *externalOtherCirclesItem = new QTreeWidgetItem();
externalOtherCirclesItem->setText(0, tr("Circles (Other)"));
ui->treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
QTreeWidgetItem *externalSubCirclesItem = new QTreeWidgetItem();
externalSubCirclesItem->setText(0, tr("Circles (Subscribed)"));
ui->treeWidget_membership->addTopLevelItem(externalSubCirclesItem);
QTreeWidgetItem *externalOtherCirclesItem = new QTreeWidgetItem();
externalOtherCirclesItem->setText(0, tr("Circles (Other)"));
ui->treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
QTreeWidgetItem *externalAdminCirclesItem = new QTreeWidgetItem();
externalAdminCirclesItem->setText(0, tr("Circles (Admin)"));
ui->treeWidget_membership->addTopLevelItem(externalAdminCirclesItem);
for(vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
{
@ -332,7 +333,8 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
QTreeWidgetItem *groupItem = new QTreeWidgetItem();
groupItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromUtf8(vit->mGroupName.c_str()));
groupItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPID, QString::fromStdString(vit->mGroupId.toStdString()));
groupItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPID, QString::fromStdString(vit->mGroupId.toStdString()));
groupItem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags));
if (vit->mCircleType == GXS_CIRCLE_TYPE_LOCAL)
{
@ -481,17 +483,25 @@ void IdDialog::circle_selected()
return;
}
uint32_t subscribe_flags = item->data(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole).toUInt();
if(subscribe_flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
ui->pushButton_editCircle->setEnabled(true) ;
else
ui->pushButton_editCircle->setEnabled(false) ;
set_item_background(item, BLUE_BACKGROUND);
QString coltext = item->text(CIRCLEGROUP_CIRCLE_COL_GROUPID);
RsGxsCircleId id ( coltext.toStdString()) ;
RsGxsCircleId id ( coltext.toStdString()) ;
#ifdef SUSPENDED
/* update friend lists */
RsGxsCircleDetails details;
if (rsGxsCircles->getCircleDetails(id, details))
{
/* now mark all the members */
std::set<RsPgpId> members;
std::set<RsPgpId> members;
std::map<RsPgpId, std::list<RsGxsId> >::iterator it;
for(it = details.mAllowedPeers.begin(); it != details.mAllowedPeers.end(); ++it)
{
@ -500,12 +510,13 @@ void IdDialog::circle_selected()
std::cerr << std::endl;
}
// mark_matching_tree(ui->treeWidget_friends, members, CIRCLEGROUP_FRIEND_COL_ID, GREEN_BACKGROUND);
mark_matching_tree(ui->treeWidget_friends, members, CIRCLEGROUP_FRIEND_COL_ID, GREEN_BACKGROUND);
}
else
{
// set_tree_background(ui->treeWidget_friends, GRAY_BACKGROUND);
set_tree_background(ui->treeWidget_friends, GRAY_BACKGROUND);
}
#endif
mStateHelper->setWidgetEnabled(ui->pushButton_editCircle, true);
}