diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 3b92883e86..ae7e7744e2 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -632,6 +632,8 @@ void ChatLobbyDialog::updateParticipantsList() if(isParticipantMuted(it2->first)) widgetitem->setIcon(COLUMN_ICON, bullet_red_128); + else if(widgetitem->mBannedState) + { /* icon set in GxsIdTreeWidgetItem */ } else if (tLastAct + timeToInactivity < now) widgetitem->setIcon(COLUMN_ICON, bullet_grey_128); else if (tLastAct + timeToInactivity2 < now) diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index b1961a6e6c..8f03cdc8af 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -1019,7 +1019,8 @@ QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDeta return getName(details); case GXS_ID_DETAILS_TYPE_BANNED: - return tr("[Banned]") ; + //return tr("[Banned]") ; + return getName(details); case GXS_ID_DETAILS_TYPE_FAILED: return getFailedText(details.mId); @@ -1073,8 +1074,9 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi QString GxsIdDetails::getName(const RsIdentityDetails &details) { - if( details.mReputation.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE ) - return tr("[Banned]"); + /*if( details.mReputation.mOverallReputationLevel == + RsReputationLevel::LOCALLY_NEGATIVE ) + return tr("[Banned]");*/ if( details.mId.isNull() ) return tr("[Nobody]"); @@ -1095,13 +1097,9 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details) QString comment; QString nickname ; - bool banned = ( details.mReputation.mOverallReputationLevel == - RsReputationLevel::LOCALLY_NEGATIVE ); if(details.mNickname.empty()) nickname = tr("[Unknown]") ; - else if(banned) - nickname = tr("[Banned]") ; else nickname = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE) ; @@ -1134,6 +1132,10 @@ QString nickname ; if(details.mReputation.mFriendsPositiveVotes > 0) comment += " +" + QString::number(details.mReputation.mFriendsPositiveVotes) + ""; if(details.mReputation.mFriendsNegativeVotes > 0) comment += " -" + QString::number(details.mReputation.mFriendsNegativeVotes) + ""; } + if(details.mReputation.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE) + comment += QString("
" + tr("Negative (Banned by you)") ); + if(details.mReputation.mOverallReputationLevel == RsReputationLevel::REMOTELY_NEGATIVE) + comment += QString("
" + tr("Negative (according to your friends)") ); return comment; } @@ -1166,13 +1168,13 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon { QPixmap pix ; - if( details.mReputation.mOverallReputationLevel == + /*if( details.mReputation.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE ) { icons.clear() ; icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_BANNED)) ; return ; - } + }*/ if(icon_types & ICON_TYPE_REPUTATION) icons.push_back(getReputationIcon(details.mReputation.mOverallReputationLevel,minimal_required_reputation)) ; diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 97f1284476..aceb924070 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -23,7 +23,9 @@ #include "GxsIdDetails.h" #include "util/HandleRichText.h" -#define BANNED_IMAGE ":/icons/yellow_biohazard64.png" +#define BANNED_IMAGE ":/icons/biohazard_yellow.png" +#define BANNED_IMAGE_RED ":/icons/biohazard_red.png" +#define COLUMN_ICON 3 // ChatLobbyDialog /** Constructor */ GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,bool auto_tooltip,QTreeWidget *parent) @@ -66,9 +68,10 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde item->processResult(true); break; - case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(FilesDefs::getIconFromQtResourcePath("BANNED_IMAGE")) ; - break ; + case GXS_ID_DETAILS_TYPE_BANNED: + GxsIdDetails::getIcons(details, icons, item->iconTypeMask()); + item->processResult(true); + break ; } int column = item->idColumn(); @@ -85,6 +88,33 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde } item->setData(column, Qt::DecorationRole, combinedPixmap); item->setAvatar(details.mAvatar); + + if(rsReputations->overallReputationLevel(details.mId) == RsReputationLevel::LOCALLY_NEGATIVE) + { + QFont font; + font = item->font(column); + font.setStrikeOut(true); + item->setFont(column, font); + item->setBannedState(true); + item->setIcon(COLUMN_ICON, QIcon(BANNED_IMAGE_RED)); + } + else if(rsReputations->overallReputationLevel(details.mId) == RsReputationLevel::REMOTELY_NEGATIVE) + { + QFont font; + font = item->font(column); + font.setStrikeOut(true); + item->setFont(column, font); + item->setBannedState(true); + item->setIcon(COLUMN_ICON, QIcon(BANNED_IMAGE)); + } + else + { + QFont font; + font = item->font(column); + font.setStrikeOut(false); + item->setFont(column, font); + item->setBannedState(false); + } } void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenFailed) @@ -95,7 +125,7 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF if (mIdFound && mColumn == column && mId == id && (mBannedState == rsReputations->isIdentityBanned(mId))) return; - mBannedState = rsReputations->isIdentityBanned(mId); + mBannedState = isBanned(mId); mIdFound = false; mRetryWhenFailed = retryWhenFailed; @@ -105,16 +135,24 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF startProcess(); } +bool GxsIdRSTreeWidgetItem::isBanned(const RsGxsId &id) +{ + RsReputationLevel overall = rsReputations->overallReputationLevel(id); + if(overall == RsReputationLevel::REMOTELY_NEGATIVE || overall == RsReputationLevel::LOCALLY_NEGATIVE) + return true; + return false; +} + void GxsIdRSTreeWidgetItem::updateBannedState() { - if(mBannedState != rsReputations->isIdentityBanned(mId)) + if(mBannedState != isBanned(mId)) forceUpdate() ; } void GxsIdRSTreeWidgetItem::forceUpdate() { mIdFound = false; - mBannedState = (rsReputations->isIdentityBanned(mId)); + mBannedState = isBanned(mId); startProcess(); } @@ -160,8 +198,8 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const if(mId.isNull()) return RSTreeWidgetItem::data(column, role); - else if( rsReputations->overallReputationLevel(mId) == RsReputationLevel::LOCALLY_NEGATIVE ) - pix = FilesDefs::getPixmapFromQtResourcePath(BANNED_IMAGE); + //else if( rsReputations->overallReputationLevel(mId) == RsReputationLevel::LOCALLY_NEGATIVE ) + //pix = FilesDefs::getPixmapFromQtResourcePath(BANNED_IMAGE); else if ( mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(mAvatar.mData, mAvatar.mSize, pix,GxsIdDetails::LARGE) ) pix = GxsIdDetails::makeDefaultIcon(mId,GxsIdDetails::LARGE); diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index 1f38ecf04d..5b22bc0e59 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -61,6 +61,9 @@ class GxsIdRSTreeWidgetItem : public QObject, public RSTreeWidgetItem void updateBannedState() ; // checks reputation, and update is needed bool autoTooltip() const { return mAutoTooltip; } + bool mBannedState ; + bool isBanned(const RsGxsId &id); + private slots: void startProcess(); @@ -70,7 +73,6 @@ private slots: RsGxsId mId; int mColumn; bool mIdFound; - bool mBannedState ; bool mRetryWhenFailed; bool mAutoTooltip; RsReputationLevel mReputationLevel;