diff options
author | Burak Hancerli <burak.hancerli@qt.io> | 2023-03-18 17:55:04 +0100 |
---|---|---|
committer | Burak Hancerli <burak.hancerli@qt.io> | 2023-03-24 08:45:28 +0000 |
commit | fef7852da53b84c7fb960b18fef8cda0b6663703 (patch) | |
tree | 29abc1b89d8b09a9268db2c0c66ef30fc6e59007 /src/plugins | |
parent | 1e2c8d42e3400ce724f5a4b1a297687f5803ab5a (diff) | |
download | qt-creator-fef7852da53b84c7fb960b18fef8cda0b6663703.tar.gz |
QmlDesigner: bulk clang-format trial
Task-number: QDS-9097
Change-Id: I9b063614030831a2dda6dbdc2bbc79205d6baeaf
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins')
8 files changed, 115 insertions, 105 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp index dfdc58c84e..2eb38d5ac6 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.cpp @@ -6,14 +6,11 @@ #include <QDebug> -namespace QmlDesigner { - -namespace Internal { +namespace QmlDesigner::Internal { StatesEditorImageProvider::StatesEditorImageProvider() : QQuickImageProvider(QQuickImageProvider::Image) -{ -} +{} QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { @@ -28,7 +25,8 @@ QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, c bool canBeConverted; int instanceId = imageId.toInt(&canBeConverted); if (canBeConverted && m_nodeInstanceView->hasModelNodeForInternalId(instanceId)) { - image = m_nodeInstanceView->statePreviewImage(m_nodeInstanceView->modelNodeForInternalId(instanceId)); + image = m_nodeInstanceView->statePreviewImage( + m_nodeInstanceView->modelNodeForInternalId(instanceId)); } } } @@ -37,7 +35,7 @@ QImage StatesEditorImageProvider::requestImage(const QString &id, QSize *size, c //creating white QImage QSize newSize = requestedSize; if (newSize.isEmpty()) - newSize = QSize (100, 100); + newSize = QSize(100, 100); QImage image(newSize, QImage::Format_ARGB32); image.fill(0xFFFFFFFF); @@ -54,7 +52,4 @@ void StatesEditorImageProvider::setNodeInstanceView(const NodeInstanceView *node m_nodeInstanceView = nodeInstanceView; } -} - -} - +} // QmlDesigner::Internal diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h index fdc5688ec2..e7d586966c 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorimageprovider.h @@ -3,10 +3,10 @@ #pragma once -#include"abstractview.h" +#include "abstractview.h" -#include <QQuickImageProvider> #include <QPointer> +#include <QQuickImageProvider> namespace QmlDesigner { namespace Internal { diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index f06dae4938..4ecc6a7504 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -6,30 +6,26 @@ #include <QDebug> -#include <nodelistproperty.h> -#include <modelnode.h> #include <bindingproperty.h> -#include <variantproperty.h> +#include <modelnode.h> +#include <nodelistproperty.h> #include <rewriterview.h> +#include <variantproperty.h> #include <coreplugin/icore.h> #include <coreplugin/messagebox.h> #include <QWidget> -enum { - debug = false -}; - +enum { debug = false }; namespace QmlDesigner { StatesEditorModel::StatesEditorModel(StatesEditorView *view) - : QAbstractListModel(view), - m_statesEditorView(view), - m_updateCounter(0) -{ -} + : QAbstractListModel(view) + , m_statesEditorView(view) + , m_updateCounter(0) +{} int StatesEditorModel::count() const { @@ -43,9 +39,12 @@ QModelIndex StatesEditorModel::index(int row, int column, const QModelIndex &par int internalNodeId = 0; if (row > 0 && row < rowCount() - 1) // first and last rows are base state, add state - internalNodeId = m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").at(row - 1).internalId(); + internalNodeId = m_statesEditorView->acitveStatesGroupNode() + .nodeListProperty("states") + .at(row - 1) + .internalId(); - return hasIndex(row, column, parent) ? createIndex(row, column, internalNodeId) : QModelIndex(); + return hasIndex(row, column, parent) ? createIndex(row, column, internalNodeId) : QModelIndex(); } int StatesEditorModel::rowCount(const QModelIndex &parent) const @@ -56,7 +55,8 @@ int StatesEditorModel::rowCount(const QModelIndex &parent) const if (!m_statesEditorView->acitveStatesGroupNode().hasNodeListProperty("states")) return 2; // base state + add new state - return m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").count() + 2; // 2 = base state + add new state + return m_statesEditorView->acitveStatesGroupNode().nodeListProperty("states").count() + + 2; // 2 = base state + add new state } void StatesEditorModel::reset() @@ -67,7 +67,8 @@ void StatesEditorModel::reset() QVariant StatesEditorModel::data(const QModelIndex &index, int role) const { - if (index.parent().isValid() || index.column() != 0 || m_statesEditorView.isNull() || !m_statesEditorView->hasModelNodeForInternalId(index.internalId())) + if (index.parent().isValid() || index.column() != 0 || m_statesEditorView.isNull() + || !m_statesEditorView->hasModelNodeForInternalId(index.internalId())) return QVariant(); ModelNode stateNode; @@ -121,16 +122,14 @@ QVariant StatesEditorModel::data(const QModelIndex &index, int role) const QHash<int, QByteArray> StatesEditorModel::roleNames() const { - static QHash<int, QByteArray> roleNames { - {StateNameRole, "stateName"}, - {StateImageSourceRole, "stateImageSource"}, - {InternalNodeId, "internalNodeId"}, - {HasWhenCondition, "hasWhenCondition"}, - {WhenConditionString, "whenConditionString"}, - {IsDefault, "isDefault"}, - {ModelHasDefaultState, "modelHasDefaultState"}, - {StateType, "type"} - }; + static QHash<int, QByteArray> roleNames{{StateNameRole, "stateName"}, + {StateImageSourceRole, "stateImageSource"}, + {InternalNodeId, "internalNodeId"}, + {HasWhenCondition, "hasWhenCondition"}, + {WhenConditionString, "whenConditionString"}, + {IsDefault, "isDefault"}, + {ModelHasDefaultState, "modelHasDefaultState"}, + {StateType, "type"}}; return roleNames; } @@ -167,19 +166,17 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName) if (newName == m_statesEditorView->currentStateName()) return; - if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) { - QTimer::singleShot(0, [newName]{ + if (newName.isEmpty() || !m_statesEditorView->validStateName(newName)) { + QTimer::singleShot(0, [newName] { Core::AsynchronousMessageBox::warning( - tr("Invalid State Name"), - newName.isEmpty() ? - tr("The empty string as a name is reserved for the base state.") : - tr("Name already used in another state.")); + tr("Invalid State Name"), + newName.isEmpty() ? tr("The empty string as a name is reserved for the base state.") + : tr("Name already used in another state.")); }); reset(); } else { m_statesEditorView->renameState(internalNodeId, newName); } - } void StatesEditorModel::setWhenCondition(int internalNodeId, const QString &condition) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h index 11f28e9879..82cb3cecf7 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h @@ -6,7 +6,6 @@ #include <QAbstractListModel> #include <QPointer> - namespace QmlDesigner { class StatesEditorView; @@ -52,7 +51,6 @@ public: void reset(); - signals: void changedToState(int n); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index bf1aea547c..09fc55c96c 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+ OR GPL-3.0 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 { @@ -63,7 +63,9 @@ WidgetInfo StatesEditorView::widgetInfo() tr("States view")); } -void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) +void StatesEditorView::rootNodeTypeChanged(const QString & /*type*/, + int /*majorVersion*/, + int /*minorVersion*/) { checkForStatesAvailability(); } @@ -94,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); @@ -129,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); @@ -154,7 +158,7 @@ void StatesEditorView::removeState(int nodeId) stateNode.destroy(); } - } catch (const RewritingException &e) { + } catch (const RewritingException &e) { e.showException(); } } @@ -485,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(); } } @@ -499,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() @@ -522,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() @@ -552,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(); } } @@ -567,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()) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 1060829265..98a646ea43 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -13,14 +13,15 @@ class StatesEditorModel; class StatesEditorWidget; class AnnotationEditor; -class StatesEditorView : public AbstractView { +class StatesEditorView : public AbstractView +{ Q_OBJECT public: explicit StatesEditorView(ExternalDependenciesInterface &externalDependencies); ~StatesEditorView() override; - void renameState(int internalNodeId,const QString &newName); + void renameState(int internalNodeId, const QString &newName); void setWhenCondition(int internalNodeId, const QString &condition); void resetWhenCondition(int internalNodeId); void setStateAsDefault(int internalNodeId); @@ -38,7 +39,7 @@ public: // AbstractView void modelAttached(Model *model) override; void modelAboutToBeDetached(Model *model) override; - void propertiesRemoved(const QList<AbstractProperty>& propertyList) override; + void propertiesRemoved(const QList<AbstractProperty> &propertyList) override; void nodeAboutToBeRemoved(const ModelNode &removedNode) override; void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, @@ -52,9 +53,10 @@ public: const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) override; void nodeOrderChanged(const NodeListProperty &listProperty) override; - void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) override; - void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange) override; - + void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, + PropertyChangeFlags propertyChange) override; + void variantPropertiesChanged(const QList<VariantProperty> &propertyList, + PropertyChangeFlags propertyChange) override; // AbstractView void currentStateChanged(const ModelNode &node) override; @@ -68,7 +70,6 @@ public: ModelNode acitveStatesGroupNode() const; void setAcitveStatesGroupNode(const ModelNode &modelNode); - public slots: void synchonizeCurrentStateFromWidget(); void createNewState(); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index 19c39656fb..9a3c93fc5e 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "stateseditorwidget.h" +#include "stateseditorimageprovider.h" #include "stateseditormodel.h" #include "stateseditorview.h" -#include "stateseditorimageprovider.h" #include <designersettings.h> #include <theme.h> @@ -13,8 +13,8 @@ #include <invalidqmlsourceexception.h> -#include <coreplugin/messagebox.h> #include <coreplugin/icore.h> +#include <coreplugin/messagebox.h> #include <utils/environment.h> #include <utils/qtcassert.h> @@ -22,18 +22,16 @@ #include <QApplication> -#include <QFileInfo> -#include <QShortcut> #include <QBoxLayout> +#include <QFileInfo> #include <QKeySequence> +#include <QShortcut> #include <QQmlContext> #include <QQmlEngine> #include <QQuickItem> -enum { - debug = false -}; +enum { debug = false }; namespace QmlDesigner { @@ -70,10 +68,11 @@ void StatesEditorWidget::showAddNewStatesButton(bool showAddNewStatesButton) rootContext()->setContextProperty(QLatin1String("canAddNewStates"), showAddNewStatesButton); } -StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel) - : m_statesEditorView(statesEditorView), - m_imageProvider(nullptr), - m_qmlSourceUpdateShortcut(nullptr) +StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, + StatesEditorModel *statesEditorModel) + : m_statesEditorView(statesEditorView) + , m_imageProvider(nullptr) + , m_qmlSourceUpdateShortcut(nullptr) { m_imageProvider = new Internal::StatesEditorImageProvider; m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView()); @@ -89,11 +88,9 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); rootContext()->setContextProperties( - QVector<QQmlContext::PropertyPair>{ - {{"statesEditorModel"}, QVariant::fromValue(statesEditorModel)}, - {{"canAddNewStates"}, true} - } - ); + QVector<QQmlContext::PropertyPair>{{{"statesEditorModel"}, + QVariant::fromValue(statesEditorModel)}, + {{"canAddNewStates"}, true}}); Theme::setupTheme(engine()); @@ -147,14 +144,17 @@ void StatesEditorWidget::reloadQmlSource() Core::AsynchronousMessageBox::warning(tr("Cannot Create QtQuick View"), tr("StatesEditorWidget: %1 cannot be created.%2") - .arg(qmlSourcesPath(), errorString)); + .arg(qmlSourcesPath(), errorString)); return; } - connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget())); + connect(rootObject(), + SIGNAL(currentStateInternalIdChanged()), + m_statesEditorView.data(), + SLOT(synchonizeCurrentStateFromWidget())); connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState())); connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int))); m_statesEditorView.data()->synchonizeCurrentStateFromWidget(); } -} // QmlDesigner +} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h index ee9081dcdb..c0b16158dc 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h @@ -19,7 +19,9 @@ class StatesEditorModel; class StatesEditorView; class NodeInstanceView; -namespace Internal { class StatesEditorImageProvider; } +namespace Internal { +class StatesEditorImageProvider; +} class StatesEditorWidget : public StudioQuickWidget { @@ -52,4 +54,4 @@ private: QElapsedTimer m_usageTimer; }; -} +} // namespace QmlDesigner |