clientmodel.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // ECOin - Copyright (c) - 2014/2021 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #ifndef CLIENTMODEL_H
  3. #define CLIENTMODEL_H
  4. #include <QObject>
  5. class OptionsModel;
  6. class AddressTableModel;
  7. class TransactionTableModel;
  8. class CWallet;
  9. QT_BEGIN_NAMESPACE
  10. class QDateTime;
  11. class QTimer;
  12. QT_END_NAMESPACE
  13. class ClientModel : public QObject
  14. {
  15. Q_OBJECT
  16. public:
  17. explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
  18. ~ClientModel();
  19. OptionsModel *getOptionsModel();
  20. int getNumConnections() const;
  21. int getNumBlocks() const;
  22. int getNumBlocksAtStartup();
  23. QDateTime getLastBlockDate() const;
  24. //! Return true if client connected to testnet
  25. bool isTestNet() const;
  26. //! Return true if core is doing initial block download
  27. bool inInitialBlockDownload() const;
  28. //! Return conservative estimate of total number of blocks, or 0 if unknown
  29. int getNumBlocksOfPeers() const;
  30. //! Return warnings to be displayed in status bar
  31. QString getStatusBarWarnings() const;
  32. QString formatFullVersion() const;
  33. QString formatBuildDate() const;
  34. QString clientName() const;
  35. QString formatClientStartupTime() const;
  36. private:
  37. OptionsModel *optionsModel;
  38. int cachedNumBlocks;
  39. int cachedNumBlocksOfPeers;
  40. int numBlocksAtStartup;
  41. QTimer *pollTimer;
  42. void subscribeToCoreSignals();
  43. void unsubscribeFromCoreSignals();
  44. signals:
  45. void numConnectionsChanged(int count);
  46. void numBlocksChanged(int count, int countOfPeers);
  47. //! Asynchronous error notification
  48. void error(const QString &title, const QString &message, bool modal);
  49. public slots:
  50. void updateTimer();
  51. void updateNumConnections(int numConnections);
  52. void updateAlert(const QString &hash, int status);
  53. };
  54. #endif // CLIENTMODEL_H