Skip to content

Commit 29c8d9b

Browse files
committed
1) Added List type support for ordinary types
1 parent 6ba6ace commit 29c8d9b

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/JObject.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
public: t x() const {return _##x;} \
1919
void x(const t& v){_##x = v;}
2020

21+
// t: type, x: property name
22+
#define MetaPropertyPrivateSet_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
23+
PropertyPrivateSet(QVariantList, x) \
24+
public: \
25+
void append##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
26+
void remove##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
27+
int count##x()const {return _##x.length();} \
28+
t item##x##At(int i) {return _##x.at(i).value<t>();} \
29+
bool item##t##Exist(const t& i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
30+
31+
// t: type, x: property name
32+
#define MetaPropertyPublicSet_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
33+
PropertyPublicSet(QVariantList, x) \
34+
public: \
35+
void append##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
36+
void remove##x(const t& i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
37+
int count##x()const {return _##x.length();} \
38+
t item##x##At(int i) {return _##x.at(i).value<t>();}
39+
2140
// t: type, x: property name
2241
#define PropertyPrivateSet_Ptr(t, x) private: t* _##x; \
2342
public: t* x() {return _##x;} \
@@ -64,7 +83,8 @@
6483
void append##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
6584
void remove##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
6685
int count##t()const {return _##x.length();} \
67-
t* item##t##At(int i) {return _##x.at(i).value<t*>();}
86+
t* item##t##At(int i) {return _##x.at(i).value<t*>();} \
87+
bool item##t##Exist(t* i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
6888

6989
// t: type, x: property name
7090
#define MetaPropertyPublicSet_Ptr_List(t, x) private: Q_PROPERTY(QVariantList x READ x WRITE x) \
@@ -73,7 +93,8 @@
7393
void append##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.append(v);}} \
7494
void remove##t(t* i){QVariant v = QVariant::fromValue(i); if (v.isValid()) { _##x.removeAll(v);}} \
7595
int count##t()const {return _##x.length();} \
76-
t* item##t##At(int i) {return _##x.at(i).value<t*>();}
96+
t* item##t##At(int i) {return _##x.at(i).value<t*>();} \
97+
bool item##t##Exist(t* i) const {QVariant v = QVariant::fromValue(i); if (v.isValid()) { return _##x.contains(v);} else return false;}
7798

7899

79100
/**

0 commit comments

Comments
 (0)