mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
commit
afc4096740
@ -54,7 +54,9 @@ bool AvatarDefs::getAvatarFromSslId(const RsPeerId& sslId, QPixmap &avatar, cons
|
||||
/* get avatar */
|
||||
rsMsgs->getAvatarData(RsPeerId(sslId), data, size);
|
||||
if (size == 0) {
|
||||
if (!defaultImage.isEmpty()) {
|
||||
avatar = FilesDefs::getPixmapFromQtResourcePath(defaultImage);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
@ -931,23 +986,28 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
||||
{
|
||||
if(!isProfileExpanded(entry))
|
||||
{
|
||||
QPixmap sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE);
|
||||
QPixmap sslOverlayIcon;
|
||||
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(onlineRole(entry,col).toInt()));
|
||||
|
||||
QPixmap sslAvatar;
|
||||
|
||||
const HierarchicalProfileInformation *hn = getProfileInfo(entry);
|
||||
|
||||
for(uint32_t i=0;i<hn->child_node_indices.size();++i)
|
||||
if(AvatarDefs::getAvatarFromSslId(RsPeerId(mLocations[hn->child_node_indices[i]].node_info.id.toStdString()), sslAvatar))
|
||||
if (mDisplayStatusIcon)
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
for(uint32_t i=0;i<hn->child_node_indices.size();++i) {
|
||||
if(AvatarDefs::getAvatarFromSslId(RsPeerId(mLocations[hn->child_node_indices[i]].node_info.id.toStdString()), sslAvatar, "")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mDisplayStatusIcon)
|
||||
if (sslAvatar.isNull()) {
|
||||
sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE);
|
||||
}
|
||||
|
||||
if (mDisplayStatusIcon) {
|
||||
uint32_t status;
|
||||
if (getProfileStatus(hn, status)) {
|
||||
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(status));
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
|
||||
@ -962,13 +1022,12 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
||||
return QVariant();
|
||||
|
||||
QPixmap sslAvatar;
|
||||
QPixmap sslOverlayIcon;
|
||||
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry,col).toInt()));
|
||||
|
||||
AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar);
|
||||
if (mDisplayStatusIcon)
|
||||
if (mDisplayStatusIcon) {
|
||||
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt()));
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
}
|
||||
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
default: return QVariant();
|
||||
|
@ -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