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