forked from qt-creator/qt-creator
QmlDesigner: Fix unenclosed multistrings
Task-number: QDS-10681 Change-Id: Ide92c93c85f0d61b48c4c1cb0096cd8db201238d Reviewed-by: Aleksei German <aleksei.german@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
d3907556bd
commit
68e83af480
@@ -100,7 +100,37 @@ QString ActionEditor::connectionValue() const
|
|||||||
if (!m_dialog)
|
if (!m_dialog)
|
||||||
return {};
|
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)
|
void ActionEditor::setConnectionValue(const QString &text)
|
||||||
@@ -109,6 +139,14 @@ void ActionEditor::setConnectionValue(const QString &text)
|
|||||||
m_dialog->setEditorValue(text);
|
m_dialog->setEditorValue(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ActionEditor::rawConnectionValue() const
|
||||||
|
{
|
||||||
|
if (!m_dialog)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return m_dialog->editorValue();
|
||||||
|
}
|
||||||
|
|
||||||
bool ActionEditor::hasModelIndex() const
|
bool ActionEditor::hasModelIndex() const
|
||||||
{
|
{
|
||||||
return m_index.isValid();
|
return m_index.isValid();
|
||||||
|
@@ -37,6 +37,8 @@ public:
|
|||||||
QString connectionValue() const;
|
QString connectionValue() const;
|
||||||
void setConnectionValue(const QString &text);
|
void setConnectionValue(const QString &text);
|
||||||
|
|
||||||
|
QString rawConnectionValue() const;
|
||||||
|
|
||||||
bool hasModelIndex() const;
|
bool hasModelIndex() const;
|
||||||
void resetModelIndex();
|
void resetModelIndex();
|
||||||
QModelIndex modelIndex() const;
|
QModelIndex modelIndex() const;
|
||||||
|
Reference in New Issue
Block a user