13#ifndef __PLUGIN_API_SCOREELEMENT_H__
14#define __PLUGIN_API_SCOREELEMENT_H__
16#include "libmscore/property.h"
64 : QObject(), _ownership(own), e(_e) {}
69 Ownership ownership()
const {
return _ownership; }
70 void setOwnership(Ownership o) { _ownership = o; }
72 Ms::ScoreElement* element() {
return e; };
73 const Ms::ScoreElement* element()
const {
return e; };
78 QVariant get(Ms::Pid pid)
const;
79 void set(Ms::Pid pid, QVariant val);
82 Q_INVOKABLE QString userName()
const;
92template <
class Wrapper,
class T>
93Wrapper* wrap(T* t, Ownership own = Ownership::SCORE)
95 Wrapper* w = t ?
new Wrapper(t, own) : nullptr;
97 QQmlEngine::setObjectOwnership(w, QQmlEngine::JavaScriptOwnership);
101extern ScoreElement* wrap(Ms::ScoreElement* se, Ownership own = Ownership::SCORE);
109template <
typename T,
class Container>
114 : QQmlListProperty<T>(obj,
const_cast<void*
>(
static_cast<const void*
>(&container)), &count, &at) {};
116 static int count(QQmlListProperty<T>* l) {
return int(
static_cast<Container*
>(l->data)->size()); }
117 static T* at(QQmlListProperty<T>* l,
int i)
119 auto el =
static_cast<Container*
>(l->data)->at(i);
122 if (std::is_same<T*,
decltype(wrap(el, Ownership::SCORE))>::value)
123 return static_cast<T*
>(wrap(el, Ownership::SCORE));
125 return wrap<T>(el, Ownership::SCORE);
131template<
typename T,
class Container>
QML access to containers.
Definition scoreelement.h:110
Base class for most of object wrappers exposed to QML.
Definition scoreelement.h:42
QString name
Name of this element's type, not localized.
Definition scoreelement.h:54
int type
Type of this element.
Definition scoreelement.h:48