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