]>
Commit | Line | Data |
---|---|---|
f914f1a7 | 1 | // Copyright (c) 2011-2013 The Bitcoin Core developers |
78253fcb | 2 | // Distributed under the MIT software license, see the accompanying |
e592d43f WL |
3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | ||
84738627 PJ |
5 | #ifndef BITCOIN_QT_CLIENTMODEL_H |
6 | #define BITCOIN_QT_CLIENTMODEL_H | |
18cab09a WL |
7 | |
8 | #include <QObject> | |
8517e970 | 9 | #include <QDateTime> |
2547f1f7 | 10 | |
2547f1f7 | 11 | class AddressTableModel; |
51ed9ec9 | 12 | class OptionsModel; |
65f78a11 | 13 | class PeerTableModel; |
467c31ea | 14 | class TransactionTableModel; |
51ed9ec9 | 15 | |
e8ef3da7 | 16 | class CWallet; |
18cab09a | 17 | |
84c8506e | 18 | QT_BEGIN_NAMESPACE |
fe4a6550 | 19 | class QTimer; |
84c8506e WL |
20 | QT_END_NAMESPACE |
21 | ||
7fea4846 PW |
22 | enum BlockSource { |
23 | BLOCK_SOURCE_NONE, | |
4881353e | 24 | BLOCK_SOURCE_REINDEX, |
7fea4846 | 25 | BLOCK_SOURCE_DISK, |
4881353e | 26 | BLOCK_SOURCE_NETWORK |
7fea4846 PW |
27 | }; |
28 | ||
8e296230 PK |
29 | enum NumConnections { |
30 | CONNECTIONS_NONE = 0, | |
31 | CONNECTIONS_IN = (1U << 0), | |
32 | CONNECTIONS_OUT = (1U << 1), | |
33 | CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT), | |
34 | }; | |
35 | ||
af836ad5 | 36 | /** Model for Bitcoin network client. */ |
18cab09a WL |
37 | class ClientModel : public QObject |
38 | { | |
39 | Q_OBJECT | |
32af5266 | 40 | |
18cab09a | 41 | public: |
ee014e5b | 42 | explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); |
ab1b288f | 43 | ~ClientModel(); |
18cab09a | 44 | |
92f20d53 | 45 | OptionsModel *getOptionsModel(); |
65f78a11 | 46 | PeerTableModel *getPeerTableModel(); |
92f20d53 | 47 | |
8e296230 PK |
48 | //! Return number of connections, default is in- and outbound (total) |
49 | int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; | |
7df70c00 | 50 | int getNumBlocks() const; |
7df70c00 | 51 | |
ce14345a SE |
52 | quint64 getTotalBytesRecv() const; |
53 | quint64 getTotalBytesSent() const; | |
54 | ||
9f2467ad | 55 | double getVerificationProgress() const; |
84c8506e WL |
56 | QDateTime getLastBlockDate() const; |
57 | ||
af836ad5 | 58 | //! Return true if core is doing initial block download |
7df70c00 | 59 | bool inInitialBlockDownload() const; |
66b02c93 | 60 | //! Return true if core is importing blocks |
7fea4846 | 61 | enum BlockSource getBlockSource() const; |
7ca47cec MC |
62 | //! Return warnings to be displayed in status bar |
63 | QString getStatusBarWarnings() const; | |
18cab09a | 64 | |
0052fe7b | 65 | QString formatFullVersion() const; |
a20c0d0f | 66 | QString formatBuildDate() const; |
62e21fb5 | 67 | bool isReleaseVersion() const; |
460c51fd | 68 | QString clientName() const; |
41c6b8ab | 69 | QString formatClientStartupTime() const; |
0052fe7b | 70 | |
92f20d53 | 71 | private: |
2547f1f7 | 72 | OptionsModel *optionsModel; |
65f78a11 | 73 | PeerTableModel *peerTableModel; |
6630c1cb | 74 | |
5df0b03c | 75 | int cachedNumBlocks; |
8517e970 | 76 | QDateTime cachedBlockDate; |
42018eff PK |
77 | bool cachedReindexing; |
78 | bool cachedImporting; | |
5df0b03c | 79 | |
fe4a6550 WL |
80 | QTimer *pollTimer; |
81 | ||
ab1b288f WL |
82 | void subscribeToCoreSignals(); |
83 | void unsubscribeFromCoreSignals(); | |
32af5266 | 84 | |
18cab09a | 85 | signals: |
18cab09a | 86 | void numConnectionsChanged(int count); |
8517e970 | 87 | void numBlocksChanged(int count, const QDateTime& blockDate); |
62e21fb5 | 88 | void alertsChanged(const QString &warnings); |
ce14345a | 89 | void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut); |
ef079e18 | 90 | |
ccd1372d | 91 | //! Fired when a message should be reported to the user |
3675588a | 92 | void message(const QString &title, const QString &message, unsigned int style); |
18cab09a | 93 | |
06a91d96 CL |
94 | // Show progress dialog e.g. for verifychain |
95 | void showProgress(const QString &title, int nProgress); | |
96 | ||
18cab09a | 97 | public slots: |
fe4a6550 WL |
98 | void updateTimer(); |
99 | void updateNumConnections(int numConnections); | |
100 | void updateAlert(const QString &hash, int status); | |
18cab09a WL |
101 | }; |
102 | ||
84738627 | 103 | #endif // BITCOIN_QT_CLIENTMODEL_H |