added display of reputation in forums

This commit is contained in:
csoler 2016-12-24 14:13:02 +01:00
parent e5e59098ac
commit 873c0e60df
7 changed files with 37 additions and 35 deletions

View File

@ -106,12 +106,6 @@
#define IMAGE_ADMIN ":/icons/bullet_blue_128.png"
#define IMAGE_INFO ":/images/info16.png"
#define REPUTATION_LOCALLY_POSITIVE_ICON ":/icons/bullet_green_yellow_star_128.png"
#define REPUTATION_REMOTELY_POSITIVE_ICON ":/icons/bullet_green_128.png"
#define REPUTATION_NEUTRAL_ICON ":/icons/bullet_grey_128.png"
#define REPUTATION_REMOTELY_NEGATIVE_ICON ":/icons/yellow_biohazard64.png"
#define REPUTATION_LOCALLY_NEGATIVE_ICON ":/icons/red_biohazard64.png"
// comment this out in order to remove the sorting of circles into "belong to" and "other visible circles"
#define CIRCLE_MEMBERSHIP_CATEGORIES 1
@ -162,18 +156,7 @@ public:
if(icon_index > 4)
return ;
QIcon icon ;
switch(icon_index)
{
case RsReputations::REPUTATION_LOCALLY_NEGATIVE: icon = QIcon(REPUTATION_LOCALLY_NEGATIVE_ICON) ; break ;
case RsReputations::REPUTATION_LOCALLY_POSITIVE: icon = QIcon(REPUTATION_LOCALLY_POSITIVE_ICON) ; break ;
case RsReputations::REPUTATION_REMOTELY_POSITIVE: icon = QIcon(REPUTATION_REMOTELY_POSITIVE_ICON) ; break ;
case RsReputations::REPUTATION_REMOTELY_NEGATIVE: icon = QIcon(REPUTATION_REMOTELY_NEGATIVE_ICON) ; break ;
case RsReputations::REPUTATION_NEUTRAL: icon = QIcon(REPUTATION_NEUTRAL_ICON) ; break ;
default:
return ; // dont draw anything
}
QIcon icon = GxsIdDetails::getReputationIcon(RsReputations::ReputationLevel(icon_index));
QPixmap pix = icon.pixmap(r.size());
@ -198,7 +181,7 @@ IdDialog::IdDialog(QWidget *parent) :
ownItem = new QTreeWidgetItem();
ownItem->setText(0, tr("My own identities"));
ownItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff);
ownItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); // this is in order to prevent displaying a reputaiton icon next to these items.
allItem = new QTreeWidgetItem();
allItem->setText(0, tr("All"));

View File

