Commit 0de18abb authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: use initializer lists

Change-Id: Ibdc46d30ad3f2b703d4cbdd796a1032030bd17cd
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent 5ca34bd3
......@@ -227,7 +227,7 @@ void LayoutInGridLayout::ensureLayoutImport(const SelectionContext &context)
{
if (!hasQtQuickLayoutImport(context)) {
Import layoutImport = Import::createLibraryImport("QtQuick.Layouts", "1.0");
context.view()-> model()->changeImports(QList<Import>() << layoutImport, QList<Import>());
context.view()-> model()->changeImports({layoutImport}, {});
}
}
......
......@@ -156,7 +156,7 @@ void goIntoComponent(const ModelNode &modelNode)
void select(const SelectionContext &selectionState)
{
if (selectionState.view())
selectionState.view()->setSelectedModelNodes(QList<ModelNode>() << selectionState.targetNode());
selectionState.view()->setSelectedModelNodes({selectionState.targetNode()});
}
void deSelect(const SelectionContext &selectionState)
......
......@@ -63,7 +63,7 @@ void AnchorIndicatorGraphicsItem::paint(QPainter *painter, const QStyleOptionGra
QPen linePen(QColor(0, 0, 0, 150));
linePen.setCosmetic(true);
linePen.setDashPattern(QVector<double>() << 3. << 2.);
linePen.setDashPattern({3., 2.});
painter->setPen(linePen);
......@@ -72,7 +72,7 @@ void AnchorIndicatorGraphicsItem::paint(QPainter *painter, const QStyleOptionGra
painter->drawLine(m_secondControlPoint, m_endPoint);
linePen.setColor(QColor(255, 255, 255, 150));
linePen.setDashPattern(QVector<double>() << 2. << 3.);
linePen.setDashPattern({2., 3.});
linePen.setDashOffset(2.);
painter->setPen(linePen);
......
......@@ -81,11 +81,11 @@ void BackgroundAction::emitBackgroundChanged(int index)
QList<QColor> BackgroundAction::colors()
{
static QColor alphaZero(Qt::transparent);
static QList<QColor> colorList = QList<QColor>() << alphaZero
<< QColor(Qt::black)
<< QColor(Qt::darkGray)
<< QColor(Qt::lightGray)
<< QColor(Qt::white);
static QList<QColor> colorList = {alphaZero,
QColor(Qt::black),
QColor(Qt::darkGray),
QColor(Qt::lightGray),
QColor(Qt::white)};
return colorList;
......
......@@ -157,7 +157,7 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName,
FormEditorItem* DragTool::targetContainerOrRootItem(const QList<QGraphicsItem*> &itemList, FormEditorItem * currentItem)
{
FormEditorItem *formEditorItem = containerFormEditorItem(itemList, QList<FormEditorItem*>() << currentItem);
FormEditorItem *formEditorItem = containerFormEditorItem(itemList, {currentItem});
if (!formEditorItem)
formEditorItem = scene()->rootFormEditorItem();
......
......@@ -109,7 +109,7 @@ void ImportManagerView::removeImport(const Import &import)
{
try {
if (model())
model()->changeImports(QList<Import>(), QList<Import>() << import);
model()->changeImports({}, {import});
}
catch (const RewritingException &e) {
e.showException();
......@@ -120,7 +120,7 @@ void ImportManagerView::addImport(const Import &import)
{
try {
if (model())
model()->changeImports(QList<Import>() << import, QList<Import>());
model()->changeImports({import}, {});
}
catch (const RewritingException &e) {
e.showException();
......
......@@ -139,7 +139,7 @@ static ComponentTextModifier *createComponentTextModifier(TextModifier *original
bool DesignDocument::loadInFileComponent(const ModelNode &componentNode)
{
QString componentText = rewriterView()->extractText(QList<ModelNode>() << componentNode).value(componentNode);
QString componentText = rewriterView()->extractText({componentNode}).value(componentNode);
if (componentText.isEmpty())
return false;
......@@ -383,7 +383,7 @@ void DesignDocument::copySelected()
{
QScopedPointer<Model> copyModel(Model::create("QtQuick.Rectangle", 1, 0, currentModel()));
copyModel->setFileUrl(currentModel()->fileUrl());
copyModel->changeImports(currentModel()->imports(), QList<Import>());
copyModel->changeImports(currentModel()->imports(), {});
Q_ASSERT(copyModel);
......@@ -480,7 +480,7 @@ void DesignDocument::paste()
{
QScopedPointer<Model> pasteModel(Model::create("empty", 1, 0, currentModel()));
pasteModel->setFileUrl(currentModel()->fileUrl());
pasteModel->changeImports(currentModel()->imports(), QList<Import>());
pasteModel->changeImports(currentModel()->imports(), {});
Q_ASSERT(pasteModel);
......@@ -575,7 +575,7 @@ void DesignDocument::paste()
transaction.commit();
NodeMetaInfo::clearCache();
view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
view.setSelectedModelNodes({pastedNode});
transaction.commit();
} catch (const RewritingException &e) {
qWarning() << e.description(); //silent error
......
......@@ -114,7 +114,7 @@ QString DesignDocumentView::toText() const
ModelNode rewriterNode(rewriterView->rootModelNode());
//get the text of the root item without imports
return rewriterView->extractText(QList<ModelNode>() << rewriterNode).value(rewriterNode);
return rewriterView->extractText({rewriterNode}).value(rewriterNode);
}
void DesignDocumentView::fromText(QString text)
......
......@@ -293,14 +293,14 @@ void ItemLibraryWidget::removeImport(const QString &name)
if (import.isLibraryImport() && import.url().compare(name, Qt::CaseInsensitive) == 0)
toBeRemovedImportList.append(import);
m_model->changeImports(QList<Import>(), toBeRemovedImportList);
m_model->changeImports({}, toBeRemovedImportList);
}
void ItemLibraryWidget::addImport(const QString &name, const QString &version)
{
if (!m_model)
return;
m_model->changeImports(QList<Import>() << Import::createLibraryImport(name, version), QList<Import>());
m_model->changeImports({Import::createLibraryImport(name, version)}, {});
}
}
......@@ -46,7 +46,7 @@ class ModelNode;
: idItem(id), lockItem(lock), visibilityItem(visibility), propertyItems(properties) {}
QList<QStandardItem*> toList() const {
return QList<QStandardItem*>() << idItem << lockItem << visibilityItem;
return {idItem, lockItem, visibilityItem};
}
QStandardItem *idItem;
......@@ -62,7 +62,7 @@ class ModelNode;
: idItem(id), exportItem(exportI), visibilityItem(visibility), propertyItems(properties) {}
QList<QStandardItem*> toList() const {
return QList<QStandardItem*>() << idItem << exportItem << visibilityItem;
return {idItem, exportItem, visibilityItem};
}
QStandardItem *idItem;
......
......@@ -153,11 +153,12 @@ void StatesEditorView::addState()
try {
if ((rootStateGroup().allStates().count() < 1) && //QtQuick import might be missing
(!model()->hasImport(Import::createLibraryImport(QLatin1String("QtQuick"), QLatin1String("1.0")), true, true)))
model()->changeImports(QList<Import>() << Import::createLibraryImport(QLatin1String("QtQuick"), QLatin1String("1.0")), QList<Import>());
(!model()->hasImport(Import::createLibraryImport("QtQuick", "1.0"), true, true))) {
model()->changeImports({Import::createLibraryImport("QtQuick", "1.0")}, {});
}
ModelNode newState = rootStateGroup().addState(newStateName);
setCurrentState(newState);
} catch (const RewritingException &e) {
} catch (const RewritingException &e) {
e.showException();
}
}
......
......@@ -244,9 +244,9 @@ void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
propertyList.append(createdNode.variantProperty("y"));
updatePosition(propertyList);
nodeInstanceServer()->createInstances(createCreateInstancesCommand(QList<NodeInstance>() << instance));
nodeInstanceServer()->createInstances(createCreateInstancesCommand({instance}));
nodeInstanceServer()->changePropertyValues(createChangeValueCommand(createdNode.variantProperties()));
nodeInstanceServer()->completeComponent(createComponentCompleteCommand(QList<NodeInstance>() << instance));
nodeInstanceServer()->completeComponent(createComponentCompleteCommand({instance}));
}
/*! Notifies the view that \a removedNode will be removed.
......@@ -420,7 +420,7 @@ void NodeInstanceView::nodeIdChanged(const ModelNode& node, const QString& /*new
{
if (hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node);
nodeInstanceServer()->changeIds(createChangeIdsCommand(QList<NodeInstance>() << instance));
nodeInstanceServer()->changeIds(createChangeIdsCommand({instance}));
}
}
......@@ -459,16 +459,16 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const Propert
QVariant value = data;
if (value.isValid()) {
PropertyValueContainer container(instance.instanceId(), name, value, TypeName());
ChangeAuxiliaryCommand changeAuxiliaryCommand(QVector<PropertyValueContainer>() << container);
ChangeAuxiliaryCommand changeAuxiliaryCommand({container});
nodeInstanceServer()->changeAuxiliaryValues(changeAuxiliaryCommand);
} else {
if (node.hasVariantProperty(name)) {
PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName());
ChangeValuesCommand changeValueCommand(QVector<PropertyValueContainer>() << container);
ChangeValuesCommand changeValueCommand({container});
nodeInstanceServer()->changePropertyValues(changeValueCommand);
} else if (node.hasBindingProperty(name)) {
PropertyBindingContainer container(instance.instanceId(), name, node.bindingProperty(name).expression(), TypeName());
ChangeBindingsCommand changeValueCommand(QVector<PropertyBindingContainer>() << container);
ChangeBindingsCommand changeValueCommand({container});
nodeInstanceServer()->changePropertyBindings(changeValueCommand);
}
}
......@@ -1082,7 +1082,7 @@ RemovePropertiesCommand NodeInstanceView::createRemovePropertiesCommand(const QL
RemoveSharedMemoryCommand NodeInstanceView::createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, quint32 keyNumber)
{
return RemoveSharedMemoryCommand(sharedMemoryTypeName, QVector<qint32>() << keyNumber);
return RemoveSharedMemoryCommand(sharedMemoryTypeName, {static_cast<qint32>(keyNumber)});
}
RemoveSharedMemoryCommand NodeInstanceView::createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, const QList<ModelNode> &nodeList)
......
......@@ -231,7 +231,7 @@ QProcess *PuppetCreator::puppetProcess(const QString &puppetPath,
QObject::connect(puppetProcess, SIGNAL(readyRead()), handlerObject, outputSlot);
}
puppetProcess->setWorkingDirectory(workingDirectory);
puppetProcess->start(puppetPath, QStringList() << socketToken << puppetMode << QLatin1String("-graphicssystem raster"));
puppetProcess->start(puppetPath, {socketToken, puppetMode, "-graphicssystem raster"});
#ifndef QMLDESIGNER_TEST
QString debugPuppet = m_designerSettings.value(DesignerSettingsKey::
......@@ -621,7 +621,7 @@ bool PuppetCreator::checkPuppetVersion(const QString &qmlPuppetPath)
{
QProcess qmlPuppetVersionProcess;
qmlPuppetVersionProcess.start(qmlPuppetPath, QStringList() << QLatin1String("--version"));
qmlPuppetVersionProcess.start(qmlPuppetPath, {"--version"});
qmlPuppetVersionProcess.waitForReadyRead(6000);
QByteArray versionString = qmlPuppetVersionProcess.readAll();
......
......@@ -1251,7 +1251,7 @@ void NodeMetaInfoPrivate::setupPrototypes()
}
m_prototypes.append(description);
} else {
if (context()->lookupType(document(), QStringList() << ov->className())) {
if (context()->lookupType(document(), {ov->className()})) {
const Imports *allImports = context()->imports(document());
ImportInfo importInfo = allImports->info(description.className, context().data());
......
......@@ -331,7 +331,7 @@ void SubComponentManager::registerQmlFile(const QFileInfo &fileInfo, const QStri
}
if (!model()->metaInfo().itemLibraryInfo()->containsEntry(itemLibraryEntry))
model()->metaInfo().itemLibraryInfo()->addEntries(QList<ItemLibraryEntry>() << itemLibraryEntry);
model()->metaInfo().itemLibraryInfo()->addEntries({itemLibraryEntry});
}
}
......
......@@ -1499,9 +1499,9 @@ static QList<PropertyPair> toPropertyPairList(const QList<InternalProperty::Poin
void ModelPrivate::removeProperty(const InternalProperty::Pointer &property)
{
notifyPropertiesAboutToBeRemoved(QList<InternalProperty::Pointer>() << property);
notifyPropertiesAboutToBeRemoved({property});
QList<PropertyPair> propertyPairList = toPropertyPairList(QList<InternalProperty::Pointer>() << property);
const QList<PropertyPair> propertyPairList = toPropertyPairList({property});
removePropertyWithoutNotification(property);
......@@ -1518,7 +1518,7 @@ void ModelPrivate::setBindingProperty(const InternalNode::Pointer &internalNodeP
InternalBindingProperty::Pointer bindingProperty = internalNodePointer->bindingProperty(name);
bindingProperty->setExpression(expression);
notifyBindingPropertiesChanged(QList<InternalBindingPropertyPointer>() << bindingProperty, propertyChange);
notifyBindingPropertiesChanged({bindingProperty}, propertyChange);
}
void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QString &source)
......@@ -1531,7 +1531,7 @@ void ModelPrivate::setSignalHandlerProperty(const InternalNodePointer &internalN
InternalSignalHandlerProperty::Pointer signalHandlerProperty = internalNodePointer->signalHandlerProperty(name);
signalHandlerProperty->setSource(source);
notifySignalHandlerPropertiesChanged(QVector<InternalSignalHandlerPropertyPointer>() << signalHandlerProperty, propertyChange);
notifySignalHandlerPropertiesChanged({signalHandlerProperty}, propertyChange);
}
void ModelPrivate::setVariantProperty(const InternalNode::Pointer &internalNodePointer, const PropertyName &name, const QVariant &value)
......@@ -1575,7 +1575,7 @@ void ModelPrivate::setDynamicBindingProperty(const InternalNodePointer &internal
InternalBindingProperty::Pointer bindingProperty = internalNodePointer->bindingProperty(name);
bindingProperty->setDynamicExpression(dynamicPropertyType, expression);
notifyBindingPropertiesChanged(QList<InternalBindingPropertyPointer>() << bindingProperty, propertyChange);
notifyBindingPropertiesChanged({bindingProperty}, propertyChange);
}
void ModelPrivate::reparentNode(const InternalNode::Pointer &newParentNode,
......
......@@ -157,7 +157,7 @@ ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
newImports.append(import);
}
view()->model()->changeImports(newImports, QList<Import>());
view()->model()->changeImports(newImports, {});
QHash<QString, QString> idRenamingHash;
setupIdRenamingHash(modelNode, idRenamingHash, view());
......@@ -168,7 +168,7 @@ ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
void ModelMerger::replaceModel(const ModelNode &modelNode)
{
view()->model()->changeImports(modelNode.model()->imports(), QList<Import>());
view()->model()->changeImports(modelNode.model()->imports(), {});
view()->model()->setFileUrl(modelNode.model()->fileUrl());
try {
......
......@@ -278,12 +278,12 @@ AnchorLineType QmlAnchors::possibleAnchorLines(AnchorLineType sourceAnchorLineTy
return AnchorLineInvalid;
if (AnchorLine::isHorizontalAnchorLine(sourceAnchorLineType)) {
if (!detectHorizontalCycle(targetQmlItemNode, QList<ModelNode>() << qmlItemNode().modelNode()))
if (!detectHorizontalCycle(targetQmlItemNode, {qmlItemNode().modelNode()}))
return AnchorLineHorizontalMask;
}
if (AnchorLine::isVerticalAnchorLine(sourceAnchorLineType)) {
if (!detectVerticalCycle(targetQmlItemNode, QList<ModelNode>() << qmlItemNode().modelNode()))
if (!detectVerticalCycle(targetQmlItemNode, {qmlItemNode().modelNode()}))
return AnchorLineVerticalMask;
}
......
......@@ -868,7 +868,7 @@ void TextToModelMerger::setupPossibleImports(const QmlJS::Snapshot &snapshot, co
void TextToModelMerger::setupUsedImports()
{
QList<QmlJS::Import> allImports = m_scopeChain->context()->imports(m_document.data())->all();
const QList<QmlJS::Import> allImports = m_scopeChain->context()->imports(m_document.data())->all();
QList<Import> usedImports;
......@@ -1110,7 +1110,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
|| isConnectionsType(typeName)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName.toUtf8());
if (context->isArrayProperty(propertyType, containingObject, name))
syncArrayProperty(modelProperty, QList<AST::UiObjectMember*>() << member, context, differenceHandler);
syncArrayProperty(modelProperty, {member}, context, differenceHandler);
else
syncNodeProperty(modelProperty, binding, context, TypeName(), differenceHandler);
modelPropertyNames.remove(astPropertyName.toUtf8());
......@@ -1710,12 +1710,12 @@ void ModelValidator::idsDiffer(ModelNode &modelNode, const QString &qmlId)
void ModelAmender::modelMissesImport(const QmlDesigner::Import &import)
{
m_merger->view()->model()->changeImports(QList<QmlDesigner::Import>() << import, QList<QmlDesigner::Import>());
m_merger->view()->model()->changeImports({import}, {});
}
void ModelAmender::importAbsentInQMl(const QmlDesigner::Import &import)
{
m_merger->view()->model()->changeImports(QList<Import>(), QList<Import>() << import);
m_merger->view()->model()->changeImports({}, {import});
}
void ModelAmender::bindingExpressionsDiffer(BindingProperty &modelProperty,
......@@ -1937,7 +1937,7 @@ void TextToModelMerger::setupComponent(const ModelNode &node)
if (!node.isValid())
return;
QString componentText = m_rewriterView->extractText(QList<ModelNode>() << node).value(node);
QString componentText = m_rewriterView->extractText({node}).value(node);
if (componentText.isEmpty())
return;
......@@ -2054,7 +2054,7 @@ void TextToModelMerger::setupCustomParserNode(const ModelNode &node)
if (!node.isValid())
return;
QString modelText = m_rewriterView->extractText(QList<ModelNode>() << node).value(node);
QString modelText = m_rewriterView->extractText({node}).value(node);
if (modelText.isEmpty())
return;
......
......@@ -347,7 +347,7 @@ void DesignModeWidget::setup()
// Finishing touches:
m_mainSplitter->setStretchFactor(1, 1);
m_mainSplitter->setSizes(QList<int>() << 150 << 300 << 150);
m_mainSplitter->setSizes({150, 300, 150});
QLayout *mainLayout = new QBoxLayout(QBoxLayout::RightToLeft, this);
mainLayout->setMargin(0);
......
......@@ -455,7 +455,7 @@ bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFilePro
if (!projectNode)
return false;
if (!projectNode->addFiles(QStringList() << resourceFilePath)) {
if (!projectNode->addFiles({resourceFilePath})) {
qCWarning(documentManagerLog) << "Failed to add resource file to" << projectNode->displayName();
return false;
}
......
......@@ -183,7 +183,7 @@ void BackendModel::deletePropertyByRow(int rowNumber)
try {
if (model->hasImport(import))
model->changeImports(QList<Import>(), QList<Import> { import } );
model->changeImports({}, {import});
} catch (const Exception &e) {
e.showException();
}
......@@ -241,7 +241,7 @@ void BackendModel::addNewBackend()
*/
if (!model->hasImport(import))
model->changeImports(QList<Import> { import }, QList<Import>());
model->changeImports({import}, {});
QString propertyName = m_connectionView->generateNewId(typeName);
......
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