diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 056744060..13c73cfb3 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -52,7 +52,6 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde return; } - QString toolTip; QList 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 = "
"+embeddedImage+"" +toolTip+ "
" ; - - 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 = "
" + embeddedImage + "" + t + "
"; + } + + return t; + } + } + } + + return RSTreeWidgetItem::data(column, role); +} diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index 53a408878..faf9767f8 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -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