Add traffic monitor
[novacoin.git] / src / qt / clientmodel.h
1 #ifndef CLIENTMODEL_H
2 #define CLIENTMODEL_H
3
4 #include <QObject>
5
6 class OptionsModel;
7 class AddressTableModel;
8 class TransactionTableModel;
9 class CWallet;
10
11 QT_BEGIN_NAMESPACE
12 class QDateTime;
13 class QTimer;
14 QT_END_NAMESPACE
15
16 /** Model for Bitcoin network client. */
17 class ClientModel : public QObject
18 {
19     Q_OBJECT
20 public:
21     explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
22     ~ClientModel();
23
24     OptionsModel *getOptionsModel();
25
26     double getPoSKernelPS();
27     double getDifficulty(bool fProofofStake);
28
29     int getNumConnections() const;
30     int getNumBlocks() const;
31     int getNumBlocksAtStartup();
32
33     quint64 getTotalBytesRecv() const;
34     quint64 getTotalBytesSent() const;
35
36     QDateTime getLastBlockDate() const;
37
38     //! Return true if client connected to testnet
39     bool isTestNet() const;
40     //! Return true if core is doing initial block download
41     bool inInitialBlockDownload() const;
42     //! Return conservative estimate of total number of blocks, or 0 if unknown
43     int getNumBlocksOfPeers() const;
44     //! Return warnings to be displayed in status bar
45     QString getStatusBarWarnings() const;
46
47     QString formatFullVersion() const;
48     QString formatBuildDate() const;
49     QString clientName() const;
50     QString formatClientStartupTime() const;
51
52 private:
53     OptionsModel *optionsModel;
54
55     int cachedNumBlocks;
56     int cachedNumBlocksOfPeers;
57
58     int numBlocksAtStartup;
59
60     QTimer *pollTimer;
61
62     void subscribeToCoreSignals();
63     void unsubscribeFromCoreSignals();
64 signals:
65     void numConnectionsChanged(int count);
66     void numBlocksChanged(int count, int countOfPeers);
67     void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
68
69     //! Asynchronous error notification
70     void error(const QString &title, const QString &message, bool modal);
71
72 public slots:
73     void updateTimer();
74     void updateNumConnections(int numConnections);
75     void updateAlert(const QString &hash, int status);
76 };
77
78 #endif // CLIENTMODEL_H