Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / src / qt / rpcconsole.h
blobc41cbb093341a1ce611ff7465485d17eb0f8bf5c
1 // Copyright (c) 2011-2017 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
8 #include <qt/guiutil.h>
9 #include <qt/peertablemodel.h>
11 #include <net.h>
13 #include <QWidget>
14 #include <QCompleter>
15 #include <QThread>
17 class ClientModel;
18 class PlatformStyle;
19 class RPCTimerInterface;
21 namespace Ui {
22 class RPCConsole;
25 QT_BEGIN_NAMESPACE
26 class QMenu;
27 class QItemSelection;
28 QT_END_NAMESPACE
30 /** Local Bitcoin RPC console. */
31 class RPCConsole: public QWidget
33 Q_OBJECT
35 public:
36 explicit RPCConsole(const PlatformStyle *platformStyle, QWidget *parent);
37 ~RPCConsole();
39 static bool RPCParseCommandLine(std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr);
40 static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr) {
41 return RPCParseCommandLine(strResult, strCommand, true, pstrFilteredOut);
44 void setClientModel(ClientModel *model);
46 enum MessageClass {
47 MC_ERROR,
48 MC_DEBUG,
49 CMD_REQUEST,
50 CMD_REPLY,
51 CMD_ERROR
54 enum TabTypes {
55 TAB_INFO = 0,
56 TAB_CONSOLE = 1,
57 TAB_GRAPH = 2,
58 TAB_PEERS = 3
61 protected:
62 virtual bool eventFilter(QObject* obj, QEvent *event);
63 void keyPressEvent(QKeyEvent *);
65 private Q_SLOTS:
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();
86 public Q_SLOTS:
87 void clear(bool clearHistory = true);
88 void fontBigger();
89 void fontSmaller();
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 */
104 void scrollToEnd();
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);
120 Q_SIGNALS:
121 // For RPC command executor
122 void stopExecutor();
123 void cmdRequest(const QString &command);
125 private:
126 void startExecutor();
127 void setTrafficGraphRange(int mins);
128 /** show detailed information on ui about selected node */
129 void updateNodeDetail(const CNodeCombinedStats *stats);
131 enum ColumnWidths
133 ADDRESS_COLUMN_WIDTH = 200,
134 SUBVERSION_COLUMN_WIDTH = 150,
135 PING_COLUMN_WIDTH = 80,
136 BANSUBNET_COLUMN_WIDTH = 200,
137 BANTIME_COLUMN_WIDTH = 250
141 Ui::RPCConsole *ui;
142 ClientModel *clientModel;
143 QStringList history;
144 int historyPtr;
145 QString cmdBeforeBrowsing;
146 QList<NodeId> cachedNodeids;
147 const PlatformStyle *platformStyle;
148 RPCTimerInterface *rpcTimerInterface;
149 QMenu *peersTableContextMenu;
150 QMenu *banTableContextMenu;
151 int consoleFontSize;
152 QCompleter *autoCompleter;
153 QThread thread;
155 /** Update UI with latest network info from model. */
156 void updateNetworkState();
159 #endif // BITCOIN_QT_RPCCONSOLE_H