aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksei German <aleksei.german@qt.io>2023-09-26 18:07:21 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2023-09-27 12:00:18 +0000
commit68e83af480fe5cdc76921960f48c5d6a7881b521 (patch)
tree2f3f9ec386851cf889b54bdde422ac371e46c9b8
parentd3907556bdf7c1262a0c4aca71d440b7e2e97ca4 (diff)
QmlDesigner: Fix unenclosed multistrings
Task-number: QDS-10681 Change-Id: Ide92c93c85f0d61b48c4c1cb0096cd8db201238d Reviewed-by: Aleksei German <aleksei.german@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp40
-rw-r--r--src/plugins/qmldesigner/components/bindingeditor/actioneditor.h2
2 files changed, 41 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp
index 0260077da8..8480115a3b 100644
--- a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp
+++ b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.cpp
@@ -100,7 +100,37 @@ QString ActionEditor::connectionValue() const
if (!m_dialog)
return {};
- return m_dialog->editorValue();
+ QString value = m_dialog->editorValue().trimmed();
+
+ //using parsed qml for unenclosed multistring (QDS-10681)
+ const QString testingString = QString("Item { \n"
+ " onWidthChanged: %1 \n"
+ "}")
+ .arg(value);
+
+ QmlJS::Document::MutablePtr firstAttemptDoc = QmlJS::Document::create({},
+ QmlJS::Dialect::QmlQtQuick2);
+ firstAttemptDoc->setSource(testingString);
+ firstAttemptDoc->parseQml();
+
+ if (!firstAttemptDoc->isParsedCorrectly()) {
+ const QString testingString2 = QString("Item { \n"
+ " onWidthChanged: { \n"
+ " %1 \n"
+ " } \n"
+ "} \n")
+ .arg(value);
+
+ QmlJS::Document::MutablePtr secondAttemptDoc = QmlJS::Document::create({},
+ QmlJS::Dialect::QmlQtQuick2);
+ secondAttemptDoc->setSource(testingString2);
+ secondAttemptDoc->parseQml();
+
+ if (secondAttemptDoc->isParsedCorrectly())
+ return QString("{\n%1\n}").arg(value);
+ }
+
+ return value;
}
void ActionEditor::setConnectionValue(const QString &text)
@@ -109,6 +139,14 @@ void ActionEditor::setConnectionValue(const QString &text)
m_dialog->setEditorValue(text);
}
+QString ActionEditor::rawConnectionValue() const
+{
+ if (!m_dialog)
+ return {};
+
+ return m_dialog->editorValue();
+}
+
bool ActionEditor::hasModelIndex() const
{
return m_index.isValid();
diff --git a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.h b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.h
index 29e5b1d99a..9a14ad2117 100644
--- a/src/plugins/qmldesigner/components/bindingeditor/actioneditor.h
+++ b/src/plugins/qmldesigner/components/bindingeditor/actioneditor.h
@@ -37,6 +37,8 @@ public:
QString connectionValue() const;
void setConnectionValue(const QString &text);
+ QString rawConnectionValue() const;
+
bool hasModelIndex() const;
void resetModelIndex();
QModelIndex modelIndex() const;