added hierarchy information in FriendList Model

This commit is contained in:
csoler 2019-06-29 17:50:13 +02:00
parent 833661fc24
commit 88ce3e4274
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 63 additions and 2 deletions

View File

@ -700,13 +700,25 @@ void RsFriendListModel::updateInternalData()
mLocations.clear();
mProfiles.clear();
mHG.clear();
mHL.clear();
mHP.clear();
// create a map of profiles and groups
std::map<RsPgpId,uint32_t> pgp_indexes;
std::map<RsPeerId,uint32_t> ssl_indexes;
std::map<RsNodeGroupId,uint32_t> grp_indexes;
// groups
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList) ;
for(auto it(groupInfoList.begin());it!=groupInfoList.end();++it)
{
grp_indexes[it->group_id] = mGroups.size();
mGroups.push_back(*it);
}
// profiles
@ -720,6 +732,7 @@ void RsFriendListModel::updateInternalData()
if(!rsPeers->getGPGDetails(*it,det))
continue;
pgp_indexes[det.gpg_id] = mProfiles.size();
mProfiles.push_back(det);
}
@ -735,9 +748,32 @@ void RsFriendListModel::updateInternalData()
if(!rsPeers->getPeerDetails(*it,det))
continue;
ssl_indexes[det.id] = mLocations.size();
mLocations.push_back(det);
}
// now build the hierarchy information for the model
for(uint32_t i=0;i<mGroups.size();++i)
{
HierarchicalGroupInformation inf;
inf.group_index = i;
for(auto it(mGroups[i].peerIds.begin());it!=mGroups[i].peerIds.end();++ii)
{
auto it2 = pgp_indexes.find(*it);
if(it2 == pgp_indexes.end())
RsErr() << "Cannot find pgp entry for peer " << *it << " in precomputed map. This is very unexpected." << std::endl;
else
inf.child_indices.push_back(it2->second);
}
mHG.push_back(inf);
}
#warning Missing code here !!!
postMods();
}

View File

@ -47,6 +47,24 @@ public:
class RsNodeDetails: public RsPeerDetails {};// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails
class RsProfileDetails: public RsPeerDetails {};
struct HierarchicalGroupInformation
{
uint32_t group_index;
std::vector<uint32_t> child_indices;
};
struct HierarchicalProfileInformation
{
uint32_t profile_index;
std::vector<uint32_t> child_indices;
uint32_t parent_group_index;
};
struct HierarchicalNodeInformation
{
uint32_t node_index;
uint32_t parent_profile_index;
};
enum Columns {
COLUMN_THREAD_NAME = 0x00,
COLUMN_THREAD_LAST_CONTACT = 0x01,
@ -164,7 +182,14 @@ private:
bool mDisplayGroups ;
// A given profile may belong to multiple groups, so the hierarchy is stored using the 3 variables below.
std::vector<HierarchicalGroupInformation> mHG;
std::vector<HierarchicalProfileInformation> mHP;
std::vector<HierarchicalNodeInformation> mHL;
std::vector<RsGroupInfo> mGroups;
std::vector<RsProfileDetails> mProfiles;
std::vector<RsNodeDetails> mLocations;
};