summaryrefslogtreecommitdiffstats
path: root/framework/actions/context.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/actions/context.h')
-rw-r--r--framework/actions/context.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/framework/actions/context.h b/framework/actions/context.h
index 42ae3a93..4207fe12 100644
--- a/framework/actions/context.h
+++ b/framework/actions/context.h
@@ -19,17 +19,20 @@
19#pragma once 19#pragma once
20 20
21#include <QObject> 21#include <QObject>
22
23#define KUBE_CONTEXT_PROPERTY(TYPE, NAME, LOWERCASENAME) \ 22#define KUBE_CONTEXT_PROPERTY(TYPE, NAME, LOWERCASENAME) \
24 public: Q_PROPERTY(TYPE LOWERCASENAME MEMBER m##NAME NOTIFY LOWERCASENAME##Changed) \ 23 public: Q_PROPERTY(TYPE LOWERCASENAME MEMBER m##NAME NOTIFY LOWERCASENAME##Changed) \
24 Q_SIGNALS: void LOWERCASENAME##Changed(); \
25 private: TYPE m##NAME;
26
27#define KUBE_CONTEXTWRAPPER_PROPERTY(TYPE, NAME, LOWERCASENAME) \
28 public: \
25 struct NAME { \ 29 struct NAME { \
26 static constexpr const char *name = #LOWERCASENAME; \ 30 static constexpr const char *name = #LOWERCASENAME; \
27 typedef TYPE Type; \ 31 typedef TYPE Type; \
28 }; \ 32 }; \
29 void set##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ 33 void set##NAME(const TYPE &value) { context.setProperty(NAME::name, QVariant::fromValue(value)); } \
30 TYPE get##NAME() const { return m##NAME; } \ 34 void clear##NAME() { context.setProperty(NAME::name, QVariant{}); } \
31 Q_SIGNALS: void LOWERCASENAME##Changed(); \ 35 TYPE get##NAME() const { return context.property(NAME::name).value<TYPE>(); } \
32 private: TYPE m##NAME;
33 36
34 37
35namespace Kube { 38namespace Kube {
@@ -38,13 +41,27 @@ class Context : public QObject {
38 Q_OBJECT 41 Q_OBJECT
39public: 42public:
40 Context(QObject *parent = 0); 43 Context(QObject *parent = 0);
44 Context(const Context &);
45
41 virtual ~Context(){}; 46 virtual ~Context(){};
47
48 Context &operator=(const Context &);
49
42 virtual void clear(); 50 virtual void clear();
51
52 QSet<QByteArray> availableProperties() const;
53};
54
55class ContextWrapper {
56public:
57 ContextWrapper(Context &c) : context{c} {}
58 Context &context;
43}; 59};
44 60
45} 61}
46 62
47QDebug operator<<(QDebug dbg, const Kube::Context &); 63QDebug operator<<(QDebug dbg, const Kube::Context &);
64QDebug operator<<(QDebug dbg, const Kube::ContextWrapper &);
48 65
49Q_DECLARE_METATYPE(Kube::Context*); 66Q_DECLARE_METATYPE(Kube::Context*);
50 67