Commit a991ecec authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: use initilizer_lists for pairs

Change-Id: I3a1ef67d8af255604494695807331576540b8afa
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent edbaea4f
......@@ -253,7 +253,7 @@ bool ObjectNodeInstance::isAnchoredByChildren() const
QPair<PropertyName, ServerNodeInstance> ObjectNodeInstance::anchor(const PropertyName &/*name*/) const
{
return qMakePair(PropertyName(), ServerNodeInstance());
return {PropertyName(), ServerNodeInstance()};
}
......
......@@ -769,7 +769,7 @@ QPair<PropertyName, ServerNodeInstance> QuickItemNodeInstance::anchor(const Prop
while (targetObject) {
if (nodeInstanceServer()->hasInstanceForObject(targetObject))
return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject));
return {targetName, nodeInstanceServer()->instanceForObject(targetObject)};
else
targetObject = parentObject(targetObject);
}
......
......@@ -64,21 +64,23 @@ void SnappingLineCreator::clearLines()
void SnappingLineCreator::addLines(const QRectF &rectInSceneSpace, FormEditorItem *item)
{
m_topLineMap.insert(rectInSceneSpace.top(), qMakePair(rectInSceneSpace, item));
m_bottomLineMap.insert(rectInSceneSpace.bottom(), qMakePair(rectInSceneSpace, item));
m_leftLineMap.insert(rectInSceneSpace.left(), qMakePair(rectInSceneSpace, item));
m_rightLineMap.insert(rectInSceneSpace.right(), qMakePair(rectInSceneSpace, item));
QPointF centerPoint(rectInSceneSpace.center());
m_horizontalCenterLineMap.insert(centerPoint.y(), qMakePair(rectInSceneSpace, item));
m_verticalCenterLineMap.insert(centerPoint.x(), qMakePair(rectInSceneSpace, item));
const QPair<QRectF, FormEditorItem*> rectInSceneSpaceItemPair = {rectInSceneSpace, item};
m_topLineMap.insert(rectInSceneSpace.top(), rectInSceneSpaceItemPair);
m_bottomLineMap.insert(rectInSceneSpace.bottom(), rectInSceneSpaceItemPair);
m_leftLineMap.insert(rectInSceneSpace.left(), rectInSceneSpaceItemPair);
m_rightLineMap.insert(rectInSceneSpace.right(), rectInSceneSpaceItemPair);
const QPointF centerPoint(rectInSceneSpace.center());
m_horizontalCenterLineMap.insert(centerPoint.y(), rectInSceneSpaceItemPair);
m_verticalCenterLineMap.insert(centerPoint.x(), rectInSceneSpaceItemPair);
}
void SnappingLineCreator::addOffsets(const QRectF &rectInSceneSpace, FormEditorItem *item)
{
m_topOffsetMap.insert(rectInSceneSpace.top() - m_topOffset, qMakePair(rectInSceneSpace, item));
m_bottomOffsetMap.insert(rectInSceneSpace.bottom() + m_bottomOffset, qMakePair(rectInSceneSpace, item));
m_leftOffsetMap.insert(rectInSceneSpace.left() - m_leftOffset, qMakePair(rectInSceneSpace, item));
m_rightOffsetMap.insert(rectInSceneSpace.right() + m_rightOffset, qMakePair(rectInSceneSpace, item));
const QPair<QRectF, FormEditorItem*> rectInSceneSpaceItemPair = {rectInSceneSpace, item};
m_topOffsetMap.insert(rectInSceneSpace.top() - m_topOffset, rectInSceneSpaceItemPair);
m_bottomOffsetMap.insert(rectInSceneSpace.bottom() + m_bottomOffset, rectInSceneSpaceItemPair);
m_leftOffsetMap.insert(rectInSceneSpace.left() - m_leftOffset, rectInSceneSpaceItemPair);
m_rightOffsetMap.insert(rectInSceneSpace.right() + m_rightOffset, rectInSceneSpaceItemPair);
}
void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionList,
......
......@@ -1107,7 +1107,7 @@ void NodeInstanceView::valuesChanged(const ValuesChangedCommand &command)
NodeInstance instance = instanceForId(container.instanceId());
if (instance.isValid()) {
instance.setProperty(container.name(), container.value());
valuePropertyChangeList.append(qMakePair(instance.modelNode(), container.name()));
valuePropertyChangeList.append({instance.modelNode(), container.name()});
}
}
}
......
......@@ -286,13 +286,13 @@ public:
if (ref) {
QVector<PropertyInfo> dotProperties;
const TypeName type = resolveTypeName(ref, m_context, dotProperties);
m_properties.append(qMakePair(propertyName, type));
m_properties.append({propertyName, type});
if (!dotProperties.isEmpty()) {
foreach (const PropertyInfo &propertyInfo, dotProperties) {
PropertyName dotName = propertyInfo.first;
TypeName type = propertyInfo.second;
dotName = propertyName + '.' + dotName;
m_properties.append(qMakePair(dotName, type));
m_properties.append({dotName, type});
}
}
} else {
......@@ -300,7 +300,7 @@ public:
if (const CppComponentValue * cppComponentValue = value_cast<CppComponentValue>(value)) {
TypeName qualifiedTypeName = qualifiedTypeNameForContext(cppComponentValue,
m_context->viewerContext(), *m_context->snapshot().importDependencies()).toUtf8();
m_properties.append(qMakePair(propertyName, qualifiedTypeName));
m_properties.append({propertyName, qualifiedTypeName});
} else {
TypeId typeId;
TypeName typeName = typeId(value).toUtf8();
......@@ -311,7 +311,7 @@ public:
typeName = "real";
}
}
m_properties.append(qMakePair(propertyName, typeName));
m_properties.append({propertyName, typeName});
}
}
return true;
......@@ -424,7 +424,7 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
foreach (const PropertyInfo &propertyInfo, dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second;
propertyList.append(qMakePair(dotName, type));
propertyList.append({dotName, type});
}
}
}
......@@ -435,7 +435,7 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
foreach (const PropertyInfo &propertyInfo, dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second;
propertyList.append(qMakePair(dotName, type));
propertyList.append({dotName, type});
}
}
}
......@@ -446,7 +446,7 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
if (type == "unknown" && objectValue->hasProperty(nameAsString))
type = objectValue->propertyType(nameAsString).toUtf8();
propertyList.append(qMakePair(name, type));
propertyList.append({name, type});
}
if (!local)
......
......@@ -1491,7 +1491,7 @@ static QList<PropertyPair> toPropertyPairList(const QList<InternalProperty::Poin
QList<PropertyPair> propertyPairList;
foreach (const InternalProperty::Pointer &property, propertyList)
propertyPairList.append(qMakePair(property->propertyOwner(), property->name()));
propertyPairList.append({property->propertyOwner(), property->name()});
return propertyPairList;
......
......@@ -118,15 +118,15 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
if (itemLibraryEntry.qmlSource().isEmpty()) {
QList<QPair<PropertyName, QVariant> > propertyPairList;
if (!position.isNull()) {
propertyPairList.append(qMakePair(PropertyName("x"), QVariant(qRound(position.x()))));
propertyPairList.append(qMakePair(PropertyName("y"), QVariant(qRound(position.y()))));
propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))});
propertyPairList.append({PropertyName("y"), QVariant(qRound(position.y()))});
}
foreach (const PropertyContainer &property, itemLibraryEntry.properties()) {
if (property.type() == QStringLiteral("binding")) {
propertyBindingList.append(PropertyBindingEntry(property.name(), property.value().toString()));
} else {
propertyPairList.append(qMakePair(property.name(), property.value()));
propertyPairList.append({property.name(), property.value()});
}
}
......@@ -182,8 +182,8 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
if (view->model()->hasNodeMetaInfo("QtQuick.Image")) {
NodeMetaInfo metaInfo = view->model()->metaInfo("QtQuick.Image");
QList<QPair<PropertyName, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(PropertyName("x"), QVariant(qRound(position.x()))));
propertyPairList.append(qMakePair(PropertyName("y"), QVariant(qRound(position.y()))));
propertyPairList.append({PropertyName("x"), QVariant(qRound(position.x()))});
propertyPairList.append({PropertyName("y"), QVariant(qRound(position.y()))});
QString relativeImageName = imageName;
......@@ -191,7 +191,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
if (QFileInfo::exists(view->model()->fileUrl().toLocalFile())) {
QDir fileDir(QFileInfo(view->model()->fileUrl().toLocalFile()).absolutePath());
relativeImageName = fileDir.relativeFilePath(imageName);
propertyPairList.append(qMakePair(PropertyName("source"), QVariant(relativeImageName)));
propertyPairList.append({PropertyName("source"), QVariant(relativeImageName)});
}
newQmlItemNode = QmlItemNode(view->createModelNode("QtQuick.Image", metaInfo.majorVersion(), metaInfo.minorVersion(), propertyPairList));
......@@ -529,11 +529,8 @@ QmlModelState QmlModelStateGroup::addState(const QString &name)
if (!modelNode().isValid())
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
PropertyListType propertyList;
propertyList.append(qMakePair(PropertyName("name"), QVariant(name)));
ModelNode newState = QmlModelState::createQmlState(modelNode().view(), propertyList);
ModelNode newState = QmlModelState::createQmlState(
modelNode().view(), {{PropertyName("name"), QVariant(name)}});
modelNode().nodeListProperty("states").reparentHere(newState);
return newState;
......
......@@ -259,9 +259,7 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
// QmlModelState newState(stateGroup().addState(name));
PropertyListType propertyList;
propertyList.append(qMakePair(PropertyName("name"), QVariant(name)));
QmlModelState newState(createQmlState(view(), propertyList));
QmlModelState newState(createQmlState(view(), {{PropertyName("name"), QVariant(name)}}));
foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
ModelNode newModelNode(view()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
foreach (const BindingProperty &bindingProperty, childNode.bindingProperties())
......
......@@ -2035,7 +2035,7 @@ void TextToModelMerger::populateQrcMapping(const QString &filePath)
fileSystemPath.remove(fileName);
if (path.isEmpty())
path.prepend(QLatin1String("/"));
m_qrcMapping.insert(qMakePair(path, fileSystemPath));
m_qrcMapping.insert({path, fileSystemPath});
}
}
......
......@@ -318,7 +318,7 @@ QPair<CubicSegment, CubicSegment> CubicSegment::split(double t)
qDebug() << firstCubicSegment << secondCubicSegment;
return qMakePair(firstCubicSegment, secondCubicSegment);
return {firstCubicSegment, secondCubicSegment};
}
void CubicSegment::makeStraightLine()
......
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