Skip to content
GitLab
Menu
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
8ab27353
Commit
8ab27353
authored
Jan 20, 2011
by
Christian Kamm
Browse files
QmlJS: Be more efficient when looking for QML libraries.
Reviewed-by: Erik Verbruggen
parent
abff92c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljstools/qmljsmodelmanager.cpp
View file @
8ab27353
...
...
@@ -357,9 +357,7 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
if
(
import
.
type
()
!=
Interpreter
::
ImportInfo
::
LibraryImport
)
continue
;
foreach
(
const
QString
&
importPath
,
importPaths
)
{
QDir
dir
(
importPath
);
dir
.
cd
(
import
.
name
());
const
QString
targetPath
=
dir
.
absolutePath
();
const
QString
targetPath
=
QDir
(
importPath
).
filePath
(
import
.
name
());
// if we know there is a library, done
if
(
snapshot
.
libraryInfo
(
targetPath
).
isValid
())
...
...
@@ -367,30 +365,37 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
if
(
newLibraries
->
contains
(
targetPath
))
break
;
// if there is a qmldir file, we found a new library!
if
(
dir
.
exists
(
"qmldir"
))
{
QFile
qmldirFile
(
dir
.
filePath
(
"qmldir"
));
qmldirFile
.
open
(
QFile
::
ReadOnly
);
QString
qmldirData
=
QString
::
fromUtf8
(
qmldirFile
.
readAll
());
QmlDirParser
qmldirParser
;
qmldirParser
.
setSource
(
qmldirData
);
qmldirParser
.
parse
();
const
QString
libraryPath
=
QFileInfo
(
qmldirFile
).
absolutePath
();
newLibraries
->
insert
(
libraryPath
);
modelManager
->
updateLibraryInfo
(
libraryPath
,
LibraryInfo
(
qmldirParser
));
// scan the qml files in the library
foreach
(
const
QmlDirParser
::
Component
&
component
,
qmldirParser
.
components
())
{
if
(
!
component
.
fileName
.
isEmpty
())
{
QFileInfo
componentFileInfo
(
dir
.
filePath
(
component
.
fileName
));
const
QString
path
=
componentFileInfo
.
absolutePath
();
if
(
!
scannedPaths
->
contains
(
path
))
{
*
importedFiles
+=
qmlFilesInDirectory
(
path
);
scannedPaths
->
insert
(
path
);
}
// check for a qmldir file
const
QDir
targetDir
(
targetPath
);
QFile
qmldirFile
(
targetDir
.
filePath
(
QLatin1String
(
"qmldir"
)));
if
(
!
qmldirFile
.
exists
())
continue
;
#ifdef Q_OS_WIN
// QTCREATORBUG-3402 - be case sensitive even here?
#endif
// found a new library!
qmldirFile
.
open
(
QFile
::
ReadOnly
);
QString
qmldirData
=
QString
::
fromUtf8
(
qmldirFile
.
readAll
());
QmlDirParser
qmldirParser
;
qmldirParser
.
setSource
(
qmldirData
);
qmldirParser
.
parse
();
const
QString
libraryPath
=
QFileInfo
(
qmldirFile
).
absolutePath
();
newLibraries
->
insert
(
libraryPath
);
modelManager
->
updateLibraryInfo
(
libraryPath
,
LibraryInfo
(
qmldirParser
));
// scan the qml files in the library
foreach
(
const
QmlDirParser
::
Component
&
component
,
qmldirParser
.
components
())
{
if
(
!
component
.
fileName
.
isEmpty
())
{
const
QFileInfo
componentFileInfo
(
targetDir
.
filePath
(
component
.
fileName
));
const
QString
path
=
QDir
::
cleanPath
(
componentFileInfo
.
absolutePath
());
if
(
!
scannedPaths
->
contains
(
path
))
{
*
importedFiles
+=
qmlFilesInDirectory
(
path
);
scannedPaths
->
insert
(
path
);
}
}
}
...
...
@@ -544,7 +549,11 @@ void ModelManager::updateImportPaths()
QMapIterator
<
ProjectExplorer
::
Project
*
,
ProjectInfo
>
it
(
m_projects
);
while
(
it
.
hasNext
())
{
it
.
next
();
m_allImportPaths
+=
it
.
value
().
importPaths
;
foreach
(
const
QString
&
path
,
it
.
value
().
importPaths
)
{
const
QString
canonicalPath
=
QFileInfo
(
path
).
canonicalFilePath
();
if
(
!
canonicalPath
.
isEmpty
())
m_allImportPaths
+=
canonicalPath
;
}
}
m_allImportPaths
+=
m_defaultImportPaths
;
m_allImportPaths
.
removeDuplicates
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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