forked from qt-creator/qt-creator
QmlDesigner: Remove double evaluation
That calls are quite expesive. So there is no need to call them twice. Change-Id: I4ef2f17693464573b7614a529038b0e06f887f49 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -72,9 +72,9 @@ static bool cleverColorCompare(const QVariant &value1, const QVariant &value2)
|
|||||||
|
|
||||||
// "red" is the same color as "#ff0000"
|
// "red" is the same color as "#ff0000"
|
||||||
// To simplify editing we convert all explicit color names in the hash format
|
// To simplify editing we convert all explicit color names in the hash format
|
||||||
static void fixAmbigousColorNames(const ModelNode &modelNode, PropertyNameView name, QVariant *value)
|
static void fixAmbigousColorNames(const NodeMetaInfo &metaInfo, QVariant *value)
|
||||||
{
|
{
|
||||||
if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isColor()) {
|
if (metaInfo.isColor()) {
|
||||||
if (value->typeId() == QMetaType::QColor) {
|
if (value->typeId() == QMetaType::QColor) {
|
||||||
QColor color = value->value<QColor>();
|
QColor color = value->value<QColor>();
|
||||||
int alpha = color.alpha();
|
int alpha = color.alpha();
|
||||||
@@ -87,9 +87,9 @@ static void fixAmbigousColorNames(const ModelNode &modelNode, PropertyNameView n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fixUrl(const ModelNode &modelNode, PropertyNameView name, QVariant *value)
|
static void fixUrl(const NodeMetaInfo &metaInfo, QVariant *value)
|
||||||
{
|
{
|
||||||
if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isUrl()) {
|
if (metaInfo.isUrl()) {
|
||||||
if (!value->isValid())
|
if (!value->isValid())
|
||||||
*value = QStringLiteral("");
|
*value = QStringLiteral("");
|
||||||
}
|
}
|
||||||
@@ -132,8 +132,9 @@ void PropertyEditorValue::setValue(const QVariant &value)
|
|||||||
if (!compareVariants(m_value, value) && !cleverDoubleCompare(value, m_value) && !colorsEqual)
|
if (!compareVariants(m_value, value) && !cleverDoubleCompare(value, m_value) && !colorsEqual)
|
||||||
m_value = value;
|
m_value = value;
|
||||||
|
|
||||||
fixAmbigousColorNames(modelNode(), name(), &m_value);
|
auto propertyTypeMetaInfo = modelNode().metaInfo().property(name()).propertyType();
|
||||||
fixUrl(modelNode(), name(), &m_value);
|
fixAmbigousColorNames(propertyTypeMetaInfo, &m_value);
|
||||||
|
fixUrl(propertyTypeMetaInfo, &m_value);
|
||||||
|
|
||||||
if (!colorsEqual)
|
if (!colorsEqual)
|
||||||
emit valueChangedQml();
|
emit valueChangedQml();
|
||||||
|
Reference in New Issue
Block a user