]> Git Repo - VerusCoin.git/blob - src/qt/clientmodel.h
Merge pull request #4223
[VerusCoin.git] / src / qt / clientmodel.h
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 #ifndef CLIENTMODEL_H
6 #define CLIENTMODEL_H
7
8 #include <QObject>
9
10 class AddressTableModel;
11 class OptionsModel;
12 class PeerTableModel;
13 class TransactionTableModel;
14
15 class CWallet;
16
17 QT_BEGIN_NAMESPACE
18 class QDateTime;
19 class QTimer;
20 QT_END_NAMESPACE
21
22 enum BlockSource {
23     BLOCK_SOURCE_NONE,
24     BLOCK_SOURCE_REINDEX,
25     BLOCK_SOURCE_DISK,
26     BLOCK_SOURCE_NETWORK
27 };
28
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
36 /** Model for Bitcoin network client. */
37 class ClientModel : public QObject
38 {
39     Q_OBJECT
40
41 public:
42     explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
43     ~ClientModel();
44
45     OptionsModel *getOptionsModel();
46     PeerTableModel *getPeerTableModel();
47
48     //! Return number of connections, default is in- and outbound (total)
49     int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
50     int getNumBlocks() const;
51     int getNumBlocksAtStartup();
52
53     quint64 getTotalBytesRecv() const;
54     quint64 getTotalBytesSent() const;
55
56     double getVerificationProgress() const;
57     QDateTime getLastBlockDate() const;
58
59     //! Return network (main, testnet3, regtest)
60     QString getNetworkName() const;
61     //! Return true if core is doing initial block download
62     bool inInitialBlockDownload() const;
63     //! Return true if core is importing blocks
64     enum BlockSource getBlockSource() const;
65     //! Return warnings to be displayed in status bar
66     QString getStatusBarWarnings() const;
67
68     QString formatFullVersion() const;
69     QString formatBuildDate() const;
70     bool isReleaseVersion() const;
71     QString clientName() const;
72     QString formatClientStartupTime() const;
73
74 private:
75     OptionsModel *optionsModel;
76     PeerTableModel *peerTableModel;
77
78     int cachedNumBlocks;
79     bool cachedReindexing;
80     bool cachedImporting;
81
82     int numBlocksAtStartup;
83
84     QTimer *pollTimer;
85
86     void subscribeToCoreSignals();
87     void unsubscribeFromCoreSignals();
88
89 signals:
90     void numConnectionsChanged(int count);
91     void numBlocksChanged(int count);
92     void alertsChanged(const QString &warnings);
93     void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
94
95     //! Fired when a message should be reported to the user
96     void message(const QString &title, const QString &message, unsigned int style);
97
98     // Show progress dialog e.g. for verifychain
99     void showProgress(const QString &title, int nProgress);
100
101 public slots:
102     void updateTimer();
103     void updateNumConnections(int numConnections);
104     void updateAlert(const QString &hash, int status);
105 };
106
107 #endif // CLIENTMODEL_H
This page took 0.0292 seconds and 4 git commands to generate.