diff options
author | Tobias Markmann <tm@ayena.de> | 2012-03-20 20:48:16 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2012-11-11 16:38:01 (GMT) |
commit | 4b9d5b776d939f861af6cfe467a3b5d9f7259b11 (patch) | |
tree | b2c5930dcb2d42719067644753a54aa6c257265b /Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h | |
parent | 40150b034eca3a5b73cb9530366840cc4386a72c (diff) | |
download | swift-contrib-4b9d5b776d939f861af6cfe467a3b5d9f7259b11.zip swift-contrib-4b9d5b776d939f861af6cfe467a3b5d9f7259b11.tar.bz2 |
Cutting down some FieldInfo code via macros.
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h')
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h b/Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h index 8a9d089..d37912c 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h +++ b/Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h @@ -8,6 +8,32 @@ #include <typeinfo> +#include <QObject> +#include <QString> + +#define GenericQtVCardFieldInfo(MENU_NAME, ALLOWED_INSTANCES, FIELD_CLASS) \ + class FieldInfo : public QtVCardFieldInfo { \ + public: \ + virtual ~FieldInfo() { \ + } \ + \ + virtual QString getMenuName() const { \ + return QObject::tr(MENU_NAME); \ + } \ + \ + virtual int getAllowedInstances() const { \ + return ALLOWED_INSTANCES; \ + } \ + \ + virtual QWidget* createFieldInstance(QWidget* parent, bool editable) const { \ + return new FIELD_CLASS(parent, editable); \ + } \ + \ + virtual bool testInstance(QWidget* widget) const { \ + return dynamic_cast<FIELD_CLASS*>(widget) != 0; \ + } \ + }; + class QWidget; namespace Swift { @@ -23,5 +49,4 @@ namespace Swift { virtual QWidget* createFieldInstance(QWidget* parent, bool editable) const = 0; virtual bool testInstance(QWidget*) const = 0; }; - } |