Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 11 additions & 9 deletions retroshare-gui/src/gui/gxs/GxsIdDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]");
Expand All @@ -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) ;

Expand Down Expand Up @@ -1134,6 +1132,10 @@ QString nickname ;
if(details.mReputation.mFriendsPositiveVotes > 0) comment += " <b>+" + QString::number(details.mReputation.mFriendsPositiveVotes) + "</b>";
if(details.mReputation.mFriendsNegativeVotes > 0) comment += " <b>-" + QString::number(details.mReputation.mFriendsNegativeVotes) + "</b>";
}
if(details.mReputation.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE)
comment += QString("<br/>" + tr("Negative (Banned by you)") );
if(details.mReputation.mOverallReputationLevel == RsReputationLevel::REMOTELY_NEGATIVE)
comment += QString("<br/>" + tr("Negative (according to your friends)") );
return comment;
}

Expand Down Expand Up @@ -1166,13 +1168,13 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &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)) ;
Expand Down
56 changes: 47 additions & 9 deletions retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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;

Expand All @@ -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();
}
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -70,7 +73,6 @@ private slots:
RsGxsId mId;
int mColumn;
bool mIdFound;
bool mBannedState ;
bool mRetryWhenFailed;
bool mAutoTooltip;
RsReputationLevel mReputationLevel;
Expand Down