mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed show best status icon for profile
This commit is contained in:
parent
c8975bb2e9
commit
2c3b0a1c44
@ -898,6 +898,61 @@ bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const
|
||||
return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED));
|
||||
}
|
||||
|
||||
bool RsFriendListModel::getProfileStatus(const HierarchicalProfileInformation *profileInfo, uint32_t &status) const
|
||||
{
|
||||
status = RS_STATUS_OFFLINE;
|
||||
|
||||
if (!profileInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int bestStatusIndex = 0;
|
||||
|
||||
/* Find the best status */
|
||||
for (uint32_t i = 0; i < profileInfo->child_node_indices.size(); ++i) {
|
||||
StatusInfo statusInfo;
|
||||
rsStatus->getStatus(mLocations[profileInfo->child_node_indices[i]].node_info.id, statusInfo);
|
||||
|
||||
int statusIndex = 0;
|
||||
switch (statusInfo.status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
statusIndex = 1;
|
||||
break;
|
||||
|
||||
case RS_STATUS_INACTIVE:
|
||||
statusIndex = 2;
|
||||
break;
|
||||
|
||||
case RS_STATUS_AWAY:
|
||||
statusIndex = 3;
|
||||
break;
|
||||
|
||||
case RS_STATUS_BUSY:
|
||||
statusIndex = 4;
|
||||
break;
|
||||
|
||||
case RS_STATUS_ONLINE:
|
||||
statusIndex = 5;
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cerr << "FriendListModel: Unknown status " << statusInfo.status << std::endl;
|
||||
}
|
||||
|
||||
if (bestStatusIndex == 0 || statusIndex > bestStatusIndex) {
|
||||
/* first status or better status */
|
||||
bestStatusIndex = statusIndex;
|
||||
status = statusInfo.status;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestStatusIndex == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) const
|
||||
{
|
||||
if(col > 0)
|
||||
@ -946,9 +1001,12 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
||||
}
|
||||
|
||||
if (mDisplayStatusIcon) {
|
||||
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(onlineRole(entry, col).toInt()));
|
||||
uint32_t status;
|
||||
if (getProfileStatus(hn, status)) {
|
||||
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(status));
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
|
@ -223,6 +223,8 @@ private:
|
||||
|
||||
uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings);
|
||||
|
||||
bool getProfileStatus(const HierarchicalProfileInformation *profileInfo, uint32_t &status) const;
|
||||
|
||||
QStringList mFilterStrings;
|
||||
FilterType mFilterType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user