forked from qt-creator/qt-creator
TaskListPlugin: Clean up APIs
Clean up singleton APIs. Task-number: QTCREATORBUG-9761 Change-Id: I42b691449dea75dc88f37db107221d4421f73529 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -54,7 +54,7 @@ void StopMonitoringHandler::handle(const ProjectExplorer::Task &task)
|
||||
{
|
||||
QTC_ASSERT(canHandle(task), return);
|
||||
Q_UNUSED(task);
|
||||
TaskList::TaskListPlugin::instance()->stopMonitoring();
|
||||
TaskList::TaskListPlugin::stopMonitoring();
|
||||
}
|
||||
|
||||
QAction *StopMonitoringHandler::createAction(QObject *parent) const
|
||||
|
||||
@@ -101,7 +101,7 @@ bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
||||
bool TaskFile::open(QString *errorString, const QString &fileName)
|
||||
{
|
||||
setFilePath(fileName);
|
||||
return TaskList::TaskListPlugin::instance()->loadFile(errorString, m_context, fileName);
|
||||
return TaskList::TaskListPlugin::loadFile(errorString, m_context, fileName);
|
||||
}
|
||||
|
||||
ProjectExplorer::Project *TaskFile::context() const
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/task.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
@@ -119,7 +119,8 @@ public:
|
||||
}
|
||||
description = unescape(description);
|
||||
|
||||
hub->addTask(ProjectExplorer::Task(type, description,
|
||||
ProjectExplorer::ProjectExplorerPlugin::taskHub()
|
||||
->addTask(ProjectExplorer::Task(type, description,
|
||||
Utils::FileName::fromUserInput(file), line,
|
||||
Core::Id(Constants::TASKLISTTASK_ID)));
|
||||
}
|
||||
@@ -163,7 +164,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectExplorer::TaskHub *hub;
|
||||
TaskFileFactory *fileFactory;
|
||||
};
|
||||
|
||||
@@ -182,19 +182,13 @@ TaskListPlugin::~TaskListPlugin()
|
||||
delete d;
|
||||
}
|
||||
|
||||
TaskListPlugin *TaskListPlugin::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
|
||||
d->hub = ExtensionSystem::PluginManager::getObject<ProjectExplorer::TaskHub>();
|
||||
|
||||
//: Category under which tasklist tasks are listed in Issues view
|
||||
d->hub->addCategory(Core::Id(Constants::TASKLISTTASK_ID), tr("My Tasks"));
|
||||
ProjectExplorer::ProjectExplorerPlugin::taskHub()
|
||||
->addCategory(Core::Id(Constants::TASKLISTTASK_ID), tr("My Tasks"));
|
||||
|
||||
if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
@@ -211,22 +205,22 @@ void TaskListPlugin::extensionsInitialized()
|
||||
bool TaskListPlugin::loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName)
|
||||
{
|
||||
clearTasks();
|
||||
return d->parseTaskFile(errorString, context, fileName);
|
||||
return m_instance->d->parseTaskFile(errorString, context, fileName);
|
||||
}
|
||||
|
||||
bool TaskListPlugin::monitorFile(ProjectExplorer::Project *context, const QString &fileName)
|
||||
{
|
||||
return d->fileFactory->open(context, fileName);
|
||||
return m_instance->d->fileFactory->open(context, fileName);
|
||||
}
|
||||
|
||||
void TaskListPlugin::stopMonitoring()
|
||||
{
|
||||
d->fileFactory->closeAllFiles();
|
||||
m_instance->d->fileFactory->closeAllFiles();
|
||||
}
|
||||
|
||||
void TaskListPlugin::clearTasks()
|
||||
{
|
||||
d->hub->clearTasks(Core::Id(Constants::TASKLISTTASK_ID));
|
||||
ProjectExplorer::ProjectExplorerPlugin::taskHub()->clearTasks(Core::Id(Constants::TASKLISTTASK_ID));
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(TaskListPlugin)
|
||||
|
||||
@@ -50,17 +50,15 @@ public:
|
||||
TaskListPlugin();
|
||||
~TaskListPlugin();
|
||||
|
||||
static TaskListPlugin *instance();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||
|
||||
void extensionsInitialized();
|
||||
|
||||
bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName);
|
||||
bool monitorFile(ProjectExplorer::Project *context, const QString &fileName);
|
||||
static bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName);
|
||||
static bool monitorFile(ProjectExplorer::Project *context, const QString &fileName);
|
||||
|
||||
void stopMonitoring();
|
||||
void clearTasks();
|
||||
static void stopMonitoring();
|
||||
static void clearTasks();
|
||||
|
||||
private:
|
||||
static TaskListPlugin *m_instance;
|
||||
|
||||
Reference in New Issue
Block a user