2020-10-31 15:16:06 +01:00
|
|
|
#ifndef BRWIDGET_H
|
|
|
|
#define BRWIDGET_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class BRProvider;
|
|
|
|
|
|
|
|
class BRWidget : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-11-05 19:37:13 +01:00
|
|
|
Q_PROPERTY(BRWidgetState state READ getState NOTIFY stateChanged)
|
2020-10-31 15:16:06 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
enum BRFederation {
|
2020-11-15 14:48:12 +01:00
|
|
|
UnknownFederation = -1,
|
2020-10-31 15:16:06 +01:00
|
|
|
IFSC,
|
|
|
|
DAV,
|
|
|
|
SAC
|
|
|
|
};
|
|
|
|
Q_ENUM(BRFederation)
|
|
|
|
|
2020-11-15 14:48:12 +01:00
|
|
|
|
|
|
|
enum BRDiscipline {
|
|
|
|
UnknownDiscipline = -1,
|
|
|
|
Speed,
|
|
|
|
Lead,
|
|
|
|
Boulder,
|
|
|
|
Combined,
|
|
|
|
AllDisciplines = 99
|
|
|
|
};
|
|
|
|
Q_ENUM(BRDiscipline)
|
|
|
|
|
2020-11-05 19:37:13 +01:00
|
|
|
enum BRWidgetState {
|
|
|
|
Unconfigured = -1,
|
|
|
|
Configured,
|
|
|
|
Loading,
|
|
|
|
Loaded
|
|
|
|
};
|
|
|
|
Q_ENUM(BRWidgetState)
|
|
|
|
|
2020-10-31 15:16:06 +01:00
|
|
|
enum BRWidgetStatusCode {
|
|
|
|
Success = 200,
|
2020-11-03 15:56:43 +01:00
|
|
|
InternalError = 900,
|
|
|
|
NoProviderError = 901,
|
2020-11-04 13:55:37 +01:00
|
|
|
NotImplementedError = 902,
|
|
|
|
OpeationNotSupportedError = 903
|
2020-10-31 15:16:06 +01:00
|
|
|
};
|
|
|
|
Q_ENUM(BRWidgetStatusCode)
|
|
|
|
|
|
|
|
Q_INVOKABLE virtual BRWidget::BRWidgetStatusCode load() = 0;
|
2020-11-03 15:56:43 +01:00
|
|
|
|
2020-11-05 19:37:13 +01:00
|
|
|
Q_INVOKABLE BRWidgetState getState() const;
|
2020-11-03 15:56:43 +01:00
|
|
|
Q_INVOKABLE BRFederation getFederation() const;
|
2020-11-04 13:55:37 +01:00
|
|
|
Q_INVOKABLE int getId() const;
|
2020-10-31 15:16:06 +01:00
|
|
|
|
|
|
|
protected:
|
2020-11-04 13:55:37 +01:00
|
|
|
explicit BRWidget(BRProvider* provider, BRFederation federation, int id);
|
2020-11-05 19:37:13 +01:00
|
|
|
void setState(BRWidgetState state);
|
2020-10-31 15:16:06 +01:00
|
|
|
BRProvider* getProvider();
|
|
|
|
|
2020-11-05 19:37:13 +01:00
|
|
|
BRWidgetState state;
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
template<typename T>
|
|
|
|
QList<QObject*> listToQmlList(QList<T*> list) {
|
|
|
|
QList<QObject*> tmpList;
|
|
|
|
|
|
|
|
for(T* item : list)
|
|
|
|
tmpList.append(static_cast<QObject*>(item));
|
|
|
|
|
|
|
|
return tmpList;
|
|
|
|
};
|
|
|
|
|
2020-10-31 15:16:06 +01:00
|
|
|
private:
|
|
|
|
BRProvider* provider;
|
2020-11-03 15:56:43 +01:00
|
|
|
const BRFederation federation;
|
2020-11-04 13:55:37 +01:00
|
|
|
const int id;
|
2020-10-31 15:16:06 +01:00
|
|
|
|
|
|
|
signals:
|
2020-11-05 19:37:13 +01:00
|
|
|
void stateChanged();
|
2020-10-31 15:16:06 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BRWIDGET_H
|