QAlphaCloud  0.0.1
Qt bindings for Alpha Cloud
storagesystemsmodel.h
1 /*
2  * SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <ghqalpha@broulik.de>
3  * SPDX-License-Identifier: LGPL-2.1-or-later
4  */
5 
6 #pragma once
7 
8 #include <QAbstractListModel>
9 
10 #include <memory>
11 
12 #include "qalphacloud.h"
13 #include "qalphacloud_export.h"
14 
15 #include "connector.h"
16 
17 namespace QAlphaCloud
18 {
19 
20 class StorageSystemsModelPrivate;
21 
29 class QALPHACLOUD_EXPORT StorageSystemsModel : public QAbstractListModel
30 {
31  Q_OBJECT
32 
36  Q_PROPERTY(QAlphaCloud::Connector *connector READ connector WRITE setConnector NOTIFY connectorChanged REQUIRED)
37 
38 
45  Q_PROPERTY(bool cached READ cached WRITE setCached NOTIFY cachedChanged)
46 
47 
50  Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
51 
52 
59  Q_PROPERTY(QString primarySerialNumber READ primarySerialNumber NOTIFY primarySerialNumberChanged)
60 
61 
67  Q_PROPERTY(QAlphaCloud::RequestStatus status READ status NOTIFY statusChanged)
68 
69 
75  Q_PROPERTY(QAlphaCloud::ErrorCode error READ error NOTIFY errorChanged)
81  Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
82 
83 public:
90  explicit StorageSystemsModel(QObject *parent = nullptr);
96  explicit StorageSystemsModel(QAlphaCloud::Connector *connector, QObject *parent = nullptr);
97  ~StorageSystemsModel() override;
98 
102  enum class Roles {
103  SerialNumber = Qt::UserRole,
104  Status,
105  InverterModel,
106  InverterPower,
107  BatteryModel,
108  BatteryGrossCapacity,
109  BatteryRemainingCapacity,
110  BatteryUsableCapacity,
111  PhotovoltaicPower,
112  RawJson = Qt::UserRole
113  + 99,
114  };
115  Q_ENUM(Roles)
116 
117  Q_REQUIRED_RESULT QAlphaCloud::Connector *connector() const;
118  void setConnector(QAlphaCloud::Connector *connector);
119  Q_SIGNAL void connectorChanged(QAlphaCloud::Connector *connector);
120 
121  Q_REQUIRED_RESULT bool cached() const;
122  void setCached(bool cached);
123  Q_SIGNAL void cachedChanged(bool cached);
124 
125  QAlphaCloud::RequestStatus status() const;
126  Q_SIGNAL void statusChanged(QAlphaCloud::RequestStatus status);
127 
128  QString primarySerialNumber() const;
129  Q_SIGNAL void primarySerialNumberChanged(const QString &primarySerialNumber);
130 
131  QAlphaCloud::ErrorCode error() const;
132  Q_SIGNAL void errorChanged(QAlphaCloud::ErrorCode error);
133 
134  QString errorString() const;
135  Q_SIGNAL void errorStringChanged(const QString &errorString);
136 
137  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
138  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
139  QHash<int, QByteArray> roleNames() const override;
140 
141 public Q_SLOTS:
152  bool reload();
153 
154 Q_SIGNALS:
155  void countChanged();
156 
157 private:
158  friend StorageSystemsModelPrivate;
159  std::unique_ptr<StorageSystemsModelPrivate> const d;
160 };
161 
162 } // namespace QAlphaCloud
API Connection.
Definition: connector.h:39
Storage Systems Model.
Definition: storagesystemsmodel.h:30
Roles
The model roles.
Definition: storagesystemsmodel.h:102
Utility namespace.
Definition: apirequest.cpp:24
RequestStatus
Request status.
Definition: qalphacloud.h:28
ErrorCode
Error codes.
Definition: qalphacloud.h:45