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);
|
QTC_ASSERT(canHandle(task), return);
|
||||||
Q_UNUSED(task);
|
Q_UNUSED(task);
|
||||||
TaskList::TaskListPlugin::instance()->stopMonitoring();
|
TaskList::TaskListPlugin::stopMonitoring();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *StopMonitoringHandler::createAction(QObject *parent) const
|
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)
|
bool TaskFile::open(QString *errorString, const QString &fileName)
|
||||||
{
|
{
|
||||||
setFilePath(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
|
ProjectExplorer::Project *TaskFile::context() const
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/task.h>
|
#include <projectexplorer/task.h>
|
||||||
#include <projectexplorer/taskhub.h>
|
#include <projectexplorer/taskhub.h>
|
||||||
@@ -119,9 +119,10 @@ public:
|
|||||||
}
|
}
|
||||||
description = unescape(description);
|
description = unescape(description);
|
||||||
|
|
||||||
hub->addTask(ProjectExplorer::Task(type, description,
|
ProjectExplorer::ProjectExplorerPlugin::taskHub()
|
||||||
Utils::FileName::fromUserInput(file), line,
|
->addTask(ProjectExplorer::Task(type, description,
|
||||||
Core::Id(Constants::TASKLISTTASK_ID)));
|
Utils::FileName::fromUserInput(file), line,
|
||||||
|
Core::Id(Constants::TASKLISTTASK_ID)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,6 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectExplorer::TaskHub *hub;
|
|
||||||
TaskFileFactory *fileFactory;
|
TaskFileFactory *fileFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -182,19 +182,13 @@ TaskListPlugin::~TaskListPlugin()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskListPlugin *TaskListPlugin::instance()
|
|
||||||
{
|
|
||||||
return m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
|
|
||||||
d->hub = ExtensionSystem::PluginManager::getObject<ProjectExplorer::TaskHub>();
|
|
||||||
|
|
||||||
//: Category under which tasklist tasks are listed in Issues view
|
//: 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))
|
if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage))
|
||||||
return false;
|
return false;
|
||||||
@@ -211,22 +205,22 @@ void TaskListPlugin::extensionsInitialized()
|
|||||||
bool TaskListPlugin::loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName)
|
bool TaskListPlugin::loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName)
|
||||||
{
|
{
|
||||||
clearTasks();
|
clearTasks();
|
||||||
return d->parseTaskFile(errorString, context, fileName);
|
return m_instance->d->parseTaskFile(errorString, context, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskListPlugin::monitorFile(ProjectExplorer::Project *context, const QString &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()
|
void TaskListPlugin::stopMonitoring()
|
||||||
{
|
{
|
||||||
d->fileFactory->closeAllFiles();
|
m_instance->d->fileFactory->closeAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListPlugin::clearTasks()
|
void TaskListPlugin::clearTasks()
|
||||||
{
|
{
|
||||||
d->hub->clearTasks(Core::Id(Constants::TASKLISTTASK_ID));
|
ProjectExplorer::ProjectExplorerPlugin::taskHub()->clearTasks(Core::Id(Constants::TASKLISTTASK_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(TaskListPlugin)
|
Q_EXPORT_PLUGIN(TaskListPlugin)
|
||||||
|
|||||||
@@ -50,17 +50,15 @@ public:
|
|||||||
TaskListPlugin();
|
TaskListPlugin();
|
||||||
~TaskListPlugin();
|
~TaskListPlugin();
|
||||||
|
|
||||||
static TaskListPlugin *instance();
|
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||||
|
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName);
|
static bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName);
|
||||||
bool monitorFile(ProjectExplorer::Project *context, const QString &fileName);
|
static bool monitorFile(ProjectExplorer::Project *context, const QString &fileName);
|
||||||
|
|
||||||
void stopMonitoring();
|
static void stopMonitoring();
|
||||||
void clearTasks();
|
static void clearTasks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static TaskListPlugin *m_instance;
|
static TaskListPlugin *m_instance;
|
||||||
|
|||||||
Reference in New Issue
Block a user