app/headers/brwidget.h

84 lines
1.6 KiB
C
Raw Normal View History

2020-10-31 15:16:06 +01:00
#ifndef BRWIDGET_H
#define BRWIDGET_H
#include <QObject>
class BRProvider;
class BRWidget : public QObject
{
Q_OBJECT
Q_PROPERTY(BRWidgetState state READ getState NOTIFY stateChanged)
2020-10-31 15:16:06 +01:00
public:
enum BRFederation {
UnknownFederation = -1,
2020-10-31 15:16:06 +01:00
IFSC,
DAV,
SAC
};
Q_ENUM(BRFederation)
enum BRDiscipline {
UnknownDiscipline = -1,
Speed,
Lead,
Boulder,
Combined,
AllDisciplines = 99
};
Q_ENUM(BRDiscipline)
enum BRWidgetState {
Unconfigured = -1,
Configured,
Loading,
Loaded
};
Q_ENUM(BRWidgetState)
2020-10-31 15:16:06 +01:00
enum BRWidgetStatusCode {
Success = 200,
InternalError = 900,
NoProviderError = 901,
NotImplementedError = 902,
OpeationNotSupportedError = 903
2020-10-31 15:16:06 +01:00
};
Q_ENUM(BRWidgetStatusCode)
Q_INVOKABLE virtual BRWidget::BRWidgetStatusCode load() = 0;
Q_INVOKABLE BRWidgetState getState() const;
Q_INVOKABLE BRFederation getFederation() const;
Q_INVOKABLE int getId() const;
2020-10-31 15:16:06 +01:00
protected:
explicit BRWidget(BRProvider* provider, BRFederation federation, int id);
void setState(BRWidgetState state);
2020-10-31 15:16:06 +01:00
BRProvider* getProvider();
BRWidgetState state;
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;
const BRFederation federation;
const int id;
2020-10-31 15:16:06 +01:00
signals:
void stateChanged();
2020-10-31 15:16:06 +01:00
};
#endif // BRWIDGET_H