diff options
Diffstat (limited to 'src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp | 82 |
1 files changed, 52 insertions, 30 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 54711a4168..2b64138387 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -2,30 +2,30 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "stateseditorview.h" -#include "stateseditorwidget.h" -#include "stateseditormodel.h" -#include <rewritingexception.h> -#include <QDebug> -#include <QRegularExpression> -#include <QMessageBox> -#include <cmath> -#include <memory> - -#include <nodemetainfo.h> +#include "stateseditormodel.h" +#include "stateseditorwidget.h" +#include <rewritingexception.h> #include <bindingproperty.h> -#include <variantproperty.h> #include <nodelistproperty.h> - +#include <nodemetainfo.h> +#include <variantproperty.h> #include <qmldesignerconstants.h> #include <qmldesignerplugin.h> #include <qmlitemnode.h> #include <qmlstate.h> + #include <annotationeditor/annotationeditor.h> #include <utils/algorithm.h> #include <utils/qtcassert.h> +#include <QDebug> +#include <QMessageBox> +#include <QRegularExpression> + +#include <cmath> +#include <memory> namespace QmlDesigner { @@ -55,10 +55,17 @@ WidgetInfo StatesEditorView::widgetInfo() if (!m_statesEditorWidget) m_statesEditorWidget = new StatesEditorWidget(this, m_statesEditorModel.data()); - return createWidgetInfo(m_statesEditorWidget.data(), QLatin1String("StatesEditor"), WidgetInfo::BottomPane, 0, tr("States")); + return createWidgetInfo(m_statesEditorWidget.data(), + QLatin1String("StatesEditor"), + WidgetInfo::BottomPane, + 0, + tr("States"), + tr("States view")); } -void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) +void StatesEditorView::rootNodeTypeChanged(const QString & /*type*/, + int /*majorVersion*/, + int /*minorVersion*/) { checkForStatesAvailability(); } @@ -89,13 +96,14 @@ void StatesEditorView::removeState(int nodeId) QStringList lockedTargets; const auto propertyChanges = modelState.propertyChanges(); - // confirm removing not empty states + // confirm removing not empty states if (!propertyChanges.isEmpty()) { QMessageBox msgBox; msgBox.setTextFormat(Qt::RichText); msgBox.setIcon(QMessageBox::Question); msgBox.setWindowTitle(tr("Remove State")); - msgBox.setText(tr("This state is not empty. Are you sure you want to remove it?")); + msgBox.setText( + tr("This state is not empty. Are you sure you want to remove it?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); @@ -124,8 +132,9 @@ void StatesEditorView::removeState(int nodeId) msgBox.setTextFormat(Qt::RichText); msgBox.setIcon(QMessageBox::Question); msgBox.setWindowTitle(tr("Remove State")); - msgBox.setText(QString(tr("Removing this state will modify locked components.") + "<br><br>%1") - .arg(detailedText)); + msgBox.setText(QString(tr("Removing this state will modify locked components.") + + "<br><br>%1") + .arg(detailedText)); msgBox.setInformativeText(tr("Continue by removing the state?")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); @@ -149,7 +158,7 @@ void StatesEditorView::removeState(int nodeId) stateNode.destroy(); } - } catch (const RewritingException &e) { + } catch (const RewritingException &e) { e.showException(); } } @@ -480,12 +489,14 @@ void StatesEditorView::modelAboutToBeDetached(Model *model) resetModel(); } -void StatesEditorView::propertiesRemoved(const QList<AbstractProperty>& propertyList) +void StatesEditorView::propertiesRemoved(const QList<AbstractProperty> &propertyList) { for (const AbstractProperty &property : propertyList) { - if (property.name() == "states" && property.parentModelNode() == activeStateGroup().modelNode()) + if (property.name() == "states" + && property.parentModelNode() == activeStateGroup().modelNode()) resetModel(); - if (property.name() == "when" && QmlModelState::isValidQmlModelState(property.parentModelNode())) + if (property.name() == "when" + && QmlModelState::isValidQmlModelState(property.parentModelNode())) resetModel(); } } @@ -494,22 +505,29 @@ void StatesEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode) { if (removedNode.hasParentProperty()) { const NodeAbstractProperty propertyParent = removedNode.parentProperty(); - if (propertyParent.parentModelNode() == activeStateGroup().modelNode() && propertyParent.name() == "states") + if (propertyParent.parentModelNode() == activeStateGroup().modelNode() + && propertyParent.name() == "states") m_lastIndex = propertyParent.indexOf(removedNode); } if (currentState().isValid() && removedNode == currentState()) setCurrentState(baseState()); } -void StatesEditorView::nodeRemoved(const ModelNode & /*removedNode*/, const NodeAbstractProperty &parentProperty, PropertyChangeFlags /*propertyChange*/) +void StatesEditorView::nodeRemoved(const ModelNode & /*removedNode*/, + const NodeAbstractProperty &parentProperty, + PropertyChangeFlags /*propertyChange*/) { - if (parentProperty.isValid() && parentProperty.parentModelNode() == activeStateGroup().modelNode() && parentProperty.name() == "states") { + if (parentProperty.isValid() && parentProperty.parentModelNode() == activeStateGroup().modelNode() + && parentProperty.name() == "states") { m_statesEditorModel->removeState(m_lastIndex); m_lastIndex = -1; } } -void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags /*propertyChange*/) +void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node, + const NodeAbstractProperty & /*newPropertyParent*/, + const NodeAbstractProperty &oldPropertyParent, + AbstractView::PropertyChangeFlags /*propertyChange*/) { if (oldPropertyParent.isValid() && oldPropertyParent.parentModelNode() == activeStateGroup().modelNode() @@ -517,8 +535,10 @@ void StatesEditorView::nodeAboutToBeReparented(const ModelNode &node, const Node m_lastIndex = oldPropertyParent.indexOf(node); } - -void StatesEditorView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags /*propertyChange*/) +void StatesEditorView::nodeReparented(const ModelNode &node, + const NodeAbstractProperty &newPropertyParent, + const NodeAbstractProperty &oldPropertyParent, + AbstractView::PropertyChangeFlags /*propertyChange*/) { if (oldPropertyParent.isValid() && oldPropertyParent.parentModelNode() == activeStateGroup().modelNode() @@ -547,7 +567,8 @@ void StatesEditorView::bindingPropertiesChanged( [[maybe_unused]] AbstractView::PropertyChangeFlags propertyChange) { for (const BindingProperty &property : propertyList) { - if (property.name() == "when" && QmlModelState::isValidQmlModelState(property.parentModelNode())) + if (property.name() == "when" + && QmlModelState::isValidQmlModelState(property.parentModelNode())) resetModel(); } } @@ -562,7 +583,8 @@ void StatesEditorView::variantPropertiesChanged(const QList<VariantProperty> &pr auto guard = qScopeGuard([&]() { m_block = false; }); for (const VariantProperty &property : propertyList) { - if (property.name() == "name" && QmlModelState::isValidQmlModelState(property.parentModelNode())) + if (property.name() == "name" + && QmlModelState::isValidQmlModelState(property.parentModelNode())) resetModel(); else if (property.name() == "state" && property.parentModelNode() == activeStateGroup().modelNode()) |