mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-19 14:55:54 -04:00
added async update of ID list
This commit is contained in:
parent
7c5a45335a
commit
6fde55217c
@ -463,21 +463,14 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
mId.clear();
|
||||
updateIdentity();
|
||||
}
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
break;
|
||||
|
||||
case RsGxsIdentityEventCode::NEW_IDENTITY:
|
||||
case RsGxsIdentityEventCode::UPDATED_IDENTITY:
|
||||
if (isVisible())
|
||||
{
|
||||
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.
|
||||
}
|
||||
else
|
||||
needUpdateIdsOnNextShow = true;
|
||||
updateIdListRequest(); // 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.
|
||||
|
||||
if(!mId.isNull() && mId == e->mIdentityId)
|
||||
updateIdentity();
|
||||
@ -537,7 +530,7 @@ void IdDialog::toggleAutoBanIdentities(bool b)
|
||||
if(!id.isNull())
|
||||
{
|
||||
rsReputations->banNode(id,b) ;
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@ -977,7 +970,7 @@ bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id)
|
||||
void IdDialog::showEvent(QShowEvent *s)
|
||||
{
|
||||
if (needUpdateIdsOnNextShow)
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
if (needUpdateCirclesOnNextShow)
|
||||
updateCircles();
|
||||
|
||||
@ -1360,7 +1353,7 @@ void IdDialog::filterToggled(const bool &value)
|
||||
QAction *source = qobject_cast<QAction *>(QObject::sender());
|
||||
if (source) {
|
||||
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()
|
||||
{
|
||||
std::cerr << "Updating identity list in widget: stack is:" << std::endl;
|
||||
std::cerr << "Updating identity list in widget." << std::endl;
|
||||
//print_stacktrace();
|
||||
|
||||
applyWhileKeepingTree( [this]() {
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::list<RsGroupMetaData> *ids = new std::list<RsGroupMetaData>();
|
||||
|
||||
mIdListModel->updateIdentityList();
|
||||
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
|
||||
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);
|
||||
|
||||
updateIdentity();
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
|
||||
void IdDialog::neutralPerson()
|
||||
@ -2423,7 +2446,7 @@ void IdDialog::neutralPerson()
|
||||
rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL);
|
||||
|
||||
updateIdentity();
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
void IdDialog::positivePerson()
|
||||
{
|
||||
@ -2433,7 +2456,7 @@ void IdDialog::positivePerson()
|
||||
rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE);
|
||||
|
||||
updateIdentity();
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
|
||||
void IdDialog::addtoContacts()
|
||||
@ -2443,7 +2466,7 @@ void IdDialog::addtoContacts()
|
||||
for(const auto& id : lst)
|
||||
rsIdentity->setAsRegularContact(id,true);
|
||||
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
|
||||
void IdDialog::removefromContacts()
|
||||
@ -2453,7 +2476,7 @@ void IdDialog::removefromContacts()
|
||||
for(const auto& id : lst)
|
||||
rsIdentity->setAsRegularContact(id,false);
|
||||
|
||||
updateIdList();
|
||||
updateIdListRequest();
|
||||
}
|
||||
|
||||
void IdDialog::on_closeInfoFrameButton_Invite_clicked()
|
||||
|
@ -61,6 +61,7 @@ protected:
|
||||
void loadIdentity(RsGxsIdGroup id_data);
|
||||
|
||||
void loadCircles(const std::list<RsGroupMetaData>& circle_metas);
|
||||
void updateIdListRequest();
|
||||
|
||||
//void requestCircleGroupData(const RsGxsCircleId& circle_id);
|
||||
bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ;
|
||||
@ -70,7 +71,7 @@ protected:
|
||||
|
||||
private slots:
|
||||
void updateIdList();
|
||||
void updateCircles();
|
||||
void updateCircles();
|
||||
void createExternalCircle();
|
||||
void showEditExistingCircle();
|
||||
void updateCirclesDisplay();
|
||||
|
@ -144,6 +144,8 @@ public:
|
||||
QColor mTextColorGroup;
|
||||
QColor mTextColorStatus[RS_STATUS_COUNT];
|
||||
|
||||
void setIdentities(const std::list<RsGroupMetaData>& identities_meta);
|
||||
|
||||
private:
|
||||
const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const;
|
||||
const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const;
|
||||
@ -178,7 +180,6 @@ signals:
|
||||
void dataAboutToLoad();
|
||||
|
||||
private:
|
||||
void setIdentities(const std::list<RsGroupMetaData>& identities_meta);
|
||||
bool passesFilter(const EntryIndex &e, int column) const;
|
||||
|
||||
void preMods() ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user