diff --git a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml index 057e08e305b..075c97641a1 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialogForm.qml @@ -223,7 +223,7 @@ Column { id: code anchors.fill: parent anchors.margins: 4 - text: backend.source + text: backend.indentedSource color: StudioTheme.Values.themeTextColor font.pixelSize: StudioTheme.Values.myFontSize wrapMode: Text.WordWrap diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index f2ef1ca02cc..f07f61babbf 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -11,18 +11,21 @@ #include #include #include -#include -#include +#include #include #include #include #include +#include +#include #include -#include #include +#include #include +#include +#include #include namespace { @@ -911,6 +914,19 @@ ConditionListModel *ConnectionModelBackendDelegate::conditionListModel() return &m_conditionListModel; } +QString ConnectionModelBackendDelegate::indentedSource() const +{ + if (m_source.isEmpty()) + return {}; + + QTextDocument doc(m_source); + QTextCursor cursor(&doc); + IndentingTextEditModifier mod(&doc, cursor); + + mod.indent(0, m_source.length() - 1); + return mod.text(); +} + QString ConnectionModelBackendDelegate::source() const { return m_source; diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h index 300fcb061a4..03ee4e7144c 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h @@ -266,6 +266,7 @@ class ConnectionModelBackendDelegate : public QObject Q_PROPERTY(bool hasCondition READ hasCondition NOTIFY hasConditionChanged) Q_PROPERTY(bool hasElse READ hasElse NOTIFY hasElseChanged) Q_PROPERTY(QString source READ source NOTIFY sourceChanged) + Q_PROPERTY(QString indentedSource READ indentedSource NOTIFY sourceChanged) Q_PROPERTY(PropertyTreeModel *propertyTreeModel READ propertyTreeModel CONSTANT) Q_PROPERTY(PropertyListProxyModel *propertyListProxyModel READ propertyListProxyModel CONSTANT) @@ -308,6 +309,7 @@ private: ConnectionModelStatementDelegate *okStatement(); ConnectionModelStatementDelegate *koStatement(); ConditionListModel *conditionListModel(); + QString indentedSource() const; QString source() const; void setSource(const QString &source);