mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #910 from csoler/v0.6-GxsTransport
improved display of GxsTrans statistics
This commit is contained in:
commit
a864cf716e
@ -60,6 +60,7 @@
|
|||||||
#define COL_GROUP_SIZE_MSGS 2
|
#define COL_GROUP_SIZE_MSGS 2
|
||||||
#define COL_GROUP_SUBSCRIBED 3
|
#define COL_GROUP_SUBSCRIBED 3
|
||||||
#define COL_GROUP_POPULARITY 4
|
#define COL_GROUP_POPULARITY 4
|
||||||
|
#define COL_GROUP_UNIQUE_ID 5
|
||||||
|
|
||||||
static const int PARTIAL_VIEW_SIZE = 9 ;
|
static const int PARTIAL_VIEW_SIZE = 9 ;
|
||||||
static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
|
static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
|
||||||
@ -70,7 +71,7 @@ static const int GXSTRANS_STATISTICS_DELAY_BETWEEN_GROUP_REQ = 30 ; // never req
|
|||||||
#define GXSTRANS_GROUP_STAT 0x03
|
#define GXSTRANS_GROUP_STAT 0x03
|
||||||
#define GXSTRANS_MSG_META 0x04
|
#define GXSTRANS_MSG_META 0x04
|
||||||
|
|
||||||
#define DEBUG_GXSTRANS_STATS 1
|
//#define DEBUG_GXSTRANS_STATS 1
|
||||||
|
|
||||||
GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
|
GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
|
||||||
: RsGxsUpdateBroadcastPage(rsGxsTrans,parent)
|
: RsGxsUpdateBroadcastPage(rsGxsTrans,parent)
|
||||||
@ -143,8 +144,9 @@ void GxsTransportStatistics::CustomPopupMenu( QPoint )
|
|||||||
void GxsTransportStatistics::updateDisplay(bool)
|
void GxsTransportStatistics::updateDisplay(bool)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
|
#ifdef DEBUG_GXSTRANS_STATS
|
||||||
std::cerr << "GxsTransportStatistics::updateDisplay()" << std::endl;
|
std::cerr << "GxsTransportStatistics::updateDisplay()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
requestGroupMeta();
|
requestGroupMeta();
|
||||||
mLastGroupReqTS = now ;
|
mLastGroupReqTS = now ;
|
||||||
@ -195,7 +197,6 @@ void GxsTransportStatistics::updateContent()
|
|||||||
|
|
||||||
rsGxsTrans->getStatistics(transinfo) ;
|
rsGxsTrans->getStatistics(transinfo) ;
|
||||||
|
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
|
|
||||||
treeWidget->clear();
|
treeWidget->clear();
|
||||||
@ -242,34 +243,57 @@ void GxsTransportStatistics::updateContent()
|
|||||||
if(groupTreeWidget->isItemExpanded(groupTreeWidget->topLevelItem(i)))
|
if(groupTreeWidget->isItemExpanded(groupTreeWidget->topLevelItem(i)))
|
||||||
openned_groups.insert(RsGxsGroupId(groupTreeWidget->topLevelItem(i)->data(COL_GROUP_GRP_ID,Qt::DisplayRole).toString().toStdString())) ;
|
openned_groups.insert(RsGxsGroupId(groupTreeWidget->topLevelItem(i)->data(COL_GROUP_GRP_ID,Qt::DisplayRole).toString().toStdString())) ;
|
||||||
|
|
||||||
groupTreeWidget->clear();
|
groupTreeWidget->clear();
|
||||||
|
|
||||||
for(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>::const_iterator it(mGroupStats.begin());it!=mGroupStats.end();++it)
|
for(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>::const_iterator it(mGroupStats.begin());it!=mGroupStats.end();++it)
|
||||||
{
|
{
|
||||||
const RsGxsTransGroupStatistics& stat(it->second) ;
|
const RsGxsTransGroupStatistics& stat(it->second) ;
|
||||||
|
QTreeWidgetItem *item ;
|
||||||
|
|
||||||
|
{
|
||||||
|
QString unique_id = QString::fromStdString(stat.mGrpId.toStdString());
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> iteml = groupTreeWidget->findItems(unique_id,Qt::MatchExactly,COL_GROUP_UNIQUE_ID) ;
|
||||||
|
|
||||||
|
if(iteml.empty())
|
||||||
|
item = new QTreeWidgetItem;
|
||||||
|
else
|
||||||
|
item = *iteml.begin();
|
||||||
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
|
||||||
groupTreeWidget->addTopLevelItem(item);
|
groupTreeWidget->addTopLevelItem(item);
|
||||||
groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end());
|
groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end());
|
||||||
|
|
||||||
QString msg_time_string = (stat.last_publish_TS>0)?QString(" (Last msg: %1)").arg(QDateTime::fromTime_t(stat.last_publish_TS).toString()):"" ;
|
QString msg_time_string = (stat.last_publish_TS>0)?QString(" (Last msg: %1)").arg(QDateTime::fromTime_t(stat.last_publish_TS).toString()):"" ;
|
||||||
|
|
||||||
|
item->setData(COL_GROUP_UNIQUE_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
|
||||||
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) + msg_time_string) ;
|
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) + msg_time_string) ;
|
||||||
item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
|
item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
|
||||||
item->setData(COL_GROUP_SIZE_MSGS, Qt::DisplayRole, QString::number(stat.mTotalSizeOfMsgs)) ;
|
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_SUBSCRIBED,Qt::DisplayRole, stat.subscribed?tr("Yes"):tr("No")) ;
|
||||||
item->setData(COL_GROUP_POPULARITY,Qt::DisplayRole, QString::number(stat.popularity)) ;
|
item->setData(COL_GROUP_POPULARITY,Qt::DisplayRole, QString::number(stat.popularity)) ;
|
||||||
|
|
||||||
for(uint32_t i=0;i<it->second.messages_metas.size();++i)
|
for(std::map<RsGxsMessageId,RsMsgMetaData>::const_iterator msgIt(stat.messages_metas.begin());msgIt!=stat.messages_metas.end();++msgIt)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *sitem = new QTreeWidgetItem(item) ;
|
const RsMsgMetaData& meta(msgIt->second);
|
||||||
|
|
||||||
const RsMsgMetaData& meta(it->second.messages_metas[i]) ;
|
QTreeWidgetItem *sitem ;
|
||||||
|
{
|
||||||
|
QString unique_id = QString::fromStdString(meta.mMsgId.toStdString());
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> iteml = groupTreeWidget->findItems(unique_id,Qt::MatchExactly,COL_GROUP_UNIQUE_ID) ;
|
||||||
|
|
||||||
|
if(iteml.empty())
|
||||||
|
sitem = new QTreeWidgetItem(item) ;
|
||||||
|
else
|
||||||
|
sitem = *iteml.begin();
|
||||||
|
}
|
||||||
|
|
||||||
GxsIdLabel *label = new GxsIdLabel();
|
GxsIdLabel *label = new GxsIdLabel();
|
||||||
label->setId(meta.mAuthorId) ;
|
label->setId(meta.mAuthorId) ;
|
||||||
groupTreeWidget->setItemWidget(sitem,COL_GROUP_GRP_ID,label) ;
|
groupTreeWidget->setItemWidget(sitem,COL_GROUP_GRP_ID,label) ;
|
||||||
|
|
||||||
|
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());
|
sitem->setData(COL_GROUP_NUM_MSGS,Qt::DisplayRole, QDateTime::fromTime_t(meta.mPublishTs).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,7 +391,9 @@ void GxsTransportStatistics::loadGroupStat(const uint32_t &token)
|
|||||||
GxsGroupStatistic stats;
|
GxsGroupStatistic stats;
|
||||||
rsGxsTrans->getGroupStatistic(token, stats);
|
rsGxsTrans->getGroupStatistic(token, stats);
|
||||||
|
|
||||||
|
#ifdef DEBUG_GXSTRANS_STATS
|
||||||
std::cerr << "Loading group stats: " << stats.mGrpId << ", num msgs=" << stats.mNumMsgs << ", total size=" << stats.mTotalSizeOfMsgs << std::endl;
|
std::cerr << "Loading group stats: " << stats.mGrpId << ", num msgs=" << stats.mNumMsgs << ", total size=" << stats.mTotalSizeOfMsgs << std::endl;
|
||||||
|
#endif
|
||||||
dynamic_cast<GxsGroupStatistic&>(mGroupStats[stats.mGrpId]) = stats ;
|
dynamic_cast<GxsGroupStatistic&>(mGroupStats[stats.mGrpId]) = stats ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
void addMessageMeta(const RsMsgMetaData& meta)
|
void addMessageMeta(const RsMsgMetaData& meta)
|
||||||
{
|
{
|
||||||
messages_metas.push_back(meta) ;
|
messages_metas[meta.mMsgId] = meta ;
|
||||||
last_publish_TS = std::max(last_publish_TS,meta.mPublishTs) ;
|
last_publish_TS = std::max(last_publish_TS,meta.mPublishTs) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
time_t last_publish_TS;
|
time_t last_publish_TS;
|
||||||
|
|
||||||
std::vector<RsMsgMetaData> messages_metas ;
|
std::map<RsGxsMessageId,RsMsgMetaData> messages_metas ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GxsTransportStatistics: public RsGxsUpdateBroadcastPage, public TokenResponse, public Ui::GxsTransportStatistics
|
class GxsTransportStatistics: public RsGxsUpdateBroadcastPage, public TokenResponse, public Ui::GxsTransportStatistics
|
||||||
|
Loading…
Reference in New Issue
Block a user