From 2bb9becbec88d2fbb0309f472675ccebb58b76bf Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Mon, 1 Feb 2021 11:47:21 +0300 Subject: [PATCH] Identities list - different color circle for people who has downvotes --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 1 + retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 24 ++++++++++++++++---- retroshare-gui/src/gui/gxs/GxsIdDetails.h | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 4e319860b..7b6053021 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1427,6 +1427,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, item->setData( RSID_COL_VOTES,SortRole, static_cast(idd.mReputation.mOverallReputationLevel)); + item->setData(RSID_COL_VOTES,Qt::UserRole,idd.mReputation.mFriendsNegativeVotes>0); if(isOwnId) { diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index a7d050dd5..9c67dfad8 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -56,6 +56,8 @@ #define REPUTATION_REMOTELY_NEGATIVE_ICON ":/icons/biohazard_yellow.png" #define REPUTATION_LOCALLY_NEGATIVE_ICON ":/icons/biohazard_red.png" #define REPUTATION_VOID ":/icons/void_128.png" +#define REPUTATION_HAS_DOWNVOTES ":/icons/bullet_yellow_128.png" +#define REPUTATION_HAS_DOWNVOTES_NEUTRAL ":/icons/bullet_red_128.png" #define TIMER_INTERVAL 500 #define MAX_ATTEMPTS 10 @@ -95,11 +97,13 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem // get pixmap unsigned int icon_index = qvariant_cast(index.data(Qt::DecorationRole)); + bool downvoted = qvariant_cast(index.data(Qt::UserRole)); + if(icon_index > mMaxLevelToDisplay) return ; QIcon icon = GxsIdDetails::getReputationIcon( - RsReputationLevel(icon_index), 0xff ); + RsReputationLevel(icon_index), 0xff, downvoted ); QPixmap pix = icon.pixmap(r.size()); @@ -1081,7 +1085,7 @@ QString nickname ; } QIcon GxsIdDetails::getReputationIcon( - RsReputationLevel icon_index, uint32_t min_reputation ) + RsReputationLevel icon_index, uint32_t min_reputation,bool has_downvotes ) { if( static_cast(icon_index) >= min_reputation ) return FilesDefs::getIconFromQtResourcePath(REPUTATION_VOID); @@ -1093,11 +1097,21 @@ QIcon GxsIdDetails::getReputationIcon( case RsReputationLevel::LOCALLY_POSITIVE: return FilesDefs::getIconFromQtResourcePath(REPUTATION_LOCALLY_POSITIVE_ICON); case RsReputationLevel::REMOTELY_POSITIVE: - return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_POSITIVE_ICON); + { + if(has_downvotes) + return FilesDefs::getIconFromQtResourcePath(REPUTATION_HAS_DOWNVOTES); + else + return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_POSITIVE_ICON); + } case RsReputationLevel::REMOTELY_NEGATIVE: return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_NEGATIVE_ICON); case RsReputationLevel::NEUTRAL: - return FilesDefs::getIconFromQtResourcePath(REPUTATION_NEUTRAL_ICON); + { + if(has_downvotes) + return FilesDefs::getIconFromQtResourcePath(REPUTATION_HAS_DOWNVOTES_NEUTRAL); + else + return FilesDefs::getIconFromQtResourcePath(REPUTATION_NEUTRAL_ICON); + } default: std::cerr << "Asked for unidentified icon index " << static_cast(icon_index) << std::endl; @@ -1118,7 +1132,7 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon } if(icon_types & ICON_TYPE_REPUTATION) - icons.push_back(getReputationIcon(details.mReputation.mOverallReputationLevel,minimal_required_reputation)) ; + icons.push_back(getReputationIcon(details.mReputation.mOverallReputationLevel,minimal_required_reputation,details.mReputation.mFriendsNegativeVotes>0)) ; if(icon_types & ICON_TYPE_AVATAR) { diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.h b/retroshare-gui/src/gui/gxs/GxsIdDetails.h index 3c04c46eb..26e4258a8 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.h +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.h @@ -105,7 +105,7 @@ public: static QIcon getLoadingIcon(const RsGxsId &id); static QIcon getReputationIcon( - RsReputationLevel icon_index, uint32_t min_reputation ); + RsReputationLevel icon_index, uint32_t min_reputation, bool has_downvotes ); static void GenerateCombinedPixmap(QPixmap &pixmap, const QList &icons, int iconSize);