SolidModules
nmpropertyhelper.h
Go to the documentation of this file.00001 // class that can extract values out of a properties map into a QObject's properties 00002 00003 #ifndef NM07_PROPERTY_HELPER_H 00004 #define NM07_PROPERTY_HELPER_H 00005 00006 #include <QPair> 00007 00008 #include "generic-types.h" 00009 00010 class NMPropertyDeserializer 00011 { 00012 public: 00013 virtual ~NMPropertyDeserializer(); 00014 virtual void deserialize(const QString& propertyName, const QVariant& value, QObject * recipient) = 0; 00015 }; 00016 00017 // deserializer for extracting a plain qvariant 00018 struct GenericDeserializer : public NMPropertyDeserializer 00019 { 00020 public: 00021 virtual void deserialize(const QString& propertyName, const QVariant& value, QObject * recipient); 00022 }; 00023 00024 typedef QPair<char*, char*> PropertySignalPair; 00025 00026 struct NMPropertySpec 00027 { 00028 public: 00029 char * propertyName; 00030 char * signalName; 00031 }; 00032 00033 class NMPropertyHelper 00034 { 00035 public: 00036 NMPropertyHelper(); 00037 NMPropertyHelper(QObject * master); 00038 ~NMPropertyHelper(); 00039 void registerProperty(const QString &nmPropertyName, QPair<char*,char*> spec); 00040 void deserializeProperties(const QVariantMap &); 00041 private: 00042 QObject * mMaster; 00043 QMap<QString, QPair<char*,char*> > mRegisteredProperties; 00044 }; 00045 /* 00046 class FrobObject : public QObject 00047 { 00048 Q_OBJECT 00049 Q_PROPERTY(QString frobozz READ frobozz WRITE setFrobozz) 00050 public: 00051 FrobObject(); 00052 ~FrobObject(); 00053 QString frobozz() const; 00054 void setFrobozz(const QString& frob); 00055 signals: 00056 void frobozzChanged(); 00057 private: 00058 QString mFrobozz; 00059 }; 00060 */ 00061 #endif 00062