forked from qt-creator/qt-creator
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:
@@ -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
|
||||||
|
|
@@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
#include <QQmlPropertyMap>
|
#include <QQmlPropertyMap>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
#include "propertyeditorvalue.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
template <class DefaultType>
|
|
||||||
class DesignerPropertyMap : public QQmlPropertyMap
|
class DesignerPropertyMap : public QQmlPropertyMap
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -46,30 +46,9 @@ public:
|
|||||||
|
|
||||||
static void registerDeclarativeType(const QString &name);
|
static void registerDeclarativeType(const QString &name);
|
||||||
private:
|
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
|
} //QmlDesigner
|
||||||
|
|
||||||
#endif // DESIGNERPROPERTYMAP_H
|
#endif // DESIGNERPROPERTYMAP_H
|
||||||
|
@@ -4,6 +4,7 @@ SOURCES += propertyeditorview.cpp \
|
|||||||
qmlanchorbindingproxy.cpp \
|
qmlanchorbindingproxy.cpp \
|
||||||
propertyeditorvalue.cpp \
|
propertyeditorvalue.cpp \
|
||||||
propertyeditortransaction.cpp \
|
propertyeditortransaction.cpp \
|
||||||
|
designerpropertymap.cpp \
|
||||||
propertyeditorcontextobject.cpp \
|
propertyeditorcontextobject.cpp \
|
||||||
quick2propertyeditorview.cpp \
|
quick2propertyeditorview.cpp \
|
||||||
propertyeditorqmlbackend.cpp \
|
propertyeditorqmlbackend.cpp \
|
||||||
|
@@ -222,7 +222,7 @@ Internal::QmlAnchorBindingProxy &PropertyEditorQmlBackend::backendAnchorBinding(
|
|||||||
return m_backendAnchorBinding;
|
return m_backendAnchorBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
DesignerPropertyMap<PropertyEditorValue> &PropertyEditorQmlBackend::backendValuesPropertyMap() {
|
DesignerPropertyMap &PropertyEditorQmlBackend::backendValuesPropertyMap() {
|
||||||
return m_backendValuesPropertyMap;
|
return m_backendValuesPropertyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public:
|
|||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
void setSource(const QUrl& url);
|
void setSource(const QUrl& url);
|
||||||
Internal::QmlAnchorBindingProxy &backendAnchorBinding();
|
Internal::QmlAnchorBindingProxy &backendAnchorBinding();
|
||||||
DesignerPropertyMap<PropertyEditorValue> &backendValuesPropertyMap();
|
DesignerPropertyMap &backendValuesPropertyMap();
|
||||||
PropertyEditorTransaction *propertyEditorTransaction();
|
PropertyEditorTransaction *propertyEditorTransaction();
|
||||||
|
|
||||||
PropertyEditorValue *propertyValueForName(const QString &propertyName);
|
PropertyEditorValue *propertyValueForName(const QString &propertyName);
|
||||||
@@ -88,7 +88,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
Quick2PropertyEditorView *m_view;
|
Quick2PropertyEditorView *m_view;
|
||||||
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
|
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
|
||||||
DesignerPropertyMap<PropertyEditorValue> m_backendValuesPropertyMap;
|
DesignerPropertyMap m_backendValuesPropertyMap;
|
||||||
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
|
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
|
||||||
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
|
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
|
||||||
QScopedPointer<PropertyEditorContextObject> m_contextObject;
|
QScopedPointer<PropertyEditorContextObject> m_contextObject;
|
||||||
|
Reference in New Issue
Block a user