Optimized load of forums by moving the avatar handling for the tooltip to the tooltip creation.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8552 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-06-24 19:27:52 +00:00
parent 89187bd453
commit da8b6cbae1
2 changed files with 39 additions and 14 deletions

View File

@ -52,7 +52,6 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
return;
}
QString toolTip;
QList<QIcon> icons;
switch (type) {
@ -73,9 +72,9 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
item->processResult(true);
break;
}
toolTip = GxsIdDetails::getComment(details);
int column = item->idColumn();
item->setToolTip(column, GxsIdDetails::getComment(details));
item->setText(column, GxsIdDetails::getNameForType(type, details));
item->setData(column, Qt::UserRole, QString::fromStdString(details.mId.toStdString()));
@ -85,17 +84,7 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde
GxsIdDetails::GenerateCombinedPixmap(combinedPixmap, icons, 16);
}
item->setData(column, Qt::DecorationRole, combinedPixmap);
QImage pix ;
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
pix = GxsIdDetails::makeDefaultIcon(details.mId);
QString embeddedImage ;
if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(64,64),Qt::KeepAspectRatio,Qt::SmoothTransformation),embeddedImage,128*128))
toolTip = "<table><tr><td>"+embeddedImage+"</td><td>" +toolTip+ "</td></table>" ;
item->setToolTip(column, toolTip);
item->setAvatar(details.mAvatar);
}
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenFailed)
@ -142,3 +131,34 @@ void GxsIdRSTreeWidgetItem::processResult(bool success)
connect(rApp, SIGNAL(minuteTick()), this, SLOT(startProcess()));
}
}
void GxsIdRSTreeWidgetItem::setAvatar(const RsGxsImage &avatar)
{
mAvatar = avatar;
}
QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
{
if (column == idColumn()) {
switch (role) {
case Qt::ToolTipRole:
{
QString t = RSTreeWidgetItem::data(column, role).toString();
QImage pix;
if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) {
pix = GxsIdDetails::makeDefaultIcon(mId);
}
QString embeddedImage;
if (RsHtml::makeEmbeddedImage(pix.scaled(QSize(64,64), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 128 * 128)) {
t = "<table><tr><td>" + embeddedImage + "</td><td>" + t + "</td></table>";
}
return t;
}
}
}
return RSTreeWidgetItem::data(column, role);
}

View File

@ -46,9 +46,13 @@ public:
void setId(const RsGxsId &id, int column, bool retryWhenFailed);
bool getId(RsGxsId &id);
int idColumn() { return mColumn; }
int idColumn() const { return mColumn; }
void processResult(bool success);
uint32_t iconTypeMask() const { return mIconTypeMask ;}
void setAvatar(const RsGxsImage &avatar);
virtual QVariant data(int column, int role) const;
private slots:
void startProcess();
@ -60,6 +64,7 @@ private:
bool mIdFound;
bool mRetryWhenFailed;
uint32_t mIconTypeMask;
RsGxsImage mAvatar;
};
#endif