forked from qt-creator/qt-creator
itaskhandler: interface cleanup
Change-Id: Ib85950a4715d6eaf4225bd8dbcc0c2a91b20dc1d Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -197,11 +197,11 @@ public:
|
||||
class DebugInfoTaskHandler : public ProjectExplorer::ITaskHandler
|
||||
{
|
||||
public:
|
||||
DebugInfoTaskHandler(GdbEngine *engine)
|
||||
: ITaskHandler(_("Debuginfo")), m_engine(engine)
|
||||
explicit DebugInfoTaskHandler(GdbEngine *engine)
|
||||
: m_engine(engine)
|
||||
{}
|
||||
|
||||
bool canHandle(const Task &task)
|
||||
bool canHandle(const Task &task) const
|
||||
{
|
||||
return m_debugInfoTasks.contains(task.taskId);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
m_debugInfoTasks[id] = task;
|
||||
}
|
||||
|
||||
QAction *createAction(QObject *parent = 0)
|
||||
QAction *createAction(QObject *parent) const
|
||||
{
|
||||
QAction *action = new QAction(DebuggerPlugin::tr("Install &Debug Information"), parent);
|
||||
action->setToolTip(DebuggerPlugin::tr("This tries to install missing debug information."));
|
||||
|
@@ -43,10 +43,6 @@
|
||||
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
CopyTaskHandler::CopyTaskHandler() :
|
||||
ITaskHandler(QLatin1String(Core::Constants::COPY))
|
||||
{ }
|
||||
|
||||
void CopyTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
{
|
||||
QString type;
|
||||
@@ -68,7 +64,7 @@ void CopyTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
+ type + task.description);
|
||||
}
|
||||
|
||||
QAction *CopyTaskHandler::createAction(QObject *parent)
|
||||
QAction *CopyTaskHandler::createAction(QObject *parent) const
|
||||
{
|
||||
QAction *copyAction = new QAction(tr("&Copy", "Name of the action triggering the copytaskhandler"), parent);
|
||||
copyAction->setToolTip(tr("Copy task to clipboard"));
|
||||
|
@@ -43,10 +43,11 @@ class CopyTaskHandler : public ITaskHandler
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CopyTaskHandler();
|
||||
CopyTaskHandler() {}
|
||||
|
||||
bool canHandle(const Task &) const { return true; }
|
||||
void handle(const Task &task);
|
||||
QAction *createAction(QObject *parent = 0);
|
||||
QAction *createAction(QObject *parent) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -50,21 +50,12 @@ class PROJECTEXPLORER_EXPORT ITaskHandler : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ITaskHandler(const QString &id) :
|
||||
m_id(id)
|
||||
{ }
|
||||
explicit ITaskHandler() {}
|
||||
|
||||
QString id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
virtual bool canHandle(const Task &) { return true; }
|
||||
virtual bool isDefaultHandler() const { return false; }
|
||||
virtual bool canHandle(const Task &) const = 0;
|
||||
virtual void handle(const Task &) = 0;
|
||||
virtual QAction *createAction(QObject *parent = 0) = 0;
|
||||
|
||||
private:
|
||||
const QString m_id;
|
||||
virtual QAction *createAction(QObject *parent) const = 0;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -84,10 +84,6 @@ const char RENAMEFILE[] = "ProjectExplorer.RenameFile";
|
||||
const char SETSTARTUP[] = "ProjectExplorer.SetStartup";
|
||||
const char PROJECTTREE_COLLAPSE_ALL[] = "ProjectExplorer.CollapseAll";
|
||||
|
||||
const char SHOW_TASK_IN_EDITOR[] = "ProjectExplorer.ShowTaskInEditor";
|
||||
const char VCS_ANNOTATE_TASK[] = "ProjectExplorer.VcsAnnotateTask";
|
||||
const char SHOW_TASK_OUTPUT[] = "ProjectExplorer.ShowTaskOutput";
|
||||
|
||||
const char SELECTTARGET[] = "ProjectExplorer.SelectTarget";
|
||||
const char SELECTTARGETQUICK[] = "ProjectExplorer.SelectTargetQuick";
|
||||
|
||||
|
@@ -42,11 +42,7 @@
|
||||
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
ShowInEditorTaskHandler::ShowInEditorTaskHandler() :
|
||||
ITaskHandler(QLatin1String(Constants::SHOW_TASK_IN_EDITOR))
|
||||
{ }
|
||||
|
||||
bool ShowInEditorTaskHandler::canHandle(const ProjectExplorer::Task &task)
|
||||
bool ShowInEditorTaskHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||
{
|
||||
if (task.file.isEmpty())
|
||||
return false;
|
||||
@@ -60,7 +56,7 @@ void ShowInEditorTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
TextEditor::BaseTextEditorWidget::openEditorAt(fi.canonicalFilePath(), task.movedLine);
|
||||
}
|
||||
|
||||
QAction *ShowInEditorTaskHandler::createAction(QObject *parent)
|
||||
QAction *ShowInEditorTaskHandler::createAction(QObject *parent) const
|
||||
{
|
||||
QAction *showAction = new QAction(tr("&Show in Editor"), parent);
|
||||
showAction->setToolTip(tr("Show task location in an editor."));
|
||||
|
@@ -43,11 +43,12 @@ class ShowInEditorTaskHandler : public ITaskHandler
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShowInEditorTaskHandler();
|
||||
ShowInEditorTaskHandler() {}
|
||||
|
||||
bool canHandle(const Task &);
|
||||
bool isDefaultHandler() const { return true; }
|
||||
bool canHandle(const Task &) const;
|
||||
void handle(const Task &task);
|
||||
QAction *createAction(QObject *parent = 0);
|
||||
QAction *createAction(QObject *parent ) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -42,13 +42,12 @@
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
ShowOutputTaskHandler::ShowOutputTaskHandler(CompileOutputWindow *window) :
|
||||
ITaskHandler(QLatin1String(Constants::SHOW_TASK_OUTPUT)),
|
||||
m_window(window)
|
||||
{
|
||||
Q_ASSERT(m_window);
|
||||
}
|
||||
|
||||
bool ShowOutputTaskHandler::canHandle(const ProjectExplorer::Task &task)
|
||||
bool ShowOutputTaskHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||
{
|
||||
return m_window->knowsPositionOf(task);
|
||||
}
|
||||
@@ -60,7 +59,7 @@ void ShowOutputTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
m_window->showPositionOf(task);
|
||||
}
|
||||
|
||||
QAction *ShowOutputTaskHandler::createAction(QObject *parent)
|
||||
QAction *ShowOutputTaskHandler::createAction(QObject *parent) const
|
||||
{
|
||||
QAction *outputAction = new QAction(tr("Show &Output"), parent);
|
||||
outputAction->setToolTip(tr("Show output generating this issue."));
|
||||
|
@@ -45,11 +45,11 @@ class ShowOutputTaskHandler : public ITaskHandler
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShowOutputTaskHandler(CompileOutputWindow *);
|
||||
explicit ShowOutputTaskHandler(CompileOutputWindow *window);
|
||||
|
||||
bool canHandle(const Task &);
|
||||
bool canHandle(const Task &) const;
|
||||
void handle(const Task &task);
|
||||
QAction *createAction(QObject *parent = 0);
|
||||
QAction *createAction(QObject *parent) const;
|
||||
|
||||
private:
|
||||
CompileOutputWindow * m_window;
|
||||
|
@@ -427,7 +427,7 @@ void TaskWindow::triggerDefaultHandler(const QModelIndex &index)
|
||||
if (!d->m_defaultHandler) {
|
||||
QList<ITaskHandler *> handlers = ExtensionSystem::PluginManager::instance()->getObjects<ITaskHandler>();
|
||||
foreach(ITaskHandler *handler, handlers) {
|
||||
if (handler->id() == QLatin1String(Constants::SHOW_TASK_IN_EDITOR)) {
|
||||
if (handler->isDefaultHandler()) {
|
||||
d->m_defaultHandler = handler;
|
||||
break;
|
||||
}
|
||||
|
@@ -45,11 +45,7 @@
|
||||
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
VcsAnnotateTaskHandler::VcsAnnotateTaskHandler() :
|
||||
ITaskHandler(QLatin1String(Constants::VCS_ANNOTATE_TASK))
|
||||
{ }
|
||||
|
||||
bool VcsAnnotateTaskHandler::canHandle(const ProjectExplorer::Task &task)
|
||||
bool VcsAnnotateTaskHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||
{
|
||||
QFileInfo fi(task.file.toFileInfo());
|
||||
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
|
||||
@@ -69,7 +65,7 @@ void VcsAnnotateTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
vc->vcsAnnotate(fi.absoluteFilePath(), task.movedLine);
|
||||
}
|
||||
|
||||
QAction *VcsAnnotateTaskHandler::createAction(QObject *parent)
|
||||
QAction *VcsAnnotateTaskHandler::createAction(QObject *parent) const
|
||||
{
|
||||
QAction *vcsannotateAction = new QAction(tr("&Annotate"), parent);
|
||||
vcsannotateAction->setToolTip(tr("Annotate using version control system"));
|
||||
|
@@ -35,10 +35,6 @@
|
||||
|
||||
#include "itaskhandler.h"
|
||||
|
||||
namespace Core {
|
||||
class IVersionControl;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -47,11 +43,11 @@ class VcsAnnotateTaskHandler : public ITaskHandler
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VcsAnnotateTaskHandler();
|
||||
VcsAnnotateTaskHandler() {}
|
||||
|
||||
bool canHandle(const Task &);
|
||||
bool canHandle(const Task &) const;
|
||||
void handle(const Task &task);
|
||||
QAction *createAction(QObject *parent = 0);
|
||||
QAction *createAction(QObject *parent) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -48,14 +48,7 @@ using namespace TaskList::Internal;
|
||||
// StopMonitoringHandler
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
StopMonitoringHandler::StopMonitoringHandler() :
|
||||
ProjectExplorer::ITaskHandler(QLatin1String("TaskList.StopMonitoringHandler"))
|
||||
{ }
|
||||
|
||||
StopMonitoringHandler::~StopMonitoringHandler()
|
||||
{ }
|
||||
|
||||
bool StopMonitoringHandler::canHandle(const ProjectExplorer::Task &task)
|
||||
bool StopMonitoringHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||
{
|
||||
return task.category == Core::Id(Constants::TASKLISTTASK_ID);
|
||||
}
|
||||
@@ -67,7 +60,7 @@ void StopMonitoringHandler::handle(const ProjectExplorer::Task &task)
|
||||
TaskList::TaskListPlugin::instance()->stopMonitoring();
|
||||
}
|
||||
|
||||
QAction *StopMonitoringHandler::createAction(QObject *parent)
|
||||
QAction *StopMonitoringHandler::createAction(QObject *parent) const
|
||||
{
|
||||
const QString text =
|
||||
QCoreApplication::translate("TaskList::Internal::StopMonitoringHandler",
|
||||
|
@@ -41,12 +41,11 @@ namespace Internal {
|
||||
class StopMonitoringHandler : public ProjectExplorer::ITaskHandler
|
||||
{
|
||||
public:
|
||||
StopMonitoringHandler();
|
||||
~StopMonitoringHandler();
|
||||
StopMonitoringHandler() {}
|
||||
|
||||
bool canHandle(const ProjectExplorer::Task &);
|
||||
bool canHandle(const ProjectExplorer::Task &) const;
|
||||
void handle(const ProjectExplorer::Task &);
|
||||
QAction *createAction(QObject *parent = 0);
|
||||
QAction *createAction(QObject *parent) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user