You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clientmodel.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #ifndef CLIENTMODEL_H
  5. #define CLIENTMODEL_H
  6. #include <QObject>
  7. class AddressTableModel;
  8. class OptionsModel;
  9. class PeerTableModel;
  10. class TransactionTableModel;
  11. class CWallet;
  12. QT_BEGIN_NAMESPACE
  13. class QDateTime;
  14. class QTimer;
  15. QT_END_NAMESPACE
  16. enum BlockSource {
  17. BLOCK_SOURCE_NONE,
  18. BLOCK_SOURCE_REINDEX,
  19. BLOCK_SOURCE_DISK,
  20. BLOCK_SOURCE_NETWORK
  21. };
  22. enum NumConnections {
  23. CONNECTIONS_NONE = 0,
  24. CONNECTIONS_IN = (1U << 0),
  25. CONNECTIONS_OUT = (1U << 1),
  26. CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT),
  27. };
  28. /** Model for Bitcoin network client. */
  29. class ClientModel : public QObject
  30. {
  31. Q_OBJECT
  32. public:
  33. explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
  34. ~ClientModel();
  35. OptionsModel *getOptionsModel();
  36. PeerTableModel *getPeerTableModel();
  37. //! Return number of connections, default is in- and outbound (total)
  38. int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
  39. int getNumBlocks() const;
  40. int getNumBlocksAtStartup();
  41. quint64 getTotalBytesRecv() const;
  42. quint64 getTotalBytesSent() const;
  43. double getVerificationProgress() const;
  44. QDateTime getLastBlockDate() const;
  45. //! Return true if core is doing initial block download
  46. bool inInitialBlockDownload() const;
  47. //! Return true if core is importing blocks
  48. enum BlockSource getBlockSource() const;
  49. //! Return warnings to be displayed in status bar
  50. QString getStatusBarWarnings() const;
  51. QString formatFullVersion() const;
  52. QString formatBuildDate() const;
  53. bool isReleaseVersion() const;
  54. QString clientName() const;
  55. QString formatClientStartupTime() const;
  56. private:
  57. OptionsModel *optionsModel;
  58. PeerTableModel *peerTableModel;
  59. int cachedNumBlocks;
  60. bool cachedReindexing;
  61. bool cachedImporting;
  62. int numBlocksAtStartup;
  63. QTimer *pollTimer;
  64. void subscribeToCoreSignals();
  65. void unsubscribeFromCoreSignals();
  66. signals:
  67. void numConnectionsChanged(int count);
  68. void numBlocksChanged(int count);
  69. void alertsChanged(const QString &warnings);
  70. void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
  71. //! Fired when a message should be reported to the user
  72. void message(const QString &title, const QString &message, unsigned int style);
  73. // Show progress dialog e.g. for verifychain
  74. void showProgress(const QString &title, int nProgress);
  75. public slots:
  76. void updateTimer();
  77. void updateNumConnections(int numConnections);
  78. void updateAlert(const QString &hash, int status);
  79. };
  80. #endif // CLIENTMODEL_H