Skip to content

Commit 803f7a0

Browse files
committed
Protected property list added
1 parent bce437e commit 803f7a0

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/JObject.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@
1313
public: t x() const {return _##x;} \
1414
private: void x(const t& v){_##x = v;}
1515

16+
17+
// t: type, x: property name
18+
#define PropertyProtectedSet(t, x) private: t _##x; \
19+
public: t x() const {return _##x;} \
20+
protected: void x(const t& v){_##x = v;}
21+
1622
// t: type, x: property name
1723
#define PropertyPublicSet(t, x) private: t _##x; \
1824
public: t x() const {return _##x;} \
1925
void x(const t& v){_##x = v;}
2026

27+
2128
// t: type, x: property name
2229
#define MetaPropertyPrivateSet_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
2330
PropertyPrivateSet(QVariantList, x) \
@@ -28,6 +35,18 @@
2835
t item##x##At(int i) {return _##x.at(i).value<t>();} \
2936
bool item##t##Exist(const t& i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
3037

38+
39+
// t: type, x: property name
40+
#define MetaPropertyProtectedSet_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
41+
PropertyProtectedSet(QVariantList, x) \
42+
void append##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
43+
void remove##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
44+
public: \
45+
int count##x()const {return _##x.length();} \
46+
t item##x##At(int i) {return _##x.at(i).value<t>();} \
47+
bool item##t##Exist(const t& i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
48+
49+
3150
// t: type, x: property name
3251
#define MetaPropertyPublicSet_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
3352
PropertyPublicSet(QVariantList, x) \
@@ -42,6 +61,12 @@
4261
public: t* x() {return _##x;} \
4362
private: void x(t* v){_##x = v;}
4463

64+
65+
// t: type, x: property name
66+
#define PropertyProtectedSet_Ptr(t, x) private: t* _##x; \
67+
public: t* x() {return _##x;} \
68+
protected: void x(t* v){_##x = v;}
69+
4570
// t: type, x: property name
4671
#define PropertyPublicSet_Ptr(t, x) private: t* _##x; \
4772
public: t* x() {return _##x;} \
@@ -53,6 +78,12 @@
5378
public: t* x() {return qobject_cast<t*>(_##x);} \
5479
private: void x(QObject* v){_##x = v;}
5580

81+
82+
// t: type, x: property name
83+
#define PropertyProtectedSet_Ptr_O(t, x) private: QObject* _##x; \
84+
public: t* x() {return qobject_cast<t*>(_##x);} \
85+
protected: void x(QObject* v){_##x = v;}
86+
5687
// t: type, x: property name
5788
#define PropertyPublicSet_Ptr_O(t, x) private: QObject* _##x; \
5889
public: t* x() {return qobject_cast<t*>(_##x);} \
@@ -62,6 +93,11 @@
6293
#define MetaPropertyPrivateSet(t, x) private: Q_PROPERTY(t x READ x WRITE x) \
6394
PropertyPrivateSet(t, x)
6495

96+
97+
// t: type, x: property name
98+
#define MetaPropertyProtectedSet(t, x) private: Q_PROPERTY(t x READ x WRITE x) \
99+
PropertyProtectedSet(t, x)
100+
65101
// t: type, x: property name
66102
#define MetaPropertyPublicSet(t, x) private: Q_PROPERTY(t x READ x WRITE x) \
67103
PropertyPublicSet(t, x)
@@ -71,6 +107,13 @@
71107
PropertyPrivateSet_Ptr_O(t, x) \
72108
public: Q_INVOKABLE void _type##x(const QString& prop){registerPtrProperty(prop, &t::staticMetaObject);}
73109

110+
111+
// t: type, x: property name
112+
#define MetaPropertyProtectedSet_Ptr(t, x) private: Q_PROPERTY(QObject* x READ x WRITE x) \
113+
PropertyProtectedSet_Ptr_O(t, x) \
114+
public: Q_INVOKABLE void _type##x(const QString& prop){registerPtrProperty(prop, &t::staticMetaObject);}
115+
116+
74117
// t: type, x: property name
75118
#define MetaPropertyPublicSet_Ptr(t, x) private: Q_PROPERTY(QObject* x READ x WRITE x) \
76119
PropertyPublicSet_Ptr_O(t, x) \
@@ -86,6 +129,18 @@
86129
t* item##t##At(int i) {return _##x.at(i).value<t*>();} \
87130
bool item##t##Exist(t* i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
88131

132+
133+
// t: type, x: property name
134+
#define MetaPropertyProtectedSet_Ptr_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
135+
PropertyProtectedSet(QVariantList, x) \
136+
protected: Q_INVOKABLE void _type##x(const QString& prop){registerPtrProperty(prop, &t::staticMetaObject);} \
137+
void append##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
138+
void remove##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
139+
public: int count##t()const {return _##x.length();} \
140+
t* item##t##At(int i) {return _##x.at(i).value<t*>();} \
141+
bool item##t##Exist(t* i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
142+
143+
89144
// t: type, x: property name
90145
#define MetaPropertyPublicSet_Ptr_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
91146
PropertyPublicSet(QVariantList, x) \

0 commit comments

Comments
 (0)