Fix IdDialog Update

No update while received new Id, wait last (5s) to update all.
Fix expanded items in same time.
This commit is contained in:
Phenom 2021-02-08 17:22:44 +01:00
parent 98c2e5fad6
commit e69585abef
4 changed files with 186 additions and 156 deletions

View file

@ -128,8 +128,8 @@ class TreeWidgetItem : public QTreeWidgetItem
{ {
public: public:
TreeWidgetItem(int type=Type): QTreeWidgetItem(type) {} TreeWidgetItem(int type=Type): QTreeWidgetItem(type) {}
TreeWidgetItem(QTreeWidget *tree): QTreeWidgetItem(tree) {} explicit TreeWidgetItem(QTreeWidget *tree): QTreeWidgetItem(tree) {}
TreeWidgetItem(const QStringList& strings): QTreeWidgetItem (strings) {} explicit TreeWidgetItem(const QStringList& strings): QTreeWidgetItem (strings) {}
bool operator< (const QTreeWidgetItem& other ) const bool operator< (const QTreeWidgetItem& other ) const
{ {
@ -148,7 +148,13 @@ class TreeWidgetItem : public QTreeWidgetItem
}; };
/** Constructor */ /** Constructor */
IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog) IdDialog::IdDialog(QWidget *parent)
: MainPage(parent)
, mExternalBelongingCircleItem(NULL)
, mExternalOtherCircleItem(NULL )
, mMyCircleItem(NULL)
, needUpdateIdsOnNextShow(true), needUpdateCirclesOnNextShow(true) // Update Ids and Circles on first show
, ui(new Ui::IdDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -174,12 +180,14 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
contactsItem->setText(0, tr("My contacts")); contactsItem->setText(0, tr("My contacts"));
contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff);
ui->idTreeWidget->insertTopLevelItem(0, ownItem);
ui->idTreeWidget->insertTopLevelItem(0, allItem);
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
ui->treeWidget_membership->clear(); ui->treeWidget_membership->clear();
ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate()); ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate());
mExternalOtherCircleItem = NULL ;
mExternalBelongingCircleItem = NULL ;
mMyCircleItem = NULL ;
/* Setup UI helper */ /* Setup UI helper */
mStateHelper = new UIStateHelper(this); mStateHelper = new UIStateHelper(this);
@ -397,8 +405,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
connect(ui->treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CircleListCustomPopupMenu(QPoint))); connect(ui->treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CircleListCustomPopupMenu(QPoint)));
connect(ui->autoBanIdentities_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoBanIdentities(bool))); connect(ui->autoBanIdentities_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoBanIdentities(bool)));
updateCircles(); updateIdTimer.setSingleShot(true);
updateIdList(); updateCircleTimer.setSingleShot(true);
connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList()));
connect(&updateCircleTimer, SIGNAL(timeout()), this, SLOT(updateCircles()));
} }
void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event) void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
@ -415,8 +425,12 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
case RsGxsIdentityEventCode::DELETED_IDENTITY: case RsGxsIdentityEventCode::DELETED_IDENTITY:
case RsGxsIdentityEventCode::NEW_IDENTITY: case RsGxsIdentityEventCode::NEW_IDENTITY:
case RsGxsIdentityEventCode::UPDATED_IDENTITY: case RsGxsIdentityEventCode::UPDATED_IDENTITY:
if (isVisible())
updateIdList(); {
updateIdTimer.start(5000);
}
else
needUpdateIdsOnNextShow = true;
if(!mId.isNull() && mId == e->mIdentityId) if(!mId.isNull() && mId == e->mIdentityId)
updateIdentity(); updateIdentity();
@ -443,7 +457,12 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
case RsGxsCircleEventCode::CIRCLE_DELETED: case RsGxsCircleEventCode::CIRCLE_DELETED:
case RsGxsCircleEventCode::CACHE_DATA_UPDATED: case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
updateCircles(); if (isVisible())
{
updateCircleTimer.start(5000);
}
else
needUpdateCirclesOnNextShow = true;
default: default:
break; break;
} }
@ -815,21 +834,21 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
// else // else
// subitem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Unknown ID:")+QString::fromStdString(it->first.toStdString())) ; // subitem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Unknown ID:")+QString::fromStdString(it->first.toStdString())) ;
QString tooltip ; QString grpTooltip ;
tooltip += tr("Identity ID: ")+QString::fromStdString(it->first.toStdString()) ; grpTooltip += tr("Identity ID: ")+QString::fromStdString(it->first.toStdString()) ;
tooltip += "\n"+tr("Status: ") ; grpTooltip += "\n"+tr("Status: ") ;
if(invited) if(invited)
if(subscrb) if(subscrb)
tooltip += tr("Full member") ; grpTooltip += tr("Full member") ;
else else
tooltip += tr("Invited by admin") ; grpTooltip += tr("Invited by admin") ;
else else
if(subscrb) if(subscrb)
tooltip += tr("Subscription request pending") ; grpTooltip += tr("Subscription request pending") ;
else else
tooltip += tr("unknown") ; grpTooltip += tr("unknown") ;
subitem->setToolTip(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tooltip) ; subitem->setToolTip(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, grpTooltip) ;
subitem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(it->second)) ; subitem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(it->second)) ;
subitem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPID, Qt::UserRole, QString::fromStdString(it->first.toStdString())) ; subitem->setData(CIRCLEGROUP_CIRCLE_COL_GROUPID, Qt::UserRole, QString::fromStdString(it->first.toStdString())) ;
@ -917,6 +936,19 @@ bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id)
return true ; return true ;
} }
void IdDialog::showEvent(QShowEvent *s)
{
if (needUpdateIdsOnNextShow)
updateIdList();
if (needUpdateCirclesOnNextShow)
updateCircles();
needUpdateIdsOnNextShow = false;
needUpdateCirclesOnNextShow = false;
MainPage::showEvent(s);
}
void IdDialog::createExternalCircle() void IdDialog::createExternalCircle()
{ {
CreateCircleDialog dlg; CreateCircleDialog dlg;
@ -1238,6 +1270,11 @@ void IdDialog::processSettings(bool load)
// state of splitter // state of splitter
ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray());
//Restore expanding
allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool());
ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool());
contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool());
} else { } else {
// save settings // save settings
@ -1292,7 +1329,6 @@ void IdDialog::updateSelection()
void IdDialog::updateIdList() void IdDialog::updateIdList()
{ {
//int accept = filter; //int accept = filter;
RsThread::async([this]() RsThread::async([this]()
@ -1518,6 +1554,15 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
oldCurrentId = RsGxsGroupId(oldCurrent->text(RSID_COL_KEYID).toStdString()); oldCurrentId = RsGxsGroupId(oldCurrent->text(RSID_COL_KEYID).toStdString());
} }
} }
//Save expanding
Settings->beginGroup("IdDialog");
Settings->setValue("ExpandAll", allItem->isExpanded());
Settings->setValue("ExpandContacts", contactsItem->isExpanded());
Settings->setValue("ExpandOwn", ownItem->isExpanded());
Settings->endGroup();
int accept = filter; int accept = filter;
mStateHelper->setActive(IDDIALOG_IDLIST, true); mStateHelper->setActive(IDDIALOG_IDLIST, true);
@ -1567,17 +1612,6 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
item = NULL; item = NULL;
ui->idTreeWidget->insertTopLevelItem(0, ownItem);
ui->idTreeWidget->insertTopLevelItem(0, allItem);
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
Settings->beginGroup("IdDialog");
allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool());
ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool());
contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool());
Settings->endGroup();
if (fillIdListItem(data, item, ownPgpId, accept)) if (fillIdListItem(data, item, ownPgpId, accept))
{ {
if(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) if(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
@ -1602,6 +1636,14 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
allItem->setText(0, tr("All") + " (" + QString::number( allCount ) + ")" ); allItem->setText(0, tr("All") + " (" + QString::number( allCount ) + ")" );
ownItem->setText(0, tr("My own identities") + " (" + QString::number( ownCount ) + ")" ); ownItem->setText(0, tr("My own identities") + " (" + QString::number( ownCount ) + ")" );
//Restore expanding
Settings->beginGroup("IdDialog");
allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool());
ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool());
contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool());
Settings->endGroup();
navigate(RsGxsId(oldCurrentId)); navigate(RsGxsId(oldCurrentId));
filterIds(); filterIds();
updateSelection(); updateSelection();
@ -1696,7 +1738,6 @@ void IdDialog::loadIdentity(RsGxsIdGroup data)
QFontMetricsF f(ui->avLabel_Person->font()) ; QFontMetricsF f(ui->avLabel_Person->font()) ;
ui->avLabel_Person->setPixmap(pixmap.scaled(f.height()*4,f.height()*4,Qt::KeepAspectRatio,Qt::SmoothTransformation)); ui->avLabel_Person->setPixmap(pixmap.scaled(f.height()*4,f.height()*4,Qt::KeepAspectRatio,Qt::SmoothTransformation));
QFontMetricsF g(ui->inviteButton->font()) ;
ui->avatarLabel->setPixmap(pixmap.scaled(ui->inviteButton->width(),ui->inviteButton->width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); ui->avatarLabel->setPixmap(pixmap.scaled(ui->inviteButton->width(),ui->inviteButton->width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
ui->avatarLabel->setScaledContents(true); ui->avatarLabel->setScaledContents(true);
@ -1901,10 +1942,10 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION: // not typically used, since most services do not require group author signatures case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION: // not typically used, since most services do not require group author signatures
return tr("Creation of author signature in service %1").arg(service_name); return tr("Creation of author signature in service %1").arg(service_name);
case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION: // most common use case. Messages are signed by authors in e.g. forums. case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION: // most common use case. Messages are signed by authors in e.g. forums.
return tr("Message signature creation in group %1 of service %2").arg(QString::fromStdString(u.mGrpId.toStdString())).arg(service_name); return tr("Message signature creation in group %1 of service %2").arg(QString::fromStdString(u.mGrpId.toStdString()), service_name);
case RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand. case RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION: case RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION:
return tr("Group author for group %1 in service %2").arg(QString::fromStdString(u.mGrpId.toStdString())).arg(service_name); return tr("Group author for group %1 in service %2").arg(QString::fromStdString(u.mGrpId.toStdString()),service_name);
break ; break ;
case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION: case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION:
case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawling the set of messages for all groups. That helps keepign the useful identities in hand. case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawling the set of messages for all groups. That helps keepign the useful identities in hand.
@ -1925,7 +1966,7 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
else else
l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message")); l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message"));
return tr("%1 in %2 service").arg(l.toHtml()).arg(service_name) ; return tr("%1 in %2 service").arg(l.toHtml(), service_name) ;
} }
case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens. case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens.
{ {
@ -1973,7 +2014,7 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
{ {
RsGxsCircleDetails det; RsGxsCircleDetails det;
if(rsGxsCircles->getCircleDetails(RsGxsCircleId(u.mGrpId),det)) if(rsGxsCircles->getCircleDetails(RsGxsCircleId(u.mGrpId),det))
return tr("Membership verification in circle \"%1\" (%2).").arg(QString::fromUtf8(det.mCircleName.c_str())).arg(QString::fromStdString(u.mGrpId.toStdString())); return tr("Membership verification in circle \"%1\" (%2).").arg(QString::fromUtf8(det.mCircleName.c_str()), QString::fromStdString(u.mGrpId.toStdString()));
else else
return tr("Membership verification in circle (ID=%1).").arg(QString::fromStdString(u.mGrpId.toStdString())); return tr("Membership verification in circle (ID=%1).").arg(QString::fromStdString(u.mGrpId.toStdString()));
} }
@ -2139,15 +2180,15 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
uint32_t n_is_not_a_contact = 0 ; uint32_t n_is_not_a_contact = 0 ;
uint32_t n_selected_items =0 ; uint32_t n_selected_items =0 ;
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it :selected_items)
{ {
if(*it == allItem || *it == contactsItem || *it == ownItem) if(it == allItem || it == contactsItem || it == ownItem)
{ {
root_node_present = true ; root_node_present = true ;
continue ; continue ;
} }
uint32_t item_flags = (*it)->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ; uint32_t item_flags = it->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
if(item_flags & RSID_FILTER_OWNED_BY_YOU) if(item_flags & RSID_FILTER_OWNED_BY_YOU)
one_item_owned_by_you = true ; one_item_owned_by_you = true ;
@ -2155,7 +2196,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
#ifdef ID_DEBUG #ifdef ID_DEBUG
std::cerr << " item flags = " << item_flags << std::endl; std::cerr << " item flags = " << item_flags << std::endl;
#endif #endif
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString()); RsGxsId keyId(it->text(RSID_COL_KEYID).toStdString());
RsIdentityDetails det ; RsIdentityDetails det ;
rsIdentity->getIdDetails(keyId,det) ; rsIdentity->getIdDetails(keyId,det) ;
@ -2316,7 +2357,7 @@ void IdDialog::copyRetroshareLink()
return ; return ;
} }
RsQThreadUtils::postToObject( [radix,details,this]() RsQThreadUtils::postToObject( [radix,details]()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information * thread, for example to update the data model with new information
@ -2392,10 +2433,10 @@ void IdDialog::chatIdentityItem(QTreeWidgetItem* item)
if(!rsMsgs->initiateDistantChatConnexion(toGxsId, fromGxsId, did, error_code)) if(!rsMsgs->initiateDistantChatConnexion(toGxsId, fromGxsId, did, error_code))
QMessageBox::information( QMessageBox::information(
nullptr, tr("Distant chat cannot work"), nullptr, tr("Distant chat cannot work")
QString("%1 %2: %3") , QString("%1 %2: %3")
.arg(tr("Distant chat refused with this person.")) .arg(tr("Distant chat refused with this person.")
.arg(tr("Error code")).arg(error_code) ) ; , tr("Error code") ).arg( error_code) );
} }
void IdDialog::sendMsg() void IdDialog::sendMsg()
@ -2413,9 +2454,9 @@ void IdDialog::sendMsg()
if (nMsgDialog == NULL) if (nMsgDialog == NULL)
return; return;
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string keyId = item->text(RSID_COL_KEYID).toStdString(); std::string keyId = item->text(RSID_COL_KEYID).toStdString();
@ -2456,9 +2497,9 @@ void IdDialog::sendInvite()
void IdDialog::negativePerson() void IdDialog::negativePerson()
{ {
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems(); QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string Id = item->text(RSID_COL_KEYID).toStdString(); std::string Id = item->text(RSID_COL_KEYID).toStdString();
@ -2472,9 +2513,9 @@ void IdDialog::negativePerson()
void IdDialog::neutralPerson() void IdDialog::neutralPerson()
{ {
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems(); QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string Id = item->text(RSID_COL_KEYID).toStdString(); std::string Id = item->text(RSID_COL_KEYID).toStdString();
@ -2487,9 +2528,9 @@ void IdDialog::neutralPerson()
void IdDialog::positivePerson() void IdDialog::positivePerson()
{ {
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems(); QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string Id = item->text(RSID_COL_KEYID).toStdString(); std::string Id = item->text(RSID_COL_KEYID).toStdString();
@ -2503,9 +2544,9 @@ void IdDialog::positivePerson()
void IdDialog::addtoContacts() void IdDialog::addtoContacts()
{ {
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems(); QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string Id = item->text(RSID_COL_KEYID).toStdString(); std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),true); rsIdentity->setAsRegularContact(RsGxsId(Id),true);
@ -2516,10 +2557,10 @@ void IdDialog::addtoContacts()
void IdDialog::removefromContacts() void IdDialog::removefromContacts()
{ {
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems(); QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it) for(auto& it : selected_items)
{ {
QTreeWidgetItem *item = *it ; QTreeWidgetItem *item = it ;
std::string Id = item->text(RSID_COL_KEYID).toStdString(); std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),false); rsIdentity->setAsRegularContact(RsGxsId(Id),false);
@ -2571,7 +2612,6 @@ void IdDialog::restoreExpandedCircleItems(const std::vector<bool>& expanded_root
for(int row=0;row<top_level_item->childCount();++row) for(int row=0;row<top_level_item->childCount();++row)
{ {
RsGxsCircleId circle_id(RsGxsCircleId(top_level_item->child(row)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString())); RsGxsCircleId circle_id(RsGxsCircleId(top_level_item->child(row)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString()));
bool expanded = expanded_circle_items.find(circle_id) != expanded_circle_items.end();
top_level_item->child(row)->setExpanded(expanded_circle_items.find(circle_id) != expanded_circle_items.end()); top_level_item->child(row)->setExpanded(expanded_circle_items.find(circle_id) != expanded_circle_items.end());
} }

View file

@ -25,6 +25,8 @@
#include <retroshare/rsidentity.h> #include <retroshare/rsidentity.h>
#include <QTimer>
#define IMAGE_IDDIALOG ":/icons/png/people.png" #define IMAGE_IDDIALOG ":/icons/png/people.png"
namespace Ui { namespace Ui {
@ -34,15 +36,6 @@ class IdDialog;
class UIStateHelper; class UIStateHelper;
class QTreeWidgetItem; class QTreeWidgetItem;
struct CircleUpdateOrder
{
enum { UNKNOWN_ACTION=0x00, GRANT_MEMBERSHIP=0x01, REVOKE_MEMBERSHIP=0x02 };
uint32_t token ;
RsGxsId gxs_id ;
uint32_t action ;
};
class IdDialog : public MainPage class IdDialog : public MainPage
{ {
Q_OBJECT Q_OBJECT
@ -51,27 +44,31 @@ public:
IdDialog(QWidget *parent = 0); IdDialog(QWidget *parent = 0);
~IdDialog(); ~IdDialog();
virtual QIcon iconPixmap() const { return QIcon(IMAGE_IDDIALOG) ; } //MainPage virtual QIcon iconPixmap() const override { return QIcon(IMAGE_IDDIALOG) ; } //MainPage
virtual QString pageName() const { return tr("People") ; } //MainPage virtual QString pageName() const override { return tr("People") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage virtual QString helpText() const override { return ""; } //MainPage
void navigate(const RsGxsId& gxs_id) ; // shows the info about this particular ID void navigate(const RsGxsId& gxs_id) ; // shows the info about this particular ID
protected: protected:
virtual void updateDisplay(bool complete); virtual void updateDisplay(bool complete);
void updateIdList();
void loadIdentities(const std::map<RsGxsGroupId, RsGxsIdGroup> &ids_set); void loadIdentities(const std::map<RsGxsGroupId, RsGxsIdGroup> &ids_set);
void updateIdentity(); void updateIdentity();
void loadIdentity(RsGxsIdGroup id_data); void loadIdentity(RsGxsIdGroup id_data);
void updateCircles();
void loadCircles(const std::list<RsGroupMetaData>& circle_metas); void loadCircles(const std::list<RsGroupMetaData>& circle_metas);
//void requestCircleGroupData(const RsGxsCircleId& circle_id); //void requestCircleGroupData(const RsGxsCircleId& circle_id);
bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ; bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ;
virtual void showEvent(QShowEvent *) override;
private slots: private slots:
void updateIdList();
void updateCircles();
void createExternalCircle(); void createExternalCircle();
void showEditExistingCircle(); void showEditExistingCircle();
void updateCirclesDisplay(); void updateCirclesDisplay();
@ -148,8 +145,6 @@ private:
void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const; void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const;
void restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items); void restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items);
std::map<uint32_t, CircleUpdateOrder> mCircleUpdates ;
RsGxsGroupId mId; RsGxsGroupId mId;
RsGxsGroupId mIdToNavigate; RsGxsGroupId mIdToNavigate;
int filter; int filter;
@ -158,6 +153,11 @@ private:
RsEventsHandlerId_t mEventHandlerId_identity; RsEventsHandlerId_t mEventHandlerId_identity;
RsEventsHandlerId_t mEventHandlerId_circles; RsEventsHandlerId_t mEventHandlerId_circles;
QTimer updateIdTimer;
QTimer updateCircleTimer;
bool needUpdateIdsOnNextShow;
bool needUpdateCirclesOnNextShow;
/* UI - Designer */ /* UI - Designer */
Ui::IdDialog *ui; Ui::IdDialog *ui;
}; };

View file

@ -32,16 +32,6 @@ class GxsCircleItem;
class FeedHolder; class FeedHolder;
struct CircleUpdateOrder
{
enum { UNKNOWN_ACTION=0x00, GRANT_MEMBERSHIP=0x01, REVOKE_MEMBERSHIP=0x02 };
uint32_t token ;
RsGxsId gxs_id ;
uint32_t action ;
};
class GxsCircleItem : public FeedItem class GxsCircleItem : public FeedItem
{ {
Q_OBJECT Q_OBJECT
@ -57,7 +47,7 @@ public:
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool /*open*/) {} virtual void doExpand(bool /*open*/) override {}
void updateCircleGroup(const uint32_t& token); void updateCircleGroup(const uint32_t& token);

View file

@ -37,7 +37,7 @@ class MainPage : public QWidget
public: public:
/** Default Constructor */ /** Default Constructor */
MainPage(QWidget *parent = 0, Qt::WindowFlags flags = 0); MainPage(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
// Icon to be used to display the main page. // Icon to be used to display the main page.
// //
@ -47,12 +47,12 @@ public:
// Name of the page, to put in the leftside list and action name // Name of the page, to put in the leftside list and action name
// //
virtual QString pageName() const { return mName ; } virtual QString pageName() const { return mName ; }
void setPageName(QString name) { mName = name; } void setPageName(const QString& name) { mName = name; }
// Text to be used to display in the help browser // Text to be used to display in the help browser
// //
virtual QString helpText() const { return mHelp ; } virtual QString helpText() const { return mHelp ; }
void setHelpText(QString help) { mHelp = help; } void setHelpText(const QString& help) { mHelp = help; }
virtual void retranslateUi() {} virtual void retranslateUi() {}