improved display of GXS Transport stats

This commit is contained in:
csoler 2017-05-30 13:57:11 +02:00
parent 2e3f62a4bb
commit f4c167c256
2 changed files with 40 additions and 22 deletions

View File

@ -24,6 +24,7 @@
#include <QObject>
#include <QFontMetrics>
#include <QWheelEvent>
#include <QDateTime>
#include <time.h>
#include <QMenu>
@ -44,15 +45,15 @@
#include "util/QtVersion.h"
#include "gui/common/UIStateHelper.h"
#include "util/misc.h"
#include "gui/gxs/GxsIdLabel.h"
#define COL_PENDING_ID 0
#define COL_PENDING_DESTINATION 1
#define COL_PENDING_NICKNAME 2
#define COL_PENDING_DATASTATUS 3
#define COL_PENDING_DATASIZE 4
#define COL_PENDING_DATAHASH 5
#define COL_PENDING_SEND 6
#define COL_PENDING_GROUP_ID 7
#define COL_PENDING_DATASTATUS 2
#define COL_PENDING_DATASIZE 3
#define COL_PENDING_DATAHASH 4
#define COL_PENDING_SEND 5
#define COL_PENDING_GROUP_ID 6
#define COL_GROUP_GRP_ID 0
#define COL_GROUP_NUM_MSGS 1
@ -69,6 +70,8 @@ static const int GXSTRANS_STATISTICS_DELAY_BETWEEN_GROUP_REQ = 30 ; // never req
#define GXSTRANS_GROUP_STAT 0x03
#define GXSTRANS_MSG_META 0x04
#define DEBUG_GXSTRANS_STATS 1
GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
: RsAutoUpdatePage(2000,parent)
{
@ -196,6 +199,9 @@ void GxsTransportStatistics::updateContent()
rsGxsTrans->getStatistics(transinfo) ;
// clear
treeWidget->clear();
time_t now = time(NULL) ;
@ -218,17 +224,28 @@ void GxsTransportStatistics::updateContent()
nickname = tr("Unknown");
item -> setData(COL_PENDING_ID, Qt::DisplayRole, QString::number(rec.trans_id,16).rightJustified(8,'0'));
item -> setData(COL_PENDING_NICKNAME, Qt::DisplayRole, nickname ) ;
item -> setData(COL_PENDING_DESTINATION, Qt::DisplayRole, QString::fromStdString(rec.recipient.toStdString()));
item -> setData(COL_PENDING_DATASTATUS, Qt::DisplayRole, getStatusString(rec.status));
item -> setData(COL_PENDING_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(rec.data_size));
item -> setData(COL_PENDING_DATAHASH, Qt::DisplayRole, QString::fromStdString(rec.data_hash.toStdString()));
item -> setData(COL_PENDING_SEND, Qt::DisplayRole, QString::number(now - rec.send_TS));
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()));
GxsIdLabel *label = new GxsIdLabel() ;
label->setId(rec.recipient) ;
treeWidget -> setItemWidget(item,COL_PENDING_DESTINATION, label) ;
}
// 2 - fill the table for pending group data
// record openned groups
std::set<RsGxsGroupId> openned_groups ;
for(uint32_t i=0;i<groupTreeWidget->topLevelItemCount();++i)
if(groupTreeWidget->isItemExpanded(groupTreeWidget->topLevelItem(i)))
openned_groups.insert(RsGxsGroupId(groupTreeWidget->topLevelItem(i)->data(COL_GROUP_GRP_ID,Qt::DisplayRole).toString().toStdString())) ;
groupTreeWidget->clear();
for(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>::const_iterator it(mGroupStats.begin());it!=mGroupStats.end();++it)
@ -237,19 +254,25 @@ void GxsTransportStatistics::updateContent()
QTreeWidgetItem *item = new QTreeWidgetItem();
groupTreeWidget->addTopLevelItem(item);
groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end());
item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs)) ;
item->setData(COL_GROUP_SIZE_MSGS,Qt::DisplayRole, QString::number(stat.mTotalSizeOfMsgs)) ;
item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs)) ;
item->setData(COL_GROUP_SIZE_MSGS, Qt::DisplayRole, QString::number(stat.mTotalSizeOfMsgs)) ;
item->setData(COL_GROUP_SUBSCRIBED,Qt::DisplayRole, stat.subscribed?tr("Yes"):tr("No")) ;
item->setData(COL_GROUP_POPULARITY,Qt::DisplayRole, QString::number(stat.popularity)) ;
for(uint32_t i=0;i<it->second.messages_metas.size();++i)
{
QTreeWidgetItem *sitem = new QTreeWidgetItem(item);
QTreeWidgetItem *sitem = new QTreeWidgetItem(item) ;
const RsMsgMetaData& meta(it->second.messages_metas[i]) ;
sitem->setData(COL_GROUP_GRP_ID,Qt::DisplayRole, QString::fromStdString(meta.mMsgId.toStdString()));
GxsIdLabel *label = new GxsIdLabel();
label->setId(meta.mAuthorId) ;
groupTreeWidget->setItemWidget(sitem,COL_GROUP_GRP_ID,label) ;
sitem->setData(COL_GROUP_NUM_MSGS,Qt::DisplayRole, QDateTime::fromTime_t(meta.mPublishTs).toString());
}
}
}

View File

@ -28,12 +28,12 @@
<widget class="QTreeWidget" name="groupTreeWidget">
<column>
<property name="text">
<string>Group ID</string>
<string>Group ID / Author</string>
</property>
</column>
<column>
<property name="text">
<string>Number of messages</string>
<string>Number of messages / Publish TS</string>
</property>
</column>
<column>
@ -81,12 +81,7 @@
</column>
<column>
<property name="text">
<string>Destination ID</string>
</property>
</column>
<column>
<property name="text">
<string>Destination Name</string>
<string>Destination</string>
</property>
</column>
<column>