@ -354,14 +354,14 @@ void RPCConsole::setClientModel(ClientModel *model)
ui - > peerWidget - > setColumnWidth ( PeerTableModel : : Ping , PING_COLUMN_WIDTH ) ;
ui - > peerWidget - > setColumnWidth ( PeerTableModel : : Ping , PING_COLUMN_WIDTH ) ;
ui - > peerWidget - > horizontalHeader ( ) - > setStretchLastSection ( true ) ;
ui - > peerWidget - > horizontalHeader ( ) - > setStretchLastSection ( true ) ;
// create context menu actions
// create peer table context menu actions
QAction * disconnectAction = new QAction ( tr ( " &Disconnect Node " ) , this ) ;
QAction * disconnectAction = new QAction ( tr ( " &Disconnect Node " ) , this ) ;
QAction * banAction1h = new QAction ( tr ( " &Ban Node for " ) + " " + tr ( " &1 hour " ) , 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 * banAction24h = new QAction ( tr ( " &Ban Node for " ) + " " + tr ( " &24 hours " ) , this ) ;
QAction * banAction7d = new QAction ( tr ( " &Ban Node for " ) + " " + tr ( " &7 days " ) , 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 ) ;
QAction * banAction365d = new QAction ( tr ( " &Ban Node for " ) + " " + tr ( " &1 year " ) , this ) ;
// create context menu
// create peer table context menu
peersTableContextMenu = new QMenu ( ) ;
peersTableContextMenu = new QMenu ( ) ;
peersTableContextMenu - > addAction ( disconnectAction ) ;
peersTableContextMenu - > addAction ( disconnectAction ) ;
peersTableContextMenu - > addAction ( banAction1h ) ;
peersTableContextMenu - > addAction ( banAction1h ) ;
@ -369,10 +369,6 @@ void RPCConsole::setClientModel(ClientModel *model)
peersTableContextMenu - > addAction ( banAction7d ) ;
peersTableContextMenu - > addAction ( banAction7d ) ;
peersTableContextMenu - > addAction ( banAction365d ) ;
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.
// Add a signal mapping to allow dynamic context menu arguments.
// We need to use int (instead of int64_t), because signal mapper only supports
// 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.
// 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 ( banAction365d , SIGNAL ( triggered ( ) ) , signalMapper , SLOT ( map ( ) ) ) ;
connect ( signalMapper , SIGNAL ( mapped ( int ) ) , this , SLOT ( banSelectedNode ( int ) ) ) ;
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 & ) ) ,
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 ( ) ) ) ;
connect ( model - > getPeerTableModel ( ) , SIGNAL ( layoutChanged ( ) ) , this , SLOT ( peerLayoutChanged ( ) ) ) ;
// set up ban table
// set up ban table
ui - > banlistWidget - > setModel ( model - > getBanTableModel ( ) ) ;
ui - > banlistWidget - > setModel ( model - > getBanTableModel ( ) ) ;
ui - > banlistWidget - > verticalHeader ( ) - > hide ( ) ;
ui - > banlistWidget - > verticalHeader ( ) - > hide ( ) ;
ui - > banlistWidget - > setEditTriggers ( QAbstractItemView : : NoEditTriggers ) ;
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 - > setSelectionBehavior ( QAbstractItemView : : SelectRows ) ;
ui - > banlistWidget - > setSelectionMode ( QAbstractItemView : : SingleSelection ) ;
ui - > banlistWidget - > setSelectionMode ( QAbstractItemView : : SingleSelection ) ;
ui - > banlistWidget - > setContextMenuPolicy ( Qt : : CustomContextMenu ) ;
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 ) ;
ui - > banlistWidget - > horizontalHeader ( ) - > setStretchLastSection ( true ) ;
// create ban table context menu action
// create ban table context menu action
@ -629,7 +630,7 @@ void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelecti
{
{
Q_UNUSED ( deselected ) ;
Q_UNUSED ( deselected ) ;
if ( ! clientModel | | selected . indexes ( ) . isEmpty ( ) )
if ( ! clientModel | | ! clientModel - > getPeerTableModel ( ) | | selected . indexes ( ) . isEmpty ( ) )
return ;
return ;
const CNodeCombinedStats * stats = clientModel - > getPeerTableModel ( ) - > getNodeStats ( selected . indexes ( ) . first ( ) . row ( ) ) ;
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 ( )
void RPCConsole : : peerLayoutChanged ( )
{
{
if ( ! clientModel )
if ( ! clientModel | | ! clientModel - > getPeerTableModel ( ) )
return ;
return ;
const CNodeCombinedStats * stats = NULL ;
const CNodeCombinedStats * stats = NULL ;
@ -748,7 +749,7 @@ void RPCConsole::showEvent(QShowEvent *event)
{
{
QWidget : : showEvent ( event ) ;
QWidget : : showEvent ( event ) ;
if ( ! clientModel )
if ( ! clientModel | | ! clientModel - > getPeerTableModel ( ) )
return ;
return ;
// start PeerTableModel auto refresh
// start PeerTableModel auto refresh
@ -759,7 +760,7 @@ void RPCConsole::hideEvent(QHideEvent *event)
{
{
QWidget : : hideEvent ( event ) ;
QWidget : : hideEvent ( event ) ;
if ( ! clientModel )
if ( ! clientModel | | ! clientModel - > getPeerTableModel ( ) )
return ;
return ;
// stop PeerTableModel auto refresh
// stop PeerTableModel auto refresh