Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
fe2e5432
Commit
fe2e5432
authored
May 16, 2011
by
Thomas Hartmann
Browse files
QmlDesigner.model: adding hasImport
The method hasImport() is able to ignore alias imports.
parent
0b0b485f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/designercore/include/model.h
View file @
fe2e5432
...
...
@@ -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
;
...
...
src/plugins/qmldesigner/designercore/model/model.cpp
View file @
fe2e5432
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment