Remove unused variable int64_t nEnd
[bitcoinplatinum.git] / src / qt / rpcconsole.h
blobec531c99c83d263372341d4f82853d4b5784cff3
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
8 #include "guiutil.h"
9 #include "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 = 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);
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 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);
132 enum ColumnWidths
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
142 Ui::RPCConsole *ui;
143 ClientModel *clientModel;
144 QStringList history;
145 int historyPtr;
146 QString cmdBeforeBrowsing;
147 QList<NodeId> cachedNodeids;
148 const PlatformStyle *platformStyle;
149 RPCTimerInterface *rpcTimerInterface;
150 QMenu *peersTableContextMenu;
151 QMenu *banTableContextMenu;
152 int consoleFontSize;
153 QCompleter *autoCompleter;
154 QThread thread;
156 /** Update UI with latest network info from model. */
157 void updateNetworkState();
160 #endif // BITCOIN_QT_RPCCONSOLE_H