Merge pull request #2858 from csoler/v0.6-Collection

fixed bug showing peers offline when status service is remotely disabled
This commit is contained in:
csoler 2024-06-13 21:38:01 +02:00 committed by GitHub
commit 2fb9b3eb46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -413,17 +413,28 @@ QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) con
{ {
switch(fmpe.type) switch(fmpe.type)
{ {
case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup)); case ENTRY_TYPE_GROUP: return QVariant(QBrush(mTextColorGroup));
case ENTRY_TYPE_PROFILE: case ENTRY_TYPE_PROFILE: return QVariant(QBrush(mTextColorStatus[onlineRole(fmpe,column).toInt()]));
case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[onlineRole(fmpe,column).toInt()])); case ENTRY_TYPE_NODE: return QVariant(QBrush(mTextColorStatus[statusRole(fmpe,column).toInt()]));
default: default:
return QVariant(); 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 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 QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
{ {
switch(e.type) switch(e.type)
@ -585,13 +599,10 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
{ {
const HierarchicalNodeInformation *node = getNodeInfo(e); const HierarchicalNodeInformation *node = getNodeInfo(e);
if(node) if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED))
{ return QVariant(RS_STATUS_ONLINE);
StatusInfo status; else
rsStatus->getStatus(node->node_info.id, status); return QVariant(RS_STATUS_OFFLINE);
return QVariant(status.status);
}
} }
} }
return QVariant(RS_STATUS_OFFLINE); return QVariant(RS_STATUS_OFFLINE);
@ -626,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 QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
{ {
#ifdef DEBUG_MODEL_INDEX #ifdef DEBUG_MODEL_INDEX
@ -750,7 +755,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
else else
{ {
return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n" return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n"
+ "(" + StatusDefs::name(onlineRole(e,col).toInt()) + ")"); + "(" + StatusDefs::name(statusRole(e,col).toInt()) + ")");
} }
else else
return QVariant(QString::fromUtf8(node->node_info.location.c_str())); return QVariant(QString::fromUtf8(node->node_info.location.c_str()));