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