forked from qt-creator/qt-creator
Core: Static pattern for ProgressManager, clean up all users
Change-Id: I4af8793ca69a3af9e99baeb7c31dad3864266f91 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Core;
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJSTools;
|
||||
using namespace QmlJSTools::Internal;
|
||||
@@ -74,22 +75,22 @@ ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject(
|
||||
ModelManagerInterface::ProjectInfo projectInfo(project);
|
||||
ProjectExplorer::Target *activeTarget = 0;
|
||||
if (project) {
|
||||
Core::MimeDatabase *db = Core::ICore::mimeDatabase();
|
||||
QList<Core::MimeGlobPattern> globs;
|
||||
QList<Core::MimeType> mimeTypes = db->mimeTypes();
|
||||
foreach (const Core::MimeType &mimeType, mimeTypes)
|
||||
MimeDatabase *db = ICore::mimeDatabase();
|
||||
QList<MimeGlobPattern> globs;
|
||||
QList<MimeType> mimeTypes = db->mimeTypes();
|
||||
foreach (const MimeType &mimeType, mimeTypes)
|
||||
if (mimeType.type() == QLatin1String(Constants::QML_MIMETYPE)
|
||||
|| mimeType.subClassesOf().contains(QLatin1String(Constants::QML_MIMETYPE)))
|
||||
globs << mimeType.globPatterns();
|
||||
if (globs.isEmpty()) {
|
||||
globs.append(Core::MimeGlobPattern(QLatin1String("*.qbs")));
|
||||
globs.append(Core::MimeGlobPattern(QLatin1String("*.qml")));
|
||||
globs.append(Core::MimeGlobPattern(QLatin1String("*.qmltypes")));
|
||||
globs.append(Core::MimeGlobPattern(QLatin1String("*.qmlproject")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qbs")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qml")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qmltypes")));
|
||||
globs.append(MimeGlobPattern(QLatin1String("*.qmlproject")));
|
||||
}
|
||||
foreach (const QString &filePath
|
||||
, project->files(ProjectExplorer::Project::ExcludeGeneratedFiles))
|
||||
foreach (const Core::MimeGlobPattern &glob, globs)
|
||||
foreach (const MimeGlobPattern &glob, globs)
|
||||
if (glob.matches(filePath))
|
||||
projectInfo.sourceFiles << filePath;
|
||||
activeTarget = project->activeTarget();
|
||||
@@ -187,17 +188,17 @@ QmlJS::Document::Language QmlJSTools::languageOfFile(const QString &fileName)
|
||||
QStringList jsonSuffixes(QLatin1String("json"));
|
||||
QStringList qbsSuffixes(QLatin1String("qbs"));
|
||||
|
||||
if (Core::ICore::instance()) {
|
||||
Core::MimeDatabase *db = Core::ICore::mimeDatabase();
|
||||
Core::MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE));
|
||||
if (ICore::instance()) {
|
||||
MimeDatabase *db = ICore::mimeDatabase();
|
||||
MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE));
|
||||
mergeSuffixes(jsSuffixes, jsSourceTy.suffixes());
|
||||
Core::MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE));
|
||||
MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE));
|
||||
mergeSuffixes(qmlSuffixes, qmlSourceTy.suffixes());
|
||||
Core::MimeType qbsSourceTy = db->findByType(QLatin1String(Constants::QBS_MIMETYPE));
|
||||
MimeType qbsSourceTy = db->findByType(QLatin1String(Constants::QBS_MIMETYPE));
|
||||
mergeSuffixes(qbsSuffixes, qbsSourceTy.suffixes());
|
||||
Core::MimeType qmlProjectSourceTy = db->findByType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
|
||||
MimeType qmlProjectSourceTy = db->findByType(QLatin1String(Constants::QMLPROJECT_MIMETYPE));
|
||||
mergeSuffixes(qmlProjectSuffixes, qmlProjectSourceTy.suffixes());
|
||||
Core::MimeType jsonSourceTy = db->findByType(QLatin1String(Constants::JSON_MIMETYPE));
|
||||
MimeType jsonSourceTy = db->findByType(QLatin1String(Constants::JSON_MIMETYPE));
|
||||
mergeSuffixes(jsonSuffixes, jsonSourceTy.suffixes());
|
||||
}
|
||||
|
||||
@@ -217,15 +218,15 @@ QmlJS::Document::Language QmlJSTools::languageOfFile(const QString &fileName)
|
||||
QStringList QmlJSTools::qmlAndJsGlobPatterns()
|
||||
{
|
||||
QStringList pattern;
|
||||
if (Core::ICore::instance()) {
|
||||
Core::MimeDatabase *db = Core::ICore::mimeDatabase();
|
||||
Core::MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE));
|
||||
Core::MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE));
|
||||
if (ICore::instance()) {
|
||||
MimeDatabase *db = ICore::mimeDatabase();
|
||||
MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE));
|
||||
MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE));
|
||||
|
||||
QStringList pattern;
|
||||
foreach (const Core::MimeGlobPattern &glob, jsSourceTy.globPatterns())
|
||||
foreach (const MimeGlobPattern &glob, jsSourceTy.globPatterns())
|
||||
pattern << glob.pattern();
|
||||
foreach (const Core::MimeGlobPattern &glob, qmlSourceTy.globPatterns())
|
||||
foreach (const MimeGlobPattern &glob, qmlSourceTy.globPatterns())
|
||||
pattern << glob.pattern();
|
||||
} else {
|
||||
pattern << QLatin1String("*.qml") << QLatin1String("*.js");
|
||||
@@ -283,9 +284,9 @@ void ModelManager::delayedInitialization()
|
||||
|
||||
void ModelManager::loadQmlTypeDescriptions()
|
||||
{
|
||||
if (Core::ICore::instance()) {
|
||||
loadQmlTypeDescriptions(Core::ICore::resourcePath());
|
||||
loadQmlTypeDescriptions(Core::ICore::userResourcePath());
|
||||
if (ICore::instance()) {
|
||||
loadQmlTypeDescriptions(ICore::resourcePath());
|
||||
loadQmlTypeDescriptions(ICore::userResourcePath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,18 +318,18 @@ void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath)
|
||||
CppQmlTypesLoader::defaultLibraryObjects.unite(
|
||||
CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings));
|
||||
|
||||
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
||||
MessageManager *messageManager = MessageManager::instance();
|
||||
foreach (const QString &error, errors)
|
||||
messageManager->printToOutputPane(error, Core::MessageManager::Flash);
|
||||
messageManager->printToOutputPane(error, MessageManager::Flash);
|
||||
foreach (const QString &warning, warnings)
|
||||
messageManager->printToOutputPane(warning, Core::MessageManager::Flash);
|
||||
messageManager->printToOutputPane(warning, MessageManager::Flash);
|
||||
}
|
||||
|
||||
ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const
|
||||
{
|
||||
WorkingCopy workingCopy;
|
||||
Core::DocumentModel *documentModel = Core::EditorManager::documentModel();
|
||||
foreach (Core::IDocument *document, documentModel->openedDocuments()) {
|
||||
DocumentModel *documentModel = EditorManager::documentModel();
|
||||
foreach (IDocument *document, documentModel->openedDocuments()) {
|
||||
const QString key = document->filePath();
|
||||
if (TextEditor::BaseTextDocument *textDocument = qobject_cast<TextEditor::BaseTextDocument *>(document)) {
|
||||
// TODO the language should be a property on the document, not the editor
|
||||
@@ -383,7 +384,7 @@ QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles,
|
||||
m_synchronizer.addFuture(result);
|
||||
|
||||
if (sourceFiles.count() > 1) {
|
||||
Core::ICore::progressManager()->addTask(result, tr("Indexing"),
|
||||
ProgressManager::addTask(result, tr("Indexing"),
|
||||
QLatin1String(Constants::TASK_INDEX));
|
||||
}
|
||||
|
||||
@@ -889,9 +890,9 @@ void ModelManager::parse(QFutureInterface<void> &future,
|
||||
}
|
||||
|
||||
// Check whether fileMimeType is the same or extends knownMimeType
|
||||
bool ModelManager::matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType)
|
||||
bool ModelManager::matchesMimeType(const MimeType &fileMimeType, const MimeType &knownMimeType)
|
||||
{
|
||||
Core::MimeDatabase *db = Core::ICore::mimeDatabase();
|
||||
MimeDatabase *db = ICore::mimeDatabase();
|
||||
|
||||
const QStringList knownTypeNames = QStringList(knownMimeType.type()) + knownMimeType.aliases();
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
||||
using namespace Core;
|
||||
using namespace QmlJSTools;
|
||||
using namespace QmlJSTools::Internal;
|
||||
|
||||
@@ -73,8 +74,7 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(error)
|
||||
|
||||
if (!Core::ICore::mimeDatabase()
|
||||
->addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml"), error))
|
||||
if (!ICore::mimeDatabase()->addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml"), error))
|
||||
return false;
|
||||
|
||||
m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings
|
||||
@@ -83,8 +83,8 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
m_modelManager = new ModelManager(this);
|
||||
m_consoleManager = new QmlConsoleManager(this);
|
||||
|
||||
// Core::VCSManager *vcsManager = core->vcsManager();
|
||||
// Core::DocumentManager *fileManager = core->fileManager();
|
||||
// VCSManager *vcsManager = core->vcsManager();
|
||||
// DocumentManager *fileManager = core->fileManager();
|
||||
// connect(vcsManager, SIGNAL(repositoryChanged(QString)),
|
||||
// m_modelManager, SLOT(updateModifiedSourceFiles()));
|
||||
// connect(fileManager, SIGNAL(filesChangedInternally(QStringList)),
|
||||
@@ -97,8 +97,8 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
addAutoReleasedObject(new BasicBundleProvider);
|
||||
|
||||
// Menus
|
||||
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||
Core::ActionContainer *mqmljstools = Core::ActionManager::createMenu(Constants::M_TOOLS_QMLJS);
|
||||
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||
ActionContainer *mqmljstools = ActionManager::createMenu(Constants::M_TOOLS_QMLJS);
|
||||
QMenu *menu = mqmljstools->menu();
|
||||
menu->setTitle(tr("&QML/JS"));
|
||||
menu->setEnabled(true);
|
||||
@@ -106,16 +106,16 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
|
||||
// Update context in global context
|
||||
m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this);
|
||||
Core::Context globalContext(Core::Constants::C_GLOBAL);
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(
|
||||
m_resetCodeModelAction, Core::Id(Constants::RESET_CODEMODEL), globalContext);
|
||||
Context globalContext(Core::Constants::C_GLOBAL);
|
||||
Command *cmd = ActionManager::registerAction(
|
||||
m_resetCodeModelAction, Constants::RESET_CODEMODEL, globalContext);
|
||||
connect(m_resetCodeModelAction, SIGNAL(triggered()), m_modelManager, SLOT(resetCodeModel()));
|
||||
mqmljstools->addAction(cmd);
|
||||
|
||||
// watch task progress
|
||||
connect(Core::ICore::progressManager(), SIGNAL(taskStarted(QString)),
|
||||
connect(ProgressManager::instance(), SIGNAL(taskStarted(QString)),
|
||||
this, SLOT(onTaskStarted(QString)));
|
||||
connect(Core::ICore::progressManager(), SIGNAL(allTasksFinished(QString)),
|
||||
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(QString)),
|
||||
this, SLOT(onAllTasksFinished(QString)));
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user