70d816ba9dd4a4ace324d09ea4b87b898a24aac5
[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     int getNumConnections() const;
27     int getNumBlocks() const;
28     int getNumBlocksAtStartup();
29
30     QDateTime getLastBlockDate() const;
31
32     //! Return true if client connected to testnet
33     bool isTestNet() const;
34     //! Return true if core is doing initial block download
35     bool inInitialBlockDownload() const;
36     //! Return conservative estimate of total number of blocks, or 0 if unknown
37     int getNumBlocksOfPeers() const;
38     //! Return warnings to be displayed in status bar
39     QString getStatusBarWarnings() const;
40
41     QString formatFullVersion() const;
42     QString formatBuildDate() const;
43     QString clientName() const;
44     QString formatClientStartupTime() const;
45
46 private:
47     OptionsModel *optionsModel;
48
49     int cachedNumBlocks;
50     int cachedNumBlocksOfPeers;
51
52     int numBlocksAtStartup;
53
54     QTimer *pollTimer;
55
56     void subscribeToCoreSignals();
57     void unsubscribeFromCoreSignals();
58 signals:
59     void numConnectionsChanged(int count);
60     void numBlocksChanged(int count, int countOfPeers);
61
62     //! Asynchronous error notification
63     void error(const QString &title, const QString &message, bool modal);
64
65 public slots:
66     void updateTimer();
67     void updateNumConnections(int numConnections);
68     void updateAlert(const QString &hash, int status);
69 };
70
71 #endif // CLIENTMODEL_H