Commit 18178718 authored by Tobias Hunger's avatar Tobias Hunger

Add task handler used to show VCS blame output

 * Add task handler to show VCS blame output.

 * This taskhandler is not yet used!
parent feaa2b2c
......@@ -35,6 +35,7 @@
#include "targetsettingspanel.h"
#include "copytaskhandler.h"
#include "showineditortaskhandler.h"
#include "vcsannotatetaskhandler.h"
#include "applicationrunconfiguration.h"
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
......@@ -283,6 +284,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
addAutoReleasedObject(new CopyTaskHandler);
addAutoReleasedObject(new ShowInEditorTaskHandler);
addAutoReleasedObject(new VcsAnnotateTaskHandler);
d->m_buildManager = new BuildManager(this);
connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
......
......@@ -20,6 +20,7 @@ HEADERS += projectexplorer.h \
itaskhandler.h \
copytaskhandler.h \
showineditortaskhandler.h \
vcsannotatetaskhandler.h \
taskwindow.h \
outputwindow.h \
persistentsettings.h \
......@@ -100,6 +101,7 @@ SOURCES += projectexplorer.cpp \
task.cpp \
copytaskhandler.cpp \
showineditortaskhandler.cpp \
vcsannotatetaskhandler.cpp \
taskwindow.cpp \
outputwindow.cpp \
persistentsettings.cpp \
......
......@@ -77,6 +77,7 @@ const char * const REMOVEFILE = "ProjectExplorer.RemoveFile";
const char * const RENAMEFILE = "ProjectExplorer.RenameFile";
const char * const SHOW_TASK_IN_EDITOR = "ProjectExplorer.ShowTaskInEditor";
const char * const VCS_ANNOTATE_TASK = "ProjectExplorer.VcsAnnotateTask";
// Run modes
const char * const RUNMODE = "ProjectExplorer.RunMode";
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "vcsannotatetaskhandler.h"
#include "task.h"
#include "projectexplorerconstants.h"
#include <coreplugin/icore.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <QtCore/QFileInfo>
#include <QtGui/QAction>
using namespace ProjectExplorer::Internal;
VcsAnnotateTaskHandler::VcsAnnotateTaskHandler() :
ITaskHandler(QLatin1String(Constants::VCS_ANNOTATE_TASK))
{ }
bool VcsAnnotateTaskHandler::canHandle(const ProjectExplorer::Task &task)
{
QFileInfo fi(task.file);
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
return false;
Core::IVersionControl *vc = Core::ICore::instance()->vcsManager()->findVersionControlForDirectory(fi.absolutePath());
if (!vc)
return false;
return vc->supportsOperation(Core::IVersionControl::AnnotateOperation);
}
void VcsAnnotateTaskHandler::handle(const ProjectExplorer::Task &task)
{
QFileInfo fi(task.file);
Core::IVersionControl *vc = Core::ICore::instance()->vcsManager()->findVersionControlForDirectory(fi.absolutePath());
Q_ASSERT(vc);
Q_ASSERT(vc->supportsOperation(Core::IVersionControl::AnnotateOperation));
vc->vcsAnnotate(fi.absoluteFilePath(), task.line);
}
QAction *VcsAnnotateTaskHandler::createAction(QObject *parent)
{
QAction *vcsannotateAction = new QAction(tr("&Annotate"), parent);
vcsannotateAction->setToolTip("Annotate using version control system");
return vcsannotateAction;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef PROJECTEXPLORER_VCSANNOTATETASKHANDLER_H
#define PROJECTEXPLORER_VCSANNOTATETASKHANDLER_H
#include "projectexplorer_export.h"
#include "itaskhandler.h"
#include <QtCore/QHash>
#include <QtCore/QString>
namespace Core {
class IVersionControl;
}
namespace ProjectExplorer {
namespace Internal {
class PROJECTEXPLORER_EXPORT VcsAnnotateTaskHandler : public ITaskHandler
{
public:
VcsAnnotateTaskHandler();
bool canHandle(const Task &);
void handle(const Task &task);
QAction *createAction(QObject *parent = 0);
};
} // namespace Internal
} // namespace ProjectExplorer
#endif // PROJECTEXPLORER_VCSANNOTATETASKHANDLER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment