forked from qt-creator/qt-creator
QmlDesigner: Process add/remove imports actions together
Task-number: QDS-10529 Change-Id: Icd4efdb4c289f686b2e6eaed67432b662ba2ad29 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -176,8 +176,8 @@ signals:
|
||||
void modelInterfaceProjectUpdated();
|
||||
|
||||
protected: // functions
|
||||
void importAdded(const Import &import);
|
||||
void importRemoved(const Import &import);
|
||||
void importsAdded(const Imports &imports);
|
||||
void importsRemoved(const Imports &imports);
|
||||
|
||||
Internal::ModelToTextMerger *modelToTextMerger() const;
|
||||
Internal::TextToModelMerger *textToModelMerger() const;
|
||||
|
@@ -112,16 +112,20 @@ void ModelToTextMerger::nodeTypeChanged(const ModelNode &node,const QString &/*t
|
||||
schedule(new ChangeTypeRewriteAction(node));
|
||||
}
|
||||
|
||||
void ModelToTextMerger::addImport(const Import &import)
|
||||
void ModelToTextMerger::addImports(const Imports &imports)
|
||||
{
|
||||
for (const Import &import : imports) {
|
||||
if (!import.isEmpty())
|
||||
schedule(new AddImportRewriteAction(import));
|
||||
}
|
||||
}
|
||||
|
||||
void ModelToTextMerger::removeImport(const Import &import)
|
||||
void ModelToTextMerger::removeImports(const Imports &imports)
|
||||
{
|
||||
for (const Import &import : imports) {
|
||||
if (!import.isEmpty())
|
||||
schedule(new RemoveImportRewriteAction(import));
|
||||
}
|
||||
}
|
||||
|
||||
void ModelToTextMerger::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
|
||||
|
@@ -38,8 +38,8 @@ public:
|
||||
void nodeSlidAround(const ModelNode &movingNode, const ModelNode &inFrontOfNode);
|
||||
void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion);
|
||||
|
||||
void addImport(const Import &import);
|
||||
void removeImport(const Import &import);
|
||||
void addImports(const Imports &import);
|
||||
void removeImports(const Imports &imports);
|
||||
|
||||
protected:
|
||||
RewriterView *view();
|
||||
|
@@ -261,40 +261,29 @@ void RewriterView::nodeReparented(const ModelNode &node, const NodeAbstractPrope
|
||||
|
||||
void RewriterView::importsChanged(const Imports &addedImports, const Imports &removedImports)
|
||||
{
|
||||
for (const Import &import : addedImports)
|
||||
importAdded(import);
|
||||
|
||||
for (const Import &import : removedImports)
|
||||
importRemoved(import);
|
||||
|
||||
importsAdded(addedImports);
|
||||
importsRemoved(removedImports);
|
||||
}
|
||||
|
||||
void RewriterView::importAdded(const Import &import)
|
||||
void RewriterView::importsAdded(const Imports &imports)
|
||||
{
|
||||
Q_ASSERT(textModifier());
|
||||
if (textToModelMerger()->isActive())
|
||||
return;
|
||||
|
||||
if (import.url() == QLatin1String("Qt")) {
|
||||
for (const Import &import : model()->imports()) {
|
||||
if (import.url() == QLatin1String("QtQuick"))
|
||||
return; //QtQuick magic we do not have to add an import for Qt
|
||||
}
|
||||
}
|
||||
|
||||
modelToTextMerger()->addImport(import);
|
||||
modelToTextMerger()->addImports(imports);
|
||||
|
||||
if (!isModificationGroupActive())
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void RewriterView::importRemoved(const Import &import)
|
||||
void RewriterView::importsRemoved(const Imports &imports)
|
||||
{
|
||||
Q_ASSERT(textModifier());
|
||||
if (textToModelMerger()->isActive())
|
||||
return;
|
||||
|
||||
modelToTextMerger()->removeImport(import);
|
||||
modelToTextMerger()->removeImports(imports);
|
||||
|
||||
if (!isModificationGroupActive())
|
||||
applyChanges();
|
||||
|
@@ -1803,7 +1803,7 @@ void ModelValidator::modelMissesImport([[maybe_unused]] const QmlDesigner::Impor
|
||||
|
||||
void ModelValidator::importAbsentInQMl([[maybe_unused]] const QmlDesigner::Import &import)
|
||||
{
|
||||
Q_ASSERT(! m_merger->view()->model()->imports().contains(import));
|
||||
QTC_ASSERT(!m_merger->view()->model()->imports().contains(import), return);
|
||||
}
|
||||
|
||||
void ModelValidator::bindingExpressionsDiffer([[maybe_unused]] BindingProperty &modelProperty,
|
||||
|
Reference in New Issue
Block a user