@ -418,7 +418,7 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
std::cerr << std::endl;
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL) ;
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_ALL) ;
QString text;
{

View File

@ -48,6 +48,12 @@
#define IMAGE_DEV_PATCHER ":/images/tags/dev-patcher.png"
#define IMAGE_DEV_DEVELOPER ":/images/tags/developer.png"
#define REPUTATION_LOCALLY_POSITIVE_ICON ":/icons/bullet_green_yellow_star_128.png"
#define REPUTATION_REMOTELY_POSITIVE_ICON ":/icons/bullet_green_128.png"
#define REPUTATION_NEUTRAL_ICON ":/icons/bullet_grey_128.png"
#define REPUTATION_REMOTELY_NEGATIVE_ICON ":/icons/yellow_biohazard64.png"
#define REPUTATION_LOCALLY_NEGATIVE_ICON ":/icons/red_biohazard64.png"
#define TIMER_INTERVAL 500
#define MAX_ATTEMPTS 10
#define MAX_PROCESS_COUNT_PER_TIMER 50
@ -958,6 +964,21 @@ QString nickname ;
return comment;
}
QIcon GxsIdDetails::getReputationIcon(RsReputations::ReputationLevel icon_index)
{
switch(icon_index)
{
case RsReputations::REPUTATION_LOCALLY_NEGATIVE: return QIcon(REPUTATION_LOCALLY_NEGATIVE_ICON) ; break ;
case RsReputations::REPUTATION_LOCALLY_POSITIVE: return QIcon(REPUTATION_LOCALLY_POSITIVE_ICON) ; break ;
case RsReputations::REPUTATION_REMOTELY_POSITIVE: return QIcon(REPUTATION_REMOTELY_POSITIVE_ICON) ; break ;
case RsReputations::REPUTATION_REMOTELY_NEGATIVE: return QIcon(REPUTATION_REMOTELY_NEGATIVE_ICON) ; break ;
case RsReputations::REPUTATION_NEUTRAL: return QIcon(REPUTATION_NEUTRAL_ICON) ; break ;
default:
std::cerr << "Asked for unidentified icon index " << icon_index << std::endl;
return QIcon(); // dont draw anything
}
}
void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icons,uint32_t icon_types)
{
QPixmap pix ;
@ -969,6 +990,10 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
return ;
}
if(icon_types & ICON_TYPE_REPUTATION)
icons.push_back(getReputationIcon(details.mReputation.mOverallReputationLevel)) ;
if(icon_types & ICON_TYPE_AVATAR)
{
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))

View File

@ -50,11 +50,11 @@ class GxsIdDetails : public QObject
Q_OBJECT
public:
static const int ICON_TYPE_AVATAR = 0x0001 ;
static const int ICON_TYPE_PGP = 0x0002 ;
static const int ICON_TYPE_RECOGN = 0x0004 ;
static const int ICON_TYPE_ALL = 0x0007 ;
static const int ICON_TYPE_REDACTED= 0x0008 ;
static const int ICON_TYPE_AVATAR = 0x0001 ;
static const int ICON_TYPE_PGP = 0x0002 ;
static const int ICON_TYPE_RECOGN = 0x0004 ;
static const int ICON_TYPE_REPUTATION = 0x0008 ;
static const int ICON_TYPE_ALL = 0x000f ;
GxsIdDetails();
virtual ~GxsIdDetails();
@ -76,6 +76,7 @@ public:
static QString getNameForType(GxsIdDetailsType type, const RsIdentityDetails &details);
static QIcon getLoadingIcon(const RsGxsId &id);
static QIcon getReputationIcon(RsReputations::ReputationLevel icon_index);
static void GenerateCombinedPixmap(QPixmap &pixmap, const QList<QIcon> &icons, int iconSize);

View File

@ -35,12 +35,6 @@ GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *
init();
}
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidgetItem *parent)
: QObject(NULL), RSTreeWidgetItem(compareRole, parent), mColumn(0), mIconTypeMask(icon_mask)
{
init();
}
void GxsIdRSTreeWidgetItem::init()
{
mIdFound = false;

View File

@ -40,8 +40,7 @@ class GxsIdRSTreeWidgetItem : public QObject, public RSTreeWidgetItem
Q_OBJECT
public:
GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask=GxsIdDetails::ICON_TYPE_ALL,QTreeWidget *parent = NULL);
GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidgetItem *parent);
GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidget *parent = NULL);
void setId(const RsGxsId &id, int column, bool retryWhenFailed);
bool getId(RsGxsId &id);

View File

@ -1000,7 +1000,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
bool redacted = (reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ;
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_REPUTATION | GxsIdDetails::ICON_TYPE_AVATAR );
item->moveToThread(ui->threadTreeWidget->thread());
if(redacted)
@ -1096,7 +1096,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
QTreeWidgetItem *GxsForumThreadWidget::generateMissingItem(const RsGxsMessageId &msgId)
{
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL);
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_REPUTATION | GxsIdDetails::ICON_TYPE_AVATAR);
item->setText(COLUMN_THREAD_TITLE, tr("[ ... Missing Message ... ]"));
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgId.toStdString()));