forked from qt-creator/qt-creator
QmlDesigner: Remove foreach / Q_FOREACH usage in componentcore
Task-number: QTCREATORBUG-27464 Change-Id: I89d78d131a11b84b592d3d10577fe1ea4c7a6b4c Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -73,7 +73,7 @@ bool checkForPropertyChanges(const QString &signal)
|
||||
void AddSignalHandlerDialog::updateComboBox()
|
||||
{
|
||||
m_ui->comboBox->clear();
|
||||
foreach (const QString &signal, m_signals) {
|
||||
for (const QString &signal : qAsConst(m_signals)) {
|
||||
if (m_ui->all->isChecked()) {
|
||||
m_ui->comboBox->addItem(signal);
|
||||
} else if (m_ui->properties->isChecked()) {
|
||||
|
@@ -39,7 +39,9 @@ static QString styleConfigFileName(const QString &qmlFileName)
|
||||
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(Utils::FilePath::fromString(qmlFileName));
|
||||
|
||||
if (currentProject) {
|
||||
foreach (const Utils::FilePath &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles))
|
||||
const QList<Utils::FilePath> fileNames = currentProject->files(
|
||||
ProjectExplorer::Project::SourceFiles);
|
||||
for (const Utils::FilePath &fileName : fileNames)
|
||||
if (fileName.endsWith("qtquickcontrols2.conf"))
|
||||
return fileName.toString();
|
||||
}
|
||||
|
@@ -178,7 +178,8 @@ void DesignerActionManagerView::setupContext(SelectionContext::UpdateMode update
|
||||
}
|
||||
SelectionContext selectionContext(this);
|
||||
selectionContext.setUpdateMode(updateMode);
|
||||
foreach (ActionInterface* action, m_designerActionManager.designerActions()) {
|
||||
const QList<ActionInterface *> actions = m_designerActionManager.designerActions();
|
||||
for (ActionInterface *action : actions) {
|
||||
action->currentContextChanged(selectionContext);
|
||||
}
|
||||
m_setupContextDirty = false;
|
||||
|
@@ -290,8 +290,8 @@ QList<QmlJSEditor::FindReferences::Usage> FindImplementation::run(const QString
|
||||
|
||||
FindImplementationVisitor visitor(document, context);
|
||||
|
||||
FindImplementationVisitor::Results results = visitor(typeName, itemName, targetValue);
|
||||
foreach (const SourceLocation &location, results) {
|
||||
const FindImplementationVisitor::Results results = visitor(typeName, itemName, targetValue);
|
||||
for (const SourceLocation &location : results) {
|
||||
usages.append(QmlJSEditor::FindReferences::Usage(fileName,
|
||||
matchingLine(location.offset, document->source()),
|
||||
location.startLine, location.startColumn - 1, location.length));
|
||||
|
@@ -103,7 +103,7 @@ static int lowerBound(int i)
|
||||
static inline QPointF getUpperLeftPosition(const QList<ModelNode> &modelNodeList)
|
||||
{
|
||||
QPointF postion(std::numeric_limits<qreal>::max(), std::numeric_limits<qreal>::max());
|
||||
foreach (const ModelNode &modelNode, modelNodeList) {
|
||||
for (const ModelNode &modelNode : modelNodeList) {
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
QmlItemNode qmlIitemNode = QmlItemNode(modelNode);
|
||||
if (qmlIitemNode.instancePosition().x() < postion.x())
|
||||
@@ -122,18 +122,20 @@ static void setUpperLeftPostionToNode(const ModelNode &layoutNode, const QList<M
|
||||
layoutNode.variantProperty("y").setValue(qRound(upperLeftPosition.y()));
|
||||
}
|
||||
|
||||
void LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(const ModelNode &parentModelNode,
|
||||
const QList<ModelNode> &modelNodeList)
|
||||
void LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(
|
||||
const ModelNode &parentModelNode, const QList<ModelNode> &modelNodeList)
|
||||
{
|
||||
foreach (ModelNode modelNode, modelNodeList) {
|
||||
for (ModelNode modelNode : modelNodeList) {
|
||||
reparentTo(modelNode, parentModelNode);
|
||||
modelNode.removeProperty("x");
|
||||
modelNode.removeProperty("y");
|
||||
foreach (const VariantProperty &variantProperty, modelNode.variantProperties()) {
|
||||
const QList<VariantProperty> variantProperties = modelNode.variantProperties();
|
||||
for (const VariantProperty &variantProperty : variantProperties) {
|
||||
if (variantProperty.name().contains("anchors."))
|
||||
modelNode.removeProperty(variantProperty.name());
|
||||
}
|
||||
foreach (const BindingProperty &bindingProperty, modelNode.bindingProperties()) {
|
||||
const QList<BindingProperty> bindingProperties = modelNode.bindingProperties();
|
||||
for (const BindingProperty &bindingProperty : bindingProperties) {
|
||||
if (bindingProperty.name().contains("anchors."))
|
||||
modelNode.removeProperty(bindingProperty.name());
|
||||
}
|
||||
@@ -142,7 +144,7 @@ void LayoutInGridLayout::reparentToNodeAndRemovePositionForModelNodes(const Mode
|
||||
|
||||
void LayoutInGridLayout::setSizeAsPreferredSize(const QList<ModelNode> &modelNodeList)
|
||||
{
|
||||
foreach (ModelNode modelNode, modelNodeList) {
|
||||
for (ModelNode modelNode : modelNodeList) {
|
||||
if (modelNode.hasVariantProperty("width")) {
|
||||
modelNode.variantProperty("Layout.preferredWidth").setValue(modelNode.variantProperty("width").value());
|
||||
modelNode.removeProperty("width");
|
||||
@@ -249,7 +251,8 @@ int LayoutInGridLayout::rowCount() const
|
||||
|
||||
void LayoutInGridLayout::collectItemNodes()
|
||||
{
|
||||
foreach (const ModelNode &modelNode, m_selectionContext.selectedModelNodes()) {
|
||||
const QList<ModelNode> modelNodes = m_selectionContext.selectedModelNodes();
|
||||
for (const ModelNode &modelNode : modelNodes) {
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
QmlItemNode itemNode = modelNode;
|
||||
if (itemNode.instanceSize().width() > 0
|
||||
@@ -267,7 +270,7 @@ void LayoutInGridLayout::collectItemNodes()
|
||||
void LayoutInGridLayout::collectOffsets()
|
||||
{
|
||||
//We collect all different x and y offsets that define the cells
|
||||
foreach (const QmlItemNode &qmlItemNode, m_qmlItemNodes) {
|
||||
for (const QmlItemNode &qmlItemNode : qAsConst(m_qmlItemNodes)) {
|
||||
int x = qRound((qmlItemNode.instancePosition().x()));
|
||||
m_xTopOffsets.append(x);
|
||||
x = qRound((qmlItemNode.instancePosition().x() + lowerBound(qmlItemNode.instanceBoundingRect().width())));
|
||||
@@ -303,7 +306,7 @@ void LayoutInGridLayout::calculateGridOffsets()
|
||||
int heightTolerance = defaultHeightTolerance;
|
||||
|
||||
//The tolerance cannot be bigger then the size of an item
|
||||
foreach (const auto &qmlItemNode, m_qmlItemNodes) {
|
||||
for (const auto &qmlItemNode : qAsConst(m_qmlItemNodes)) {
|
||||
widthTolerance = qMin(qmlItemNode.instanceSize().toSize().width() - 1, widthTolerance);
|
||||
heightTolerance = qMin(qmlItemNode.instanceSize().toSize().height() - 1, heightTolerance);
|
||||
}
|
||||
@@ -340,7 +343,7 @@ void LayoutInGridLayout::removeEmtpyRowsAndColumns()
|
||||
m_columns = QVector<bool>(columnCount());
|
||||
m_columns.fill(false);
|
||||
|
||||
foreach (const auto &qmlItemNode, m_qmlItemNodes) {
|
||||
for (const auto &qmlItemNode : qAsConst(m_qmlItemNodes)) {
|
||||
int xCell = getCell(m_xTopOffsets, qmlItemNode.instancePosition().x());
|
||||
int yCell = getCell(m_yTopOffsets, qmlItemNode.instancePosition().y());
|
||||
|
||||
@@ -372,7 +375,7 @@ void LayoutInGridLayout::initializeCells()
|
||||
void LayoutInGridLayout::markUsedCells()
|
||||
{
|
||||
//We mark cells which are covered by items with true
|
||||
foreach (const auto &qmlItemNode, m_qmlItemNodes) {
|
||||
for (const auto &qmlItemNode : qAsConst(m_qmlItemNodes)) {
|
||||
int xCell = getCell(m_xTopOffsets, qmlItemNode.instancePosition().x());
|
||||
int yCell = getCell(m_yTopOffsets, qmlItemNode.instancePosition().y());
|
||||
|
||||
@@ -391,7 +394,7 @@ void LayoutInGridLayout::fillEmptyCells()
|
||||
//Cells which are not covered by items and are not marked as true have to be filled with a "spacer" item
|
||||
m_layoutedNodes = m_selectionContext.selectedModelNodes();
|
||||
|
||||
foreach (const QmlItemNode &itemNode, m_qmlItemNodes) {
|
||||
for (const auto &itemNode : qAsConst(m_qmlItemNodes)) {
|
||||
m_layoutedNodes.append(itemNode);
|
||||
}
|
||||
|
||||
@@ -431,7 +434,7 @@ void LayoutInGridLayout::setSpanning(const ModelNode &layoutNode)
|
||||
layoutNode.variantProperty("columns").setValue(columnCount());
|
||||
layoutNode.variantProperty("rows").setValue(rowCount());
|
||||
|
||||
foreach (const ModelNode &modelNode, m_layoutedNodes) {
|
||||
for (const ModelNode &modelNode : qAsConst(m_layoutedNodes)) {
|
||||
QmlItemNode qmlItemNode(modelNode);
|
||||
int xCell = getCell(m_xTopOffsets, qmlItemNode.instancePosition().x());
|
||||
int yCell = getCell(m_yTopOffsets, qmlItemNode.instancePosition().y());
|
||||
@@ -461,7 +464,7 @@ void LayoutInGridLayout::setSpanning(const ModelNode &layoutNode)
|
||||
|
||||
void LayoutInGridLayout::removeSpacersBySpanning(QList<ModelNode> &nodes)
|
||||
{
|
||||
foreach (const ModelNode &node, m_spacerNodes) {
|
||||
for (const ModelNode &node : qAsConst(m_spacerNodes)) {
|
||||
if (int index = nodes.indexOf(node)) {
|
||||
ModelNode before = nodes.at(index -1);
|
||||
if (m_spacerNodes.contains(before)) {
|
||||
|
@@ -41,19 +41,18 @@ ModelNodeContextMenu::ModelNodeContextMenu(AbstractView *view) :
|
||||
{
|
||||
}
|
||||
|
||||
static QSet<ActionInterface* > findMembers(QSet<ActionInterface* > actionInterface,
|
||||
static QSet<ActionInterface *> findMembers(const QSet<ActionInterface *> actionInterface,
|
||||
const QByteArray &category)
|
||||
{
|
||||
QSet<ActionInterface* > ret;
|
||||
QSet<ActionInterface *> ret;
|
||||
|
||||
foreach (ActionInterface* factory, actionInterface) {
|
||||
for (ActionInterface *factory : actionInterface) {
|
||||
if (factory->category() == category)
|
||||
ret.insert(factory);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
||||
const QByteArray &category,
|
||||
QMenu* menu,
|
||||
@@ -68,7 +67,7 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
||||
return l->priority() > r->priority();
|
||||
});
|
||||
|
||||
foreach (ActionInterface* actionInterface, matchingFactoriesList) {
|
||||
for (ActionInterface* actionInterface : qAsConst(matchingFactoriesList)) {
|
||||
if (actionInterface->type() == ActionInterface::ContextMenu) {
|
||||
actionInterface->currentContextChanged(selectionContext);
|
||||
QMenu *newMenu = actionInterface->action()->menu();
|
||||
|
@@ -54,7 +54,7 @@ static inline bool itemsHaveSameParent(const QList<ModelNode> &siblingList)
|
||||
if (!parent.isValid())
|
||||
return false;
|
||||
|
||||
foreach (const ModelNode &node, siblingList) {
|
||||
for (const ModelNode &node : siblingList) {
|
||||
QmlItemNode currentItem(node);
|
||||
if (!currentItem.isValid())
|
||||
return false;
|
||||
|
@@ -114,7 +114,7 @@ static inline void reparentTo(const ModelNode &node, const QmlItemNode &parent)
|
||||
static inline QPointF getUpperLeftPosition(const QList<ModelNode> &modelNodeList)
|
||||
{
|
||||
QPointF postion(std::numeric_limits<qreal>::max(), std::numeric_limits<qreal>::max());
|
||||
foreach (const ModelNode &modelNode, modelNodeList) {
|
||||
for (const ModelNode &modelNode : modelNodeList) {
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
QmlItemNode qmlIitemNode = QmlItemNode(modelNode);
|
||||
if (qmlIitemNode.instancePosition().x() < postion.x())
|
||||
@@ -151,7 +151,8 @@ void deSelect(const SelectionContext &selectionState)
|
||||
{
|
||||
if (selectionState.view()) {
|
||||
QList<ModelNode> selectedNodes = selectionState.view()->selectedModelNodes();
|
||||
foreach (const ModelNode &node, selectionState.selectedModelNodes()) {
|
||||
const QList<ModelNode> nodes = selectionState.selectedModelNodes();
|
||||
for (const ModelNode &node : nodes) {
|
||||
if (selectedNodes.contains(node))
|
||||
selectedNodes.removeAll(node);
|
||||
}
|
||||
@@ -310,7 +311,8 @@ void resetSize(const SelectionContext &selectionState)
|
||||
return;
|
||||
|
||||
selectionState.view()->executeInTransaction("DesignerActionManager|resetSize",[selectionState](){
|
||||
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
||||
const QList<ModelNode> nodes = selectionState.selectedModelNodes();
|
||||
for (const ModelNode &node : nodes) {
|
||||
QmlItemNode itemNode(node);
|
||||
if (itemNode.isValid()) {
|
||||
itemNode.removeProperty("width");
|
||||
@@ -326,7 +328,8 @@ void resetPosition(const SelectionContext &selectionState)
|
||||
return;
|
||||
|
||||
selectionState.view()->executeInTransaction("DesignerActionManager|resetPosition",[selectionState](){
|
||||
foreach (ModelNode node, selectionState.selectedModelNodes()) {
|
||||
const QList<ModelNode> nodes = selectionState.selectedModelNodes();
|
||||
for (const ModelNode &node : nodes) {
|
||||
QmlItemNode itemNode(node);
|
||||
if (itemNode.isValid()) {
|
||||
itemNode.removeProperty("x");
|
||||
@@ -602,8 +605,8 @@ static void addSignal(const QString &typeName, const QString &itemId, const QStr
|
||||
signalHandlerName = "on" + toUpper(signalName).toUtf8();
|
||||
else
|
||||
signalHandlerName = itemId.toUtf8() + ".on" + toUpper(signalName).toUtf8();
|
||||
|
||||
foreach (const ModelNode &modelNode, rewriterView.allModelNodes()) {
|
||||
const QList<ModelNode> nodes = rewriterView.allModelNodes();
|
||||
for (const ModelNode &modelNode : nodes) {
|
||||
if (modelNode.type() == typeName.toUtf8()) {
|
||||
modelNode.signalHandlerProperty(signalHandlerName).setSource(QLatin1String("{\n}"));
|
||||
}
|
||||
@@ -614,7 +617,7 @@ static QStringList cleanSignalNames(const QStringList &input)
|
||||
{
|
||||
QStringList output;
|
||||
|
||||
foreach (const QString &signal, input)
|
||||
for (const QString &signal : input)
|
||||
if (!signal.startsWith(QLatin1String("__")) && !output.contains(signal))
|
||||
output.append(signal);
|
||||
|
||||
@@ -627,11 +630,13 @@ static QStringList getSortedSignalNameList(const ModelNode &modelNode)
|
||||
QStringList signalNames;
|
||||
|
||||
if (metaInfo.isValid()) {
|
||||
foreach (const PropertyName &signalName, sortedPropertyNameList(metaInfo.signalNames()))
|
||||
const PropertyNameList signalNameList = sortedPropertyNameList(metaInfo.signalNames());
|
||||
for (const PropertyName &signalName : signalNameList)
|
||||
if (!signalName.contains("Changed"))
|
||||
signalNames.append(QString::fromUtf8(signalName));
|
||||
|
||||
foreach (const PropertyName &propertyName, sortedPropertyNameList(metaInfo.propertyNames()))
|
||||
const PropertyNameList propertyNameList = sortedPropertyNameList(metaInfo.propertyNames());
|
||||
for (const PropertyName &propertyName : propertyNameList)
|
||||
if (!propertyName.contains("."))
|
||||
signalNames.append(QString::fromUtf8(propertyName + "Changed"));
|
||||
}
|
||||
@@ -743,7 +748,8 @@ void removeLayout(const SelectionContext &selectionContext)
|
||||
return;
|
||||
|
||||
selectionContext.view()->executeInTransaction("DesignerActionManager|removeLayout", [selectionContext, &layoutItem, parent](){
|
||||
foreach (const ModelNode &modelNode, selectionContext.currentSingleSelectedNode().directSubModelNodes()) {
|
||||
const QList<ModelNode> modelNodes = selectionContext.currentSingleSelectedNode().directSubModelNodes();
|
||||
for (const ModelNode &modelNode : modelNodes) {
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
|
||||
QmlItemNode qmlItem(modelNode);
|
||||
|
@@ -105,7 +105,8 @@ void BackendModel::resetModel()
|
||||
}
|
||||
|
||||
if (rootNode.isValid()) {
|
||||
foreach (const AbstractProperty &property ,rootNode.properties())
|
||||
const QList<AbstractProperty> properties = rootNode.properties();
|
||||
for (const AbstractProperty &property : properties)
|
||||
if (property.isDynamic() && !simpleTypes.contains(property.dynamicTypeName())) {
|
||||
|
||||
NodeMetaInfo metaInfo = m_connectionView->model()->metaInfo(property.dynamicTypeName());
|
||||
@@ -147,7 +148,8 @@ QStringList BackendModel::possibleCppTypes() const
|
||||
QStringList list;
|
||||
|
||||
if (rewriterView) {
|
||||
foreach (const QmlTypeData &cppTypeData, rewriterView->getQMLTypes())
|
||||
const QList<QmlTypeData> cppTypes = rewriterView->getQMLTypes();
|
||||
for (const QmlTypeData &cppTypeData : cppTypes)
|
||||
list.append(cppTypeData.typeName);
|
||||
}
|
||||
|
||||
|
@@ -139,7 +139,8 @@ QStringList BindingModel::possibleTargetProperties(const BindingProperty &bindin
|
||||
|
||||
if (metaInfo.isValid()) {
|
||||
QStringList possibleProperties;
|
||||
foreach (const PropertyName &propertyName, metaInfo.propertyNames()) {
|
||||
const QList<PropertyName> propertyNames = metaInfo.propertyNames();
|
||||
for (const PropertyName &propertyName : propertyNames) {
|
||||
if (metaInfo.propertyIsWritable(propertyName))
|
||||
possibleProperties << QString::fromUtf8(propertyName);
|
||||
}
|
||||
@@ -232,7 +233,8 @@ static PropertyName unusedProperty(const ModelNode &modelNode)
|
||||
{
|
||||
PropertyName propertyName = "none";
|
||||
if (modelNode.metaInfo().isValid()) {
|
||||
foreach (const PropertyName &propertyName, modelNode.metaInfo().propertyNames()) {
|
||||
const QList<PropertyName> propertyNames = modelNode.metaInfo().propertyNames();
|
||||
for (const PropertyName &propertyName : propertyNames) {
|
||||
if (modelNode.metaInfo().propertyIsWritable(propertyName) && !modelNode.hasProperty(propertyName))
|
||||
return propertyName;
|
||||
}
|
||||
@@ -305,7 +307,8 @@ void BindingModel::updateBindingProperty(int rowNumber)
|
||||
|
||||
void BindingModel::addModelNode(const ModelNode &modelNode)
|
||||
{
|
||||
foreach (const BindingProperty &bindingProperty, modelNode.bindingProperties()) {
|
||||
const QList<BindingProperty> bindingProperties = modelNode.bindingProperties();
|
||||
for (const BindingProperty &bindingProperty : bindingProperties) {
|
||||
addBindingProperty(bindingProperty);
|
||||
}
|
||||
}
|
||||
|
@@ -112,7 +112,7 @@ void ConnectionView::propertiesRemoved(const QList<AbstractProperty> &propertyLi
|
||||
|
||||
void ConnectionView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &propertyList)
|
||||
{
|
||||
foreach (const AbstractProperty &property, propertyList) {
|
||||
for (const AbstractProperty &property : propertyList) {
|
||||
if (property.isBindingProperty()) {
|
||||
bindingModel()->bindingRemoved(property.toBindingProperty());
|
||||
dynamicPropertiesModel()->bindingRemoved(property.toBindingProperty());
|
||||
@@ -127,7 +127,7 @@ void ConnectionView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &p
|
||||
void ConnectionView::variantPropertiesChanged(const QList<VariantProperty> &propertyList,
|
||||
AbstractView::PropertyChangeFlags /*propertyChange*/)
|
||||
{
|
||||
foreach (const VariantProperty &variantProperty, propertyList) {
|
||||
for (const VariantProperty &variantProperty : propertyList) {
|
||||
if (variantProperty.isDynamic())
|
||||
dynamicPropertiesModel()->variantPropertyChanged(variantProperty);
|
||||
if (variantProperty.isDynamic() && variantProperty.parentModelNode().isRootNode())
|
||||
@@ -141,7 +141,7 @@ void ConnectionView::variantPropertiesChanged(const QList<VariantProperty> &prop
|
||||
void ConnectionView::bindingPropertiesChanged(const QList<BindingProperty> &propertyList,
|
||||
AbstractView::PropertyChangeFlags /*propertyChange*/)
|
||||
{
|
||||
foreach (const BindingProperty &bindingProperty, propertyList) {
|
||||
for (const BindingProperty &bindingProperty : propertyList) {
|
||||
bindingModel()->bindingChanged(bindingProperty);
|
||||
if (bindingProperty.isDynamic())
|
||||
dynamicPropertiesModel()->bindingPropertyChanged(bindingProperty);
|
||||
|
@@ -345,7 +345,8 @@ QStringList DynamicPropertiesModel::possibleTargetProperties(const BindingProper
|
||||
|
||||
if (metaInfo.isValid()) {
|
||||
QStringList possibleProperties;
|
||||
foreach (const PropertyName &propertyName, metaInfo.propertyNames()) {
|
||||
const QList<PropertyName> propertyNames = metaInfo.propertyNames();
|
||||
for (const PropertyName &propertyName : propertyNames) {
|
||||
if (metaInfo.propertyIsWritable(propertyName))
|
||||
possibleProperties << QString::fromUtf8(propertyName);
|
||||
}
|
||||
@@ -401,7 +402,8 @@ QStringList DynamicPropertiesModel::possibleSourceProperties(const BindingProper
|
||||
|
||||
if (metaInfo.isValid()) {
|
||||
QStringList possibleProperties;
|
||||
foreach (const PropertyName &propertyName, metaInfo.propertyNames()) {
|
||||
const QList<PropertyName> propertyNames = metaInfo.propertyNames();
|
||||
for (const PropertyName &propertyName : propertyNames) {
|
||||
if (metaInfo.propertyTypeName(propertyName) == typeName) //### todo proper check
|
||||
possibleProperties << QString::fromUtf8(propertyName);
|
||||
}
|
||||
@@ -504,12 +506,14 @@ void DynamicPropertiesModel::updateVariantProperty(int rowNumber)
|
||||
|
||||
void DynamicPropertiesModel::addModelNode(const ModelNode &modelNode)
|
||||
{
|
||||
foreach (const BindingProperty &bindingProperty, modelNode.bindingProperties()) {
|
||||
const QList<BindingProperty> bindingProperties = modelNode.bindingProperties();
|
||||
for (const BindingProperty &bindingProperty : bindingProperties) {
|
||||
if (bindingProperty.isDynamic())
|
||||
addBindingProperty(bindingProperty);
|
||||
}
|
||||
|
||||
foreach (const VariantProperty &variantProperty, modelNode.variantProperties()) {
|
||||
const QList<VariantProperty> variantProperties = modelNode.variantProperties();
|
||||
for (const VariantProperty &variantProperty : variantProperties) {
|
||||
if (variantProperty.isDynamic())
|
||||
addVariantProperty(variantProperty);
|
||||
}
|
||||
|
@@ -90,12 +90,12 @@ void DebugView::importsChanged(const QList<Import> &addedImports, const QList<Im
|
||||
if (isDebugViewEnabled()) {
|
||||
QString message;
|
||||
message += QString("added imports:") += lineBreak;
|
||||
foreach (const Import &import, addedImports) {
|
||||
for (const Import &import : addedImports) {
|
||||
message += import.toImportString() += lineBreak;
|
||||
}
|
||||
|
||||
message += QString("removed imports:") += lineBreak;
|
||||
foreach (const Import &import, removedImports) {
|
||||
for (const Import &import : removedImports) {
|
||||
message += import.toImportString() += lineBreak;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,8 @@ void DebugView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
message << removedNode << lineBreak;
|
||||
foreach (const ModelNode &modelNode, removedNode.allSubModelNodes()) {
|
||||
const QList<ModelNode> modelNodes = removedNode.allSubModelNodes();
|
||||
for (const ModelNode &modelNode : modelNodes) {
|
||||
message << "child node:" << modelNode << lineBreak;
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ void DebugView::variantPropertiesChanged(const QList<VariantProperty> &propertyL
|
||||
QTextStream message;
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
foreach (const VariantProperty &property, propertyList) {
|
||||
for (const VariantProperty &property : propertyList) {
|
||||
message << property;
|
||||
}
|
||||
log("::variantPropertiesChanged:", string);
|
||||
@@ -206,7 +207,7 @@ void DebugView::bindingPropertiesChanged(const QList<BindingProperty> &propertyL
|
||||
QTextStream message;
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
foreach (const BindingProperty &property, propertyList) {
|
||||
for (const BindingProperty &property : propertyList) {
|
||||
message << property;
|
||||
}
|
||||
log("::Binding properties changed:", string);
|
||||
@@ -219,7 +220,7 @@ void DebugView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProper
|
||||
QTextStream message;
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
foreach (const SignalHandlerProperty &property, propertyList) {
|
||||
for (const SignalHandlerProperty &property : propertyList) {
|
||||
message << property;
|
||||
}
|
||||
log("::signalHandlerPropertiesChanged:", string);
|
||||
@@ -242,7 +243,7 @@ void DebugView::rootNodeTypeChanged(const QString &type, int majorVersion, int m
|
||||
void DebugView::selectedNodesChanged(const QList<ModelNode> &selectedNodes /*selectedNodeList*/,
|
||||
const QList<ModelNode> & /*lastSelectedNodeList*/)
|
||||
{
|
||||
foreach (const ModelNode &selectedNode, selectedNodes) {
|
||||
for (const ModelNode &selectedNode : selectedNodes) {
|
||||
QTextStream message;
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
@@ -305,7 +306,7 @@ void DebugView::propertiesRemoved(const QList<AbstractProperty> &propertyList)
|
||||
QTextStream message;
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
foreach (const AbstractProperty &property, propertyList) {
|
||||
for (const AbstractProperty &property : propertyList) {
|
||||
message << property;
|
||||
}
|
||||
log("::propertiesRemoved:", string);
|
||||
@@ -334,11 +335,11 @@ void DebugView::documentMessagesChanged(const QList<DocumentMessage> &errors, co
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
|
||||
foreach (const DocumentMessage &error, errors) {
|
||||
for (const DocumentMessage &error : errors) {
|
||||
message << error.toString();
|
||||
}
|
||||
|
||||
foreach (const DocumentMessage &warning, warnings) {
|
||||
for (const DocumentMessage &warning : warnings) {
|
||||
message << warning.toString();
|
||||
}
|
||||
|
||||
@@ -380,7 +381,7 @@ void DebugView::instancePropertyChanged(const QList<QPair<ModelNode, PropertyNam
|
||||
|
||||
using Pair = QPair<ModelNode, PropertyName>;
|
||||
|
||||
foreach (const Pair &pair, propertyList) {
|
||||
for (const Pair &pair : propertyList) {
|
||||
message << pair.first;
|
||||
message << lineBreak;
|
||||
message << pair.second;
|
||||
@@ -401,7 +402,7 @@ void DebugView::instancesCompleted(const QVector<ModelNode> &completedNodeList)
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
|
||||
foreach (const ModelNode &modelNode, completedNodeList) {
|
||||
for (const ModelNode &modelNode : completedNodeList) {
|
||||
message << modelNode << lineBreak;
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
message << "parent: " << QmlItemNode(modelNode).instanceParent() << lineBreak;
|
||||
@@ -419,7 +420,8 @@ void DebugView::instanceInformationsChanged(const QMultiHash<ModelNode, Informat
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
|
||||
foreach (const ModelNode &modelNode, informationChangedHash.keys()) {
|
||||
const QList<ModelNode> modelNodes = informationChangedHash.keys();
|
||||
for (const ModelNode &modelNode : modelNodes) {
|
||||
message << modelNode;
|
||||
message << informationChangedHash.value(modelNode);
|
||||
}
|
||||
@@ -444,7 +446,7 @@ void DebugView::instancesChildrenChanged(const QVector<ModelNode> & nodeList)
|
||||
QString string;
|
||||
message.setString(&string);
|
||||
|
||||
foreach (const ModelNode &modelNode, nodeList) {
|
||||
for (const ModelNode &modelNode : nodeList) {
|
||||
message << modelNode << lineBreak;
|
||||
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
|
||||
message << "parent: " << QmlItemNode(modelNode).instanceParent() << lineBreak;
|
||||
@@ -464,11 +466,11 @@ void DebugView::customNotification(const AbstractView *view, const QString &iden
|
||||
|
||||
message << view;
|
||||
message << identifier;
|
||||
foreach (const ModelNode &node, nodeList) {
|
||||
for (const ModelNode &node : nodeList) {
|
||||
message << node;
|
||||
}
|
||||
|
||||
foreach (const QVariant &variant, data) {
|
||||
for (const QVariant &variant : data) {
|
||||
message << variant.toString();
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ static QStringList arrayToStringList(const QByteArray &byteArray)
|
||||
static QByteArray stringListToArray(const QStringList &stringList)
|
||||
{
|
||||
QString str;
|
||||
foreach (const QString &subString, stringList)
|
||||
for (const QString &subString : stringList)
|
||||
str += subString + QLatin1Char('\n');
|
||||
return str.toUtf8();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void DesignDocumentView::toClipboard() const
|
||||
|
||||
data->setText(toText());
|
||||
QStringList imports;
|
||||
foreach (const Import &import, model()->imports())
|
||||
for (const Import &import : model()->imports())
|
||||
imports.append(import.toImportString());
|
||||
|
||||
data->setData(QLatin1String("QmlDesigner::imports"), stringListToArray(imports));
|
||||
@@ -95,7 +95,7 @@ void DesignDocumentView::fromClipboard()
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
fromText(clipboard->text());
|
||||
QStringList imports = arrayToStringList(clipboard->mimeData()->data(QLatin1String("QmlDesigner::imports")));
|
||||
// foreach (const QString &importString, imports) {
|
||||
// for (const QString &importString, imports) {
|
||||
// Import import(Import::createLibraryImport();
|
||||
// model()->addImport(import); //### imports
|
||||
// }
|
||||
@@ -109,7 +109,7 @@ QString DesignDocumentView::toText() const
|
||||
QPlainTextEdit textEdit;
|
||||
|
||||
QString imports;
|
||||
foreach (const Import &import, model()->imports()) {
|
||||
for (const Import &import : model()->imports()) {
|
||||
if (import.isFileImport())
|
||||
imports += QStringLiteral("import ") + QStringLiteral("\"") + import.file() + QStringLiteral("\"")+ QStringLiteral(";\n");
|
||||
else
|
||||
@@ -215,10 +215,11 @@ void DesignDocumentView::copyModelNodes(const QList<ModelNode> &nodesToCopy)
|
||||
if (selectedNodes.isEmpty())
|
||||
return;
|
||||
|
||||
foreach (const ModelNode &node, selectedNodes) {
|
||||
foreach (const ModelNode &node2, selectedNodes) {
|
||||
if (node.isAncestorOf(node2))
|
||||
selectedNodes.removeAll(node2);
|
||||
QList<ModelNode> nodeList = selectedNodes;
|
||||
for (int end = nodeList.length(), i = 0; i < end; ++i) {
|
||||
for (int j = 0; j < end; ++j) {
|
||||
if (nodeList.at(i).isAncestorOf(nodeList.at(j)))
|
||||
selectedNodes.removeAll(nodeList.at(j));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,14 +239,13 @@ void DesignDocumentView::copyModelNodes(const QList<ModelNode> &nodesToCopy)
|
||||
|
||||
view.toClipboard();
|
||||
} else { // multi items selected
|
||||
|
||||
foreach (ModelNode node, view.rootModelNode().directSubModelNodes()) {
|
||||
for (ModelNode node : view.rootModelNode().directSubModelNodes()) {
|
||||
node.destroy();
|
||||
}
|
||||
view.changeRootNodeType("QtQuick.Rectangle", 2, 0);
|
||||
view.rootModelNode().setIdWithRefactoring("__multi__selection__");
|
||||
|
||||
foreach (const ModelNode &selectedNode, selectedNodes) {
|
||||
for (const ModelNode &selectedNode : qAsConst(selectedNodes)) {
|
||||
ModelNode newNode(view.insertModel(selectedNode));
|
||||
view.rootModelNode().nodeListProperty("data").reparentHere(newNode);
|
||||
}
|
||||
|
Reference in New Issue
Block a user