forked from qt-creator/qt-creator
Apply 'static' pattern to VcsManager
Adapt user and surrounding code. Change-Id: Id2648f82a9cbbd0ad0bfb91f6958b8cee7ea29cc Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -31,33 +31,35 @@
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
using namespace ProjectExplorer::Internal;
|
||||
using namespace Core;
|
||||
|
||||
bool VcsAnnotateTaskHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||
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;
|
||||
Core::IVersionControl *vc = Core::ICore::vcsManager()->findVersionControlForDirectory(fi.absolutePath());
|
||||
IVersionControl *vc = VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
||||
if (!vc)
|
||||
return false;
|
||||
return vc->supportsOperation(Core::IVersionControl::AnnotateOperation);
|
||||
return vc->supportsOperation(IVersionControl::AnnotateOperation);
|
||||
}
|
||||
|
||||
void VcsAnnotateTaskHandler::handle(const ProjectExplorer::Task &task)
|
||||
void VcsAnnotateTaskHandler::handle(const Task &task)
|
||||
{
|
||||
QFileInfo fi(task.file.toFileInfo());
|
||||
Core::IVersionControl *vc = Core::ICore::vcsManager()->findVersionControlForDirectory(fi.absolutePath());
|
||||
Q_ASSERT(vc);
|
||||
Q_ASSERT(vc->supportsOperation(Core::IVersionControl::AnnotateOperation));
|
||||
IVersionControl *vc = VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
||||
QTC_ASSERT(vc, return);
|
||||
QTC_ASSERT(vc->supportsOperation(IVersionControl::AnnotateOperation), return);
|
||||
vc->vcsAnnotate(fi.absoluteFilePath(), task.movedLine);
|
||||
}
|
||||
|
||||
@@ -67,3 +69,6 @@ QAction *VcsAnnotateTaskHandler::createAction(QObject *parent) const
|
||||
vcsannotateAction->setToolTip(tr("Annotate using version control system"));
|
||||
return vcsannotateAction;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
Reference in New Issue
Block a user