diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-01-21 15:33:11 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-01-23 16:47:45 +0100 |
commit | cb3152086c61e7c51ed1c5f8c5946364e19abc4d (patch) | |
tree | 5624826388b8b5d8a80f4020cba701868e1b2c44 /src/tools | |
parent | 49f143e19ca11ef48260a3aaaa4ddbe490cf81ab (diff) |
Introduce Q_PROPERTY attribute REQUIRED
This is meant to correspond to required properties in QML.
Change-Id: I2645981e13f7423bc86b48370c165b3cfe2aaa62
Task-number: QTBUG-81561
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/moc/generator.cpp | 2 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 4 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 034e846918..8d4fb2efc6 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -864,6 +864,8 @@ void Generator::generateProperties() flags |= Constant; if (p.final) flags |= Final; + if (p.required) + flags |= Required; fprintf(out, " %4d, ", stridx(p.name)); generateTypeInfo(p.type); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index d7a1af0a18..b562416c31 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1238,6 +1238,9 @@ void Moc::createPropertyDef(PropertyDef &propDef) } else if(l[0] == 'F' && l == "FINAL") { propDef.final = true; continue; + } else if (l[0] == 'R' && l == "REQUIRED") { + propDef.required = true; + continue; } QByteArray v, v2; @@ -1960,6 +1963,7 @@ QJsonObject PropertyDef::toJson() const prop[QLatin1String("constant")] = constant; prop[QLatin1String("final")] = final; + prop[QLatin1String("required")] = required; if (revision > 0) prop[QLatin1String("revision")] = revision; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 5d1ae0ad6d..04814b85a1 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -137,6 +137,7 @@ struct PropertyDef int revision = 0; bool constant = false; bool final = false; + bool required = false; QJsonObject toJson() const; }; |