forked from qt-creator/qt-creator
Locator: run external tools
Change-Id: I7f5b6a452822481e4b85b91a356727979b23cab4 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
This commit is contained in:
@@ -259,6 +259,8 @@ QtcPlugin {
|
||||
"directoryfilter.ui",
|
||||
"executefilter.cpp",
|
||||
"executefilter.h",
|
||||
"externaltoolsfilter.cpp",
|
||||
"externaltoolsfilter.h",
|
||||
"filesystemfilter.cpp",
|
||||
"filesystemfilter.h",
|
||||
"filesystemfilter.ui",
|
||||
|
86
src/plugins/coreplugin/locator/externaltoolsfilter.cpp
Normal file
86
src/plugins/coreplugin/locator/externaltoolsfilter.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <coreplugin/externaltool.h>
|
||||
#include <coreplugin/externaltoolmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include "externaltoolsfilter.h"
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
ExternalToolsFilter::ExternalToolsFilter()
|
||||
{
|
||||
setId("Run external tool");
|
||||
setDisplayName(tr("Run External Tool"));
|
||||
setShortcutString(QLatin1String("x"));
|
||||
setPriority(Medium);
|
||||
}
|
||||
|
||||
QList<LocatorFilterEntry> ExternalToolsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &,
|
||||
const QString &)
|
||||
{
|
||||
return m_results;
|
||||
}
|
||||
|
||||
void ExternalToolsFilter::accept(LocatorFilterEntry selection) const
|
||||
{
|
||||
auto tool = selection.internalData.value<ExternalTool *>();
|
||||
QTC_ASSERT(tool, return);
|
||||
|
||||
auto runner = new ExternalToolRunner(tool);
|
||||
if (runner->hasError())
|
||||
MessageManager::write(runner->errorString());
|
||||
}
|
||||
|
||||
void ExternalToolsFilter::refresh(QFutureInterface<void> &)
|
||||
{
|
||||
}
|
||||
|
||||
void ExternalToolsFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
m_results.clear();
|
||||
|
||||
Qt::CaseSensitivity useCaseSensitivity = caseSensitivity(entry);
|
||||
const QMap<QString, ExternalTool *> externalToolsById = ExternalToolManager::toolsById();
|
||||
auto end = externalToolsById.cend();
|
||||
for (auto it = externalToolsById.cbegin(); it != end; ++it) {
|
||||
ExternalTool *tool = *it;
|
||||
if (tool->description().contains(entry, useCaseSensitivity) ||
|
||||
tool->displayName().contains(entry, useCaseSensitivity)) {
|
||||
|
||||
LocatorFilterEntry filterEntry(this, tool->displayName(), QVariant::fromValue(tool));
|
||||
filterEntry.extraInfo = tool->description();
|
||||
m_results.append(filterEntry);
|
||||
}
|
||||
}
|
||||
}
|
58
src/plugins/coreplugin/locator/externaltoolsfilter.h
Normal file
58
src/plugins/coreplugin/locator/externaltoolsfilter.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EXTERNALTOOLSFILTER_H
|
||||
#define EXTERNALTOOLSFILTER_H
|
||||
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class ExternalToolsFilter : public ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExternalToolsFilter();
|
||||
|
||||
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
void accept(LocatorFilterEntry selection) const override;
|
||||
void refresh(QFutureInterface<void> &future) override;
|
||||
void prepareSearch(const QString &entry) override;
|
||||
|
||||
private:
|
||||
QList<LocatorFilterEntry> m_results;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // EXTERNALTOOLSFILTER_H
|
@@ -36,6 +36,7 @@
|
||||
#include "opendocumentsfilter.h"
|
||||
#include "filesystemfilter.h"
|
||||
#include "locatorsettingspage.h"
|
||||
#include "externaltoolsfilter.h"
|
||||
|
||||
#include <coreplugin/coreplugin.h>
|
||||
#include <coreplugin/statusbarwidget.h>
|
||||
@@ -79,10 +80,12 @@ Locator::~Locator()
|
||||
m_corePlugin->removeObject(m_fileSystemFilter);
|
||||
m_corePlugin->removeObject(m_executeFilter);
|
||||
m_corePlugin->removeObject(m_settingsPage);
|
||||
m_corePlugin->removeObject(m_externalToolsFilter);
|
||||
delete m_openDocumentsFilter;
|
||||
delete m_fileSystemFilter;
|
||||
delete m_executeFilter;
|
||||
delete m_settingsPage;
|
||||
delete m_externalToolsFilter;
|
||||
qDeleteAll(m_customFilters);
|
||||
}
|
||||
|
||||
@@ -122,6 +125,9 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
|
||||
m_executeFilter = new ExecuteFilter();
|
||||
m_corePlugin->addObject(m_executeFilter);
|
||||
|
||||
m_externalToolsFilter = new ExternalToolsFilter;
|
||||
m_corePlugin->addObject(m_externalToolsFilter);
|
||||
|
||||
m_corePlugin->addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget));
|
||||
#ifdef Q_OS_OSX
|
||||
m_corePlugin->addAutoReleasedObject(new SpotlightLocatorFilter);
|
||||
|
@@ -50,6 +50,7 @@ class LocatorWidget;
|
||||
class OpenDocumentsFilter;
|
||||
class FileSystemFilter;
|
||||
class LocatorSettingsPage;
|
||||
class ExternalToolsFilter;
|
||||
|
||||
class Locator : public QObject
|
||||
{
|
||||
@@ -97,6 +98,7 @@ private:
|
||||
FileSystemFilter *m_fileSystemFilter;
|
||||
ExecuteFilter *m_executeFilter;
|
||||
CorePlugin *m_corePlugin;
|
||||
ExternalToolsFilter *m_externalToolsFilter;
|
||||
};
|
||||
|
||||
template <typename S>
|
||||
|
@@ -12,7 +12,8 @@ HEADERS += \
|
||||
$$PWD/basefilefilter.h \
|
||||
$$PWD/executefilter.h \
|
||||
$$PWD/locatorsearchutils.h \
|
||||
$$PWD/locatorsettingspage.h
|
||||
$$PWD/locatorsettingspage.h \
|
||||
$$PWD/externaltoolsfilter.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/locator.cpp \
|
||||
@@ -27,7 +28,8 @@ SOURCES += \
|
||||
$$PWD/ilocatorfilter.cpp \
|
||||
$$PWD/executefilter.cpp \
|
||||
$$PWD/locatorsearchutils.cpp \
|
||||
$$PWD/locatorsettingspage.cpp
|
||||
$$PWD/locatorsettingspage.cpp \
|
||||
$$PWD/externaltoolsfilter.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/filesystemfilter.ui \
|
||||
|
Reference in New Issue
Block a user