forked from qt-creator/qt-creator
ScXMLEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: Ifaacfe54553e5400ae334263c2d346eeafe4b66c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -85,7 +85,7 @@ void SCUtilsProvider::checkInitialState(const QList<QGraphicsItem*> &items, Scxm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QGraphicsItem *item, items) {
|
for (QGraphicsItem *item : items) {
|
||||||
if (item->type() >= StateType) {
|
if (item->type() >= StateType) {
|
||||||
auto stateItem = static_cast<StateItem*>(item);
|
auto stateItem = static_cast<StateItem*>(item);
|
||||||
if (stateItem)
|
if (stateItem)
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ bool ScxmlDocument::pasteData(const QByteArray &data, const QPointF &minPos, con
|
|||||||
QBuffer buffer(&d);
|
QBuffer buffer(&d);
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
QXmlStreamReader xml(&buffer);
|
QXmlStreamReader xml(&buffer);
|
||||||
foreach (ScxmlNamespace *ns, m_namespaces) {
|
for (ScxmlNamespace *ns : qAsConst(m_namespaces)) {
|
||||||
xml.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration(ns->prefix(), ns->name()));
|
xml.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration(ns->prefix(), ns->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ QByteArray ScxmlDocument::content(const QVector<ScxmlTag*> &tags) const
|
|||||||
if (writeScxml)
|
if (writeScxml)
|
||||||
xml.writeStartElement("scxml");
|
xml.writeStartElement("scxml");
|
||||||
|
|
||||||
foreach (ScxmlTag *tag, tags) {
|
for (ScxmlTag *tag : tags) {
|
||||||
tag->writeXml(xml);
|
tag->writeXml(xml);
|
||||||
}
|
}
|
||||||
xml.writeEndDocument();
|
xml.writeEndDocument();
|
||||||
@@ -597,7 +597,7 @@ QString ScxmlDocument::nextUniqueId(const QString &key)
|
|||||||
name = QString::fromLatin1("%1_%2").arg(key).arg(id);
|
name = QString::fromLatin1("%1_%2").arg(key).arg(id);
|
||||||
|
|
||||||
// Check duplicate
|
// Check duplicate
|
||||||
foreach (const ScxmlTag *tag, m_tags) {
|
for (const ScxmlTag *tag : qAsConst(m_tags)) {
|
||||||
if (tag->attribute("id") == name) {
|
if (tag->attribute("id") == name) {
|
||||||
bFound = true;
|
bFound = true;
|
||||||
break;
|
break;
|
||||||
@@ -619,7 +619,7 @@ QString ScxmlDocument::getUniqueCopyId(const ScxmlTag *tag)
|
|||||||
while (true) {
|
while (true) {
|
||||||
bFound = false;
|
bFound = false;
|
||||||
// Check duplicate
|
// Check duplicate
|
||||||
foreach (const ScxmlTag *t, m_tags) {
|
for (const ScxmlTag *t : qAsConst(m_tags)) {
|
||||||
if (t->attribute("id") == name && t != tag) {
|
if (t->attribute("id") == name && t != tag) {
|
||||||
name = QString::fromLatin1("%1_Copy%2").arg(key).arg(counter);
|
name = QString::fromLatin1("%1_Copy%2").arg(key).arg(counter);
|
||||||
bFound = true;
|
bFound = true;
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ bool ScxmlTag::hasData() const
|
|||||||
if (!m_attributeNames.isEmpty() || !m_content.isEmpty())
|
if (!m_attributeNames.isEmpty() || !m_content.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
foreach (ScxmlTag *tag, m_childTags) {
|
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||||
if (tag->hasData())
|
if (tag->hasData())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ bool ScxmlTag::hasData() const
|
|||||||
|
|
||||||
bool ScxmlTag::hasChild(TagType type) const
|
bool ScxmlTag::hasChild(TagType type) const
|
||||||
{
|
{
|
||||||
foreach (ScxmlTag *tag, m_childTags) {
|
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||||
if (tag->tagType() == type)
|
if (tag->tagType() == type)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ bool ScxmlTag::hasChild(TagType type) const
|
|||||||
|
|
||||||
bool ScxmlTag::hasChild(const QString &name) const
|
bool ScxmlTag::hasChild(const QString &name) const
|
||||||
{
|
{
|
||||||
foreach (ScxmlTag *tag, m_childTags) {
|
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||||
if (tag->tagName() == name)
|
if (tag->tagName() == name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -507,7 +507,7 @@ QVector<ScxmlTag*> ScxmlTag::allChildren() const
|
|||||||
QVector<ScxmlTag*> ScxmlTag::children(const QString &name) const
|
QVector<ScxmlTag*> ScxmlTag::children(const QString &name) const
|
||||||
{
|
{
|
||||||
QVector<ScxmlTag*> children;
|
QVector<ScxmlTag*> children;
|
||||||
foreach (ScxmlTag *tag, m_childTags) {
|
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||||
if (tag->tagName() == name)
|
if (tag->tagName() == name)
|
||||||
children << tag;
|
children << tag;
|
||||||
}
|
}
|
||||||
@@ -517,7 +517,7 @@ QVector<ScxmlTag*> ScxmlTag::children(const QString &name) const
|
|||||||
|
|
||||||
ScxmlTag *ScxmlTag::child(const QString &name) const
|
ScxmlTag *ScxmlTag::child(const QString &name) const
|
||||||
{
|
{
|
||||||
foreach (ScxmlTag *tag, m_childTags) {
|
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||||
if (tag->tagName() == name)
|
if (tag->tagName() == name)
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -639,8 +639,8 @@ void ScxmlTag::readXml(QXmlStreamReader &xml, bool checkCopyId)
|
|||||||
else if (token == QXmlStreamReader::StartElement) {
|
else if (token == QXmlStreamReader::StartElement) {
|
||||||
if (m_tagType != Metadata && m_tagType != MetadataItem && xml.qualifiedName().toString() == "qt:editorinfo") {
|
if (m_tagType != Metadata && m_tagType != MetadataItem && xml.qualifiedName().toString() == "qt:editorinfo") {
|
||||||
// Read editorinfos
|
// Read editorinfos
|
||||||
QXmlStreamAttributes attributes = xml.attributes();
|
const QXmlStreamAttributes attributes = xml.attributes();
|
||||||
foreach (QXmlStreamAttribute attr, attributes) {
|
for (QXmlStreamAttribute attr : attributes) {
|
||||||
m_editorInfo[attr.name().toString()] = attr.value().toString();
|
m_editorInfo[attr.name().toString()] = attr.value().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ bool checkPaste(const QString &copiedTagTypes, const ScxmlTag *currentTag)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
QVector<TagType> childTags = allowedChildTypes(currentTag->tagType());
|
QVector<TagType> childTags = allowedChildTypes(currentTag->tagType());
|
||||||
foreach (const TagType &type, tagTypes) {
|
for (const TagType &type : qAsConst(tagTypes)) {
|
||||||
if (!childTags.contains(type))
|
if (!childTags.contains(type))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ void ScxmlUiFactory::initPlugins()
|
|||||||
QStringList nameFilters;
|
QStringList nameFilters;
|
||||||
nameFilters << "*.dll" << "*.so";
|
nameFilters << "*.dll" << "*.so";
|
||||||
|
|
||||||
foreach (QFileInfo dllFileInfo, pluginDir.entryInfoList(nameFilters)) {
|
const QList<QFileInfo> dllFileInfos = pluginDir.entryInfoList(nameFilters);
|
||||||
|
for (QFileInfo dllFileInfo : dllFileInfos) {
|
||||||
|
|
||||||
QPluginLoader loader(dllFileInfo.absoluteFilePath());
|
QPluginLoader loader(dllFileInfo.absoluteFilePath());
|
||||||
loader.load();
|
loader.load();
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ void StateItem::updateBoundingRect()
|
|||||||
void StateItem::shrink()
|
void StateItem::shrink()
|
||||||
{
|
{
|
||||||
QRectF trect;
|
QRectF trect;
|
||||||
foreach (TransitionItem *item, outputTransitions()) {
|
const QVector<TransitionItem *> items = outputTransitions();
|
||||||
|
for (TransitionItem *item : items) {
|
||||||
if (item->targetType() == TransitionItem::InternalSameTarget || item->targetType() == TransitionItem::InternalNoTarget) {
|
if (item->targetType() == TransitionItem::InternalSameTarget || item->targetType() == TransitionItem::InternalNoTarget) {
|
||||||
trect = trect.united(item->wholeBoundingRect());
|
trect = trect.united(item->wholeBoundingRect());
|
||||||
}
|
}
|
||||||
@@ -239,8 +240,8 @@ void StateItem::transitionsChanged()
|
|||||||
{
|
{
|
||||||
QRectF rr = boundingRect();
|
QRectF rr = boundingRect();
|
||||||
QRectF rectInternalTransitions;
|
QRectF rectInternalTransitions;
|
||||||
QVector<TransitionItem*> internalTransitions = outputTransitions();
|
const QVector<TransitionItem*> internalTransitions = outputTransitions();
|
||||||
foreach (TransitionItem *item, internalTransitions) {
|
for (TransitionItem *item : internalTransitions) {
|
||||||
if (item->targetType() <= TransitionItem::InternalNoTarget) {
|
if (item->targetType() <= TransitionItem::InternalNoTarget) {
|
||||||
QRectF br = mapFromItem(item, item->boundingRect()).boundingRect();
|
QRectF br = mapFromItem(item, item->boundingRect()).boundingRect();
|
||||||
br.setLeft(rr.left() + 20);
|
br.setLeft(rr.left() + 20);
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ bool TagTextItem::needIgnore(const QPointF sPos)
|
|||||||
{
|
{
|
||||||
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
||||||
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
||||||
foreach (QGraphicsItem *item, scene()->items(sPos)) {
|
const QList<QGraphicsItem *> items = scene()->items(sPos);
|
||||||
|
for (QGraphicsItem *item : items) {
|
||||||
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this))
|
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ bool TextItem::needIgnore(const QPointF sPos) const
|
|||||||
{
|
{
|
||||||
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
||||||
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
||||||
foreach (QGraphicsItem *item, scene()->items(sPos)) {
|
const QList<QGraphicsItem *> items = scene()->items(sPos);
|
||||||
|
for (QGraphicsItem *item : items) {
|
||||||
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this))
|
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,7 +280,8 @@ void TransitionItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
if (bLeftButton) {
|
if (bLeftButton) {
|
||||||
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
// If we found QuickTransition-item or CornerGrabber at this point, we must ignore mouse press here
|
||||||
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
// So we can press QuickTransition/CornerGrabber item although there is transition lines front of these items
|
||||||
foreach (QGraphicsItem *item, scene()->items(event->scenePos())) {
|
const QList<QGraphicsItem *> items = scene()->items(event->scenePos());
|
||||||
|
for (QGraphicsItem *item : items) {
|
||||||
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this)) {
|
if (item->type() == QuickTransitionType || (item->type() == CornerGrabberType && item->parentItem() != this)) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -354,7 +354,8 @@ void ChangeFullNameSpaceCommand::makeIdMap(ScxmlTag *tag, QHash<QString, QString
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ScxmlTag *child, tag->allChildren()) {
|
const QVector<ScxmlTag *> children = tag->allChildren();
|
||||||
|
for (ScxmlTag *child : children) {
|
||||||
makeIdMap(child, map, use);
|
makeIdMap(child, map, use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -380,7 +381,8 @@ void ChangeFullNameSpaceCommand::updateNameSpace(ScxmlTag *tag, const QHash<QStr
|
|||||||
tag->setAttribute(name, map[attr]);
|
tag->setAttribute(name, map[attr]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ScxmlTag *child, tag->allChildren()) {
|
const QVector<ScxmlTag *> children = tag->allChildren();
|
||||||
|
for (ScxmlTag *child : children) {
|
||||||
updateNameSpace(child, map);
|
updateNameSpace(child, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user