mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
Moved to display pending packets on a QTreeWidget.
Fixed People layout/spacing & display votes column.
This commit is contained in:
parent
441b164c73
commit
66670315dc
@ -32,6 +32,7 @@
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "util/QtVersion.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsreputations.h>
|
||||
@ -56,6 +57,7 @@
|
||||
#define RSID_COL_NICKNAME 0
|
||||
#define RSID_COL_KEYID 1
|
||||
#define RSID_COL_IDTYPE 2
|
||||
#define RSID_COL_VOTES 3
|
||||
|
||||
#define RSIDREP_COL_NAME 0
|
||||
#define RSIDREP_COL_OPINION 1
|
||||
@ -168,12 +170,15 @@ IdDialog::IdDialog(QWidget *parent) :
|
||||
|
||||
ui->idTreeWidget->enableColumnCustomize(true);
|
||||
ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false);
|
||||
|
||||
ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true);
|
||||
/* Set initial column width */
|
||||
int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W");
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 18 * fontWidth);
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_KEYID, 25 * fontWidth);
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth);
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_KEYID, 20 * fontWidth);
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_IDTYPE, 18 * fontWidth);
|
||||
ui->idTreeWidget->setColumnWidth(RSID_COL_VOTES, 7 * fontWidth);
|
||||
|
||||
//QHeaderView_setSectionResizeMode(ui->idTreeWidget->header(), QHeaderView::ResizeToContents);
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
@ -285,6 +290,24 @@ void IdDialog::updateSelection()
|
||||
}
|
||||
}
|
||||
|
||||
static QString getHumanReadableDuration(uint32_t seconds)
|
||||
{
|
||||
if(seconds < 60)
|
||||
return QString(QObject::tr("%1 seconds ago")).arg(seconds) ;
|
||||
else if(seconds < 120)
|
||||
return QString(QObject::tr("%1 minute ago")).arg(seconds/60) ;
|
||||
else if(seconds < 3600)
|
||||
return QString(QObject::tr("%1 minutes ago")).arg(seconds/60) ;
|
||||
else if(seconds < 7200)
|
||||
return QString(QObject::tr("%1 hour ago")).arg(seconds/3600) ;
|
||||
else if(seconds < 24*3600)
|
||||
return QString(QObject::tr("%1 hours ago")).arg(seconds/3600) ;
|
||||
else if(seconds < 2*24*3600)
|
||||
return QString(QObject::tr("%1 day ago")).arg(seconds/86400) ;
|
||||
else
|
||||
return QString(QObject::tr("%1 days ago")).arg(seconds/86400) ;
|
||||
}
|
||||
|
||||
void IdDialog::requestIdList()
|
||||
{
|
||||
//Disable by default, will be enable by insertIdDetails()
|
||||
@ -352,11 +375,16 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
if (!item)
|
||||
item = new QTreeWidgetItem();
|
||||
|
||||
RsReputations::ReputationInfo info ;
|
||||
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),info) ;
|
||||
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||
|
||||
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||
|
||||
item->setData(RSID_COL_VOTES,Qt::DisplayRole, QString::number(info.mOverallReputationScore-1.0f));
|
||||
|
||||
if(isOwnId)
|
||||
{
|
||||
QFont font = item->font(RSID_COL_NICKNAME) ;
|
||||
@ -507,23 +535,6 @@ void IdDialog::requestIdDetails()
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS);
|
||||
}
|
||||
|
||||
static QString getHumanReadableDuration(uint32_t seconds)
|
||||
{
|
||||
if(seconds < 60)
|
||||
return QString(QObject::tr("%1 seconds ago")).arg(seconds) ;
|
||||
else if(seconds < 120)
|
||||
return QString(QObject::tr("%1 minute ago")).arg(seconds/60) ;
|
||||
else if(seconds < 3600)
|
||||
return QString(QObject::tr("%1 minutes ago")).arg(seconds/60) ;
|
||||
else if(seconds < 7200)
|
||||
return QString(QObject::tr("%1 hour ago")).arg(seconds/3600) ;
|
||||
else if(seconds < 24*3600)
|
||||
return QString(QObject::tr("%1 hours ago")).arg(seconds/3600) ;
|
||||
else if(seconds < 2*24*3600)
|
||||
return QString(QObject::tr("%1 day ago")).arg(seconds/86400) ;
|
||||
else
|
||||
return QString(QObject::tr("%1 days ago")).arg(seconds/86400) ;
|
||||
}
|
||||
|
||||
void IdDialog::insertIdDetails(uint32_t token)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>826</width>
|
||||
<height>757</height>
|
||||
<height>630</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -208,6 +208,11 @@
|
||||
<string>Owned by</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Votes</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -307,26 +312,9 @@
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Identity name :</string>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
@ -334,6 +322,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Identity name :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="PgpId_LB">
|
||||
<property name="text">
|
||||
@ -457,7 +452,7 @@
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<height>2</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@ -467,8 +462,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="reputationGroupBox">
|
||||
<property name="sizePolicy">
|
||||
@ -483,6 +476,9 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="neighborNodesOpinion_TF">
|
||||
<property name="toolTip">
|
||||
@ -584,13 +580,14 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
|
@ -28,12 +28,17 @@
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <QLayout>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include <retroshare/rsgrouter.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "GlobalRouterStatistics.h"
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
|
||||
|
||||
@ -54,6 +59,9 @@ GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
|
||||
|
||||
_router_F->setWidget( _tst_CW = new GlobalRouterStatisticsWidget() ) ;
|
||||
|
||||
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
||||
QHeaderView_setSectionResizeMode(treeWidget->header(), QHeaderView::ResizeToContents);
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
}
|
||||
@ -92,6 +100,8 @@ void GlobalRouterStatistics::processSettings(bool bLoad)
|
||||
void GlobalRouterStatistics::updateDisplay()
|
||||
{
|
||||
_tst_CW->updateContent() ;
|
||||
updateContent();
|
||||
|
||||
}
|
||||
|
||||
QString GlobalRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
||||
@ -112,6 +122,43 @@ QString GlobalRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalRouterStatistics::updateContent()
|
||||
{
|
||||
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
|
||||
rsGRouter->getRoutingCacheInfo(cache_infos) ;
|
||||
|
||||
treeWidget->clear();
|
||||
|
||||
static const QString data_status_string[6] = { "Unkown","Pending","Sent","Receipt OK","Ongoing","Done" } ;
|
||||
static const QString tunnel_status_string[4] = { "Unmanaged", "Pending", "Ready" } ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
groupBox->setTitle(tr("Pending packets")+": " + QString::number(cache_infos.size()) );
|
||||
|
||||
for(int i=0;i<cache_infos.size();++i)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
treeWidget->addTopLevelItem(item);
|
||||
|
||||
RsIdentityDetails details ;
|
||||
rsIdentity->getIdDetails(cache_infos[i].destination,details);
|
||||
QString nicknames = QString::fromUtf8(details.mNickname.c_str());
|
||||
|
||||
if(nicknames.isEmpty())
|
||||
nicknames = tr("Unknown");
|
||||
|
||||
item -> setData(0, Qt::DisplayRole, QString::number(cache_infos[i].mid,16).rightJustified(16,'0'));
|
||||
item -> setData(1, Qt::DisplayRole, nicknames + "@" + QString::fromStdString(cache_infos[i].destination.toStdString()));
|
||||
item -> setData(2, Qt::DisplayRole, data_status_string[cache_infos[i].data_status % 6]);
|
||||
item -> setData(3, Qt::DisplayRole, tunnel_status_string[cache_infos[i].tunnel_status % 3]);
|
||||
item -> setData(4, Qt::DisplayRole, misc::friendlyUnit(cache_infos[i].data_size));
|
||||
item -> setData(5, Qt::DisplayRole, QString::fromStdString(cache_infos[i].item_hash.toStdString()));
|
||||
item -> setData(6, Qt::DisplayRole, QString::number(now - cache_infos[i].routing_time));
|
||||
item -> setData(7, Qt::DisplayRole, QString::number(now - cache_infos[i].last_sent_time));
|
||||
}
|
||||
}
|
||||
|
||||
GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -124,10 +171,8 @@ GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
|
||||
|
||||
void GlobalRouterStatisticsWidget::updateContent()
|
||||
{
|
||||
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
|
||||
RsGRouter::GRouterRoutingMatrixInfo matrix_info ;
|
||||
|
||||
rsGRouter->getRoutingCacheInfo(cache_infos) ;
|
||||
rsGRouter->getRoutingMatrixInfo(matrix_info) ;
|
||||
|
||||
float size = QFontMetricsF(font()).height() ;
|
||||
@ -188,92 +233,11 @@ void GlobalRouterStatisticsWidget::updateContent()
|
||||
}
|
||||
oy += celly ;
|
||||
|
||||
painter.setFont(times_f) ;
|
||||
painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ;
|
||||
|
||||
painter.setFont(monospace_f) ;
|
||||
|
||||
static const QString data_status_string[6] = { "Unkown","Pending","Sent","Receipt OK","Ongoing","Done" } ;
|
||||
static const QString tunnel_status_string[4] = { "Unmanaged", "Pending", "Ready" } ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
std::map<QString, std::vector<QString> > tos ;
|
||||
static const int nb_fields = 8 ;
|
||||
|
||||
static const QString fname[nb_fields] = {
|
||||
tr("Id"),
|
||||
tr("Destination"),
|
||||
tr("Data status"),
|
||||
tr("Tunnel status"),
|
||||
tr("Data size"),
|
||||
tr("Data hash"),
|
||||
tr("Received"),
|
||||
tr("Send") } ;
|
||||
|
||||
std::vector<int> max_column_width(nb_fields,0) ;
|
||||
|
||||
for(int i=0;i<cache_infos.size();++i)
|
||||
{
|
||||
std::vector<QString> strings;
|
||||
strings.push_back( QString::number(cache_infos[i].mid,16).rightJustified(16,'0') ) ;
|
||||
strings.push_back( QString::fromStdString(cache_infos[i].destination.toStdString()) ) ;
|
||||
|
||||
//for(std::set<RsPeerId>::const_iterator it(cache_infos[i].local_origin.begin());it!=cache_infos[i].local_origin.end();++it)
|
||||
// packet_string += QString::fromStdString((*it).toStdString()) + " - ";
|
||||
|
||||
strings.push_back( data_status_string[cache_infos[i].data_status % 6]) ;
|
||||
strings.push_back( tunnel_status_string[cache_infos[i].tunnel_status % 3]) ;
|
||||
strings.push_back( QString::number(cache_infos[i].data_size) );
|
||||
strings.push_back( QString::fromStdString(cache_infos[i].item_hash.toStdString())) ;
|
||||
strings.push_back( QString::number(now - cache_infos[i].routing_time)) ;
|
||||
strings.push_back( QString::number(now - cache_infos[i].last_sent_time)) ;
|
||||
|
||||
tos[ strings[0] ] = strings ;
|
||||
|
||||
// now compute max column sizes
|
||||
|
||||
for(int j=0;j<nb_fields;++j)
|
||||
max_column_width[j] = std::max(max_column_width[j],(int)(fm_monospace.boundingRect(strings[j]).width()+cellx+2*fact)) ;
|
||||
}
|
||||
|
||||
// compute cumulated sizes
|
||||
|
||||
std::vector<int> cumulated_sizes(nb_fields+1,0) ;
|
||||
|
||||
for(int i=1;i<=nb_fields;++i)
|
||||
{
|
||||
cumulated_sizes[i] = std::max(max_column_width[i-1],(int)(fm_monospace.boundingRect(fname[i-1]).width()+cellx+2*fact)) ;
|
||||
cumulated_sizes[i] += cumulated_sizes[i-1] ;
|
||||
}
|
||||
|
||||
// Now draw the matrix
|
||||
|
||||
for(int i=0;i<nb_fields;++i)
|
||||
painter.drawText(ox+cumulated_sizes[i]+2,oy+celly,fname[i]) ;
|
||||
|
||||
painter.drawLine(ox,oy,ox+cumulated_sizes.back(),oy) ;
|
||||
|
||||
int top_matrix_oy = oy ;
|
||||
oy += celly +2*fact;
|
||||
|
||||
painter.drawLine(ox,oy,ox+cumulated_sizes.back(),oy) ;
|
||||
|
||||
for(std::map<QString,std::vector<QString> >::const_iterator it(tos.begin());it!=tos.end();++it)
|
||||
{
|
||||
for(int i=0;i<it->second.size();++i)
|
||||
painter.drawText(ox+cumulated_sizes[i]+2,oy+celly,it->second[i] ) ;
|
||||
|
||||
oy += celly ;
|
||||
}
|
||||
|
||||
oy += 2*fact;
|
||||
|
||||
for(int i=0;i<=nb_fields;++i)
|
||||
painter.drawLine(ox+cumulated_sizes[i],top_matrix_oy,ox+cumulated_sizes[i],oy) ;
|
||||
|
||||
painter.drawLine(ox,oy,ox+cumulated_sizes.back(),oy) ;
|
||||
oy += celly ;
|
||||
|
||||
QString prob_string ;
|
||||
painter.setFont(times_f) ;
|
||||
QString Q = tr("Routing matrix (") ;
|
||||
|
@ -41,6 +41,8 @@ class GlobalRouterStatistics: public RsAutoUpdatePage, public Ui::GlobalRouterSt
|
||||
// Cache for peer names.
|
||||
static QString getPeerName(const RsPeerId& peer_id) ;
|
||||
|
||||
void updateContent() ;
|
||||
|
||||
private:
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string>Router Statistics</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -35,17 +35,71 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>593</width>
|
||||
<height>390</height>
|
||||
<height>159</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>GroupBox</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Destinaton</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Tunnel status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data size</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Data hash</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Received</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user