added count of online nodes

This commit is contained in:
csoler 2019-08-11 14:44:58 +02:00
parent ebed027cba
commit e6a70691f7
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 19 additions and 10 deletions

View File

@ -408,7 +408,7 @@ QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) con
} }
break; break;
case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[getPeerStatus(fmpe)])); case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[getPeerOnlineStatus(fmpe)?RS_STATUS_ONLINE:RS_STATUS_OFFLINE]));
default: default:
return QVariant(); return QVariant();
} }
@ -599,6 +599,16 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
{ {
const HierarchicalGroupInformation *group = getGroupInfo(e); const HierarchicalGroupInformation *group = getGroupInfo(e);
uint32_t nb_online = 0;
for(uint32_t i=0;i<group->child_profile_indices.size();++i)
for(uint32_t j=0;j<mProfiles[group->child_profile_indices[i]].child_node_indices.size();++j)
if(mLocations[mProfiles[group->child_profile_indices[i]].child_node_indices[j]].node_info.state & RS_PEER_STATE_CONNECTED)
{
nb_online++;
break;// only breaks the inner loop, on purpose.
}
if(!group) if(!group)
return QVariant(); return QVariant();
@ -606,7 +616,11 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
{ {
case COLUMN_THREAD_NAME: case COLUMN_THREAD_NAME:
std::cerr << group->group_info.name.c_str() << std::endl; std::cerr << group->group_info.name.c_str() << std::endl;
return QVariant(QString::fromUtf8(group->group_info.name.c_str()));
if(!group->child_profile_indices.empty())
return QVariant(QString::fromUtf8(group->group_info.name.c_str())+" (" + QString::number(nb_online) + "/" + QString::number(group->child_profile_indices.size()) + ")");
else
return QVariant(QString::fromUtf8(group->group_info.name.c_str()));
default: default:
return QVariant(); return QVariant();
@ -722,15 +736,10 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNode
return &node; return &node;
} }
uint32_t RsFriendListModel::getPeerStatus(const EntryIndex& e) const bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const
{ {
const HierarchicalNodeInformation *noded = getNodeInfo(e) ; const HierarchicalNodeInformation *noded = getNodeInfo(e) ;
StatusInfo info; return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED));
if(!noded || !rsStatus->getStatus(noded->node_info.id,info))
return RS_STATUS_OFFLINE;
return info.status;
} }
QVariant RsFriendListModel::userRole(const EntryIndex& fmpe,int col) const QVariant RsFriendListModel::userRole(const EntryIndex& fmpe,int col) const

View File

@ -153,7 +153,7 @@ private:
const HierarchicalProfileInformation *getProfileInfo(const EntryIndex&) const; const HierarchicalProfileInformation *getProfileInfo(const EntryIndex&) const;
const HierarchicalNodeInformation *getNodeInfo(const EntryIndex&) const; const HierarchicalNodeInformation *getNodeInfo(const EntryIndex&) const;
uint32_t getPeerStatus(const EntryIndex& e) const; bool getPeerOnlineStatus(const EntryIndex& e) const;
QVariant sizeHintRole (int col) const; QVariant sizeHintRole (int col) const;