1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_QT_RPCCONSOLE_H
6 #define BITCOIN_QT_RPCCONSOLE_H
9 #include "peertablemodel.h"
19 class RPCTimerInterface
;
30 /** Local Bitcoin RPC console. */
31 class RPCConsole
: public QWidget
36 explicit RPCConsole(const PlatformStyle
*platformStyle
, QWidget
*parent
);
39 static bool RPCParseCommandLine(std::string
&strResult
, const std::string
&strCommand
, bool fExecute
, std::string
* const pstrFilteredOut
= NULL
);
40 static bool RPCExecuteCommandLine(std::string
&strResult
, const std::string
&strCommand
, std::string
* const pstrFilteredOut
= NULL
) {
41 return RPCParseCommandLine(strResult
, strCommand
, true, pstrFilteredOut
);
44 void setClientModel(ClientModel
*model
);
62 virtual bool eventFilter(QObject
* obj
, QEvent
*event
);
63 void keyPressEvent(QKeyEvent
*);
66 void on_lineEdit_returnPressed();
67 void on_tabWidget_currentChanged(int index
);
68 /** open the debug.log from the current datadir */
69 void on_openDebugLogfileButton_clicked();
70 /** change the time range of the network traffic graph */
71 void on_sldGraphRange_valueChanged(int value
);
72 /** update traffic statistics */
73 void updateTrafficStats(quint64 totalBytesIn
, quint64 totalBytesOut
);
74 void resizeEvent(QResizeEvent
*event
);
75 void showEvent(QShowEvent
*event
);
76 void hideEvent(QHideEvent
*event
);
77 /** Show custom context menu on Peers tab */
78 void showPeersTableContextMenu(const QPoint
& point
);
79 /** Show custom context menu on Bans tab */
80 void showBanTableContextMenu(const QPoint
& point
);
81 /** Hides ban table if no bans are present */
82 void showOrHideBanTableIfRequired();
83 /** clear the selected node */
84 void clearSelectedNode();
87 void clear(bool clearHistory
= true);
90 void setFontSize(int newSize
);
91 /** Append the message to the message widget */
92 void message(int category
, const QString
&message
, bool html
= false);
93 /** Set number of connections shown in the UI */
94 void setNumConnections(int count
);
95 /** Set network state shown in the UI */
96 void setNetworkActive(bool networkActive
);
97 /** Set number of blocks and last block date shown in the UI */
98 void setNumBlocks(int count
, const QDateTime
& blockDate
, double nVerificationProgress
, bool headers
);
99 /** Set size (number of transactions and memory usage) of the mempool in the UI */
100 void setMempoolSize(long numberOfTxs
, size_t dynUsage
);
101 /** Go forward or back in history */
102 void browseHistory(int offset
);
103 /** Scroll console view to end */
105 /** Handle selection of peer in peers list */
106 void peerSelected(const QItemSelection
&selected
, const QItemSelection
&deselected
);
107 /** Handle selection caching before update */
108 void peerLayoutAboutToChange();
109 /** Handle updated peer information */
110 void peerLayoutChanged();
111 /** Disconnect a selected node on the Peers tab */
112 void disconnectSelectedNode();
113 /** Ban a selected node on the Peers tab */
114 void banSelectedNode(int bantime
);
115 /** Unban a selected node on the Bans tab */
116 void unbanSelectedNode();
117 /** set which tab has the focus (is visible) */
118 void setTabFocus(enum TabTypes tabType
);
121 // For RPC command executor
123 void cmdRequest(const QString
&command
);
126 static QString
FormatBytes(quint64 bytes
);
127 void startExecutor();
128 void setTrafficGraphRange(int mins
);
129 /** show detailed information on ui about selected node */
130 void updateNodeDetail(const CNodeCombinedStats
*stats
);
134 ADDRESS_COLUMN_WIDTH
= 200,
135 SUBVERSION_COLUMN_WIDTH
= 150,
136 PING_COLUMN_WIDTH
= 80,
137 BANSUBNET_COLUMN_WIDTH
= 200,
138 BANTIME_COLUMN_WIDTH
= 250
143 ClientModel
*clientModel
;
146 QString cmdBeforeBrowsing
;
147 QList
<NodeId
> cachedNodeids
;
148 const PlatformStyle
*platformStyle
;
149 RPCTimerInterface
*rpcTimerInterface
;
150 QMenu
*peersTableContextMenu
;
151 QMenu
*banTableContextMenu
;
153 QCompleter
*autoCompleter
;
156 /** Update UI with latest network info from model. */
157 void updateNetworkState();
160 #endif // BITCOIN_QT_RPCCONSOLE_H