From 7dfd6de15f8913f4721497d8635d9380ceef4cf4 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 7 Jun 2024 11:26:35 +0200 Subject: [PATCH 1/3] fixed bug showing peers offline when status service is remotely disabled --- retroshare-gui/src/gui/common/FriendListModel.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index cc6fd9c43..6f01b72d4 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -585,13 +585,10 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const { const HierarchicalNodeInformation *node = getNodeInfo(e); - if(node) - { - StatusInfo status; - rsStatus->getStatus(node->node_info.id, status); - - return QVariant(status.status); - } + if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED)) + return QVariant(RS_STATUS_ONLINE); + else + return QVariant(RS_STATUS_OFFLINE); } } return QVariant(RS_STATUS_OFFLINE); From 1b4886715df63606bdeb5d9d22c246945f3a5013 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 9 Jun 2024 21:25:43 +0200 Subject: [PATCH 2/3] fixed usage of statusRole in FriendListModel --- .../src/gui/common/FriendListModel.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 6f01b72d4..7f05b8221 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -413,17 +413,28 @@ QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) con { switch(fmpe.type) { - case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup)); - case ENTRY_TYPE_PROFILE: - case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[onlineRole(fmpe,column).toInt()])); + case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup)); + case ENTRY_TYPE_PROFILE: return QVariant(QBrush(mTextColorStatus[onlineRole(fmpe,column).toInt()])); + case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[statusRole(fmpe,column).toInt()])); default: return QVariant(); } } -QVariant RsFriendListModel::statusRole(const EntryIndex& /*fmpe*/,int /*column*/) const +// statusRole returns the status (e.g. RS_STATUS_BUSY). It is used only to change the font color + +QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int /*column*/) const { - return QVariant();//fmpe.mMsgStatus); + const HierarchicalNodeInformation *node = getNodeInfo(fmpe); + + if(node) + { + StatusInfo status; + rsStatus->getStatus(node->node_info.id, status); + + return QVariant(status.status); + } + return QVariant(); } bool RsFriendListModel::passesFilter(const EntryIndex& e,int /*column*/) const @@ -548,6 +559,9 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& entry,int column) const } } +// Only returns two values: RS_STATUS_ONLINE, or RS_STATUS_OFFLINE. This is used to decide on text font (bold) +// and whether profiles have children or not when offline nodes are shown. + QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const { switch(e.type) @@ -623,12 +637,6 @@ QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const } } -class AutoEndel -{ -public: - ~AutoEndel() { std::cerr << std::endl;} -}; - QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const { #ifdef DEBUG_MODEL_INDEX From 794ec3576ccc7a9ac8d7ff2c60e0a10bf3c63101 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Jun 2024 11:08:28 +0200 Subject: [PATCH 3/3] using statusRole instead of onlineRole to decide on node string --- retroshare-gui/src/gui/common/FriendListModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 7f05b8221..d4c5e74b6 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -755,7 +755,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const else { return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n" - + "(" + StatusDefs::name(onlineRole(e,col).toInt()) + ")"); + + "(" + StatusDefs::name(statusRole(e,col).toInt()) + ")"); } else return QVariant(QString::fromUtf8(node->node_info.location.c_str()));