diff options
Diffstat (limited to 'framework/src/actions/context.cpp')
-rw-r--r-- | framework/src/actions/context.cpp | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/framework/src/actions/context.cpp b/framework/src/actions/context.cpp deleted file mode 100644 index 45b660a9..00000000 --- a/framework/src/actions/context.cpp +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "context.h" | ||
20 | |||
21 | #include <QDebug> | ||
22 | #include <QMetaProperty> | ||
23 | |||
24 | using namespace Kube; | ||
25 | |||
26 | Context::Context(QObject *parent) | ||
27 | : QObject(parent) | ||
28 | { | ||
29 | |||
30 | } | ||
31 | |||
32 | Context::Context(const Context &other) | ||
33 | : QObject() | ||
34 | { | ||
35 | *this = other; | ||
36 | } | ||
37 | |||
38 | Context &Context::operator=(const Context &other) | ||
39 | { | ||
40 | for (const auto &p : other.availableProperties()) { | ||
41 | setProperty(p, other.property(p)); | ||
42 | } | ||
43 | return *this; | ||
44 | } | ||
45 | |||
46 | void Context::clear() | ||
47 | { | ||
48 | auto meta = metaObject(); | ||
49 | for (auto i = meta->propertyOffset(); i < meta->propertyCount(); i++) { | ||
50 | auto property = meta->property(i); | ||
51 | setProperty(property.name(), QVariant()); | ||
52 | } | ||
53 | for (const auto &p : dynamicPropertyNames()) { | ||
54 | setProperty(p, QVariant()); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | QSet<QByteArray> Context::availableProperties() const | ||
59 | { | ||
60 | QSet<QByteArray> names; | ||
61 | auto meta = metaObject(); | ||
62 | for (auto i = meta->propertyOffset(); i < meta->propertyCount(); i++) { | ||
63 | auto property = meta->property(i); | ||
64 | names << property.name(); | ||
65 | } | ||
66 | for (const auto &p : dynamicPropertyNames()) { | ||
67 | names << p; | ||
68 | } | ||
69 | return names; | ||
70 | } | ||
71 | |||
72 | QDebug operator<<(QDebug dbg, const Kube::Context &context) | ||
73 | { | ||
74 | dbg << "Kube::Context {\n"; | ||
75 | auto metaObject = context.metaObject(); | ||
76 | for (auto i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) { | ||
77 | auto property = metaObject->property(i); | ||
78 | dbg << property.name() << context.property(property.name()) << "\n"; | ||
79 | } | ||
80 | for (const auto &p : context.dynamicPropertyNames()) { | ||
81 | dbg << p << context.property(p) << "\n"; | ||
82 | } | ||
83 | dbg << "\n}"; | ||
84 | return dbg; | ||
85 | } | ||
86 | |||
87 | QDebug operator<<(QDebug dbg, const Kube::ContextWrapper &context) | ||
88 | { | ||
89 | dbg << context.context; | ||
90 | return dbg; | ||
91 | } | ||