forked from qt-creator/qt-creator
ScXMLEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: Ic439470b7c23022fee6acbf0cdaba7760309edb0 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -154,7 +154,7 @@ void Structure::addCheckbox(const QString &name, TagType type)
|
||||
void Structure::updateCheckBoxes()
|
||||
{
|
||||
QVector<TagType> visibleTags;
|
||||
foreach (QCheckBox *box, m_checkboxes) {
|
||||
for (QCheckBox *box : qAsConst(m_checkboxes)) {
|
||||
if (box->isChecked()) {
|
||||
switch (TagType(box->property(Constants::C_SCXMLTAG_TAGTYPE).toInt())) {
|
||||
case State:
|
||||
|
@@ -58,7 +58,7 @@ void WarningModel::clear(bool sendSignal)
|
||||
{
|
||||
emit modelAboutToBeClear();
|
||||
|
||||
foreach (Warning *w, m_warnings)
|
||||
for (Warning *w : qAsConst(m_warnings))
|
||||
w->disconnect(this);
|
||||
|
||||
beginResetModel();
|
||||
|
@@ -64,19 +64,16 @@ ConnectableItem::~ConnectableItem()
|
||||
{
|
||||
setBlockUpdates(true);
|
||||
|
||||
foreach (ConnectableItem *item, m_overlappedItems) {
|
||||
for (ConnectableItem *item : qAsConst(m_overlappedItems))
|
||||
item->removeOverlappingItem(this);
|
||||
}
|
||||
m_overlappedItems.clear();
|
||||
|
||||
foreach (TransitionItem *transition, m_outputTransitions) {
|
||||
for (TransitionItem *transition : qAsConst(m_outputTransitions))
|
||||
transition->disconnectItem(this);
|
||||
}
|
||||
m_outputTransitions.clear();
|
||||
|
||||
foreach (TransitionItem *transition, m_inputTransitions) {
|
||||
for (TransitionItem *transition : qAsConst(m_inputTransitions))
|
||||
transition->disconnectItem(this);
|
||||
}
|
||||
m_inputTransitions.clear();
|
||||
|
||||
qDeleteAll(m_quickTransitions);
|
||||
@@ -291,7 +288,7 @@ void ConnectableItem::removeInputTransition(TransitionItem *transition)
|
||||
|
||||
void ConnectableItem::updateInputTransitions()
|
||||
{
|
||||
foreach (TransitionItem *transition, m_inputTransitions) {
|
||||
for (TransitionItem *transition : qAsConst(m_inputTransitions)) {
|
||||
transition->updateComponents();
|
||||
transition->updateUIProperties();
|
||||
}
|
||||
@@ -300,7 +297,7 @@ void ConnectableItem::updateInputTransitions()
|
||||
|
||||
void ConnectableItem::updateOutputTransitions()
|
||||
{
|
||||
foreach (TransitionItem *transition, m_outputTransitions) {
|
||||
for (TransitionItem *transition : qAsConst(m_outputTransitions)) {
|
||||
transition->updateComponents();
|
||||
transition->updateUIProperties();
|
||||
}
|
||||
@@ -313,7 +310,7 @@ void ConnectableItem::updateTransitions(bool allChildren)
|
||||
updateInputTransitions();
|
||||
|
||||
if (allChildren) {
|
||||
foreach (QGraphicsItem *it, childItems()) {
|
||||
for (QGraphicsItem *it : childItems()) {
|
||||
auto item = static_cast<ConnectableItem*>(it);
|
||||
if (item && item->type() >= InitialStateType)
|
||||
item->updateTransitions(allChildren);
|
||||
@@ -323,14 +320,15 @@ void ConnectableItem::updateTransitions(bool allChildren)
|
||||
|
||||
void ConnectableItem::updateTransitionAttributes(bool allChildren)
|
||||
{
|
||||
foreach (TransitionItem *transition, m_outputTransitions)
|
||||
for (TransitionItem *transition : qAsConst(m_outputTransitions))
|
||||
transition->updateTarget();
|
||||
|
||||
foreach (TransitionItem *transition, m_inputTransitions)
|
||||
for (TransitionItem *transition : qAsConst(m_inputTransitions))
|
||||
transition->updateTarget();
|
||||
|
||||
if (allChildren) {
|
||||
foreach (QGraphicsItem *it, childItems()) {
|
||||
const QList<QGraphicsItem *> items = childItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
auto item = static_cast<ConnectableItem*>(it);
|
||||
if (item && item->type() >= InitialStateType)
|
||||
item->updateTransitionAttributes(allChildren);
|
||||
@@ -352,7 +350,7 @@ QPointF ConnectableItem::getInternalPosition(const TransitionItem *transition, T
|
||||
|
||||
int ind = 0;
|
||||
if (type == TransitionItem::InternalNoTarget) {
|
||||
foreach (TransitionItem *item, m_outputTransitions) {
|
||||
for (TransitionItem *item : qAsConst(m_outputTransitions)) {
|
||||
if (item->targetType() == TransitionItem::InternalSameTarget)
|
||||
ind++;
|
||||
}
|
||||
@@ -396,7 +394,8 @@ void ConnectableItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
//Restore old behavior if ctrl & alt modifiers are present
|
||||
if (!m_releasedFromParent && !(event->modifiers() & Qt::AltModifier) && !(event->modifiers() & Qt::ControlModifier)) {
|
||||
releaseFromParent();
|
||||
foreach (QGraphicsItem *it, scene()->selectedItems()) {
|
||||
const QList<QGraphicsItem *> items = scene()->selectedItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= InitialStateType && it != this) {
|
||||
qgraphicsitem_cast<ConnectableItem*>(it)->releaseFromParent();
|
||||
}
|
||||
@@ -431,7 +430,8 @@ void ConnectableItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
}
|
||||
}
|
||||
connectToParent(parentItem);
|
||||
foreach (QGraphicsItem *it, scene()->selectedItems()) {
|
||||
const QList<QGraphicsItem *> items = scene()->selectedItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= InitialStateType && it != this)
|
||||
qgraphicsitem_cast<ConnectableItem*>(it)->connectToParent(parentItem);
|
||||
}
|
||||
@@ -582,7 +582,7 @@ void ConnectableItem::updateAttributes()
|
||||
{
|
||||
BaseItem::updateAttributes();
|
||||
|
||||
foreach (TransitionItem *transition, m_inputTransitions) {
|
||||
for (TransitionItem *transition : qAsConst(m_inputTransitions)) {
|
||||
if (transition->isEndItem(this))
|
||||
transition->setTagValue("target", itemId());
|
||||
}
|
||||
@@ -698,13 +698,13 @@ void ConnectableItem::finalizeCreation()
|
||||
|
||||
bool ConnectableItem::hasInputTransitions(const ConnectableItem *parentItem, bool checkChildren) const
|
||||
{
|
||||
foreach (const TransitionItem *it, m_inputTransitions) {
|
||||
for (const TransitionItem *it : qAsConst(m_inputTransitions))
|
||||
if (!SceneUtils::isChild(parentItem, it->connectedItem(this)))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkChildren) {
|
||||
foreach (QGraphicsItem *it, childItems()) {
|
||||
const QList<QGraphicsItem *> items = childItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= InitialStateType) {
|
||||
auto item = qgraphicsitem_cast<ConnectableItem*>(it);
|
||||
if (item && item->hasInputTransitions(parentItem, checkChildren))
|
||||
@@ -718,13 +718,13 @@ bool ConnectableItem::hasInputTransitions(const ConnectableItem *parentItem, boo
|
||||
|
||||
bool ConnectableItem::hasOutputTransitions(const ConnectableItem *parentItem, bool checkChildren) const
|
||||
{
|
||||
foreach (TransitionItem *it, m_outputTransitions) {
|
||||
for (TransitionItem *it : qAsConst(m_outputTransitions))
|
||||
if (!SceneUtils::isChild(parentItem, it->connectedItem(this)))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkChildren) {
|
||||
foreach (QGraphicsItem *it, childItems()) {
|
||||
const QList<QGraphicsItem *> items = childItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= InitialStateType) {
|
||||
auto item = qgraphicsitem_cast<ConnectableItem*>(it);
|
||||
if (item && item->hasOutputTransitions(parentItem, checkChildren))
|
||||
@@ -755,7 +755,8 @@ void ConnectableItem::removeOverlappingItem(ConnectableItem *item)
|
||||
void ConnectableItem::checkOverlapping()
|
||||
{
|
||||
QVector<ConnectableItem*> overlappedItems;
|
||||
foreach (QGraphicsItem *it, collidingItems()) {
|
||||
const QList<QGraphicsItem *> items = collidingItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= InitialStateType && it->parentItem() == parentItem()) {
|
||||
overlappedItems << qgraphicsitem_cast<ConnectableItem*>(it);
|
||||
}
|
||||
@@ -770,7 +771,7 @@ void ConnectableItem::checkOverlapping()
|
||||
}
|
||||
|
||||
// Add new overlapped items
|
||||
foreach (ConnectableItem *it, overlappedItems) {
|
||||
for (ConnectableItem *it : qAsConst(overlappedItems)) {
|
||||
if (!m_overlappedItems.contains(it)) {
|
||||
m_overlappedItems << it;
|
||||
it->addOverlappingItem(this);
|
||||
|
@@ -67,7 +67,7 @@ GraphicsScene::~GraphicsScene()
|
||||
void GraphicsScene::unselectAll()
|
||||
{
|
||||
const QList<QGraphicsItem*> selectedItems = this->selectedItems();
|
||||
foreach (QGraphicsItem *it, selectedItems)
|
||||
for (QGraphicsItem *it : selectedItems)
|
||||
it->setSelected(false);
|
||||
if (m_document)
|
||||
m_document->setCurrentTag(nullptr);
|
||||
@@ -75,20 +75,20 @@ void GraphicsScene::unselectAll()
|
||||
|
||||
void GraphicsScene::unhighlightAll()
|
||||
{
|
||||
foreach (BaseItem *it, m_baseItems)
|
||||
for (BaseItem *it : qAsConst(m_baseItems))
|
||||
it->setHighlight(false);
|
||||
}
|
||||
|
||||
void GraphicsScene::highlightItems(const QVector<ScxmlTag*> &lstIds)
|
||||
{
|
||||
foreach (BaseItem *it, m_baseItems)
|
||||
for (BaseItem *it : qAsConst(m_baseItems))
|
||||
it->setHighlight(lstIds.contains(it->tag()));
|
||||
}
|
||||
|
||||
QRectF GraphicsScene::selectedBoundingRect() const
|
||||
{
|
||||
QRectF r;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected())
|
||||
r = r.united(item->sceneBoundingRect());
|
||||
}
|
||||
@@ -98,7 +98,7 @@ QRectF GraphicsScene::selectedBoundingRect() const
|
||||
qreal GraphicsScene::selectedMaxWidth() const
|
||||
{
|
||||
qreal maxw = 0;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
maxw = qMax(maxw, item->sceneBoundingRect().width());
|
||||
}
|
||||
@@ -108,7 +108,7 @@ qreal GraphicsScene::selectedMaxWidth() const
|
||||
qreal GraphicsScene::selectedMaxHeight() const
|
||||
{
|
||||
qreal maxh = 0;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
maxh = qMax(maxh, item->sceneBoundingRect().height());
|
||||
}
|
||||
@@ -124,37 +124,37 @@ void GraphicsScene::alignStates(int alignType)
|
||||
if (r.isValid()) {
|
||||
switch (alignType) {
|
||||
case ActionAlignLeft:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(r.left() - item->sceneBoundingRect().left(), 0);
|
||||
}
|
||||
break;
|
||||
case ActionAlignRight:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(r.right() - item->sceneBoundingRect().right(), 0);
|
||||
}
|
||||
break;
|
||||
case ActionAlignTop:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(0, r.top() - item->sceneBoundingRect().top());
|
||||
}
|
||||
break;
|
||||
case ActionAlignBottom:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(0, r.bottom() - item->sceneBoundingRect().bottom());
|
||||
}
|
||||
break;
|
||||
case ActionAlignHorizontal:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(0, r.center().y() - item->sceneBoundingRect().center().y());
|
||||
}
|
||||
break;
|
||||
case ActionAlignVertical:
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType)
|
||||
item->moveStateBy(r.center().x() - item->sceneBoundingRect().center().x(), 0);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void GraphicsScene::adjustStates(int adjustType)
|
||||
qreal maxw = selectedMaxWidth();
|
||||
qreal maxh = selectedMaxHeight();
|
||||
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= InitialStateType) {
|
||||
QRectF rr = item->boundingRect();
|
||||
if ((adjustType == ActionAdjustWidth || adjustType == ActionAdjustSize) && !qFuzzyCompare(rr.width(), maxw))
|
||||
@@ -223,7 +223,7 @@ void GraphicsScene::copy()
|
||||
QVector<ScxmlTag*> tags;
|
||||
if (m_document->currentTag()->tagType() == Scxml) {
|
||||
QVector<BaseItem*> items;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (!item->parentItem())
|
||||
items << item;
|
||||
}
|
||||
@@ -241,9 +241,9 @@ void GraphicsScene::copy()
|
||||
mime->setText(QLatin1String(result));
|
||||
mime->setData("StateChartEditor/StateData", result);
|
||||
QStringList strTypes;
|
||||
foreach (const ScxmlTag *tag, tags) {
|
||||
for (const ScxmlTag *tag : qAsConst(tags))
|
||||
strTypes << tag->tagName(false);
|
||||
}
|
||||
|
||||
mime->setData("StateChartEditor/CopiedTagTypes", strTypes.join(",").toLocal8Bit());
|
||||
mime->setData("StateChartEditor/CopiedMinPos", QString::fromLatin1("%1:%2").arg(minPos.x()).arg(minPos.y()).toLocal8Bit());
|
||||
QGuiApplication::clipboard()->setMimeData(mime);
|
||||
@@ -267,7 +267,7 @@ void GraphicsScene::paste(const QPointF &targetPos)
|
||||
QPointF startPos(targetPos);
|
||||
|
||||
BaseItem *targetItem = nullptr;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= StateType) {
|
||||
targetItem = item;
|
||||
break;
|
||||
@@ -296,7 +296,7 @@ void GraphicsScene::paste(const QPointF &targetPos)
|
||||
|
||||
void GraphicsScene::setEditorInfo(const QString &key, const QString &value)
|
||||
{
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected() && item->type() >= TransitionType)
|
||||
item->setEditorInfo(key, value);
|
||||
}
|
||||
@@ -371,7 +371,7 @@ void GraphicsScene::runLayoutToSelectedStates()
|
||||
m_document->undoStack()->beginMacro(tr("Re-layout"));
|
||||
|
||||
QVector<BaseItem*> selectedItems;
|
||||
foreach (BaseItem *node, m_baseItems) {
|
||||
for (BaseItem *node : qAsConst(m_baseItems)) {
|
||||
if (node->isSelected()) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < selectedItems.count(); ++i) {
|
||||
@@ -391,22 +391,20 @@ void GraphicsScene::runLayoutToSelectedStates()
|
||||
// Layout scene items if necessary
|
||||
if (selectedItems.isEmpty()) {
|
||||
QList<QGraphicsItem*> sceneItems;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->type() >= InitialStateType && !item->parentItem())
|
||||
sceneItems << item;
|
||||
}
|
||||
SceneUtils::layout(sceneItems);
|
||||
|
||||
foreach (QGraphicsItem *item, sceneItems) {
|
||||
for (QGraphicsItem *item : qAsConst(sceneItems))
|
||||
if (item->type() >= StateType)
|
||||
static_cast<StateItem*>(item)->shrink();
|
||||
}
|
||||
}
|
||||
|
||||
// Update properties
|
||||
foreach (BaseItem *node, selectedItems) {
|
||||
for (BaseItem *node : qAsConst(selectedItems))
|
||||
node->updateUIProperties();
|
||||
}
|
||||
|
||||
m_document->undoStack()->endMacro();
|
||||
}
|
||||
@@ -417,31 +415,31 @@ void GraphicsScene::runAutomaticLayout()
|
||||
|
||||
// 1. Find max depth
|
||||
int maxDepth = 0;
|
||||
foreach (BaseItem *node, m_baseItems) {
|
||||
for (BaseItem *node : qAsConst(m_baseItems)) {
|
||||
maxDepth = qMax(maxDepth, node->depth());
|
||||
node->setBlockUpdates(true);
|
||||
}
|
||||
|
||||
// 2. Layout every depth-level separately
|
||||
for (int d = (maxDepth + 1); d--;) {
|
||||
foreach (BaseItem *node, m_baseItems)
|
||||
for (BaseItem *node : qAsConst(m_baseItems))
|
||||
node->doLayout(d);
|
||||
}
|
||||
|
||||
// 3. Layout scene items
|
||||
QList<QGraphicsItem*> sceneItems;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->type() >= InitialStateType && !item->parentItem())
|
||||
sceneItems << item;
|
||||
}
|
||||
SceneUtils::layout(sceneItems);
|
||||
|
||||
foreach (QGraphicsItem *item, sceneItems) {
|
||||
for (QGraphicsItem *item : qAsConst(sceneItems)) {
|
||||
if (item->type() >= StateType)
|
||||
static_cast<StateItem*>(item)->shrink();
|
||||
}
|
||||
|
||||
foreach (BaseItem *node, m_baseItems) {
|
||||
for (BaseItem *node : qAsConst(m_baseItems)) {
|
||||
node->updateUIProperties();
|
||||
node->setBlockUpdates(false);
|
||||
}
|
||||
@@ -468,21 +466,21 @@ void GraphicsScene::endTagChange(ScxmlDocument::TagChange change, ScxmlTag *tag,
|
||||
|
||||
switch (change) {
|
||||
case ScxmlDocument::TagAttributesChanged: {
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->tag() == tag)
|
||||
item->updateAttributes();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ScxmlDocument::TagEditorInfoChanged: {
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->tag() == tag)
|
||||
item->updateEditorInfo();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ScxmlDocument::TagCurrentChanged: {
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (!item->isSelected() && item->tag() == tag)
|
||||
item->setSelected(true);
|
||||
}
|
||||
@@ -725,7 +723,7 @@ BaseItem *GraphicsScene::findItem(const ScxmlTag *tag) const
|
||||
if (!tag)
|
||||
return nullptr;
|
||||
|
||||
foreach (BaseItem *it, m_baseItems) {
|
||||
for (BaseItem *it : qAsConst(m_baseItems)) {
|
||||
if (it->tag() == tag)
|
||||
return it;
|
||||
}
|
||||
@@ -738,7 +736,7 @@ void GraphicsScene::removeItems(const ScxmlTag *tag)
|
||||
if (tag) {
|
||||
// Find right items
|
||||
QVector<BaseItem*> items;
|
||||
foreach (BaseItem *it, m_baseItems) {
|
||||
for (BaseItem *it : qAsConst(m_baseItems)) {
|
||||
if (it->tag() == tag)
|
||||
items << it;
|
||||
}
|
||||
@@ -764,7 +762,7 @@ QPair<bool, bool> GraphicsScene::checkSnapToItem(BaseItem *item, const QPointF &
|
||||
qreal diffY = 8;
|
||||
qreal diffYdX = 2000;
|
||||
|
||||
foreach (BaseItem *it, m_baseItems) {
|
||||
for (BaseItem *it : qAsConst(m_baseItems)) {
|
||||
if (!it->isSelected() && it != item && it->parentItem() == parentItem && it->type() >= InitialStateType) {
|
||||
QPointF c = it->sceneCenter();
|
||||
qreal dX = qAbs(c.x() - p.x());
|
||||
@@ -802,7 +800,7 @@ void GraphicsScene::selectionChanged(bool para)
|
||||
int baseCount = 0;
|
||||
int stateTypeCount = 0;
|
||||
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->isSelected()) {
|
||||
if (item->type() >= TransitionType)
|
||||
baseCount++;
|
||||
@@ -848,22 +846,20 @@ void GraphicsScene::removeWarningItem(WarningItem *item)
|
||||
void GraphicsScene::warningVisibilityChanged(int type, WarningItem *item)
|
||||
{
|
||||
if (!m_autoLayoutRunning && !m_initializing) {
|
||||
foreach (WarningItem *it, m_allWarnings) {
|
||||
for (WarningItem *it : qAsConst(m_allWarnings))
|
||||
if (it != item && (type == 0 || it->type() == type))
|
||||
it->check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScxmlTag *GraphicsScene::tagByWarning(const ScxmlEditor::OutputPane::Warning *w) const
|
||||
{
|
||||
ScxmlTag *tag = nullptr;
|
||||
foreach (WarningItem *it, m_allWarnings) {
|
||||
for (WarningItem *it : qAsConst(m_allWarnings))
|
||||
if (it->warning() == w) {
|
||||
tag = it->tag();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -921,7 +917,7 @@ void GraphicsScene::removeChild(BaseItem *item)
|
||||
|
||||
void GraphicsScene::checkItemsVisibility(double scaleFactor)
|
||||
{
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
item->checkVisibility(scaleFactor);
|
||||
}
|
||||
}
|
||||
@@ -930,7 +926,7 @@ void GraphicsScene::checkInitialState()
|
||||
{
|
||||
if (m_document) {
|
||||
QList<QGraphicsItem*> sceneItems;
|
||||
foreach (BaseItem *item, m_baseItems) {
|
||||
for (BaseItem *item : qAsConst(m_baseItems)) {
|
||||
if (item->type() >= InitialStateType && !item->parentItem())
|
||||
sceneItems << item;
|
||||
}
|
||||
@@ -944,14 +940,14 @@ void GraphicsScene::checkInitialState()
|
||||
|
||||
void GraphicsScene::clearAllTags()
|
||||
{
|
||||
foreach (BaseItem *it, m_baseItems) {
|
||||
for (BaseItem *it : qAsConst(m_baseItems)) {
|
||||
it->setTag(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsScene::setBlockUpdates(bool block)
|
||||
{
|
||||
foreach (BaseItem *it, m_baseItems) {
|
||||
for (BaseItem *it : qAsConst(m_baseItems)) {
|
||||
it->setBlockUpdates(block);
|
||||
}
|
||||
}
|
||||
|
@@ -63,7 +63,8 @@ void ParallelItem::doLayout(int d)
|
||||
|
||||
// 1. Find children items
|
||||
QVector<StateItem*> children;
|
||||
foreach (QGraphicsItem *it, childItems()) {
|
||||
const QList<QGraphicsItem *> items = childItems();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (it->type() >= StateType) {
|
||||
auto itt = qgraphicsitem_cast<StateItem*>(it);
|
||||
if (itt)
|
||||
@@ -72,17 +73,16 @@ void ParallelItem::doLayout(int d)
|
||||
}
|
||||
|
||||
// 2. Adjust sizes
|
||||
foreach (StateItem *itt, children) {
|
||||
for (StateItem *itt : qAsConst(children))
|
||||
itt->shrink();
|
||||
}
|
||||
|
||||
qreal maxw = 0;
|
||||
foreach (StateItem *itt, children) {
|
||||
for (StateItem *itt : qAsConst(children)) {
|
||||
QRectF rr = itt->boundingRect();
|
||||
maxw = qMax(rr.width(), maxw);
|
||||
}
|
||||
|
||||
foreach (StateItem *itt, children) {
|
||||
for (StateItem *itt : qAsConst(children)) {
|
||||
QRectF rr = itt->boundingRect();
|
||||
if (!qFuzzyCompare(rr.width(), maxw))
|
||||
rr.setWidth(maxw);
|
||||
|
@@ -78,9 +78,9 @@ void SCAttributeItemDelegate::setEditorData(QWidget *editor, const QModelIndex &
|
||||
auto combo = qobject_cast<QComboBox*>(editor);
|
||||
if (combo) {
|
||||
combo->clear();
|
||||
QStringList values = index.data(DataRole).toString().split(";");
|
||||
const QStringList values = index.data(DataRole).toString().split(";");
|
||||
|
||||
foreach (QString val, values)
|
||||
for (QString val : values)
|
||||
combo->addItem(val);
|
||||
|
||||
combo->setCurrentText(index.data().toString());
|
||||
|
@@ -149,7 +149,7 @@ QVector<ScxmlTag*> findCopyTags(const QVector<BaseItem*> &items, QPointF &minPos
|
||||
{
|
||||
QPointF pp(0, 0);
|
||||
QVector<ScxmlTag*> tags;
|
||||
foreach (BaseItem *it, items) {
|
||||
for (BaseItem *it : items) {
|
||||
if (it->type() >= InitialStateType && it->isSelected()) {
|
||||
BaseItem *parent = it->parentBaseItem();
|
||||
BaseItem *lastSelectedParent = it;
|
||||
@@ -181,7 +181,7 @@ QVector<ScxmlTag*> findRemovedTags(const QVector<BaseItem*> &items)
|
||||
{
|
||||
// Find right tags
|
||||
QVector<ScxmlTag*> tags;
|
||||
foreach (BaseItem *it, items) {
|
||||
for (BaseItem *it : items) {
|
||||
if (it->isSelected()) {
|
||||
// Find the last selected parent
|
||||
BaseItem *parent = it->parentBaseItem();
|
||||
@@ -207,7 +207,7 @@ void layout(const QList<QGraphicsItem*> &items)
|
||||
QList<ConnectableItem*> childItems;
|
||||
ConnectableItem *initialItem = nullptr;
|
||||
ConnectableItem *finalItem = nullptr;
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
for (QGraphicsItem *item : items) {
|
||||
auto connectableItem = qgraphicsitem_cast<ConnectableItem*>(item);
|
||||
if (connectableItem) {
|
||||
if (connectableItem->type() == InitialStateType)
|
||||
@@ -317,12 +317,16 @@ void layout(const QList<QGraphicsItem*> &items)
|
||||
}
|
||||
|
||||
// Finally set initial and final positions
|
||||
foreach (ConnectableItem *item, childItems) {
|
||||
for (const ConnectableItem *item : qAsConst(childItems)) {
|
||||
if (item == firstItem)
|
||||
initialItem->setPos(firstItem->pos() + firstItem->boundingRect().topLeft() - QPointF(50, 50));
|
||||
initialItem->setPos(firstItem->pos() + firstItem->boundingRect().topLeft()
|
||||
- QPointF(50, 50));
|
||||
else if (item == lastItem) {
|
||||
int angle = startAngle + childItems.indexOf(item) * angleDiff;
|
||||
QLineF line = QLineF::fromPolar(qMax(lastItem->boundingRect().width() / 2, lastItem->boundingRect().height() / 2) + 20, angle);
|
||||
QLineF line = QLineF::fromPolar(qMax(lastItem->boundingRect().width() / 2,
|
||||
lastItem->boundingRect().height() / 2)
|
||||
+ 20,
|
||||
angle);
|
||||
finalItem->setPos(lastItem->pos() + lastItem->boundingRect().center() + line.p2());
|
||||
}
|
||||
}
|
||||
|
@@ -70,18 +70,16 @@ bool hasSiblingStates(T *item)
|
||||
if (parentItem) {
|
||||
children = parentItem->childItems();
|
||||
} else if (item->scene()) {
|
||||
foreach (QGraphicsItem *it, item->scene()->items()) {
|
||||
const QList<QGraphicsItem *> items = item->scene()->items();
|
||||
for (QGraphicsItem *it : items)
|
||||
if (!it->parentItem())
|
||||
children << it;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QGraphicsItem *it, children) {
|
||||
if (it != item && it->type() == item->type()) {
|
||||
for (QGraphicsItem *it : qAsConst(children))
|
||||
if (it != item && it->type() == item->type())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user