TaskHub: Move code to be more conform with other singletons

Make methods static and add a instance() method for Signals/Slots.

Remove ProjectExplorerPlugin::taskHub() method and use the new
ones instead.

Change-Id: Ifae24ff19579fc524cbd61bddc826095c443adfa
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Tobias Hunger
2013-08-15 12:14:46 +02:00
parent 53a49e3a64
commit 85b2017a69
21 changed files with 117 additions and 151 deletions

View File

@@ -60,7 +60,6 @@
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/taskhub.h>
#include <projectexplorer/projectexplorer.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/textfilewizard.h>
@@ -248,9 +247,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
void QmlJSEditorPlugin::extensionsInitialized()
{
TaskHub *taskHub = ProjectExplorerPlugin::taskHub();
taskHub->addCategory(Constants::TASK_CATEGORY_QML, tr("QML"));
taskHub->addCategory(Constants::TASK_CATEGORY_QML_ANALYSIS, tr("QML Analysis"), false);
TaskHub::addCategory(Constants::TASK_CATEGORY_QML, tr("QML"));
TaskHub::addCategory(Constants::TASK_CATEGORY_QML_ANALYSIS, tr("QML Analysis"), false);
}
ExtensionSystem::IPlugin::ShutdownFlag QmlJSEditorPlugin::aboutToShutdown()
@@ -348,9 +346,8 @@ void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor)
void QmlJSEditorPlugin::runSemanticScan()
{
m_qmlTaskManager->updateSemanticMessagesNow();
TaskHub *hub = ProjectExplorerPlugin::taskHub();
hub->setCategoryVisibility(Constants::TASK_CATEGORY_QML_ANALYSIS, true);
hub->requestPopup();
TaskHub::setCategoryVisibility(Constants::TASK_CATEGORY_QML_ANALYSIS, true);
TaskHub::requestPopup();
}
void QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate()

View File

@@ -51,11 +51,8 @@ namespace Internal {
QmlTaskManager::QmlTaskManager(QObject *parent) :
QObject(parent),
m_taskHub(0),
m_updatingSemantic(false)
{
m_taskHub = ProjectExplorer::ProjectExplorerPlugin::taskHub();
// displaying results incrementally leads to flickering
// connect(&m_messageCollector, SIGNAL(resultsReadyAt(int,int)),
// SLOT(displayResults(int,int)));
@@ -195,7 +192,7 @@ void QmlTaskManager::insertTask(const ProjectExplorer::Task &task)
QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(task.file.toString());
tasks.append(task);
m_docsWithTasks.insert(task.file.toString(), tasks);
m_taskHub->addTask(task);
ProjectExplorer::TaskHub::addTask(task);
}
void QmlTaskManager::removeTasksForFile(const QString &fileName)
@@ -203,16 +200,16 @@ void QmlTaskManager::removeTasksForFile(const QString &fileName)
if (m_docsWithTasks.contains(fileName)) {
const QList<ProjectExplorer::Task> tasks = m_docsWithTasks.value(fileName);
foreach (const ProjectExplorer::Task &task, tasks)
m_taskHub->removeTask(task);
ProjectExplorer::TaskHub::removeTask(task);
m_docsWithTasks.remove(fileName);
}
}
void QmlTaskManager::removeAllTasks(bool clearSemantic)
{
m_taskHub->clearTasks(Constants::TASK_CATEGORY_QML);
ProjectExplorer::TaskHub::clearTasks(Constants::TASK_CATEGORY_QML);
if (clearSemantic)
m_taskHub->clearTasks(Constants::TASK_CATEGORY_QML_ANALYSIS);
ProjectExplorer::TaskHub::clearTasks(Constants::TASK_CATEGORY_QML_ANALYSIS);
m_docsWithTasks.clear();
}

View File

@@ -89,7 +89,6 @@ private:
bool updateSemantic);
private:
ProjectExplorer::TaskHub *m_taskHub;
QHash<QString, QList<ProjectExplorer::Task> > m_docsWithTasks;
QFutureWatcher<FileErrorMessages> m_messageCollector;
QTimer m_updateDelay;