mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-28 08:54:13 -04:00
added async update of ID list
This commit is contained in:
parent
7c5a45335a
commit
6fde55217c
3 changed files with 50 additions and 25 deletions
|
@ -463,21 +463,14 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||||
mId.clear();
|
mId.clear();
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
}
|
}
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsIdentityEventCode::NEW_IDENTITY:
|
case RsGxsIdentityEventCode::NEW_IDENTITY:
|
||||||
case RsGxsIdentityEventCode::UPDATED_IDENTITY:
|
case RsGxsIdentityEventCode::UPDATED_IDENTITY:
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
{
|
updateIdListRequest(); // use a timer for events not generated by local changes which generally
|
||||||
if(rsIdentity->isOwnId(RsGxsId(e->mIdentityId)))
|
|
||||||
updateIdList();
|
|
||||||
else
|
|
||||||
updateIdTimer.start(3000); // use a timer for events not generated by local changes which generally
|
|
||||||
// come in large herds. Allows to group multiple changes into a single UI update.
|
// come in large herds. Allows to group multiple changes into a single UI update.
|
||||||
}
|
|
||||||
else
|
|
||||||
needUpdateIdsOnNextShow = true;
|
|
||||||
|
|
||||||
if(!mId.isNull() && mId == e->mIdentityId)
|
if(!mId.isNull() && mId == e->mIdentityId)
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
|
@ -537,7 +530,7 @@ void IdDialog::toggleAutoBanIdentities(bool b)
|
||||||
if(!id.isNull())
|
if(!id.isNull())
|
||||||
{
|
{
|
||||||
rsReputations->banNode(id,b) ;
|
rsReputations->banNode(id,b) ;
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,7 +970,7 @@ bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id)
|
||||||
void IdDialog::showEvent(QShowEvent *s)
|
void IdDialog::showEvent(QShowEvent *s)
|
||||||
{
|
{
|
||||||
if (needUpdateIdsOnNextShow)
|
if (needUpdateIdsOnNextShow)
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
if (needUpdateCirclesOnNextShow)
|
if (needUpdateCirclesOnNextShow)
|
||||||
updateCircles();
|
updateCircles();
|
||||||
|
|
||||||
|
@ -1360,7 +1353,7 @@ void IdDialog::filterToggled(const bool &value)
|
||||||
QAction *source = qobject_cast<QAction *>(QObject::sender());
|
QAction *source = qobject_cast<QAction *>(QObject::sender());
|
||||||
if (source) {
|
if (source) {
|
||||||
filter = source->data().toInt();
|
filter = source->data().toInt();
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1377,19 +1370,49 @@ void IdDialog::updateSelection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IdDialog::updateIdListRequest()
|
||||||
|
{
|
||||||
|
if(updateIdTimer.isActive())
|
||||||
|
{
|
||||||
|
std::cerr << "updateIdListRequest(): restarting timer"<< std::endl;
|
||||||
|
updateIdTimer.stop();
|
||||||
|
updateIdTimer.start(1000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "updateIdListRequest(): starting timer"<< std::endl;
|
||||||
|
updateIdTimer.start(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IdDialog::updateIdList()
|
void IdDialog::updateIdList()
|
||||||
{
|
{
|
||||||
std::cerr << "Updating identity list in widget: stack is:" << std::endl;
|
std::cerr << "Updating identity list in widget." << std::endl;
|
||||||
//print_stacktrace();
|
//print_stacktrace();
|
||||||
|
|
||||||
applyWhileKeepingTree( [this]() {
|
RsThread::async([this]()
|
||||||
|
{
|
||||||
mIdListModel->updateIdentityList();
|
std::list<RsGroupMetaData> *ids = new std::list<RsGroupMetaData>();
|
||||||
|
|
||||||
|
if(!rsIdentity->getIdentitiesSummaries(*ids))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identity metadata." << std::endl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
RsQThreadUtils::postToObject( [ids,this]()
|
||||||
|
{
|
||||||
|
|
||||||
|
applyWhileKeepingTree( [ids,this]() {
|
||||||
|
|
||||||
|
mIdListModel->setIdentities(*ids) ;
|
||||||
|
delete ids;
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept)
|
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept)
|
||||||
{
|
{
|
||||||
|
@ -2412,7 +2435,7 @@ void IdDialog::negativePerson()
|
||||||
rsReputations->setOwnOpinion(id, RsOpinion::NEGATIVE);
|
rsReputations->setOwnOpinion(id, RsOpinion::NEGATIVE);
|
||||||
|
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::neutralPerson()
|
void IdDialog::neutralPerson()
|
||||||
|
@ -2423,7 +2446,7 @@ void IdDialog::neutralPerson()
|
||||||
rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL);
|
rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL);
|
||||||
|
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
void IdDialog::positivePerson()
|
void IdDialog::positivePerson()
|
||||||
{
|
{
|
||||||
|
@ -2433,7 +2456,7 @@ void IdDialog::positivePerson()
|
||||||
rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE);
|
rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE);
|
||||||
|
|
||||||
updateIdentity();
|
updateIdentity();
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::addtoContacts()
|
void IdDialog::addtoContacts()
|
||||||
|
@ -2443,7 +2466,7 @@ void IdDialog::addtoContacts()
|
||||||
for(const auto& id : lst)
|
for(const auto& id : lst)
|
||||||
rsIdentity->setAsRegularContact(id,true);
|
rsIdentity->setAsRegularContact(id,true);
|
||||||
|
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::removefromContacts()
|
void IdDialog::removefromContacts()
|
||||||
|
@ -2453,7 +2476,7 @@ void IdDialog::removefromContacts()
|
||||||
for(const auto& id : lst)
|
for(const auto& id : lst)
|
||||||
rsIdentity->setAsRegularContact(id,false);
|
rsIdentity->setAsRegularContact(id,false);
|
||||||
|
|
||||||
updateIdList();
|
updateIdListRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::on_closeInfoFrameButton_Invite_clicked()
|
void IdDialog::on_closeInfoFrameButton_Invite_clicked()
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
void loadIdentity(RsGxsIdGroup id_data);
|
void loadIdentity(RsGxsIdGroup id_data);
|
||||||
|
|
||||||
void loadCircles(const std::list<RsGroupMetaData>& circle_metas);
|
void loadCircles(const std::list<RsGroupMetaData>& circle_metas);
|
||||||
|
void updateIdListRequest();
|
||||||
|
|
||||||
//void requestCircleGroupData(const RsGxsCircleId& circle_id);
|
//void requestCircleGroupData(const RsGxsCircleId& circle_id);
|
||||||
bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ;
|
bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ;
|
||||||
|
|
|
@ -144,6 +144,8 @@ public:
|
||||||
QColor mTextColorGroup;
|
QColor mTextColorGroup;
|
||||||
QColor mTextColorStatus[RS_STATUS_COUNT];
|
QColor mTextColorStatus[RS_STATUS_COUNT];
|
||||||
|
|
||||||
|
void setIdentities(const std::list<RsGroupMetaData>& identities_meta);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const;
|
const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const;
|
||||||
const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const;
|
const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const;
|
||||||
|
@ -178,7 +180,6 @@ signals:
|
||||||
void dataAboutToLoad();
|
void dataAboutToLoad();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setIdentities(const std::list<RsGroupMetaData>& identities_meta);
|
|
||||||
bool passesFilter(const EntryIndex &e, int column) const;
|
bool passesFilter(const EntryIndex &e, int column) const;
|
||||||
|
|
||||||
void preMods() ;
|
void preMods() ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue