forked from qt-creator/qt-creator
Replace the current license disclaimer in files by a SPDX-License-Identifier. Task-number: QTBUG-67283 Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
|
|
|
#include "vcsannotatetaskhandler.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include <coreplugin/iversioncontrol.h>
|
|
#include <coreplugin/vcsmanager.h>
|
|
#include <utils/qtcassert.h>
|
|
|
|
#include <QAction>
|
|
#include <QFileInfo>
|
|
|
|
using namespace Core;
|
|
using namespace Utils;
|
|
|
|
namespace ProjectExplorer {
|
|
namespace Internal {
|
|
|
|
bool VcsAnnotateTaskHandler::canHandle(const Task &task) const
|
|
{
|
|
QFileInfo fi(task.file.toFileInfo());
|
|
if (!fi.exists() || !fi.isFile() || !fi.isReadable())
|
|
return false;
|
|
IVersionControl *vc = VcsManager::findVersionControlForDirectory(task.file.absolutePath());
|
|
if (!vc)
|
|
return false;
|
|
return vc->supportsOperation(IVersionControl::AnnotateOperation);
|
|
}
|
|
|
|
void VcsAnnotateTaskHandler::handle(const Task &task)
|
|
{
|
|
IVersionControl *vc = VcsManager::findVersionControlForDirectory(task.file.absolutePath());
|
|
QTC_ASSERT(vc, return);
|
|
QTC_ASSERT(vc->supportsOperation(IVersionControl::AnnotateOperation), return);
|
|
vc->vcsAnnotate(task.file.absoluteFilePath(), task.movedLine);
|
|
}
|
|
|
|
QAction *VcsAnnotateTaskHandler::createAction(QObject *parent) const
|
|
{
|
|
QAction *vcsannotateAction = new QAction(tr("&Annotate"), parent);
|
|
vcsannotateAction->setToolTip(tr("Annotate using version control system."));
|
|
return vcsannotateAction;
|
|
}
|
|
|
|
} // namespace Internal
|
|
} // namespace ProjectExplorer
|