Dash Core  0.12.2.1
P2P Digital Currency
clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 The Bitcoin Core developers
2 // Copyright (c) 2014-2017 The Dash Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_QT_CLIENTMODEL_H
7 #define BITCOIN_QT_CLIENTMODEL_H
8 
9 #include <QObject>
10 #include <QDateTime>
11 
12 #include <atomic>
13 
14 class AddressTableModel;
15 class BanTableModel;
16 class OptionsModel;
17 class PeerTableModel;
19 
20 class CWallet;
21 class CBlockIndex;
22 
23 QT_BEGIN_NAMESPACE
24 class QTimer;
25 QT_END_NAMESPACE
26 
32 };
33 
36  CONNECTIONS_IN = (1U << 0),
37  CONNECTIONS_OUT = (1U << 1),
39 };
40 
42 class ClientModel : public QObject
43 {
44  Q_OBJECT
45 
46 public:
47  explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
48  ~ClientModel();
49 
53 
55  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
56  QString getMasternodeCountString() const;
57  int getNumBlocks() const;
58  int getHeaderTipHeight() const;
59  int64_t getHeaderTipTime() const;
61  long getMempoolSize() const;
63  size_t getMempoolDynamicUsage() const;
64 
65  quint64 getTotalBytesRecv() const;
66  quint64 getTotalBytesSent() const;
67 
68  double getVerificationProgress(const CBlockIndex *tip) const;
69  QDateTime getLastBlockDate() const;
70 
72  bool inInitialBlockDownload() const;
74  enum BlockSource getBlockSource() const;
76  bool getNetworkActive() const;
78  void setNetworkActive(bool active);
80  QString getStatusBarWarnings() const;
81 
82  QString formatFullVersion() const;
83  QString formatSubVersion() const;
84  bool isReleaseVersion() const;
85  QString clientName() const;
86  QString formatClientStartupTime() const;
87  QString dataDir() const;
88 
89  // caches for the best header
90  mutable std::atomic<int> cachedBestHeaderHeight;
91  mutable std::atomic<int64_t> cachedBestHeaderTime;
92 
93 private:
98 
99  QTimer *pollTimer;
100  QTimer *pollMnTimer;
101 
102  void subscribeToCoreSignals();
104 
105 Q_SIGNALS:
106  void numConnectionsChanged(int count);
107  void strMasternodesChanged(const QString &strMasternodes);
108  void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
109  void additionalDataSyncProgressChanged(double nSyncProgress);
110  void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
111  void networkActiveChanged(bool networkActive);
112  void alertsChanged(const QString &warnings);
113  void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
114 
116  void message(const QString &title, const QString &message, unsigned int style);
117 
118  // Show progress dialog e.g. for verifychain
119  void showProgress(const QString &title, int nProgress);
120 
121 public Q_SLOTS:
122  void updateTimer();
123  void updateMnTimer();
124  void updateNumConnections(int numConnections);
125  void updateNetworkActive(bool networkActive);
126  void updateAlert(const QString &hash, int status);
127  void updateBanlist();
128 };
129 
130 #endif // BITCOIN_QT_CLIENTMODEL_H
void subscribeToCoreSignals()
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:37
void additionalDataSyncProgressChanged(double nSyncProgress)
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes)
size_t getMempoolDynamicUsage() const
Return the dynamic memory usage of the mempool.
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
int64_t getHeaderTipTime() const
void updateAlert(const QString &hash, int status)
int flags
Definition: dash-tx.cpp:326
QTimer * pollMnTimer
Definition: clientmodel.h:100
int getNumBlocks() const
Definition: clientmodel.cpp:94
QString cachedMasternodeCountString
Definition: clientmodel.h:96
void updateNumConnections(int numConnections)
void setNetworkActive(bool active)
Toggle network activity state in core.
std::atomic< int64_t > cachedBestHeaderTime
Definition: clientmodel.h:91
bool isReleaseVersion() const
void showProgress(const QString &title, int nProgress)
void strMasternodesChanged(const QString &strMasternodes)
BanTableModel * banTableModel
Definition: clientmodel.h:97
NumConnections
Definition: clientmodel.h:34
QString getMasternodeCountString() const
Definition: clientmodel.cpp:82
void updateNetworkActive(bool networkActive)
BlockSource
Definition: clientmodel.h:27
void updateMnTimer()
PeerTableModel * peerTableModel
Definition: clientmodel.h:95
QString formatSubVersion() const
QString dataDir() const
OptionsModel * optionsModel
Definition: clientmodel.h:94
int getHeaderTipHeight() const
long getMempoolSize() const
Return number of transactions in the mempool.
QString formatFullVersion() const
QString formatClientStartupTime() const
bool getNetworkActive() const
Return true if network activity in core is enabled.
quint64 getTotalBytesRecv() const
void updateBanlist()
static int count
Definition: tests.c:41
double getVerificationProgress(const CBlockIndex *tip) const
void alertsChanged(const QString &warnings)
std::atomic< int > cachedBestHeaderHeight
Definition: clientmodel.h:90
void unsubscribeFromCoreSignals()
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
QTimer * pollTimer
Definition: clientmodel.h:99
quint64 getTotalBytesSent() const
void numConnectionsChanged(int count)
QDateTime getLastBlockDate() const
QString clientName() const
OptionsModel * getOptionsModel()
void updateTimer()
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header)
BanTableModel * getBanTableModel()
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:66
void networkActiveChanged(bool networkActive)
PeerTableModel * getPeerTableModel()