blob: f9904b790821cc01c59a1b9f3fe010c6f5a81bea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "showineditortaskhandler.h"
#include "task.h"
#include "projectexplorertr.h"
#include <coreplugin/editormanager/editormanager.h>
#include <QAction>
#include <QFileInfo>
namespace ProjectExplorer {
namespace Internal {
bool ShowInEditorTaskHandler::canHandle(const Task &task) const
{
if (task.file.isEmpty())
return false;
QFileInfo fi(task.file.toFileInfo());
return fi.exists() && fi.isFile() && fi.isReadable();
}
void ShowInEditorTaskHandler::handle(const Task &task)
{
const int column = task.column ? task.column - 1 : 0;
Core::EditorManager::openEditorAt({task.file, task.movedLine, column},
{},
Core::EditorManager::SwitchSplitIfAlreadyVisible);
}
QAction *ShowInEditorTaskHandler::createAction(QObject *parent) const
{
QAction *showAction = new QAction(Tr::tr("Show in Editor"), parent);
showAction->setToolTip(Tr::tr("Show task location in an editor."));
showAction->setShortcut(QKeySequence(Qt::Key_Return));
showAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
return showAction;
}
} // namespace Internal
} // namespace ProjectExplorer
|