Anoncoin  0.9.4
P2P Digital Currency
clientmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2013-2015 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef CLIENTMODEL_H
7 #define CLIENTMODEL_H
8 
9 // Many builder specific things set in the config file, for any source files where we rely on moc_xxx files being generated
10 // it is best to include the anoncoin-config.h in the header file itself. Not the .cpp src file, because otherwise any
11 // conditional compilation guidelines, which rely on the build configuration, will not be present in the moc_xxx files.
12 #if defined(HAVE_CONFIG_H)
13 #include "config/anoncoin-config.h"
14 #endif
15 
16 #include <QObject>
17 
18 class AddressTableModel;
19 class OptionsModel;
20 class PeerTableModel;
22 
23 class CWallet;
24 
25 QT_BEGIN_NAMESPACE
26 class QDateTime;
27 class QTimer;
28 QT_END_NAMESPACE
29 
35 };
36 
39  CONNECTIONS_IN = (1U << 0),
40  CONNECTIONS_OUT = (1U << 1),
42 };
43 
45 class ClientModel : public QObject
46 {
47  Q_OBJECT
48 
49 public:
50  explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
51  ~ClientModel();
52 
55 
57  int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
58  int getNumBlocks() const;
60 
61  quint64 getTotalBytesRecv() const;
62  quint64 getTotalBytesSent() const;
63 
64  double getVerificationProgress() const;
65  QDateTime getLastBlockDate() const;
66 
68  QString getNetworkName() const;
70  bool inInitialBlockDownload() const;
72  enum BlockSource getBlockSource() const;
74  QString getStatusBarWarnings() const;
75 
76  QString formatFullVersion() const;
77  QString formatBuildDate() const;
78  bool isReleaseVersion() const;
79  QString clientName() const;
80  QString formatClientStartupTime() const;
81 
82 #ifdef ENABLE_I2PSAM
83  /*
84  * Public functions needed for handling the I2P Config and operational settings
85  */
86  QString formatI2PNativeFullVersion() const;
87  int getNumI2PConnections() const;
88 
89  QString getPublicI2PKey() const;
90  QString getPrivateI2PKey() const;
91  bool isI2PAddressGenerated() const;
92  bool isI2POnly() const;
93  bool isTorOnly() const;
94  bool isDarknetOnly() const;
95  bool isBehindDarknet() const;
96  QString getB32Address(const QString& destination) const;
97  void generateI2PDestination(QString& pub, QString& priv) const;
98 #endif // ENABLE_I2PSAM
99 
100 private:
103 
107 
109 
110  QTimer *pollTimer;
111 
112  void subscribeToCoreSignals();
114 
120 signals:
121  void numConnectionsChanged(int count);
122  void numBlocksChanged(int count);
123  void alertsChanged(const QString &warnings);
124  void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
125 #ifdef ENABLE_I2PSAM
126  void numI2PConnectionsChanged(int count); // When the I2P connection # changes, this signal is generated
127 #endif
128  void message(const QString &title, const QString &message, unsigned int style);
130 
136 public slots:
137  void updateTimer();
138  void updateNumConnections(int numConnections);
139  void updateAlert(const QString &hash, int status);
140 #ifdef ENABLE_I2PSAM
141  void updateNumI2PConnections(int numI2PConnections); // For I2P connection count updates, emit an numI2PConnectionsChanged signal
142 #endif
143 };
144 
145 #endif // CLIENTMODEL_H
void numBlocksChanged(int count)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
PeerTableModel * peerTableModel
Definition: clientmodel.h:102
quint64 getTotalBytesRecv() const
Definition: clientmodel.cpp:77
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:51
OptionsModel * getOptionsModel()
QString formatClientStartupTime() const
PeerTableModel * getPeerTableModel()
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
void numConnectionsChanged(int count)
Note signal functions like this are created here in the header file, yet no source implmentation will...
bool isReleaseVersion() const
void alertsChanged(const QString &warnings)
QString getNetworkName() const
Return network (main, testnetX, regtest)
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut)
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
bool cachedImporting
Definition: clientmodel.h:106
double getVerificationProgress() const
Definition: clientmodel.cpp:96
NumConnections
Definition: clientmodel.h:37
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
QDateTime getLastBlockDate() const
Definition: clientmodel.cpp:87
BlockSource
Definition: clientmodel.h:30
void updateAlert(const QString &hash, int status)
void unsubscribeFromCoreSignals()
QString clientName() const
void subscribeToCoreSignals()
QString formatBuildDate() const
UI model for the transaction table of a wallet.
Model for Anoncoin network client.
Definition: clientmodel.h:45
int cachedNumBlocks
Definition: clientmodel.h:104
QTimer * pollTimer
Definition: clientmodel.h:110
Qt model of the address book in the core.
int getNumBlocks() const
Definition: clientmodel.cpp:65
quint64 getTotalBytesSent() const
Definition: clientmodel.cpp:82
int numBlocksAtStartup
Definition: clientmodel.h:108
bool cachedReindexing
Definition: clientmodel.h:105
ClientModel(OptionsModel *optionsModel, QObject *parent=0)
Definition: clientmodel.cpp:30
Interface from Qt to configuration data structure for Anoncoin client.
Definition: optionsmodel.h:27
void updateTimer()
From: https://qt-project.org/doc/qt-5-snapshot/signalsandslots.html A slot is a function that is call...
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:101
OptionsModel * optionsModel
Definition: clientmodel.h:101
int getNumBlocksAtStartup()
Definition: clientmodel.cpp:71
void updateNumConnections(int numConnections)
QString formatFullVersion() const
enum BlockSource getBlockSource() const
Return true if core is importing blocks.