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