mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-12 01:09:26 -04:00
Optimized avatar loading in RsFriendListModel
This commit is contained in:
parent
19d613edcc
commit
c8975bb2e9
2 changed files with 23 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -931,23 +931,25 @@ 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) {
|
||||
QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(onlineRole(entry, col).toInt()));
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
}
|
||||
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
|
||||
|
@ -962,13 +964,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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue