From 7f8d0fb23fdca4ff534698fdff758f9c8aeb0867 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 11 Oct 2019 22:36:34 +0200 Subject: [PATCH] Fixed to use GxsIdRSTreeWidgetItem on Pending packets & pending data items Fixed to use GxsIdRSTreeWidgetItem on Pending packets & pending data items Added to display on Pending data items the time in seconds Set text alingment for some items --- .../gui/statistics/GlobalRouterStatistics.cpp | 12 ++++------ .../gui/statistics/GxsTransportStatistics.cpp | 24 +++++++++---------- .../gui/statistics/GxsTransportStatistics.ui | 7 +++++- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index f80188f63..0a992353b 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -41,6 +41,7 @@ #include "gui/Identity/IdDetailsDialog.h" #include "gui/settings/rsharesettings.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/gxs/GxsIdTreeWidgetItem.h" #include "util/DateTime.h" #include "util/QtVersion.h" #include "util/misc.h" @@ -173,7 +174,8 @@ void GlobalRouterStatistics::updateContent() for(uint32_t i=0;iaddTopLevelItem(item); RsIdentityDetails details ; @@ -188,13 +190,7 @@ void GlobalRouterStatistics::updateContent() 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 -> setId(cache_infos[i].destination,COL_NICKNAME, false) ; item -> setData(COL_ID, Qt::DisplayRole, QString::number(cache_infos[i].mid,16).rightJustified(16,'0')); item -> setData(COL_NICKNAME, Qt::DisplayRole, nicknames ) ; item -> setData(COL_DESTINATION, Qt::DisplayRole, QString::fromStdString(cache_infos[i].destination.toStdString())); diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp index 2eeba44f6..b5a42264e 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp @@ -47,6 +47,7 @@ #include "util/misc.h" #include "gui/gxs/GxsIdLabel.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/gxs/GxsIdTreeWidgetItem.h" #define COL_PENDING_ID 0 #define COL_PENDING_DESTINATION 1 @@ -55,7 +56,8 @@ #define COL_PENDING_DATAHASH 4 #define COL_PENDING_SEND 5 #define COL_PENDING_GROUP_ID 6 -#define COL_PENDING_DESTINATION_ID 7 +#define COL_PENDING_SENDTIME 7 +#define COL_PENDING_DESTINATION_ID 8 #define COL_GROUP_GRP_ID 0 #define COL_GROUP_NUM_MSGS 1 @@ -207,6 +209,8 @@ void GxsTransportStatistics::updateContent() //time_t now = time(NULL) ; // 1 - fill the table for pending packets + + time_t now = time(NULL) ; groupBox->setTitle(tr("Pending data items")+": " + QString::number(transinfo.outgoing_records.size()) ); @@ -214,23 +218,18 @@ void GxsTransportStatistics::updateContent() { const RsGxsTransOutgoingRecord& rec(transinfo.outgoing_records[i]) ; - QTreeWidgetItem *item = new QTreeWidgetItem(); + //QTreeWidgetItem *item = new QTreeWidgetItem(); + GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR) ; treeWidget->addTopLevelItem(item); 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"); + item -> setId(rec.recipient,COL_PENDING_DESTINATION, false) ; item -> setData(COL_PENDING_ID, Qt::DisplayRole, QString::number(rec.trans_id,16).rightJustified(8,'0')); item -> setData(COL_PENDING_DATASTATUS, Qt::DisplayRole, getStatusString(rec.status)); item -> setData(COL_PENDING_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(rec.data_size)); @@ -238,12 +237,11 @@ void GxsTransportStatistics::updateContent() 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())); + item -> setData(COL_PENDING_SENDTIME, Qt::DisplayRole, QString::number(now - rec.send_TS)); + item->setTextAlignment(COL_PENDING_DATASIZE, Qt::AlignRight ); + item->setTextAlignment(COL_PENDING_SEND, Qt::AlignRight ); - GxsIdLabel *label = new GxsIdLabel() ; - label->setId(rec.recipient) ; - - treeWidget -> setItemWidget(item,COL_PENDING_DESTINATION, label) ; } // 2 - fill the table for pending group data diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui index ee76d42ac..e2c7449c0 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.ui @@ -70,7 +70,7 @@ - Sending time (secs ago) + Sending time @@ -78,6 +78,11 @@ Group ID + + + Sending time (secs ago) + + Destination ID