From c89ff9f059f0a471467d39459eafd8d44699f0cb Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 21 Nov 2015 13:47:50 +0100 Subject: [PATCH] Added nickname column to pending packets & context menu action to view details Fixed ui layout. --- .../gui/statistics/BandwidthStatsWidget.ui | 33 ++++++++-- .../src/gui/statistics/BwCtrlWindow.ui | 11 +++- .../gui/statistics/GlobalRouterStatistics.cpp | 60 ++++++++++++++++--- .../gui/statistics/GlobalRouterStatistics.h | 8 ++- .../gui/statistics/GlobalRouterStatistics.ui | 8 +++ 5 files changed, 104 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.ui b/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.ui index 56f5e5315..3ed54ef4e 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.ui +++ b/retroshare-gui/src/gui/statistics/BandwidthStatsWidget.ui @@ -6,14 +6,17 @@ 0 0 - 1597 - 811 + 812 + 349 Form + + 0 + @@ -44,7 +47,17 @@ - + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + @@ -75,7 +88,17 @@ - + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + @@ -94,7 +117,7 @@ - 726 + 20 20 diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui index dc20f8015..cf9e0ab8d 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui @@ -7,7 +7,7 @@ 0 0 1447 - 911 + 471 @@ -89,7 +89,14 @@ Qt::Vertical - + + + + 0 + 0 + + + diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 53d7f52c4..91139618b 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -36,10 +37,22 @@ #include "GlobalRouterStatistics.h" +#include "gui/Identity/IdDetailsDialog.h" #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/misc.h" +#define COL_ID 0 +#define COL_NICKNAME 1 +#define COL_DESTINATION 2 +#define COL_DATASTATUS 3 +#define COL_TUNNELSTATUS 4 +#define COL_DATASIZE 5 +#define COL_DATAHASH 6 +#define COL_RECEIVED 7 +#define COL_SEND 8 + + static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ; static QColor colorScale(float f) @@ -61,6 +74,9 @@ GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent) /* Set header resize modes and initial section sizes Uploads TreeView*/ QHeaderView_setSectionResizeMode(treeWidget->header(), QHeaderView::ResizeToContents); + + connect(treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CustomPopupMenu(QPoint))); + // load settings processSettings(true); @@ -97,6 +113,19 @@ void GlobalRouterStatistics::processSettings(bool bLoad) m_bProcessSettings = false; } +void GlobalRouterStatistics::CustomPopupMenu( QPoint ) +{ + QMenu contextMnu( this ); + + QTreeWidgetItem *item = treeWidget->currentItem(); + if (item) { + contextMnu.addAction(QIcon(":/images/info16.png"), tr("Details"), this, SLOT(personDetails())); + + } + + contextMnu.exec(QCursor::pos()); +} + void GlobalRouterStatistics::updateDisplay() { _tst_CW->updateContent() ; @@ -148,17 +177,32 @@ void GlobalRouterStatistics::updateContent() 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)); + 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())); + item -> setData(COL_DATASTATUS, Qt::DisplayRole, data_status_string[cache_infos[i].data_status % 6]); + item -> setData(COL_TUNNELSTATUS, Qt::DisplayRole, tunnel_status_string[cache_infos[i].tunnel_status % 3]); + item -> setData(COL_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(cache_infos[i].data_size)); + item -> setData(COL_DATAHASH, Qt::DisplayRole, QString::fromStdString(cache_infos[i].item_hash.toStdString())); + item -> setData(COL_RECEIVED, Qt::DisplayRole, QString::number(now - cache_infos[i].routing_time)); + item -> setData(COL_SEND, Qt::DisplayRole, QString::number(now - cache_infos[i].last_sent_time)); } } +void GlobalRouterStatistics::personDetails() +{ + QTreeWidgetItem *item = treeWidget->currentItem(); + std::string id = item->text(COL_DESTINATION).toStdString(); + + if (id.empty()) { + return; + } + + IdDetailsDialog *dialog = new IdDetailsDialog(RsGxsGroupId(id)); + dialog->show(); + +} + GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent) : QWidget(parent) { diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h index eeea4517d..2180849cc 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h @@ -42,7 +42,12 @@ class GlobalRouterStatistics: public RsAutoUpdatePage, public Ui::GlobalRouterSt static QString getPeerName(const RsPeerId& peer_id) ; void updateContent() ; - + +private slots: + /** Create the context popup menu and it's submenus */ + void CustomPopupMenu( QPoint point ); + void personDetails(); + private: void processSettings(bool bLoad); @@ -50,6 +55,7 @@ class GlobalRouterStatistics: public RsAutoUpdatePage, public Ui::GlobalRouterSt virtual void updateDisplay() ; + GlobalRouterStatisticsWidget *_tst_CW ; } ; diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui index 17e95c2a8..38890fa2f 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.ui @@ -50,6 +50,9 @@ + + Qt::CustomContextMenu + true @@ -58,6 +61,11 @@ ID + + + Identity Name + + Destinaton