forked from qt-creator/qt-creator
QmlDesigner: Add code preview indentation
Task-number: QDS-10680 Change-Id: I61528f517ed4baef2115fbddf1b014b9f7f966d2 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -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
|
||||
|
@@ -11,18 +11,21 @@
|
||||
#include <nodeabstractproperty.h>
|
||||
#include <nodelistproperty.h>
|
||||
#include <nodemetainfo.h>
|
||||
#include <qmldesignerconstants.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <plaintexteditmodifier.h>
|
||||
#include <rewritertransaction.h>
|
||||
#include <rewriterview.h>
|
||||
#include <signalhandlerproperty.h>
|
||||
#include <variantproperty.h>
|
||||
#include <qmldesignerconstants.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
#include <QTimer>
|
||||
|
||||
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;
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user