Commit 56476566 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: add designerpropertymap.h

parent d2c96147
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef DESIGNERPROPERTYMAP_H
#define DESIGNERPROPERTYMAP_H
#include <QDeclarativePropertyMap>
#include <qdeclarative.h>
namespace QmlDesigner {
template <class DefaultType>
class DesignerPropertyMap : public QDeclarativePropertyMap
{
public:
DesignerPropertyMap(QObject *parent = 0);
QVariant value(const QString &key) const;
static void registerDeclarativeType(const QString &name);
private:
DefaultType m_defaultValue;
};
template <class DefaultType>
DesignerPropertyMap<DefaultType>::DesignerPropertyMap(QObject *parent) : QDeclarativePropertyMap(parent), m_defaultValue(this)
{
}
template <class DefaultType>
QVariant DesignerPropertyMap<DefaultType>::value(const QString &key) const
{
if (contains(key))
return QDeclarativePropertyMap::value(key);
qWarning() << QString("DesignerPropertyMap::value() %1 not found").arg(key);
return QVariant(&m_defaultValue);
}
template <class DefaultType>
void DesignerPropertyMap<DefaultType>::registerDeclarativeType(const QString &name)
{
typedef typename DesignerPropertyMap<DefaultType> myType;
qmlRegisterType<myType>("Bauhaus",1,0,name);
}
} //QmlDesigner
#endif // DESIGNERPROPERTYMAP_H
......@@ -18,6 +18,7 @@ SOURCES += propertyeditor.cpp \
originwidget.cpp \
siblingcombobox.cpp \
propertyeditortransaction.cpp
HEADERS += propertyeditor.h \
qmlanchorbindingproxy.h \
allpropertiesbox.h \
......@@ -34,7 +35,8 @@ HEADERS += propertyeditor.h \
fontwidget.h \
originwidget.h \
siblingcombobox.h \
propertyeditortransaction.h
propertyeditortransaction.h \
designerpropertymap.h
QT += declarative
RESOURCES += propertyeditor.qrc
FORMS += behaviordialog.ui
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment