mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-10 03:49:51 -05:00
added hierarchy information in FriendList Model
This commit is contained in:
parent
833661fc24
commit
88ce3e4274
@ -700,13 +700,25 @@ void RsFriendListModel::updateInternalData()
|
|||||||
mLocations.clear();
|
mLocations.clear();
|
||||||
mProfiles.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
|
// groups
|
||||||
|
|
||||||
std::list<RsGroupInfo> groupInfoList;
|
std::list<RsGroupInfo> groupInfoList;
|
||||||
rsPeers->getGroupInfoList(groupInfoList) ;
|
rsPeers->getGroupInfoList(groupInfoList) ;
|
||||||
|
|
||||||
for(auto it(groupInfoList.begin());it!=groupInfoList.end();++it)
|
for(auto it(groupInfoList.begin());it!=groupInfoList.end();++it)
|
||||||
|
{
|
||||||
|
grp_indexes[it->group_id] = mGroups.size();
|
||||||
mGroups.push_back(*it);
|
mGroups.push_back(*it);
|
||||||
|
}
|
||||||
|
|
||||||
// profiles
|
// profiles
|
||||||
|
|
||||||
@ -720,6 +732,7 @@ void RsFriendListModel::updateInternalData()
|
|||||||
if(!rsPeers->getGPGDetails(*it,det))
|
if(!rsPeers->getGPGDetails(*it,det))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
pgp_indexes[det.gpg_id] = mProfiles.size();
|
||||||
mProfiles.push_back(det);
|
mProfiles.push_back(det);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,9 +748,32 @@ void RsFriendListModel::updateInternalData()
|
|||||||
if(!rsPeers->getPeerDetails(*it,det))
|
if(!rsPeers->getPeerDetails(*it,det))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
ssl_indexes[det.id] = mLocations.size();
|
||||||
mLocations.push_back(det);
|
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();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 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 {};
|
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 {
|
enum Columns {
|
||||||
COLUMN_THREAD_NAME = 0x00,
|
COLUMN_THREAD_NAME = 0x00,
|
||||||
COLUMN_THREAD_LAST_CONTACT = 0x01,
|
COLUMN_THREAD_LAST_CONTACT = 0x01,
|
||||||
@ -164,7 +182,14 @@ private:
|
|||||||
|
|
||||||
bool mDisplayGroups ;
|
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<RsGroupInfo> mGroups;
|
||||||
std::vector<RsProfileDetails> mProfiles;
|
std::vector<RsProfileDetails> mProfiles;
|
||||||
std::vector<RsNodeDetails> mLocations;
|
std::vector<RsNodeDetails> mLocations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user