QmlDesigner.PropertyEditor: Fix CLANG warning

The constructor creates a true boolean QVariant. We have
to use fromValue instead.
Since Q_DECLARE_METATYPE does not work on template parameters
and there is no reason to use a template class, I turned
DesignerPropertyMap into a normal class.

Change-Id: I89d3ed727680fe0e62c94b67e7481fb202b26ca7
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
Thomas Hartmann
2014-02-28 17:48:39 +01:00
parent 9bf9f165ba
commit f18faa714d
5 changed files with 57 additions and 26 deletions

View File

@@ -0,0 +1,51 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "designerpropertymap.h"
namespace QmlDesigner {
DesignerPropertyMap::DesignerPropertyMap(QObject *parent) : QQmlPropertyMap(parent), m_defaultValue(new PropertyEditorValue(this))
{
}
QVariant DesignerPropertyMap::value(const QString &key) const
{
if (contains(key))
return QQmlPropertyMap::value(key);
return QVariant::fromValue(m_defaultValue);
}
void DesignerPropertyMap::registerDeclarativeType(const QString &name)
{
qmlRegisterType<DesignerPropertyMap>("Bauhaus",1,0,name.toLatin1());
}
} //QmlDesigner

View File

@@ -32,10 +32,10 @@
#include <QQmlPropertyMap>
#include <QtQml>
#include "propertyeditorvalue.h"
namespace QmlDesigner {
template <class DefaultType>
class DesignerPropertyMap : public QQmlPropertyMap
{
@@ -46,30 +46,9 @@ public:
static void registerDeclarativeType(const QString &name);
private:
DefaultType m_defaultValue;
PropertyEditorValue *m_defaultValue;
};
template <class DefaultType>
DesignerPropertyMap<DefaultType>::DesignerPropertyMap(QObject *parent) : QQmlPropertyMap(parent), m_defaultValue(this)
{
}
template <class DefaultType>
QVariant DesignerPropertyMap<DefaultType>::value(const QString &key) const
{
if (contains(key))
return QQmlPropertyMap::value(key);
return QVariant(&m_defaultValue);
}
template <class DefaultType>
void DesignerPropertyMap<DefaultType>::registerDeclarativeType(const QString &name)
{
typedef DesignerPropertyMap<DefaultType> myType;
qmlRegisterType<myType>("Bauhaus",1,0,name);
}
} //QmlDesigner
#endif // DESIGNERPROPERTYMAP_H

View File

@@ -4,6 +4,7 @@ SOURCES += propertyeditorview.cpp \
qmlanchorbindingproxy.cpp \
propertyeditorvalue.cpp \
propertyeditortransaction.cpp \
designerpropertymap.cpp \
propertyeditorcontextobject.cpp \
quick2propertyeditorview.cpp \
propertyeditorqmlbackend.cpp \

View File

@@ -222,7 +222,7 @@ Internal::QmlAnchorBindingProxy &PropertyEditorQmlBackend::backendAnchorBinding(
return m_backendAnchorBinding;
}
DesignerPropertyMap<PropertyEditorValue> &PropertyEditorQmlBackend::backendValuesPropertyMap() {
DesignerPropertyMap &PropertyEditorQmlBackend::backendValuesPropertyMap() {
return m_backendValuesPropertyMap;
}

View File

@@ -59,7 +59,7 @@ public:
QWidget *widget();
void setSource(const QUrl& url);
Internal::QmlAnchorBindingProxy &backendAnchorBinding();
DesignerPropertyMap<PropertyEditorValue> &backendValuesPropertyMap();
DesignerPropertyMap &backendValuesPropertyMap();
PropertyEditorTransaction *propertyEditorTransaction();
PropertyEditorValue *propertyValueForName(const QString &propertyName);
@@ -88,7 +88,7 @@ private:
private:
Quick2PropertyEditorView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
DesignerPropertyMap<PropertyEditorValue> m_backendValuesPropertyMap;
DesignerPropertyMap m_backendValuesPropertyMap;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
QScopedPointer<PropertyEditorContextObject> m_contextObject;