From ba7128b30850594c7efb258d1794e377eede364a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 1 Jan 2017 13:37:19 +0100 Subject: Instead of using the action system we use controllers only. It's simpler, and the action system was just too complex to use in a typesafe way. --- framework/actions/context.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'framework/actions/context.h') 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 @@ #pragma once #include - #define KUBE_CONTEXT_PROPERTY(TYPE, NAME, LOWERCASENAME) \ public: Q_PROPERTY(TYPE LOWERCASENAME MEMBER m##NAME NOTIFY LOWERCASENAME##Changed) \ + Q_SIGNALS: void LOWERCASENAME##Changed(); \ + private: TYPE m##NAME; + +#define KUBE_CONTEXTWRAPPER_PROPERTY(TYPE, NAME, LOWERCASENAME) \ + public: \ struct NAME { \ static constexpr const char *name = #LOWERCASENAME; \ typedef TYPE Type; \ }; \ - void set##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ - TYPE get##NAME() const { return m##NAME; } \ - Q_SIGNALS: void LOWERCASENAME##Changed(); \ - private: TYPE m##NAME; + void set##NAME(const TYPE &value) { context.setProperty(NAME::name, QVariant::fromValue(value)); } \ + void clear##NAME() { context.setProperty(NAME::name, QVariant{}); } \ + TYPE get##NAME() const { return context.property(NAME::name).value(); } \ namespace Kube { @@ -38,13 +41,27 @@ class Context : public QObject { Q_OBJECT public: Context(QObject *parent = 0); + Context(const Context &); + virtual ~Context(){}; + + Context &operator=(const Context &); + virtual void clear(); + + QSet availableProperties() const; +}; + +class ContextWrapper { +public: + ContextWrapper(Context &c) : context{c} {} + Context &context; }; } QDebug operator<<(QDebug dbg, const Kube::Context &); +QDebug operator<<(QDebug dbg, const Kube::ContextWrapper &); Q_DECLARE_METATYPE(Kube::Context*); -- cgit v1.2.3