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
This commit is contained in:
defnax 2019-10-11 22:36:34 +02:00
parent ef5c6c3f65
commit 7f8d0fb23f
3 changed files with 21 additions and 22 deletions

View File

@ -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;i<cache_infos.size();++i)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
//QTreeWidgetItem *item = new QTreeWidgetItem();
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR) ;
treeWidget->addTopLevelItem(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()));

View File

@ -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
@ -208,29 +210,26 @@ void GxsTransportStatistics::updateContent()
// 1 - fill the table for pending packets
time_t now = time(NULL) ;
groupBox->setTitle(tr("Pending data items")+": " + QString::number(transinfo.outgoing_records.size()) );
for(uint32_t i=0;i<transinfo.outgoing_records.size();++i)
{
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

View File

@ -70,7 +70,7 @@
</column>
<column>
<property name="text">
<string>Sending time (secs ago)</string>
<string>Sending time</string>
</property>
</column>
<column>
@ -78,6 +78,11 @@
<string>Group ID</string>
</property>
</column>
<column>
<property name="text">
<string>Sending time (secs ago)</string>
</property>
</column>
<column>
<property name="text">
<string>Destination ID</string>