forked from qt-creator/qt-creator
Changed conversion to variant to use the functions in the PropertyParser namespace.
This commit is contained in:
@@ -31,9 +31,11 @@
|
|||||||
#include "bindingproperty.h"
|
#include "bindingproperty.h"
|
||||||
#include "filemanager/firstdefinitionfinder.h"
|
#include "filemanager/firstdefinitionfinder.h"
|
||||||
#include "filemanager/objectlengthcalculator.h"
|
#include "filemanager/objectlengthcalculator.h"
|
||||||
|
#include "metainfo.h"
|
||||||
#include "nodemetainfo.h"
|
#include "nodemetainfo.h"
|
||||||
#include "nodeproperty.h"
|
#include "nodeproperty.h"
|
||||||
#include "propertymetainfo.h"
|
#include "propertymetainfo.h"
|
||||||
|
#include "propertyparser.h"
|
||||||
#include "textmodifier.h"
|
#include "textmodifier.h"
|
||||||
#include "texttomodelmerger.h"
|
#include "texttomodelmerger.h"
|
||||||
#include "rewriterview.h"
|
#include "rewriterview.h"
|
||||||
@@ -628,27 +630,23 @@ QVariant TextToModelMerger::convertToVariant(const ModelNode &node,
|
|||||||
const QString &astType)
|
const QString &astType)
|
||||||
{
|
{
|
||||||
const QString cleanedValue = stripQuotes(astValue.trimmed());
|
const QString cleanedValue = stripQuotes(astValue.trimmed());
|
||||||
|
const NodeMetaInfo nodeMetaInfo = node.metaInfo();
|
||||||
|
|
||||||
if (!astType.isEmpty()) {
|
if (!astType.isEmpty()) {
|
||||||
const int type = propertyType(astType);
|
const int type = propertyType(astType);
|
||||||
QVariant value(cleanedValue);
|
QVariant value(cleanedValue);
|
||||||
value.convert(static_cast<QVariant::Type>(type));
|
value.convert(static_cast<QVariant::Type>(type));
|
||||||
return value;
|
return value;
|
||||||
}
|
|
||||||
|
|
||||||
const NodeMetaInfo nodeMetaInfo = node.metaInfo();
|
const QString typeName = QMetaType::typeName(type);
|
||||||
|
return Internal::PropertyParser::read(typeName, astValue, nodeMetaInfo.metaInfo());
|
||||||
|
}
|
||||||
|
|
||||||
if (nodeMetaInfo.isValid()) {
|
if (nodeMetaInfo.isValid()) {
|
||||||
const PropertyMetaInfo propertyMetaInfo = nodeMetaInfo.property(astName, true);
|
const PropertyMetaInfo propertyMetaInfo = nodeMetaInfo.property(astName, true);
|
||||||
|
|
||||||
if (propertyMetaInfo.isValid()) {
|
if (propertyMetaInfo.isValid()) {
|
||||||
QVariant castedValue = propertyMetaInfo.castedValue(cleanedValue);
|
return Internal::PropertyParser::read(propertyMetaInfo.type(), cleanedValue, nodeMetaInfo.metaInfo());
|
||||||
if (!castedValue.isValid())
|
|
||||||
qWarning() << "Casting the value" << cleanedValue
|
|
||||||
<< "of property" << astName
|
|
||||||
<< "to the property type" << propertyMetaInfo.type()
|
|
||||||
<< "failed";
|
|
||||||
return castedValue;
|
|
||||||
} else if (node.type() == QLatin1String("Qt/PropertyChanges")) {
|
} else if (node.type() == QLatin1String("Qt/PropertyChanges")) {
|
||||||
// In the future, we should do the type resolving in a second pass, or delay setting properties until the full file has been parsed.
|
// In the future, we should do the type resolving in a second pass, or delay setting properties until the full file has been parsed.
|
||||||
return QVariant(cleanedValue);
|
return QVariant(cleanedValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user