From fe3eec64e948df0a877a99de0753dda2e88b31f3 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 10 Oct 2019 19:56:07 +0200 Subject: [PATCH] Added to display avatar icons & fixes for context menu & format send/receive time Added to display avatar icons for global router & gxs transport Fixed to work context menu call for details View Updated Person details windows Display the receive/send time with date format --- .../src/gui/Identity/IdDetailsDialog.cpp | 12 +- .../src/gui/Identity/IdDetailsDialog.ui | 493 +++++++++--------- .../gui/statistics/GlobalRouterStatistics.cpp | 27 +- .../gui/statistics/GlobalRouterStatistics.ui | 4 +- .../gui/statistics/GxsTransportStatistics.cpp | 28 +- .../gui/statistics/GxsTransportStatistics.ui | 8 + 6 files changed, 312 insertions(+), 260 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index e5aae3b49..ad0c261c9 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -17,6 +17,7 @@ * along with this program. If not, see . * * * *******************************************************************************/ +#include #include "IdDetailsDialog.h" #include "ui_IdDetailsDialog.h" @@ -53,6 +54,7 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); + mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Created); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->ownOpinion_CB); mStateHelper->addWidget(IDDETAILSDIALOG_IDDETAILS, ui->overallOpinion_TF); @@ -63,6 +65,7 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); + mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Created); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addLoadPlaceholder(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); @@ -70,6 +73,7 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgId); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Type); + mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_Created); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_LastUsed); mStateHelper->addClear(IDDETAILSDIALOG_IDDETAILS, ui->lineEdit_GpgName); @@ -80,7 +84,7 @@ IdDetailsDialog::IdDetailsDialog(const RsGxsGroupId& id, QWidget *parent) : Settings->loadWidgetInformation(this); - ui->headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_64.png")); + ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/person.png")); ui->headerFrame->setHeaderText(tr("Person Details")); //connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(changeGroup())); @@ -178,8 +182,10 @@ void IdDetailsDialog::insertIdDetails(uint32_t token) ui->autoBanIdentities_CB->setVisible(!data.mPgpId.isNull()) ; ui->banoption_label->setVisible(!data.mPgpId.isNull()) ; - time_t now = time(NULL) ; - ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; + ui->lineEdit_Created->setText(QDateTime::fromMSecsSinceEpoch(qint64(1000)*data.mMeta.mPublishTs).toString(Qt::SystemLocaleShortDate)); + + time_t now = time(NULL) ; + ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; QPixmap pixmap; diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui b/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui index 73e1006f0..3faad4076 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.ui @@ -17,7 +17,7 @@ :/images/logo/logo_32.png:/images/logo/logo_32.png - + 0 @@ -30,6 +30,9 @@ 0 + + 0 + @@ -41,7 +44,7 @@ - + 9 @@ -52,235 +55,99 @@ 9 - 0 + 9 Identity Info - - - - - 6 + + + + + Qt::Vertical - - 6 + + + 20 + 40 + - - 6 - - - 6 - - - - - - 75 - true - - - - Overall: - - - - - - - Friends votes: - - - - - - - Your opinion: - - - - - - - - 0 - 0 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the average of your friend's opinions. If not, your own opinion gives the score.</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -0.6, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a higher reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 30 days). </span></p></body></html> - - - 0 - - - - Negative - - - - :/icons/png/thumbs-down.png:/icons/png/thumbs-down.png - - - - - Neutral - - - - :/icons/png/thumbs-neutral.png:/icons/png/thumbs-neutral.png - - - - - Positive - - - - :/icons/png/thumbs-up.png:/icons/png/thumbs-up.png - - - - - - - - <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> - - - true - - - - - - - <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> - - - true - - - - - - - Owner node ID : - - - - - - - Type: - - - - - - - Owner node name : - - - - - - - Identity name : - - - - - - - Identity ID : - - - - - - - Last used: - - - - - - - Ban-option: - - - - - - - Auto-Ban all identities signed by the same node - - - - - - - true - - - true - - - - - - - true - - - true - - - - - - - true - - - true - - - - - - - - - - true - - - true - - - - - - - true - - - true - - - - + - + + + + Ban-option: + + + + + + + <html><head/><body><p>Overall reputation score, accounting for yours and your friends'.</p><p>Negative is bad, positive is good. Zero is neutral. If the score is too low,</p><p>the identity is flagged as bad, and will be filtered out in forums, chat lobbies,</p><p>channels, etc.</p></body></html> + + + true + + + + + + + Auto-Ban all identities signed by the same node + + + + + + + + 75 + true + + + + Overall: + + + + + + + Type: + + + + + + + Identity ID : + + + + + + + + + + Owner node ID : + + + + + + + true + + + true + + + + QLayout::SetDefaultConstraint @@ -426,25 +293,172 @@ p, li { white-space: pre-wrap; } - - - - Qt::Vertical + + + + Owner node name : - - - 20 - 40 - + + + + + + true - + + true + + + + + + + Last used: + + + + + + + true + + + true + + + + + + + Identity name : + + + + + + + true + + + true + + + + + + + true + + + true + + + + + + + Friends votes: + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Your own opinion about an identity rules the visibility of that identity for yourself and your friend nodes. Your own opinion is shared among friends and used to compute a reputation score: If your opinion about an identity is neutral, the reputation score is the average of your friend's opinions. If not, your own opinion gives the score.</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">The overall score is used in chat lobbies, forums and channels to decide on the actions to take for each specific identity. When the overall score is lower than -0.6, the identity is banned, which prevents all messages and forums/channels authored by this identity to be forwarded, both ways. Some forums also have special anti-spam flags that require a higher reputation level, making them more sensitive to bad opinions. Banned identities gradually lose their activity and eventually disappear (after 30 days). </span></p></body></html> + + + 0 + + + + Negative + + + + :/icons/png/thumbs-down.png:/icons/png/thumbs-down.png + + + + + Neutral + + + + :/icons/png/thumbs-neutral.png:/icons/png/thumbs-neutral.png + + + + + Positive + + + + :/icons/png/thumbs-up.png:/icons/png/thumbs-up.png + + + + + + + + Your opinion: + + + + + + + <html><head/><body><p>Average opinion of neighbor nodes about this identity. Negative is bad,</p><p>positive is good. Zero is neutral.</p></body></html> + + + true + + + + + + + true + + + + + + + Created : + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + 9 @@ -483,19 +497,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 85adb8293..eb11ab19a 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include #include #include #include @@ -39,6 +40,8 @@ #include "gui/Identity/IdDetailsDialog.h" #include "gui/settings/rsharesettings.h" +#include "gui/gxs/GxsIdDetails.h" +#include "util/DateTime.h" #include "util/QtVersion.h" #include "util/misc.h" @@ -49,8 +52,8 @@ #define COL_TUNNELSTATUS 4 #define COL_DATASIZE 5 #define COL_DATAHASH 6 -#define COL_RECEIVED 7 -#define COL_SEND 8 +#define COL_RECEIVED 7 +#define COL_SEND 8 #define COL_DUPLICATION_FACTOR 9 static const int PARTIAL_VIEW_SIZE = 9 ; @@ -65,7 +68,7 @@ static QColor colorScale(float f) } GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent) - : RsAutoUpdatePage(2000,parent) + : RsAutoUpdatePage(4000,parent) { setupUi(this) ; @@ -177,6 +180,18 @@ void GlobalRouterStatistics::updateContent() if(nicknames.isEmpty()) nicknames = tr("Unknown"); + + QDateTime routingtime; + routingtime.setTime_t(cache_infos[i].routing_time); + QDateTime senttime; + senttime.setTime_t(cache_infos[i].last_sent_time); + + QPixmap pixmap ; + + if(details.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(details.mAvatar.mData, details.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(cache_infos[i].destination,GxsIdDetails::SMALL); + + item ->setIcon(COL_NICKNAME, QIcon(pixmap)); item -> setData(COL_ID, Qt::DisplayRole, QString::number(cache_infos[i].mid,16).rightJustified(16,'0')); item -> setData(COL_NICKNAME, Qt::DisplayRole, nicknames ) ; @@ -185,9 +200,9 @@ void GlobalRouterStatistics::updateContent() item -> setData(COL_TUNNELSTATUS, Qt::DisplayRole, tunnel_status_string[cache_infos[i].tunnel_status % 3]); item -> setData(COL_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(cache_infos[i].data_size)); item -> setData(COL_DATAHASH, Qt::DisplayRole, QString::fromStdString(cache_infos[i].item_hash.toStdString())); - item -> setData(COL_RECEIVED, Qt::DisplayRole, QString::number(now - cache_infos[i].routing_time)); - item -> setData(COL_SEND, Qt::DisplayRole, QString::number(now - cache_infos[i].last_sent_time)); - item -> setData(COL_DUPLICATION_FACTOR, Qt::DisplayRole, QString::number(cache_infos[i].duplication_factor)); + item -> setData(COL_RECEIVED, Qt::DisplayRole, DateTime::formatDateTime(routingtime)); + item -> setData(COL_SEND, Qt::DisplayRole, DateTime::formatDateTime(senttime)); + item -> setData(COL_DUPLICATION_FACTOR, Qt::DisplayRole, QString::number(cache_infos[i].duplication_factor)); } } diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui index 1a5133251..5a4da3859 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui @@ -93,12 +93,12 @@ - Receive time (secs ago) + Receive time - Sending time (secs ago) + Sending time diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp index 87b59cb16..2eeba44f6 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp @@ -33,7 +33,6 @@ #include #include - #include #include #include @@ -47,6 +46,7 @@ #include "gui/common/UIStateHelper.h" #include "util/misc.h" #include "gui/gxs/GxsIdLabel.h" +#include "gui/gxs/GxsIdDetails.h" #define COL_PENDING_ID 0 #define COL_PENDING_DESTINATION 1 @@ -55,6 +55,7 @@ #define COL_PENDING_DATAHASH 4 #define COL_PENDING_SEND 5 #define COL_PENDING_GROUP_ID 6 +#define COL_PENDING_DESTINATION_ID 7 #define COL_GROUP_GRP_ID 0 #define COL_GROUP_NUM_MSGS 1 @@ -89,9 +90,11 @@ GxsTransportStatistics::GxsTransportStatistics(QWidget *parent) /* Set header resize modes and initial section sizes Uploads TreeView*/ QHeaderView_setSectionResizeMode(treeWidget->header(), QHeaderView::ResizeToContents); + QHeaderView_setSectionResizeMode(groupTreeWidget->header(), QHeaderView::ResizeToContents); connect(treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CustomPopupMenu(QPoint))); - + + treeWidget->setColumnHidden(COL_PENDING_DESTINATION_ID,true); // load settings processSettings(true); @@ -217,6 +220,13 @@ void GxsTransportStatistics::updateContent() RsIdentityDetails details ; rsIdentity->getIdDetails(rec.recipient,details); QString nickname = QString::fromUtf8(details.mNickname.c_str()); + + QPixmap pixmap ; + + if(details.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(details.mAvatar.mData, details.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(rec.recipient,GxsIdDetails::SMALL); + + item ->setIcon(COL_PENDING_DESTINATION, QIcon(pixmap)); if(nickname.isEmpty()) nickname = tr("Unknown"); @@ -227,6 +237,8 @@ void GxsTransportStatistics::updateContent() item -> setData(COL_PENDING_DATAHASH, Qt::DisplayRole, QString::fromStdString(rec.data_hash.toStdString())); item -> setData(COL_PENDING_SEND, Qt::DisplayRole, QDateTime::fromTime_t(rec.send_TS).toString()); item -> setData(COL_PENDING_GROUP_ID, Qt::DisplayRole, QString::fromStdString(rec.group_id.toStdString())); + item -> setData(COL_PENDING_DESTINATION_ID, Qt::DisplayRole, QString::fromStdString(rec.recipient.toStdString())); + GxsIdLabel *label = new GxsIdLabel() ; label->setId(rec.recipient) ; @@ -293,6 +305,16 @@ void GxsTransportStatistics::updateContent() GxsIdLabel *label = new GxsIdLabel(); label->setId(meta.mAuthorId) ; groupTreeWidget->setItemWidget(sitem,COL_GROUP_GRP_ID,label) ; + + RsIdentityDetails idDetails ; + rsIdentity->getIdDetails(meta.mAuthorId,idDetails); + + QPixmap pixmap ; + + if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(meta.mAuthorId,GxsIdDetails::SMALL); + + sitem->setIcon(COL_GROUP_GRP_ID, QIcon(pixmap)); sitem->setData(COL_GROUP_UNIQUE_ID, Qt::DisplayRole,QString::fromStdString(meta.mMsgId.toStdString())); sitem->setData(COL_GROUP_NUM_MSGS,Qt::DisplayRole, QDateTime::fromTime_t(meta.mPublishTs).toString()); @@ -303,7 +325,7 @@ void GxsTransportStatistics::updateContent() void GxsTransportStatistics::personDetails() { QTreeWidgetItem *item = treeWidget->currentItem(); - std::string id = item->text(COL_PENDING_DESTINATION).toStdString(); + std::string id = item->text(COL_PENDING_DESTINATION_ID).toStdString(); if (id.empty()) { return; diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui index 07b726275..ee76d42ac 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui @@ -78,6 +78,11 @@ Group ID + + + Destination ID + + @@ -95,6 +100,9 @@ Qt::Vertical + + Qt::CustomContextMenu + Group ID / Author