13 #ifndef __PLUGIN_API_SCOREELEMENT_H__ 14 #define __PLUGIN_API_SCOREELEMENT_H__ 48 Q_PROPERTY(
int type READ type)
54 Q_PROPERTY(QString name READ name)
66 : QObject(), _ownership(own), e(_e) {}
80 QVariant
get(
Ms::Pid pid)
const;
81 void set(
Ms::Pid pid, QVariant val);
84 Q_INVOKABLE QString userName()
const;
96 template <
class Wrapper,
class T>
99 Wrapper* w = t ?
new Wrapper(t, own) :
nullptr;
101 QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership);
113 template <
typename T,
class Container>
118 : QQmlListProperty<T>(obj, const_cast<void*>(static_cast<const void*>(&container)), &count, &at) {};
120 static int count(QQmlListProperty<T>* l) {
return int(static_cast<Container*>(l->data)->size()); }
121 static T*
at(QQmlListProperty<T>* l,
int i)
123 auto el =
static_cast<Container*
>(l->data)->at(i);
135 template<
typename T,
class Container>
Wrapper * wrap(T *t, Ownership own=Ownership::SCORE)
Definition: scoreelement.h:97
Base class for most of object wrappers exposed to QML.
Definition: scoreelement.h:42
Pid
Definition: property.h:62
Ms::ScoreElement * element()
Definition: scoreelement.h:74
Definition: scoreElement.h:173
QML access to containers.
Definition: scoreelement.h:114
Ownership ownership() const
Definition: scoreelement.h:71
Ownership
Definition: scoreelement.h:32
const Ms::ScoreElement * element() const
Definition: scoreelement.h:75
Definition: aeolus.cpp:26
Q_INVOKABLE bool is(Ms::PluginAPI::ScoreElement *other)
Checks whether two variables represent the same object.
Definition: scoreelement.h:86
static int count(QQmlListProperty< T > *l)
Definition: scoreelement.h:120
Element * wrap(Ms::Element *e, Ownership own)
Wraps Ms::Element choosing the correct wrapper type at runtime based on the actual element type...
Definition: elements.cpp:247
QmlListAccess(QObject *obj, Container &container)
Definition: scoreelement.h:117
static T * at(QQmlListProperty< T > *l, int i)
Definition: scoreelement.h:121
void setOwnership(Ownership o)
Definition: scoreelement.h:72
QmlListAccess< T, Container > wrapContainerProperty(QObject *obj, Container &c)
Definition: scoreelement.h:136