Commit fe2e5432 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.model: adding hasImport

The method hasImport() is able to ignore alias imports.
parent 0b0b485f
......@@ -104,6 +104,7 @@ public:
// Imports:
QList<Import> imports() const;
void changeImports(const QList<Import> &importsToBeAdded, const QList<Import> &importsToBeRemoved);
bool hasImport(const Import &import, bool ignoreAlias = true);
RewriterView *rewriterView() const;
......@@ -1723,6 +1723,24 @@ void Model::changeImports(const QList<Import> &importsToBeAdded, const QList<Imp
m_d->changeImports(importsToBeAdded, importsToBeRemoved);
bool Model::hasImport(const Import &import, bool ignoreAlias)
if (imports().contains(import))
return true;
if (!ignoreAlias)
return false;
foreach (const Import &existingImport, imports()) {
if (existingImport.isFileImport() && import.isFileImport())
if (existingImport.file() == import.file() && existingImport.version() == import.version())
return true;
if (existingImport.isLibraryImport() && import.isLibraryImport())
if (existingImport.url() == import.url() && existingImport.version() == import.version())
return true;
return false;
RewriterView *Model::rewriterView() const
return m_d->rewriterView();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment