From 5ff4ebbd12fa6049a5a1c98dce6d00fbabd25685 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 16 Feb 2019 11:42:22 -0300 Subject: [PATCH] Fix retroshare-gui compilation after RsReputations refactoring --- .../src/gui/Identity/IdDetailsDialog.cpp | 69 +++++++----- retroshare-gui/src/gui/Identity/IdDialog.cpp | 105 ++++++++++-------- .../src/gui/chat/ChatLobbyDialog.cpp | 25 +++-- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 40 ++++--- retroshare-gui/src/gui/gxs/GxsIdDetails.h | 6 +- .../src/gui/gxs/GxsIdTreeWidgetItem.cpp | 46 ++++---- .../src/gui/gxs/GxsIdTreeWidgetItem.h | 2 +- .../src/gui/gxsforums/GxsForumModel.cpp | 14 ++- .../src/gui/gxsforums/GxsForumModel.h | 2 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 27 +++-- .../src/gui/settings/PeoplePage.cpp | 8 +- 11 files changed, 199 insertions(+), 145 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index 98b8a0d91..58378a656 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -285,7 +285,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) #endif - RsReputations::ReputationInfo info ; + RsReputationInfo info; rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ; #warning (csoler) Do we need to do this? This code is apparently not used. @@ -302,23 +302,34 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) ui->label_positive->setText(QString::number(info.mFriendsPositiveVotes)); ui->label_negative->setText(QString::number(info.mFriendsNegativeVotes)); - switch(info.mOverallReputationLevel) - { - case RsReputations::REPUTATION_LOCALLY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive")) ; break ; - case RsReputations::REPUTATION_LOCALLY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")) ; break ; - case RsReputations::REPUTATION_REMOTELY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive (according to your friends)")) ; break ; - case RsReputations::REPUTATION_REMOTELY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (according to your friends)")) ; break ; - default: - case RsReputations::REPUTATION_NEUTRAL: ui->overallOpinion_TF->setText(tr("Neutral")) ; break ; - } - - switch(info.mOwnOpinion) + switch(info.mOverallReputationLevel) { - case RsReputations::OPINION_NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break ; - case RsReputations::OPINION_NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break ; - case RsReputations::OPINION_POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break ; - default: - std::cerr << "Unexpected value in own opinion: " << info.mOwnOpinion << std::endl; + case RsReputationLevel::LOCALLY_POSITIVE: + ui->overallOpinion_TF->setText(tr("Positive")); break; + case RsReputationLevel::LOCALLY_NEGATIVE: + ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")); break; + case RsReputationLevel::REMOTELY_POSITIVE: + ui->overallOpinion_TF->setText( + tr("Positive (according to your friends)")); + break; + case RsReputationLevel::REMOTELY_NEGATIVE: + ui->overallOpinion_TF->setText( + tr("Negative (according to your friends)")); + break; + case RsReputationLevel::NEUTRAL: // fallthrough + default: + ui->overallOpinion_TF->setText(tr("Neutral")); break; + } + + switch(info.mOwnOpinion) + { + case RsOpinion::NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break; + case RsOpinion::NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break; + case RsOpinion::POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break; + default: + std::cerr << "Unexpected value in own opinion: " + << static_cast(info.mOwnOpinion) << std::endl; + break; } } @@ -330,19 +341,19 @@ void IdDetailsDialog::modifyReputation() #endif RsGxsId id(ui->lineEdit_KeyId->text().toStdString()); - - RsReputations::Opinion op ; - switch(ui->ownOpinion_CB->currentIndex()) - { - case 0: op = RsReputations::OPINION_NEGATIVE ; break ; - case 1: op = RsReputations::OPINION_NEUTRAL ; break ; - case 2: op = RsReputations::OPINION_POSITIVE ; break ; - default: - std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl; - - } - rsReputations->setOwnOpinion(id,op) ; + RsOpinion op; + + switch(ui->ownOpinion_CB->currentIndex()) + { + case 0: op = RsOpinion::NEGATIVE; break; + case 1: op = RsOpinion::NEUTRAL ; break; + case 2: op = RsOpinion::POSITIVE; break; + default: + std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl; + break; + } + rsReputations->setOwnOpinion(id,op); #ifdef ID_DEBUG std::cerr << "IdDialog::modifyReputation() ID: " << id << " Mod: " << mod; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 0f6817067..703405bb0 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -344,7 +344,9 @@ IdDialog::IdDialog(QWidget *parent) : ui->idTreeWidget->setColumnWidth(RSID_COL_IDTYPE, 18 * fontWidth); ui->idTreeWidget->setColumnWidth(RSID_COL_VOTES, 2 * fontWidth); - ui->idTreeWidget->setItemDelegateForColumn(RSID_COL_VOTES,new ReputationItemDelegate(RsReputations::ReputationLevel(0xff))) ; + ui->idTreeWidget->setItemDelegateForColumn( + RSID_COL_VOTES, + new ReputationItemDelegate(RsReputationLevel(0xff))); /* Set header resize modes and initial section sizes */ QHeaderView * idheader = ui->idTreeWidget->header(); @@ -1444,8 +1446,9 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, RsIdentityDetails idd ; rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),idd) ; - bool isBanned = idd.mReputation.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE; - uint32_t item_flags = 0 ; + bool isBanned = idd.mReputation.mOverallReputationLevel == + RsReputationLevel::LOCALLY_NEGATIVE; + uint32_t item_flags = 0; /* do filtering */ bool ok = false; @@ -1514,8 +1517,12 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ; item->setTextAlignment(RSID_COL_VOTES, Qt::AlignRight | Qt::AlignVCenter); - item->setData(RSID_COL_VOTES,Qt::DecorationRole, idd.mReputation.mOverallReputationLevel); - item->setData(RSID_COL_VOTES,SortRole, idd.mReputation.mOverallReputationLevel); + item->setData( + RSID_COL_VOTES,Qt::DecorationRole, + static_cast(idd.mReputation.mOverallReputationLevel)); + item->setData( + RSID_COL_VOTES,SortRole, + static_cast(idd.mReputation.mOverallReputationLevel)); if(isOwnId) { @@ -1910,7 +1917,7 @@ void IdDialog::insertIdDetails(uint32_t token) #endif - RsReputations::ReputationInfo info ; + RsReputationInfo info; rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ; QString frep_string ; @@ -1925,23 +1932,32 @@ void IdDialog::insertIdDetails(uint32_t token) ui->label_positive->setText(QString::number(info.mFriendsPositiveVotes)); ui->label_negative->setText(QString::number(info.mFriendsNegativeVotes)); - switch(info.mOverallReputationLevel) - { - case RsReputations::REPUTATION_LOCALLY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive")) ; break ; - case RsReputations::REPUTATION_LOCALLY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")) ; break ; - case RsReputations::REPUTATION_REMOTELY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive (according to your friends)")) ; break ; - case RsReputations::REPUTATION_REMOTELY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (according to your friends)")) ; break ; - default: - case RsReputations::REPUTATION_NEUTRAL: ui->overallOpinion_TF->setText(tr("Neutral")) ; break ; - } - - switch(info.mOwnOpinion) + switch(info.mOverallReputationLevel) { - case RsReputations::OPINION_NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break ; - case RsReputations::OPINION_NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break ; - case RsReputations::OPINION_POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break ; - default: - std::cerr << "Unexpected value in own opinion: " << info.mOwnOpinion << std::endl; + case RsReputationLevel::LOCALLY_POSITIVE: + ui->overallOpinion_TF->setText(tr("Positive")); break; + case RsReputationLevel::LOCALLY_NEGATIVE: + ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")); break; + case RsReputationLevel::REMOTELY_POSITIVE: + ui->overallOpinion_TF->setText(tr("Positive (according to your friends)")); + break; + case RsReputationLevel::REMOTELY_NEGATIVE: + ui->overallOpinion_TF->setText(tr("Negative (according to your friends)")); + break; + case RsReputationLevel::NEUTRAL: // fallthrough + default: + ui->overallOpinion_TF->setText(tr("Neutral")) ; break ; + } + + switch(info.mOwnOpinion) + { + case RsOpinion::NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break; + case RsOpinion::NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break; + case RsOpinion::POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break; + default: + std::cerr << "Unexpected value in own opinion: " + << static_cast(info.mOwnOpinion) << std::endl; + break; } // now fill in usage cases @@ -2060,19 +2076,19 @@ void IdDialog::modifyReputation() #endif RsGxsId id(ui->lineEdit_KeyId->text().toStdString()); - - RsReputations::Opinion op ; - switch(ui->ownOpinion_CB->currentIndex()) - { - case 0: op = RsReputations::OPINION_NEGATIVE ; break ; - case 1: op = RsReputations::OPINION_NEUTRAL ; break ; - case 2: op = RsReputations::OPINION_POSITIVE ; break ; - default: - std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl; - - } - rsReputations->setOwnOpinion(id,op) ; + RsOpinion op; + + switch(ui->ownOpinion_CB->currentIndex()) + { + case 0: op = RsOpinion::NEGATIVE; break; + case 1: op = RsOpinion::NEUTRAL ; break; + case 2: op = RsOpinion::POSITIVE; break; + default: + std::cerr << "Wrong value from opinion combobox. Bug??" << std::endl; + break; + } + rsReputations->setOwnOpinion(id,op); #ifdef ID_DEBUG std::cerr << "IdDialog::modifyReputation() ID: " << id << " Mod: " << op; @@ -2386,17 +2402,12 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) switch(det.mReputation.mOwnOpinion) { - case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ; - break ; - - case RsReputations::OPINION_POSITIVE: ++n_positive_reputations ; - break ; - - case RsReputations::OPINION_NEUTRAL: ++n_neutral_reputations ; - break ; + case RsOpinion::NEGATIVE: ++n_negative_reputations; break; + case RsOpinion::POSITIVE: ++n_positive_reputations; break; + case RsOpinion::NEUTRAL: ++n_neutral_reputations; break; } - ++n_selected_items ; + ++n_selected_items; if(rsIdentity->isARegularContact(keyId)) ++n_is_a_contact ; @@ -2674,7 +2685,7 @@ void IdDialog::negativePerson() std::string Id = item->text(RSID_COL_KEYID).toStdString(); - rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEGATIVE) ; + rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::NEGATIVE); } requestIdDetails(); @@ -2690,7 +2701,7 @@ void IdDialog::neutralPerson() std::string Id = item->text(RSID_COL_KEYID).toStdString(); - rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_NEUTRAL) ; + rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::NEUTRAL); } requestIdDetails(); @@ -2703,9 +2714,9 @@ void IdDialog::positivePerson() { QTreeWidgetItem *item = *it ; - std::string Id = item->text(RSID_COL_KEYID).toStdString(); + std::string Id = item->text(RSID_COL_KEYID).toStdString(); - rsReputations->setOwnOpinion(RsGxsId(Id),RsReputations::OPINION_POSITIVE) ; + rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::POSITIVE); } requestIdDetails(); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index f31f8c456..ec2994ced 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -300,9 +300,17 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListsetEnabled(true); sendMessageAct->setEnabled(true); - votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); - voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); - voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); + votePositiveAct->setEnabled( + rsReputations->overallReputationLevel(gxsid) != + RsReputationLevel::LOCALLY_POSITIVE ); + voteNeutralAct->setEnabled( + ( rsReputations->overallReputationLevel(gxsid) == + RsReputationLevel::LOCALLY_POSITIVE ) || + ( rsReputations->overallReputationLevel(gxsid) == + RsReputationLevel::LOCALLY_NEGATIVE ) ); + voteNegativeAct->setEnabled( + rsReputations->overallReputationLevel(gxsid) != + RsReputationLevel::LOCALLY_NEGATIVE ); muteAct->setEnabled(true); muteAct->setChecked(isParticipantMuted(gxsid)); } @@ -319,16 +327,15 @@ void ChatLobbyDialog::voteParticipant() QList idList = act->data().value>(); - RsReputations::Opinion op = RsReputations::OPINION_NEUTRAL ; - if (act == votePositiveAct) - op = RsReputations::OPINION_POSITIVE; - if (act == voteNegativeAct) - op = RsReputations::OPINION_NEGATIVE; + RsOpinion op = RsOpinion::NEUTRAL; + if (act == votePositiveAct) op = RsOpinion::POSITIVE; + if (act == voteNegativeAct) op = RsOpinion::NEGATIVE; for (QList::iterator item = idList.begin(); item != idList.end(); ++item) { rsReputations->setOwnOpinion(*item, op); - std::cerr << "Giving opinion to GXS id " << *item << " to " << op << std::endl; + std::cerr << "Giving opinion to GXS id " << *item << " to " + << static_cast(op) << std::endl; } updateParticipantsList(); diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index 6168090eb..7c65e0d17 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -84,7 +84,8 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem if(icon_index > mMaxLevelToDisplay) return ; - QIcon icon = GxsIdDetails::getReputationIcon(RsReputations::ReputationLevel(icon_index),0xff); + QIcon icon = GxsIdDetails::getReputationIcon( + RsReputationLevel(icon_index), 0xff ); QPixmap pix = icon.pixmap(r.size()); @@ -937,8 +938,9 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi QString GxsIdDetails::getName(const RsIdentityDetails &details) { - if(details.mReputation.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE) - return tr("[Banned]") ; + if( details.mReputation.mOverallReputationLevel == + RsReputationLevel::LOCALLY_NEGATIVE ) + return tr("[Banned]"); QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE); @@ -956,7 +958,8 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details) QString comment; QString nickname ; - bool banned = (details.mReputation.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE); + bool banned = ( details.mReputation.mOverallReputationLevel == + RsReputationLevel::LOCALLY_NEGATIVE ); if(details.mNickname.empty()) nickname = tr("[Unknown]") ; @@ -997,19 +1000,27 @@ QString nickname ; return comment; } -QIcon GxsIdDetails::getReputationIcon(RsReputations::ReputationLevel icon_index,uint32_t min_reputation) +QIcon GxsIdDetails::getReputationIcon( + RsReputationLevel icon_index, uint32_t min_reputation ) { - if( icon_index >= min_reputation ) return QIcon(REPUTATION_VOID) ; + if( static_cast(icon_index) >= min_reputation ) + return QIcon(REPUTATION_VOID); 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; + case RsReputationLevel::LOCALLY_NEGATIVE: + return QIcon(REPUTATION_LOCALLY_NEGATIVE_ICON); + case RsReputationLevel::LOCALLY_POSITIVE: + return QIcon(REPUTATION_LOCALLY_POSITIVE_ICON); + case RsReputationLevel::REMOTELY_POSITIVE: + return QIcon(REPUTATION_REMOTELY_POSITIVE_ICON); + case RsReputationLevel::REMOTELY_NEGATIVE: + return QIcon(REPUTATION_REMOTELY_NEGATIVE_ICON); + case RsReputationLevel::NEUTRAL: + return QIcon(REPUTATION_NEUTRAL_ICON); + default: + std::cerr << "Asked for unidentified icon index " + << static_cast(icon_index) << std::endl; return QIcon(); // dont draw anything } } @@ -1018,7 +1029,8 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon { QPixmap pix ; - if(details.mReputation.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE) + if( details.mReputation.mOverallReputationLevel == + RsReputationLevel::LOCALLY_NEGATIVE ) { icons.clear() ; icons.push_back(QIcon(IMAGE_BANNED)) ; diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.h b/retroshare-gui/src/gui/gxs/GxsIdDetails.h index 8c6c8edac..29e876e55 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.h +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.h @@ -49,7 +49,8 @@ typedef void (*GxsIdDetailsCallbackFunction)(GxsIdDetailsType type, const RsIden class ReputationItemDelegate: public QStyledItemDelegate { public: - ReputationItemDelegate(RsReputations::ReputationLevel max_level_to_display) : mMaxLevelToDisplay(max_level_to_display) {} + ReputationItemDelegate(RsReputationLevel max_level_to_display) : + mMaxLevelToDisplay(static_cast(max_level_to_display)) {} virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; @@ -96,7 +97,8 @@ public: static QString getNameForType(GxsIdDetailsType type, const RsIdentityDetails &details); static QIcon getLoadingIcon(const RsGxsId &id); - static QIcon getReputationIcon(RsReputations::ReputationLevel icon_index, uint32_t min_reputation); + static QIcon getReputationIcon( + RsReputationLevel icon_index, uint32_t min_reputation ); static void GenerateCombinedPixmap(QPixmap &pixmap, const QList &icons, int iconSize); diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index d01135577..bfe8cf052 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -149,30 +149,34 @@ void GxsIdRSTreeWidgetItem::setAvatar(const RsGxsImage &avatar) QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const { - if (column == idColumn()) - { - if (role == Qt::ToolTipRole) - { - QString t = RSTreeWidgetItem::data(column, role).toString(); - QImage pix; + if (column == idColumn()) + { + if (role == Qt::ToolTipRole) + { + QString t = RSTreeWidgetItem::data(column, role).toString(); + QImage pix; - if(mId.isNull()) - return RSTreeWidgetItem::data(column, role); - else if(rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) - pix = QImage(BANNED_IMAGE) ; - else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG")) - pix = GxsIdDetails::makeDefaultIcon(mId); + if(mId.isNull()) return RSTreeWidgetItem::data(column, role); + else if( rsReputations->overallReputationLevel(mId) == + RsReputationLevel::LOCALLY_NEGATIVE ) + pix = QImage(BANNED_IMAGE); + else if ( mAvatar.mSize == 0 || + !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG") ) + pix = GxsIdDetails::makeDefaultIcon(mId); - int S = QFontMetricsF(font(column)).height(); + int S = QFontMetricsF(font(column)).height(); - QString embeddedImage; - if (RsHtml::makeEmbeddedImage(pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, Qt::SmoothTransformation), embeddedImage, 8*S * 8*S)) { - t = "
" + embeddedImage + "" + t + "
"; - } + QString embeddedImage; + if ( RsHtml::makeEmbeddedImage( + pix.scaled(QSize(4*S,4*S), Qt::KeepAspectRatio, + Qt::SmoothTransformation ), + embeddedImage, 8*S * 8*S ) ) + t = "
" + embeddedImage + "" + t + + "
"; - return t; - } - } + return t; + } + } - return RSTreeWidgetItem::data(column, role); + return RSTreeWidgetItem::data(column, role); } diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index edb8515e4..72e8fad11 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -64,7 +64,7 @@ private: bool mIdFound; bool mBannedState ; bool mRetryWhenFailed; - RsReputations::ReputationLevel mReputationLevel ; + RsReputationLevel mReputationLevel; uint32_t mIconTypeMask; RsGxsImage mAvatar; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index c13c80a3f..c9fc624c1 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -824,19 +824,20 @@ void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,c void RsGxsForumModel::computeReputationLevel(uint32_t forum_sign_flags,ForumModelPostEntry& fentry) { uint32_t idflags =0; - RsReputations::ReputationLevel reputation_level = rsReputations->overallReputationLevel(fentry.mAuthorId,&idflags) ; + RsReputationLevel reputation_level = + rsReputations->overallReputationLevel(fentry.mAuthorId, &idflags); bool redacted = false; - if(reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE) + if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE) fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED; else fentry.mPostFlags &= ~ForumModelPostEntry::FLAG_POST_IS_REDACTED; // We use a specific item model for forums in order to handle the post pinning. - if(reputation_level == RsReputations::REPUTATION_UNKNOWN) + if(reputation_level == RsReputationLevel::UNKNOWN) fentry.mReputationWarningLevel = 3 ; - else if(reputation_level == RsReputations::REPUTATION_LOCALLY_NEGATIVE) + else if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE) fentry.mReputationWarningLevel = 2 ; else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(forum_sign_flags,idflags)) fentry.mReputationWarningLevel = 1 ; @@ -1301,7 +1302,7 @@ void RsGxsForumModel::debug_dump() } #endif -void RsGxsForumModel::setAuthorOpinion(const QModelIndex& indx,RsReputations::Opinion op) +void RsGxsForumModel::setAuthorOpinion(const QModelIndex& indx, RsOpinion op) { if(!indx.isValid()) return ; @@ -1312,7 +1313,8 @@ void RsGxsForumModel::setAuthorOpinion(const QModelIndex& indx,RsReputations::Op if(!convertRefPointerToTabEntry(ref,entry) || entry >= mPosts.size()) return ; - std::cerr << "Setting own opinion for author " << mPosts[entry].mAuthorId << " to " << op << std::endl; + std::cerr << "Setting own opinion for author " << mPosts[entry].mAuthorId + << " to " << static_cast(op) << std::endl; RsGxsId author_id = mPosts[entry].mAuthorId; rsReputations->setOwnOpinion(author_id,op) ; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h index 85714ffa2..cdbed3b0b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h @@ -119,7 +119,7 @@ public: void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); void setFilter(int column, const QStringList &strings, uint32_t &count) ; - void setAuthorOpinion(const QModelIndex& indx,RsReputations::Opinion op); + void setAuthorOpinion(const QModelIndex& indx,RsOpinion op); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index f388564c1..952d9e818 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -770,17 +770,17 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) QAction *flagaspositiveAct = new QAction(QIcon(IMAGE_POSITIVE_OPINION), tr("Give positive opinion"), &contextMnu); flagaspositiveAct->setToolTip(tr("This will block/hide messages from this person, and notify friend nodes.")) ; - flagaspositiveAct->setData(RsReputations::OPINION_POSITIVE) ; + flagaspositiveAct->setData(static_cast(RsOpinion::POSITIVE)); connect(flagaspositiveAct, SIGNAL(triggered()), this, SLOT(flagperson())); QAction *flagasneutralAct = new QAction(QIcon(IMAGE_NEUTRAL_OPINION), tr("Give neutral opinion"), &contextMnu); flagasneutralAct->setToolTip(tr("Doing this, you trust your friends to decide to forward this message or not.")) ; - flagasneutralAct->setData(RsReputations::OPINION_NEUTRAL) ; + flagasneutralAct->setData(static_cast(RsOpinion::NEUTRAL)); connect(flagasneutralAct, SIGNAL(triggered()), this, SLOT(flagperson())); QAction *flagasnegativeAct = new QAction(QIcon(IMAGE_NEGATIVE_OPINION), tr("Give negative opinion"), &contextMnu); flagasnegativeAct->setToolTip(tr("This will block/hide messages from this person, and notify friend nodes.")) ; - flagasnegativeAct->setData(RsReputations::OPINION_NEGATIVE) ; + flagasnegativeAct->setData(static_cast(RsOpinion::NEGATIVE)); connect(flagasnegativeAct, SIGNAL(triggered()), this, SLOT(flagperson())); QAction *newthreadAct = new QAction(QIcon(IMAGE_MESSAGE), tr("Start New Thread"), &contextMnu); @@ -876,19 +876,19 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) #endif contextMnu.addSeparator(); - RsReputations::Opinion op ; + RsOpinion op; if(!rsIdentity->isOwnId(current_post.mAuthorId) && rsReputations->getOwnOpinion(current_post.mAuthorId,op)) { QMenu *submenu1 = contextMnu.addMenu(tr("Author's reputation")) ; - if(op != RsReputations::OPINION_POSITIVE) + if(op != RsOpinion::POSITIVE) submenu1->addAction(flagaspositiveAct); - if(op != RsReputations::OPINION_NEUTRAL) + if(op != RsOpinion::NEUTRAL) submenu1->addAction(flagasneutralAct); - if(op != RsReputations::OPINION_NEGATIVE) + if(op != RsOpinion::NEGATIVE) submenu1->addAction(flagasnegativeAct); } @@ -1294,8 +1294,10 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) return; } - uint32_t overall_reputation = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId) ; - bool redacted = (overall_reputation == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ; + RsReputationLevel overall_reputation = + rsReputations->overallReputationLevel(msg.mMeta.mAuthorId); + bool redacted = + (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); #ifdef TO_REMOVE bool setToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); @@ -1621,9 +1623,12 @@ void GxsForumThreadWidget::flagperson() return; } - RsReputations::Opinion opinion = static_cast(qobject_cast(sender())->data().toUInt()); + RsOpinion opinion = + static_cast( + qobject_cast(sender())->data().toUInt() ); - mThreadModel->setAuthorOpinion(mThreadProxyModel->mapToSource(getCurrentIndex()),opinion); + mThreadModel->setAuthorOpinion( + mThreadProxyModel->mapToSource(getCurrentIndex()), opinion ); } void GxsForumThreadWidget::replytoforummessage() { async_msg_action( &GxsForumThreadWidget::replyForumMessageData ); } diff --git a/retroshare-gui/src/gui/settings/PeoplePage.cpp b/retroshare-gui/src/gui/settings/PeoplePage.cpp index 3124c1b6b..c528db090 100644 --- a/retroshare-gui/src/gui/settings/PeoplePage.cpp +++ b/retroshare-gui/src/gui/settings/PeoplePage.cpp @@ -38,12 +38,12 @@ PeoplePage::PeoplePage(QWidget * parent, Qt::WindowFlags flags) connect(ui.autoAddFriendIdsAsContact_CB,SIGNAL(toggled(bool)),this,SLOT(updateAutoAddFriendIdsAsContact())); } -void PeoplePage::updateAutoPositiveOpinion() { rsReputations->setNodeAutoPositiveOpinionForContacts(ui.autoPositiveOpinion_CB->isChecked()) ; } +void PeoplePage::updateAutoPositiveOpinion() { rsReputations->setAutoPositiveOpinionForContacts(ui.autoPositiveOpinion_CB->isChecked()) ; } void PeoplePage::updateThresholdForRemotelyPositiveReputation() { rsReputations->setThresholdForRemotelyPositiveReputation(ui.thresholdForPositive_SB->value()); } void PeoplePage::updateThresholdForRemotelyNegativeReputation() { rsReputations->setThresholdForRemotelyNegativeReputation(ui.thresholdForNegative_SB->value()); } -void PeoplePage::updateRememberDeletedNodes() { rsReputations->setRememberDeletedNodesThreshold(ui.preventReloadingBannedIdentitiesFor_SB->value()); } +void PeoplePage::updateRememberDeletedNodes() { rsReputations->setRememberBannedIdThreshold(ui.preventReloadingBannedIdentitiesFor_SB->value()); } void PeoplePage::updateDeleteBannedNodesThreshold() { rsIdentity->setDeleteBannedNodesThreshold(ui.deleteBannedIdentitiesAfter_SB->value());} void PeoplePage::updateAutoAddFriendIdsAsContact() { rsIdentity->setAutoAddFriendIdsAsContact(ui.autoAddFriendIdsAsContact_CB->isChecked()) ; } @@ -54,7 +54,7 @@ PeoplePage::~PeoplePage() /** Loads the settings for this page */ void PeoplePage::load() { - bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ; + bool auto_positive_contacts = rsReputations->autoPositiveOpinionForContacts() ; uint32_t threshold_for_positive = rsReputations->thresholdForRemotelyPositiveReputation(); uint32_t threshold_for_negative = rsReputations->thresholdForRemotelyNegativeReputation(); bool auto_add_friend_ids_as_contact = rsIdentity->autoAddFriendIdsAsContact(); @@ -64,5 +64,5 @@ void PeoplePage::load() whileBlocking(ui.thresholdForPositive_SB )->setValue(threshold_for_positive); whileBlocking(ui.thresholdForNegative_SB )->setValue(threshold_for_negative); whileBlocking(ui.deleteBannedIdentitiesAfter_SB )->setValue(rsIdentity->deleteBannedNodesThreshold()); - whileBlocking(ui.preventReloadingBannedIdentitiesFor_SB)->setValue(rsReputations->rememberDeletedNodesThreshold()); + whileBlocking(ui.preventReloadingBannedIdentitiesFor_SB)->setValue(rsReputations->rememberBannedIdThreshold()); }