b523f0fa9024de45ae2e52c925c88619a0b2dc03
[novacoin.git] / src / qt / rpcconsole.h
1 #ifndef RPCCONSOLE_H
2 #define RPCCONSOLE_H
3
4 #include <QWidget>
5
6 namespace Ui {
7     class RPCConsole;
8 }
9 class ClientModel;
10
11 /** Local Bitcoin RPC console. */
12 class RPCConsole: public QWidget
13 {
14     Q_OBJECT
15
16 public:
17     explicit RPCConsole(QWidget *parent = 0);
18     ~RPCConsole();
19
20     void setClientModel(ClientModel *model);
21
22     enum MessageClass {
23         MC_ERROR,
24         MC_DEBUG,
25         CMD_REQUEST,
26         CMD_REPLY,
27         CMD_ERROR
28     };
29
30 protected:
31     virtual bool eventFilter(QObject* obj, QEvent *event);
32     void keyPressEvent(QKeyEvent *);
33
34 private slots:
35     void on_lineEdit_returnPressed();
36     void on_tabWidget_currentChanged(int index);
37     /** open the debug.log from the current datadir */
38     void on_openDebugLogfileButton_clicked();
39     /** change the time range of the network traffic graph */
40     void on_sldGraphRange_valueChanged(int value);
41     /** update traffic statistics */
42     void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
43     void resizeEvent(QResizeEvent *event);
44     void showEvent(QShowEvent *event);
45     void hideEvent(QHideEvent *event);
46     /** display messagebox with program parameters (same as bitcoin-qt --help) */
47     void on_showCLOptionsButton_clicked();
48
49 public slots:
50     void clear();
51     void message(int category, const QString &message, bool html = false);
52     /** Set number of connections shown in the UI */
53     void setNumConnections(int count);
54     /** Set number of blocks shown in the UI */
55     void setNumBlocks(int count, int countOfPeers);
56     /** Go forward or back in history */
57     void browseHistory(int offset);
58     /** Scroll console view to end */
59     void scrollToEnd();
60 signals:
61     // For RPC command executor
62     void stopExecutor();
63     void cmdRequest(const QString &command);
64
65 private:
66     static QString FormatBytes(quint64 bytes);
67     void setTrafficGraphRange(int mins);
68     /** show detailed information on ui about selected node */
69
70     enum ColumnWidths
71     {
72         ADDRESS_COLUMN_WIDTH = 200,
73         SUBVERSION_COLUMN_WIDTH = 100,
74         PING_COLUMN_WIDTH = 80
75     };
76
77     Ui::RPCConsole *ui;
78     ClientModel *clientModel;
79     QStringList history;
80     int historyPtr;
81
82     void startExecutor();
83 };
84
85 #endif // RPCCONSOLE_H