diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-29 20:23:58 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-29 20:37:22 +0100 |
commit | 48da7de1b6bcd87c57b4c7f60133f3f13fc4bff2 (patch) | |
tree | afad136d1179480301646355fab0d95c1302d7e7 /framework/actions/context.cpp | |
parent | 08dbe5251cb818b4f548029a6e96b4500fe7a35f (diff) | |
download | kube-48da7de1b6bcd87c57b4c7f60133f3f13fc4bff2.tar.gz kube-48da7de1b6bcd87c57b4c7f60133f3f13fc4bff2.zip |
A typesafe action context
Diffstat (limited to 'framework/actions/context.cpp')
-rw-r--r-- | framework/actions/context.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/framework/actions/context.cpp b/framework/actions/context.cpp index 205b1606..8f370a0b 100644 --- a/framework/actions/context.cpp +++ b/framework/actions/context.cpp | |||
@@ -29,10 +29,22 @@ Context::Context(QObject *parent) | |||
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | void Context::clear() | ||
33 | { | ||
34 | auto meta = metaObject(); | ||
35 | for (auto i = meta->propertyOffset(); i < meta->propertyCount(); i++) { | ||
36 | auto property = meta->property(i); | ||
37 | setProperty(property.name(), QVariant()); | ||
38 | } | ||
39 | for (const auto &p : dynamicPropertyNames()) { | ||
40 | setProperty(p, QVariant()); | ||
41 | } | ||
42 | } | ||
43 | |||
32 | QDebug operator<<(QDebug dbg, const Kube::Context &context) | 44 | QDebug operator<<(QDebug dbg, const Kube::Context &context) |
33 | { | 45 | { |
34 | dbg << "Kube::Context {\n"; | 46 | dbg << "Kube::Context {\n"; |
35 | auto metaObject = context.QObject::metaObject(); | 47 | auto metaObject = context.metaObject(); |
36 | for (auto i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) { | 48 | for (auto i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) { |
37 | auto property = metaObject->property(i); | 49 | auto property = metaObject->property(i); |
38 | dbg << property.name() << context.property(property.name()) << "\n"; | 50 | dbg << property.name() << context.property(property.name()) << "\n"; |