83 lines
1.6 KiB
C++
83 lines
1.6 KiB
C++
#ifndef BRWIDGET_H
|
|
#define BRWIDGET_H
|
|
|
|
#include <QObject>
|
|
|
|
class BRProvider;
|
|
|
|
class BRWidget : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(BRWidgetState state READ getState NOTIFY stateChanged)
|
|
public:
|
|
|
|
enum BRFederation {
|
|
UnknownFederation = -1,
|
|
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)
|
|
|
|
enum BRWidgetStatusCode {
|
|
Success = 200,
|
|
InternalError = 900,
|
|
NoProviderError = 901,
|
|
NotImplementedError = 902,
|
|
OpeationNotSupportedError = 903
|
|
};
|
|
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;
|
|
|
|
protected:
|
|
explicit BRWidget(BRProvider* provider, BRFederation federation, int id);
|
|
void setState(BRWidgetState state);
|
|
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;
|
|
};
|
|
|
|
private:
|
|
BRProvider* provider;
|
|
const BRFederation federation;
|
|
const int id;
|
|
|
|
signals:
|
|
void stateChanged();
|
|
|
|
};
|
|
|
|
#endif // BRWIDGET_H
|