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) {
|
||||
auto stateItem = static_cast<StateItem*>(item);
|
||||
if (stateItem)
|
||||
|
||||
@@ -312,7 +312,7 @@ bool ScxmlDocument::pasteData(const QByteArray &data, const QPointF &minPos, con
|
||||
QBuffer buffer(&d);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
QXmlStreamReader xml(&buffer);
|
||||
foreach (ScxmlNamespace *ns, m_namespaces) {
|
||||
for (ScxmlNamespace *ns : qAsConst(m_namespaces)) {
|
||||
xml.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration(ns->prefix(), ns->name()));
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ QByteArray ScxmlDocument::content(const QVector<ScxmlTag*> &tags) const
|
||||
if (writeScxml)
|
||||
xml.writeStartElement("scxml");
|
||||
|
||||
foreach (ScxmlTag *tag, tags) {
|
||||
for (ScxmlTag *tag : tags) {
|
||||
tag->writeXml(xml);
|
||||
}
|
||||
xml.writeEndDocument();
|
||||
@@ -597,7 +597,7 @@ QString ScxmlDocument::nextUniqueId(const QString &key)
|
||||
name = QString::fromLatin1("%1_%2").arg(key).arg(id);
|
||||
|
||||
// Check duplicate
|
||||
foreach (const ScxmlTag *tag, m_tags) {
|
||||
for (const ScxmlTag *tag : qAsConst(m_tags)) {
|
||||
if (tag->attribute("id") == name) {
|
||||
bFound = true;
|
||||
break;
|
||||
@@ -619,7 +619,7 @@ QString ScxmlDocument::getUniqueCopyId(const ScxmlTag *tag)
|
||||
while (true) {
|
||||
bFound = false;
|
||||
// Check duplicate
|
||||
foreach (const ScxmlTag *t, m_tags) {
|
||||
for (const ScxmlTag *t : qAsConst(m_tags)) {
|
||||
if (t->attribute("id") == name && t != tag) {
|
||||
name = QString::fromLatin1("%1_Copy%2").arg(key).arg(counter);
|
||||
bFound = true;
|
||||
|
||||
@@ -272,7 +272,7 @@ bool ScxmlTag::hasData() const
|
||||
if (!m_attributeNames.isEmpty() || !m_content.isEmpty())
|
||||
return true;
|
||||
|
||||
foreach (ScxmlTag *tag, m_childTags) {
|
||||
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||
if (tag->hasData())
|
||||
return true;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ bool ScxmlTag::hasData() const
|
||||
|
||||
bool ScxmlTag::hasChild(TagType type) const
|
||||
{
|
||||
foreach (ScxmlTag *tag, m_childTags) {
|
||||
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||
if (tag->tagType() == type)
|
||||
return true;
|
||||
}
|
||||
@@ -292,7 +292,7 @@ bool ScxmlTag::hasChild(TagType type) const
|
||||
|
||||
bool ScxmlTag::hasChild(const QString &name) const
|
||||
{
|
||||
foreach (ScxmlTag *tag, m_childTags) {
|
||||
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||
if (tag->tagName() == name)
|
||||
return true;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ QVector<ScxmlTag*> ScxmlTag::allChildren() const
|
||||
QVector<ScxmlTag*> ScxmlTag::children(const QString &name) const
|
||||
{
|
||||
QVector<ScxmlTag*> children;
|
||||
foreach (ScxmlTag *tag, m_childTags) {
|
||||
for (ScxmlTag *tag : qAsConst(m_childTags)) {
|
||||
if (tag->tagName() == name)
|
||||
children << tag;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ QVector<ScxmlTag*> ScxmlTag::children(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)
|
||||
return tag;
|
||||
}
|
||||
@@ -639,8 +639,8 @@ void ScxmlTag::readXml(QXmlStreamReader &xml, bool checkCopyId)
|
||||
else if (token == QXmlStreamReader::StartElement) {
|
||||
if (m_tagType != Metadata && m_tagType != MetadataItem && xml.qualifiedName().toString() == "qt:editorinfo") {
|
||||
// Read editorinfos
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
foreach (QXmlStreamAttribute attr, attributes) {
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
for (QXmlStreamAttribute attr : attributes) {
|
||||
m_editorInfo[attr.name().toString()] = attr.value().toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ bool checkPaste(const QString &copiedTagTypes, const ScxmlTag *currentTag)
|
||||
return false;
|
||||
|
||||
QVector<TagType> childTags = allowedChildTypes(currentTag->tagType());
|
||||
foreach (const TagType &type, tagTypes) {
|
||||
for (const TagType &type : qAsConst(tagTypes)) {
|
||||
if (!childTags.contains(type))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,8 @@ void ScxmlUiFactory::initPlugins()
|
||||
QStringList nameFilters;
|
||||
nameFilters << "*.dll" << "*.so";
|
||||
|
||||
foreach (QFileInfo dllFileInfo, pluginDir.entryInfoList(nameFilters)) {
|
||||
const QList<QFileInfo> dllFileInfos = pluginDir.entryInfoList(nameFilters);
|
||||
for (QFileInfo dllFileInfo : dllFileInfos) {
|
||||
|
||||
QPluginLoader loader(dllFileInfo.absoluteFilePath());
|
||||
loader.load();
|
||||
|
||||
@@ -207,7 +207,8 @@ void StateItem::updateBoundingRect()
|
||||
void StateItem::shrink()
|
||||
{
|
||||
QRectF trect;
|
||||
foreach (TransitionItem *item, outputTransitions()) {
|
||||
const QVector<TransitionItem *> items = outputTransitions();
|
||||
for (TransitionItem *item : items) {
|
||||
if (item->targetType() == TransitionItem::InternalSameTarget || item->targetType() == TransitionItem::InternalNoTarget) {
|
||||
trect = trect.united(item->wholeBoundingRect());
|
||||
}
|
||||
@@ -239,8 +240,8 @@ void StateItem::transitionsChanged()
|
||||
{
|
||||
QRectF rr = boundingRect();
|
||||
QRectF rectInternalTransitions;
|
||||
QVector<TransitionItem*> internalTransitions = outputTransitions();
|
||||
foreach (TransitionItem *item, internalTransitions) {
|
||||
const QVector<TransitionItem*> internalTransitions = outputTransitions();
|
||||
for (TransitionItem *item : internalTransitions) {
|
||||
if (item->targetType() <= TransitionItem::InternalNoTarget) {
|
||||
QRectF br = mapFromItem(item, item->boundingRect()).boundingRect();
|
||||
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
|
||||
// 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))
|
||||
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
|
||||
// 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))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -280,7 +280,8 @@ void TransitionItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
if (bLeftButton) {
|
||||
// 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
|
||||
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)) {
|
||||
event->ignore();
|
||||
return;
|
||||
|
||||
@@ -354,7 +354,8 @@ void ChangeFullNameSpaceCommand::makeIdMap(ScxmlTag *tag, QHash<QString, QString
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (ScxmlTag *child, tag->allChildren()) {
|
||||
const QVector<ScxmlTag *> children = tag->allChildren();
|
||||
for (ScxmlTag *child : children) {
|
||||
makeIdMap(child, map, use);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +381,8 @@ void ChangeFullNameSpaceCommand::updateNameSpace(ScxmlTag *tag, const QHash<QStr
|
||||
tag->setAttribute(name, map[attr]);
|
||||
}
|
||||
|
||||
foreach (ScxmlTag *child, tag->allChildren()) {
|
||||
const QVector<ScxmlTag *> children = tag->allChildren();
|
||||
for (ScxmlTag *child : children) {
|
||||
updateNameSpace(child, map);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user