forked from qt-creator/qt-creator
QmlProject: Simplify interface a bit
Remove unneeded code and don't repeately fetch a singleton value. Change-Id: I718a44c28be7ef8718f813f987f45b32cbcd7ad5 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -145,8 +145,8 @@ void QmlProject::parseProject(RefreshOptions options)
|
|||||||
}
|
}
|
||||||
if (m_projectItem) {
|
if (m_projectItem) {
|
||||||
m_projectItem.data()->setSourceDirectory(projectDir().path());
|
m_projectItem.data()->setSourceDirectory(projectDir().path());
|
||||||
if (modelManager())
|
if (auto modelManager = QmlJS::ModelManagerInterface::instance())
|
||||||
modelManager()->updateSourceFiles(m_projectItem.data()->files(), true);
|
modelManager->updateSourceFiles(m_projectItem.data()->files(), true);
|
||||||
|
|
||||||
QString mainFilePath = m_projectItem.data()->mainFile();
|
QString mainFilePath = m_projectItem.data()->mainFile();
|
||||||
if (!mainFilePath.isEmpty()) {
|
if (!mainFilePath.isEmpty()) {
|
||||||
@@ -180,37 +180,21 @@ void QmlProject::refresh(RefreshOptions options)
|
|||||||
if (options & Files)
|
if (options & Files)
|
||||||
generateProjectTree();
|
generateProjectTree();
|
||||||
|
|
||||||
if (!modelManager())
|
auto modelManager = QmlJS::ModelManagerInterface::instance();
|
||||||
|
if (!modelManager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
||||||
modelManager()->defaultProjectInfoForProject(this);
|
modelManager->defaultProjectInfoForProject(this);
|
||||||
foreach (const QString &searchPath, customImportPaths())
|
foreach (const QString &searchPath, customImportPaths())
|
||||||
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
|
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(searchPath),
|
||||||
QmlJS::Dialect::Qml);
|
QmlJS::Dialect::Qml);
|
||||||
|
|
||||||
modelManager()->updateProjectInfo(projectInfo, this);
|
modelManager->updateProjectInfo(projectInfo, this);
|
||||||
|
|
||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmlProject::convertToAbsoluteFiles(const QStringList &paths) const
|
|
||||||
{
|
|
||||||
const QDir projectDir(projectDirectory().toString());
|
|
||||||
QStringList absolutePaths;
|
|
||||||
foreach (const QString &file, paths) {
|
|
||||||
QFileInfo fileInfo(projectDir, file);
|
|
||||||
absolutePaths.append(fileInfo.absoluteFilePath());
|
|
||||||
}
|
|
||||||
absolutePaths.removeDuplicates();
|
|
||||||
return absolutePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlJS::ModelManagerInterface *QmlProject::modelManager() const
|
|
||||||
{
|
|
||||||
return QmlJS::ModelManagerInterface::instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList QmlProject::files() const
|
QStringList QmlProject::files() const
|
||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
@@ -265,8 +249,10 @@ QmlProject::QmlImport QmlProject::defaultImport() const
|
|||||||
void QmlProject::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
|
void QmlProject::refreshFiles(const QSet<QString> &/*added*/, const QSet<QString> &removed)
|
||||||
{
|
{
|
||||||
refresh(Files);
|
refresh(Files);
|
||||||
if (!removed.isEmpty() && modelManager())
|
if (!removed.isEmpty()) {
|
||||||
modelManager()->removeFiles(removed.toList());
|
if (auto modelManager = QmlJS::ModelManagerInterface::instance())
|
||||||
|
modelManager->removeFiles(removed.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlProject::displayName() const
|
QString QmlProject::displayName() const
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
namespace ProjectExplorer { class RunConfiguration; }
|
namespace ProjectExplorer { class RunConfiguration; }
|
||||||
namespace QmlJS { class ModelManagerInterface; }
|
|
||||||
|
|
||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
|
|
||||||
@@ -91,8 +90,6 @@ private:
|
|||||||
|
|
||||||
// plain format
|
// plain format
|
||||||
void parseProject(RefreshOptions options);
|
void parseProject(RefreshOptions options);
|
||||||
QStringList convertToAbsoluteFiles(const QStringList &paths) const;
|
|
||||||
QmlJS::ModelManagerInterface *modelManager() const;
|
|
||||||
|
|
||||||
QmlImport m_defaultImport;
|
QmlImport m_defaultImport;
|
||||||
ProjectExplorer::Target *m_activeTarget = 0;
|
ProjectExplorer::Target *m_activeTarget = 0;
|
||||||
|
Reference in New Issue
Block a user