fixed display of reputation

This commit is contained in:
csoler 2025-02-14 22:01:11 +01:00
parent 40d6c3c973
commit ac620d9077
3 changed files with 45 additions and 33 deletions

View File

@ -226,8 +226,8 @@ IdDialog::IdDialog(QWidget *parent)
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
connect(ui->idTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection()));
connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation()));
@ -1283,6 +1283,7 @@ void IdDialog::updateSelection()
{
auto id = RsGxsGroupId(getSelectedIdentity());
std::cerr << "updating selection to id " << id << std::endl;
if(id != mId)
{
mId = id;
@ -2042,8 +2043,13 @@ std::list<RsGxsId> IdDialog::getSelectedIdentities() const
std::list<RsGxsId> res;
for(auto indx:selectedIndexes)
{
RsGxsId id;
if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates
res.push_back(mIdListModel->getIdentity(indx));
if( !(id = mIdListModel->getIdentity(indx)).isNull() )
res.push_back(id);
}
return res;
}
@ -2232,29 +2238,27 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
if(n_is_not_a_contact == 0)
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
}
if (n_selected_items==1)
contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ;
if (n_selected_items==1)
contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ;
contextMenu->addSeparator();
if(n_positive_reputations == 0) // only unban when all items are banned
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson()));
if(n_neutral_reputations == 0) // only unban when all items are banned
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson()));
if(n_negative_reputations == 0)
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson()));
if(one_item_owned_by_you && n_selected_items==1)
{
contextMenu->addSeparator();
if(n_positive_reputations == 0) // only unban when all items are banned
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson()));
if(n_neutral_reputations == 0) // only unban when all items are banned
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson()));
if(n_negative_reputations == 0)
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson()));
if(one_item_owned_by_you && n_selected_items==1)
{
contextMenu->addSeparator();
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ;
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ;
}
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ;
contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ;
}
//contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu);

View File

@ -567,7 +567,6 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str()));
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) );
case COLUMN_THREAD_OWNER: return QVariant(QString::fromStdString(det.mPgpId.toStdString()) );
case COLUMN_THREAD_REPUTATION: return QVariant(QString::number((uint8_t)det.mReputation.mOverallReputationLevel));
default:
return QVariant();
}
@ -579,7 +578,7 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const
}
}
// This function makes sure that the internal data gets updated. They are situations where the otification system cannot
// This function makes sure that the internal data gets updated. They are situations where the notification system cannot
// send the information about changes, such as when the computer is put on sleep.
void RsIdentityListModel::checkInternalData(bool force)
@ -616,12 +615,8 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel:
QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) const
{
if(col > 0)
return QVariant();
switch(entry.type)
{
case ENTRY_TYPE_CATEGORY:
return QVariant();
@ -632,12 +627,20 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co
if(!hn)
return QVariant();
QPixmap sslAvatar;
AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar);
if(col == COLUMN_THREAD_REPUTATION)
return QVariant( static_cast<uint8_t>(rsReputations->overallReputationLevel(hn->id)) );
else if(col == COLUMN_THREAD_NAME)
{
QPixmap sslAvatar;
AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar);
return QVariant(QIcon(sslAvatar));
return QVariant(QIcon(sslAvatar));
}
}
default: return QVariant();
break;
default:
return QVariant();
}
}

View File

@ -95,7 +95,12 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
const QRect r = option.rect;
// get pixmap
unsigned int icon_index = qvariant_cast<unsigned int>(index.data(Qt::DecorationRole));
auto v = index.data(Qt::DecorationRole);
if(!v.canConvert(QVariant::Int))
return;
unsigned int icon_index = qvariant_cast<unsigned int>(v);
if(icon_index > mMaxLevelToDisplay)
return ;