aa8c8f3182b7905c80d28b95fbddd327269a62d4
[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     /** open the novacoin.conf from the current datadir */
40     void on_openConfigurationfileButton_clicked();
41     /** change the time range of the network traffic graph */
42     void on_sldGraphRange_valueChanged(int value);
43     /** update traffic statistics */
44     void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut);
45     void resizeEvent(QResizeEvent *event);
46     void showEvent(QShowEvent *event);
47     void hideEvent(QHideEvent *event);
48     /** display messagebox with program parameters (same as bitcoin-qt --help) */
49     void on_showCLOptionsButton_clicked();
50
51 public slots:
52     void clear();
53     void message(int category, const QString &message, bool html = false);
54     /** Set number of connections shown in the UI */
55     void setNumConnections(int count);
56     /** Set number of blocks shown in the UI */
57     void setNumBlocks(int count, int countOfPeers);
58     /** Go forward or back in history */
59     void browseHistory(int offset);
60     /** Scroll console view to end */
61     void scrollToEnd();
62 signals:
63     // For RPC command executor
64     void stopExecutor();
65     void cmdRequest(const QString &command);
66
67 private:
68     static QString FormatBytes(quint64 bytes);
69     void setTrafficGraphRange(int mins);
70     /** show detailed information on ui about selected node */
71
72     enum ColumnWidths
73     {
74         ADDRESS_COLUMN_WIDTH = 200,
75         SUBVERSION_COLUMN_WIDTH = 100,
76         PING_COLUMN_WIDTH = 80
77     };
78
79     Ui::RPCConsole *ui;
80     ClientModel *clientModel;
81     QStringList history;
82     int historyPtr;
83
84     void startExecutor();
85 };
86
87 #endif // RPCCONSOLE_H