mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
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:
parent
89187bd453
commit
da8b6cbae1
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user