aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2015-06-26 14:55:52 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-09-16 16:50:19 +0200
commit51654deff2661732c5e2a2aa8ac1f632f5880f45 (patch)
treed0cf07ef08416030d1ae12c88f48c49565a06a6e /src/qt
parentcdd72cd5fbc2b287559f7230d1616339e9ff2d6d (diff)
downloadbitcoin-51654deff2661732c5e2a2aa8ac1f632f5880f45.tar.xz
[Qt] bantable polish
- add missing NULL pointer checks - add better comments and reorder some code in rpcconsole.cpp - remove unneeded leftovers in bantable.cpp - update bantable column sizes to prevent cutting of banned until
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bantablemodel.cpp6
-rw-r--r--src/qt/rpcconsole.cpp41
-rw-r--r--src/qt/rpcconsole.h4
3 files changed, 23 insertions, 28 deletions
diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp
index ee40cdbf57..6074cd2f07 100644
--- a/src/qt/bantablemodel.cpp
+++ b/src/qt/bantablemodel.cpp
@@ -14,8 +14,6 @@
#include <QDebug>
#include <QList>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/date_time/c_local_time_adjustor.hpp>
// private implementation
class BanTablePriv
@@ -38,7 +36,6 @@ public:
#if QT_VERSION >= 0x040700
cachedBanlist.reserve(banMap.size());
#endif
- std::map<CSubNet, int64_t>::iterator iter;
foreach (const PAIRTYPE(CSubNet, int64_t)& banentry, banMap)
{
CCombinedBan banEntry;
@@ -104,9 +101,6 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const
date = date.addSecs(rec->bantil);
return date.toString(Qt::SystemLocaleLongDate);
}
- } else if (role == Qt::TextAlignmentRole) {
- if (index.column() == Bantime)
- return (QVariant)(Qt::AlignRight | Qt::AlignVCenter);
}
return QVariant();
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 1b82aada41..c417ec3f32 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -354,14 +354,14 @@ void RPCConsole::setClientModel(ClientModel *model)
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
- // create context menu actions
- QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
- QAction* banAction1h = new QAction(tr("&Ban Node for") + " " + tr("&1 hour"), this);
- QAction* banAction24h = new QAction(tr("&Ban Node for") + " " + tr("&24 hours"), this);
- QAction* banAction7d = new QAction(tr("&Ban Node for") + " " + tr("&7 days"), this);
- QAction* banAction365d = new QAction(tr("&Ban Node for") + " " + tr("&1 year"), this);
-
- // create context menu
+ // create peer table context menu actions
+ QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
+ QAction* banAction1h = new QAction(tr("&Ban Node for") + " " + tr("&1 hour"), this);
+ QAction* banAction24h = new QAction(tr("&Ban Node for") + " " + tr("&24 hours"), this);
+ QAction* banAction7d = new QAction(tr("&Ban Node for") + " " + tr("&7 days"), this);
+ QAction* banAction365d = new QAction(tr("&Ban Node for") + " " + tr("&1 year"), this);
+
+ // create peer table context menu
peersTableContextMenu = new QMenu();
peersTableContextMenu->addAction(disconnectAction);
peersTableContextMenu->addAction(banAction1h);
@@ -369,10 +369,6 @@ void RPCConsole::setClientModel(ClientModel *model)
peersTableContextMenu->addAction(banAction7d);
peersTableContextMenu->addAction(banAction365d);
- // context menu signals
- connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&)));
- connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode()));
-
// Add a signal mapping to allow dynamic context menu arguments.
// We need to use int (instead of int64_t), because signal mapper only supports
// int or objects, which is okay because max bantime (1 year) is < int_max.
@@ -387,20 +383,25 @@ void RPCConsole::setClientModel(ClientModel *model)
connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(banSelectedNode(int)));
- // connect the peerWidget selection model to our peerSelected() handler
+ // peer table context menu signals
+ connect(ui->peerWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showPeersTableContextMenu(const QPoint&)));
+ connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSelectedNode()));
+
+ // peer table signal handling - update peer details when selecting new node
connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
- this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &)));
+ this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &)));
+ // peer table signal handling - update peer details when new nodes are added to the model
connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged()));
// set up ban table
ui->banlistWidget->setModel(model->getBanTableModel());
ui->banlistWidget->verticalHeader()->hide();
ui->banlistWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
- ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
- ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
+ ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
// create ban table context menu action
@@ -629,7 +630,7 @@ void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelecti
{
Q_UNUSED(deselected);
- if (!clientModel || selected.indexes().isEmpty())
+ if (!clientModel || !clientModel->getPeerTableModel() || selected.indexes().isEmpty())
return;
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
@@ -639,7 +640,7 @@ void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelecti
void RPCConsole::peerLayoutChanged()
{
- if (!clientModel)
+ if (!clientModel || !clientModel->getPeerTableModel())
return;
const CNodeCombinedStats *stats = NULL;
@@ -748,7 +749,7 @@ void RPCConsole::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
- if (!clientModel)
+ if (!clientModel || !clientModel->getPeerTableModel())
return;
// start PeerTableModel auto refresh
@@ -759,7 +760,7 @@ void RPCConsole::hideEvent(QHideEvent *event)
{
QWidget::hideEvent(event);
- if (!clientModel)
+ if (!clientModel || !clientModel->getPeerTableModel())
return;
// stop PeerTableModel auto refresh
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index d5a769ae72..b86f776786 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -108,8 +108,8 @@ private:
ADDRESS_COLUMN_WIDTH = 200,
SUBVERSION_COLUMN_WIDTH = 100,
PING_COLUMN_WIDTH = 80,
- BANSUBNET_COLUMN_WIDTH = 250,
- BANTIME_COLUMN_WIDTH = 200
+ BANSUBNET_COLUMN_WIDTH = 200,
+ BANTIME_COLUMN_WIDTH = 250
};