From 65f2d26651d2e45b1f040f42256079d55b786689 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 25 Nov 2018 21:12:26 +0100 Subject: [PATCH] fixed author tooltip in ForumModel --- .../src/gui/gxsforums/GxsForumModel.cpp | 45 ++++++++++++++----- .../gui/gxsforums/GxsForumThreadWidget.cpp | 3 ++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 62413404f..f79ecddf3 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -4,7 +4,9 @@ #include #include "util/qtthreadsutils.h" +#include "util/HandleRichText.h" #include "util/DateTime.h" +#include "gui/gxs/GxsIdDetails.h" #include "GxsForumModel.h" #include "retroshare/rsgxsflags.h" #include "retroshare/rsgxsforums.h" @@ -333,18 +335,36 @@ QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int column QVariant RsGxsForumModel::toolTipRole(const ForumModelPostEntry& fmpe,int column) const { - if(column != COLUMN_THREAD_DISTRIBUTION) - return QVariant(); + if(column == COLUMN_THREAD_DISTRIBUTION) + switch(fmpe.mReputationWarningLevel) + { + case 3: return QVariant(tr("Information for this identity is currently missing.")) ; + case 2: return QVariant(tr("You have banned this ID. The message will not be\ndisplayed nor forwarded to your friends.")) ; + case 1: return QVariant(tr("You have not set an opinion for this person,\n and your friends do not vote positively: Spam regulation \nprevents the message to be forwarded to your friends.")) ; + case 0: return QVariant(tr("Message will be forwarded to your friends.")) ; + default: + return QVariant("[ERROR: missing reputation level information - contact the developers]"); + } - switch(fmpe.mReputationWarningLevel) - { - case 3: return QVariant(tr("Information for this identity is currently missing.")) ; - case 2: return QVariant(tr("You have banned this ID. The message will not be\ndisplayed nor forwarded to your friends.")) ; - case 1: return QVariant(tr("You have not set an opinion for this person,\n and your friends do not vote positively: Spam regulation \nprevents the message to be forwarded to your friends.")) ; - case 0: return QVariant(tr("Message will be forwarded to your friends.")) ; - default: - return QVariant("[ERROR: missing reputation level information - contact the developers]"); - } + if(column == COLUMN_THREAD_AUTHOR) + { + QString str,comment ; + QList icons; + + if(!GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR)) + return QVariant(); + + int S = QFontMetricsF(QApplication::font()).height(); + QImage pix( (*icons.begin()).pixmap(QSize(4*S,4*S)).toImage()); + + QString embeddedImage; + if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S)) + comment = "
" + embeddedImage + "" + comment + "
"; + + return comment; + } + + return QVariant(); } QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int column) const @@ -474,8 +494,9 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector