forked from qt-creator/qt-creator
Locator: Cleanup and modernize Locator and filters
* Omit QLatin1{Char|String} * Use member initialization * Use range-based-for (and fixed the cases with non-const Qt container) * Sort includes to common style Change-Id: Ibc33a732bb153862efd6d5febfac758229cb61d4 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
André Hartmann
parent
ccc0bebcf4
commit
b2aa1b9845
@@ -45,7 +45,7 @@ CMakeLocatorFilter::CMakeLocatorFilter()
|
||||
{
|
||||
setId("Build CMake target");
|
||||
setDisplayName(tr("Build CMake target"));
|
||||
setShortcutString(QLatin1String("cm"));
|
||||
setShortcutString("cm");
|
||||
setPriority(High);
|
||||
|
||||
connect(SessionManager::instance(), &SessionManager::projectAdded,
|
||||
@@ -60,11 +60,13 @@ CMakeLocatorFilter::CMakeLocatorFilter()
|
||||
void CMakeLocatorFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
m_result.clear();
|
||||
for (Project *p : SessionManager::projects()) {
|
||||
const QList<Project *> projects = SessionManager::projects();
|
||||
for (Project *p : projects) {
|
||||
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
|
||||
if (!cmakeProject)
|
||||
continue;
|
||||
foreach (const QString &title, cmakeProject->buildTargetTitles()) {
|
||||
const QStringList buildTargetTitles = cmakeProject->buildTargetTitles();
|
||||
for (const QString &title : buildTargetTitles) {
|
||||
const int index = title.indexOf(entry);
|
||||
if (index >= 0) {
|
||||
Core::LocatorFilterEntry filterEntry(this, title, cmakeProject->projectFilePath().toString());
|
||||
|
@@ -105,7 +105,7 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
|
||||
d->m_current.clear(); // free memory
|
||||
return betterEntries;
|
||||
}
|
||||
const QChar pathSeparator(QLatin1Char('/'));
|
||||
const QChar pathSeparator('/');
|
||||
const bool hasPathSeparator = fp.filePath.contains(pathSeparator);
|
||||
const bool containsPreviousEntry = !d->m_current.previousEntry.isEmpty()
|
||||
&& fp.filePath.contains(d->m_current.previousEntry);
|
||||
@@ -212,7 +212,7 @@ void BaseFileFilter::updatePreviousResultData()
|
||||
BaseFileFilter::ListIterator::ListIterator(const QStringList &filePaths)
|
||||
{
|
||||
m_filePaths = filePaths;
|
||||
foreach (const QString &path, m_filePaths) {
|
||||
for (const QString &path : filePaths) {
|
||||
QFileInfo fi(path);
|
||||
m_fileNames.append(fi.fileName());
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@ protected:
|
||||
private:
|
||||
void updatePreviousResultData();
|
||||
|
||||
Internal::BaseFileFilterPrivate *d;
|
||||
Internal::BaseFileFilterPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -40,7 +40,7 @@ class CORE_EXPORT CommandLocator : public ILocatorFilter
|
||||
|
||||
public:
|
||||
CommandLocator(Id id, const QString &displayName,
|
||||
const QString &shortCutString, QObject *parent = 0);
|
||||
const QString &shortCutString, QObject *parent = nullptr);
|
||||
~CommandLocator();
|
||||
|
||||
void appendCommand(Command *cmd);
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void refresh(QFutureInterface<void> &future) override;
|
||||
|
||||
private:
|
||||
CommandLocatorPrivate *d;
|
||||
CommandLocatorPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -112,13 +112,12 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
m_ui.filePatternLabel->setText(Utils::msgFilePatternLabel());
|
||||
m_ui.filePatternLabel->setBuddy(m_ui.filePattern);
|
||||
m_ui.filePattern->setToolTip(Utils::msgFilePatternToolTip());
|
||||
m_ui.filePattern->setText(Utils::transform(m_filters, &QDir::toNativeSeparators)
|
||||
.join(QLatin1Char(',')));
|
||||
m_ui.filePattern->setText(Utils::transform(m_filters, &QDir::toNativeSeparators).join(','));
|
||||
m_ui.exclusionPatternLabel->setText(Utils::msgExclusionPatternLabel());
|
||||
m_ui.exclusionPatternLabel->setBuddy(m_ui.exclusionPattern);
|
||||
m_ui.exclusionPattern->setToolTip(Utils::msgFilePatternToolTip());
|
||||
m_ui.exclusionPattern->setText(Utils::transform(m_exclusionFilters, &QDir::toNativeSeparators)
|
||||
.join(QLatin1Char(',')));
|
||||
.join(','));
|
||||
m_ui.shortcutEdit->setText(shortcutString());
|
||||
m_ui.defaultFlag->setChecked(isIncludedByDefault());
|
||||
updateOptionButtons();
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/macroexpander.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
@@ -38,7 +39,7 @@ ExecuteFilter::ExecuteFilter()
|
||||
{
|
||||
setId("Execute custom commands");
|
||||
setDisplayName(tr("Execute Custom Commands"));
|
||||
setShortcutString(QString(QLatin1Char('!')));
|
||||
setShortcutString("!");
|
||||
setPriority(High);
|
||||
setIncludedByDefault(false);
|
||||
|
||||
@@ -61,7 +62,7 @@ QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<LocatorFilt
|
||||
value.append(LocatorFilterEntry(this, entry, QVariant()));
|
||||
QList<LocatorFilterEntry> others;
|
||||
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry);
|
||||
foreach (const QString &cmd, m_commandHistory) {
|
||||
for (const QString &cmd : Utils::asConst(m_commandHistory)) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
if (cmd == entry) // avoid repeated entry
|
||||
@@ -101,7 +102,7 @@ void ExecuteFilter::accept(LocatorFilterEntry selection,
|
||||
|
||||
ExecuteData d;
|
||||
d.workingDirectory = workingDirectory;
|
||||
const int pos = value.indexOf(QLatin1Char(' '));
|
||||
const int pos = value.indexOf(' ');
|
||||
if (pos == -1) {
|
||||
d.executable = value;
|
||||
} else {
|
||||
@@ -187,6 +188,5 @@ QString ExecuteFilter::headCommand() const
|
||||
const ExecuteData &data = m_taskQueue.head();
|
||||
if (data.arguments.isEmpty())
|
||||
return data.executable;
|
||||
else
|
||||
return data.executable + QLatin1Char(' ') + data.arguments;
|
||||
return data.executable + ' ' + data.arguments;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ private:
|
||||
|
||||
QQueue<ExecuteData> m_taskQueue;
|
||||
QStringList m_commandHistory;
|
||||
Utils::QtcProcess *m_process;
|
||||
Utils::QtcProcess *m_process = nullptr;
|
||||
QTimer m_runTimer;
|
||||
QTextCodec::ConverterState m_stdoutState;
|
||||
QTextCodec::ConverterState m_stderrState;
|
||||
|
@@ -23,13 +23,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "externaltoolsfilter.h"
|
||||
|
||||
#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;
|
||||
|
||||
@@ -37,7 +37,7 @@ ExternalToolsFilter::ExternalToolsFilter()
|
||||
{
|
||||
setId("Run external tool");
|
||||
setDisplayName(tr("Run External Tool"));
|
||||
setShortcutString(QLatin1String("x"));
|
||||
setShortcutString("x");
|
||||
setPriority(Medium);
|
||||
}
|
||||
|
||||
|
@@ -24,12 +24,15 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "filesystemfilter.h"
|
||||
|
||||
#include "locatorwidget.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -50,9 +53,9 @@ QList<LocatorFilterEntry> *categorize(const QString &entry, const QString &candi
|
||||
|
||||
if (entry.isEmpty() || position == 0)
|
||||
return betterEntries;
|
||||
else if (position >= 0)
|
||||
if (position >= 0)
|
||||
return goodEntries;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // anynoumous namespace
|
||||
@@ -61,7 +64,7 @@ FileSystemFilter::FileSystemFilter()
|
||||
{
|
||||
setId("Files in file system");
|
||||
setDisplayName(tr("Files in File System"));
|
||||
setShortcutString(QString(QLatin1Char('f')));
|
||||
setShortcutString("f");
|
||||
setIncludedByDefault(false);
|
||||
}
|
||||
|
||||
@@ -76,17 +79,16 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
|
||||
{
|
||||
QList<LocatorFilterEntry> goodEntries;
|
||||
QList<LocatorFilterEntry> betterEntries;
|
||||
QFileInfo entryInfo(entry);
|
||||
const QFileInfo entryInfo(entry);
|
||||
const QString entryFileName = entryInfo.fileName();
|
||||
QString directory = entryInfo.path();
|
||||
QString filePath = entryInfo.filePath();
|
||||
if (entryInfo.isRelative()) {
|
||||
if (filePath.startsWith(QLatin1String("~/")))
|
||||
if (entryInfo.filePath().startsWith("~/"))
|
||||
directory.replace(0, 1, QDir::homePath());
|
||||
else if (!m_currentDocumentDirectory.isEmpty())
|
||||
directory.prepend(m_currentDocumentDirectory + "/");
|
||||
}
|
||||
QDir dirInfo(directory);
|
||||
const QDir dirInfo(directory);
|
||||
QDir::Filters dirFilter = QDir::Dirs|QDir::Drives|QDir::NoDot|QDir::NoDotDot;
|
||||
QDir::Filters fileFilter = QDir::Files;
|
||||
if (m_includeHidden) {
|
||||
@@ -98,11 +100,11 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
|
||||
const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entryFileName);
|
||||
QStringList dirs = dirInfo.entryList(dirFilter,
|
||||
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
QStringList files = dirInfo.entryList(fileFilter,
|
||||
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
const QStringList files = dirInfo.entryList(fileFilter,
|
||||
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
dirs.prepend("..");
|
||||
|
||||
foreach (const QString &dir, dirs) {
|
||||
for (const QString &dir : Utils::asConst(dirs)) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
int index = -1;
|
||||
@@ -120,7 +122,7 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
|
||||
// file names can match with +linenumber or :linenumber
|
||||
const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry);
|
||||
const QString fileName = QFileInfo(fp.filePath).fileName();
|
||||
foreach (const QString &file, files) {
|
||||
for (const QString &file : files) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
int index = -1;
|
||||
@@ -156,9 +158,8 @@ void FileSystemFilter::accept(LocatorFilterEntry selection,
|
||||
QString fileName = selection.fileName;
|
||||
QFileInfo info(fileName);
|
||||
if (info.isDir()) {
|
||||
QString value = shortcutString();
|
||||
value += QLatin1Char(' ');
|
||||
value += QDir::toNativeSeparators(info.absoluteFilePath() + QLatin1Char('/'));
|
||||
const QString value = shortcutString() + ' '
|
||||
+ QDir::toNativeSeparators(info.absoluteFilePath() + '/');
|
||||
*newText = value;
|
||||
*selectionStart = value.length();
|
||||
return;
|
||||
|
@@ -28,10 +28,10 @@
|
||||
#include "ilocatorfilter.h"
|
||||
#include "ui_filesystemfilter.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
#include <QFutureInterface>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
@@ -24,20 +24,21 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "locator.h"
|
||||
|
||||
#include "externaltoolsfilter.h"
|
||||
#include "filesystemfilter.h"
|
||||
#include "locatorconstants.h"
|
||||
#include "locatorfiltersfilter.h"
|
||||
#include "locatormanager.h"
|
||||
#include "locatorsettingspage.h"
|
||||
#include "locatorwidget.h"
|
||||
#include "opendocumentsfilter.h"
|
||||
#include "filesystemfilter.h"
|
||||
#include "locatorsettingspage.h"
|
||||
#include "externaltoolsfilter.h"
|
||||
|
||||
#include <coreplugin/coreplugin.h>
|
||||
#include <coreplugin/statusbarwidget.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/settingsdatabase.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/settingsdatabase.h>
|
||||
#include <coreplugin/statusbarwidget.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -46,14 +47,15 @@
|
||||
#include <coreplugin/progressmanager/futureprogress.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/mapreduce.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QFuture>
|
||||
#include <QSettings>
|
||||
#include <QtPlugin>
|
||||
#include <QFuture>
|
||||
#include <QAction>
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
#include "spotlightlocatorfilter.h"
|
||||
@@ -165,22 +167,22 @@ bool Locator::delayedInitialize()
|
||||
void Locator::loadSettings()
|
||||
{
|
||||
SettingsDatabase *settings = ICore::settingsDatabase();
|
||||
settings->beginGroup(QLatin1String("QuickOpen"));
|
||||
m_refreshTimer.setInterval(settings->value(QLatin1String("RefreshInterval"), 60).toInt() * 60000);
|
||||
settings->beginGroup("QuickOpen");
|
||||
m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000);
|
||||
|
||||
foreach (ILocatorFilter *filter, m_filters) {
|
||||
for (ILocatorFilter *filter : Utils::asConst(m_filters)) {
|
||||
if (settings->contains(filter->id().toString())) {
|
||||
const QByteArray state = settings->value(filter->id().toString()).toByteArray();
|
||||
if (!state.isEmpty())
|
||||
filter->restoreState(state);
|
||||
}
|
||||
}
|
||||
settings->beginGroup(QLatin1String("CustomFilters"));
|
||||
settings->beginGroup("CustomFilters");
|
||||
QList<ILocatorFilter *> customFilters;
|
||||
const QStringList keys = settings->childKeys();
|
||||
int count = 0;
|
||||
Id baseId(Constants::CUSTOM_FILTER_BASEID);
|
||||
foreach (const QString &key, keys) {
|
||||
for (const QString &key : keys) {
|
||||
ILocatorFilter *filter = new DirectoryFilter(baseId.withSuffix(++count));
|
||||
filter->restoreState(settings->value(key).toByteArray());
|
||||
customFilters.append(filter);
|
||||
@@ -200,7 +202,7 @@ void Locator::updateFilterActions()
|
||||
QMap<Id, QAction *> actionCopy = m_filterActionMap;
|
||||
m_filterActionMap.clear();
|
||||
// register new actions, update existent
|
||||
for (ILocatorFilter *filter : m_filters) {
|
||||
for (ILocatorFilter *filter : Utils::asConst(m_filters)) {
|
||||
if (filter->shortcutString().isEmpty() || filter->isHidden())
|
||||
continue;
|
||||
Id filterId = filter->id();
|
||||
@@ -274,29 +276,29 @@ void Locator::updateEditorManagerPlaceholderText()
|
||||
EditorManagerPrivate::setPlaceholderText(placeholderText.arg(classes, methods));
|
||||
}
|
||||
|
||||
void Locator::saveSettings()
|
||||
void Locator::saveSettings() const
|
||||
{
|
||||
if (m_settingsInitialized) {
|
||||
SettingsDatabase *s = ICore::settingsDatabase();
|
||||
s->beginTransaction();
|
||||
s->beginGroup(QLatin1String("QuickOpen"));
|
||||
s->remove(QString());
|
||||
s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
|
||||
foreach (ILocatorFilter *filter, m_filters) {
|
||||
if (!m_customFilters.contains(filter))
|
||||
s->setValue(filter->id().toString(), filter->saveState());
|
||||
}
|
||||
s->beginGroup(QLatin1String("CustomFilters"));
|
||||
int i = 0;
|
||||
foreach (ILocatorFilter *filter, m_customFilters) {
|
||||
s->setValue(QLatin1String("directory") + QString::number(i),
|
||||
filter->saveState());
|
||||
++i;
|
||||
}
|
||||
s->endGroup();
|
||||
s->endGroup();
|
||||
s->endTransaction();
|
||||
if (!m_settingsInitialized)
|
||||
return;
|
||||
|
||||
SettingsDatabase *s = ICore::settingsDatabase();
|
||||
s->beginTransaction();
|
||||
s->beginGroup("QuickOpen");
|
||||
s->remove(QString());
|
||||
s->setValue("RefreshInterval", refreshInterval());
|
||||
for (ILocatorFilter *filter : m_filters) {
|
||||
if (!m_customFilters.contains(filter))
|
||||
s->setValue(filter->id().toString(), filter->saveState());
|
||||
}
|
||||
s->beginGroup("CustomFilters");
|
||||
int i = 0;
|
||||
for (ILocatorFilter *filter : m_customFilters) {
|
||||
s->setValue("directory" + QString::number(i), filter->saveState());
|
||||
++i;
|
||||
}
|
||||
s->endGroup();
|
||||
s->endGroup();
|
||||
s->endTransaction();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -329,7 +331,7 @@ void Locator::setCustomFilters(QList<ILocatorFilter *> filters)
|
||||
m_customFilters = filters;
|
||||
}
|
||||
|
||||
int Locator::refreshInterval()
|
||||
int Locator::refreshInterval() const
|
||||
{
|
||||
return m_refreshTimer.interval() / 60000;
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
QList<ILocatorFilter *> customFilters();
|
||||
void setFilters(QList<ILocatorFilter *> f);
|
||||
void setCustomFilters(QList<ILocatorFilter *> f);
|
||||
int refreshInterval();
|
||||
int refreshInterval() const;
|
||||
void setRefreshInterval(int interval);
|
||||
|
||||
signals:
|
||||
@@ -71,26 +71,25 @@ signals:
|
||||
|
||||
public slots:
|
||||
void refresh(QList<ILocatorFilter *> filters = QList<ILocatorFilter *>());
|
||||
void saveSettings();
|
||||
void saveSettings() const;
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void updateFilterActions();
|
||||
void updateEditorManagerPlaceholderText();
|
||||
|
||||
LocatorSettingsPage *m_settingsPage;
|
||||
LocatorSettingsPage *m_settingsPage = nullptr;
|
||||
|
||||
bool m_settingsInitialized = false;
|
||||
QList<ILocatorFilter *> m_filters;
|
||||
QList<ILocatorFilter *> m_customFilters;
|
||||
QMap<Id, QAction *> m_filterActionMap;
|
||||
int m_refreshInterval;
|
||||
QTimer m_refreshTimer;
|
||||
OpenDocumentsFilter *m_openDocumentsFilter;
|
||||
FileSystemFilter *m_fileSystemFilter;
|
||||
ExecuteFilter *m_executeFilter;
|
||||
OpenDocumentsFilter *m_openDocumentsFilter = nullptr;
|
||||
FileSystemFilter *m_fileSystemFilter = nullptr;
|
||||
ExecuteFilter *m_executeFilter = nullptr;
|
||||
CorePlugin *m_corePlugin = nullptr;
|
||||
ExternalToolsFilter *m_externalToolsFilter;
|
||||
ExternalToolsFilter *m_externalToolsFilter = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "locatorfiltertest.h"
|
||||
|
||||
#include <coreplugin/testdatadir.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -52,8 +53,6 @@ public:
|
||||
void refresh(QFutureInterface<void> &) override {}
|
||||
};
|
||||
|
||||
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
|
||||
|
||||
class ReferenceData
|
||||
{
|
||||
public:
|
||||
@@ -78,7 +77,7 @@ void Core::Internal::CorePlugin::test_basefilefilter()
|
||||
MyBaseFileFilter filter(testFiles);
|
||||
BasicLocatorFilterTest test(&filter);
|
||||
|
||||
foreach (const ReferenceData &reference, referenceDataList) {
|
||||
for (const ReferenceData &reference : Utils::asConst(referenceDataList)) {
|
||||
const QList<LocatorFilterEntry> filterEntries = test.matchesFor(reference.searchText);
|
||||
const ResultDataList results = ResultData::fromFilterEntryList(filterEntries);
|
||||
// QTextStream(stdout) << "----" << endl;
|
||||
@@ -93,12 +92,12 @@ void Core::Internal::CorePlugin::test_basefilefilter_data()
|
||||
QTest::addColumn<QList<ReferenceData> >("referenceDataList");
|
||||
|
||||
const QChar pathSeparator = QDir::separator();
|
||||
const MyTestDataDir testDir(QLatin1String("testdata_basic"));
|
||||
const MyTestDataDir testDir("testdata_basic");
|
||||
const QStringList testFiles({QDir::fromNativeSeparators(testDir.file("file.cpp")),
|
||||
QDir::fromNativeSeparators(testDir.file("main.cpp")),
|
||||
QDir::fromNativeSeparators(testDir.file("subdir/main.cpp"))});
|
||||
QStringList testFilesShort;
|
||||
foreach (const QString &file, testFiles)
|
||||
for (const QString &file : testFiles)
|
||||
testFilesShort << Utils::FileUtils::shortNativePath(Utils::FileName::fromString(file));
|
||||
|
||||
QTest::newRow("BaseFileFilter-EmptyInput")
|
||||
@@ -107,56 +106,56 @@ void Core::Internal::CorePlugin::test_basefilefilter_data()
|
||||
<< ReferenceData(
|
||||
QString(),
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("file.cpp"), testFilesShort.at(0))
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(1))
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("file.cpp", testFilesShort.at(0))
|
||||
<< ResultData("main.cpp", testFilesShort.at(1))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
);
|
||||
|
||||
QTest::newRow("BaseFileFilter-InputIsFileName")
|
||||
<< testFiles
|
||||
<< (QList<ReferenceData>()
|
||||
<< ReferenceData(
|
||||
_("main.cpp"),
|
||||
"main.cpp",
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(1))
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(1))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
);
|
||||
|
||||
QTest::newRow("BaseFileFilter-InputIsFilePath")
|
||||
<< testFiles
|
||||
<< (QList<ReferenceData>()
|
||||
<< ReferenceData(
|
||||
QString(_("subdir") + pathSeparator + _("main.cpp")),
|
||||
QString("subdir" + pathSeparator + "main.cpp"),
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
);
|
||||
|
||||
QTest::newRow("BaseFileFilter-InputIsDirIsPath")
|
||||
<< testFiles
|
||||
<< (QList<ReferenceData>()
|
||||
<< ReferenceData( _("subdir"), QList<ResultData>())
|
||||
<< ReferenceData( "subdir", QList<ResultData>())
|
||||
<< ReferenceData(
|
||||
QString(_("subdir") + pathSeparator + _("main.cpp")),
|
||||
QString("subdir" + pathSeparator + "main.cpp"),
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
);
|
||||
|
||||
QTest::newRow("BaseFileFilter-InputIsFileNameFilePathFileName")
|
||||
<< testFiles
|
||||
<< (QList<ReferenceData>()
|
||||
<< ReferenceData(
|
||||
_("main.cpp"),
|
||||
"main.cpp",
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(1))
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(1))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
<< ReferenceData(
|
||||
QString(_("subdir") + pathSeparator + _("main.cpp")),
|
||||
QString("subdir" + pathSeparator + "main.cpp"),
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
<< ReferenceData(
|
||||
_("main.cpp"),
|
||||
"main.cpp",
|
||||
(QList<ResultData>()
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(1))
|
||||
<< ResultData(_("main.cpp"), testFilesShort.at(2))))
|
||||
<< ResultData("main.cpp", testFilesShort.at(1))
|
||||
<< ResultData("main.cpp", testFilesShort.at(2))))
|
||||
);
|
||||
}
|
||||
|
@@ -23,10 +23,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "locator.h"
|
||||
#include "locatorfiltersfilter.h"
|
||||
|
||||
#include "locator.h"
|
||||
#include "locatorwidget.h"
|
||||
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -54,12 +56,13 @@ void LocatorFiltersFilter::prepareSearch(const QString &entry)
|
||||
return;
|
||||
|
||||
QMap<QString, ILocatorFilter *> uniqueFilters;
|
||||
foreach (ILocatorFilter *filter, Locator::filters()) {
|
||||
const QString filterId = filter->shortcutString() + QLatin1Char(',') + filter->displayName();
|
||||
const QList<ILocatorFilter *> allFilters = Locator::filters();
|
||||
for (ILocatorFilter *filter : allFilters) {
|
||||
const QString filterId = filter->shortcutString() + ',' + filter->displayName();
|
||||
uniqueFilters.insert(filterId, filter);
|
||||
}
|
||||
|
||||
foreach (ILocatorFilter *filter, uniqueFilters) {
|
||||
for (ILocatorFilter *filter : Utils::asConst(uniqueFilters)) {
|
||||
if (!filter->shortcutString().isEmpty() && !filter->isHidden() && filter->isEnabled()) {
|
||||
m_filterShortcutStrings.append(filter->shortcutString());
|
||||
m_filterDisplayNames.append(filter->displayName());
|
||||
@@ -93,7 +96,7 @@ void LocatorFiltersFilter::accept(LocatorFilterEntry selection,
|
||||
QTC_ASSERT(ok && index >= 0 && index < m_filterShortcutStrings.size(), return);
|
||||
const QString shortcutString = m_filterShortcutStrings.at(index);
|
||||
if (!shortcutString.isEmpty()) {
|
||||
*newText = shortcutString + QLatin1Char(' ');
|
||||
*newText = shortcutString + ' ';
|
||||
*selectionStart = shortcutString.length() + 1;
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "locatorfiltertest.h"
|
||||
|
||||
#include "locatorsearchutils.h"
|
||||
|
||||
#include <utils/runextensions.h>
|
||||
@@ -73,7 +74,7 @@ bool ResultData::operator==(const ResultData &other) const
|
||||
ResultData::ResultDataList ResultData::fromFilterEntryList(const QList<LocatorFilterEntry> &entries)
|
||||
{
|
||||
ResultDataList result;
|
||||
foreach (const LocatorFilterEntry &entry, entries)
|
||||
for (const LocatorFilterEntry &entry : entries)
|
||||
result << ResultData(entry.displayName, entry.extraInfo);
|
||||
return result;
|
||||
}
|
||||
@@ -83,7 +84,7 @@ void ResultData::printFilterEntries(const ResultData::ResultDataList &entries, c
|
||||
QTextStream out(stdout);
|
||||
if (!msg.isEmpty())
|
||||
out << msg << endl;
|
||||
foreach (const ResultData entry, entries) {
|
||||
for (const ResultData &entry : entries) {
|
||||
out << "<< ResultData(_(\"" << entry.textColumn1 << "\"), _(\"" << entry.textColumn2
|
||||
<< "\"))" << endl;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ private:
|
||||
virtual void doBeforeLocatorRun() {}
|
||||
virtual void doAfterLocatorRun() {}
|
||||
|
||||
ILocatorFilter *m_filter;
|
||||
ILocatorFilter *m_filter = nullptr;
|
||||
};
|
||||
|
||||
class CORE_EXPORT ResultData
|
||||
|
@@ -67,14 +67,15 @@ void LocatorManager::showFilter(ILocatorFilter *filter)
|
||||
// add shortcut string at front or replace existing shortcut string
|
||||
if (!currentText.isEmpty()) {
|
||||
searchText = currentText;
|
||||
foreach (ILocatorFilter *otherfilter, Locator::filters()) {
|
||||
if (currentText.startsWith(otherfilter->shortcutString() + QLatin1Char(' '))) {
|
||||
const QList<ILocatorFilter *> allFilters = Locator::filters();
|
||||
for (ILocatorFilter *otherfilter : allFilters) {
|
||||
if (currentText.startsWith(otherfilter->shortcutString() + ' ')) {
|
||||
searchText = currentText.mid(otherfilter->shortcutString().length() + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
show(filter->shortcutString() + QLatin1Char(' ') + searchText,
|
||||
show(filter->shortcutString() + ' ' + searchText,
|
||||
filter->shortcutString().length() + 1,
|
||||
searchText.length());
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class CORE_EXPORT LocatorManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LocatorManager(QObject *parent = 0);
|
||||
LocatorManager(QObject *parent = nullptr);
|
||||
|
||||
static void showFilter(ILocatorFilter *filter);
|
||||
static void show(const QString &text, int selectionStart = -1, int selectionLength = 0);
|
||||
|
@@ -45,14 +45,14 @@ void Core::Internal::runSearch(QFutureInterface<Core::LocatorFilterEntry> &futur
|
||||
{
|
||||
QSet<LocatorFilterEntry> alreadyAdded;
|
||||
const bool checkDuplicates = (filters.size() > 1);
|
||||
foreach (ILocatorFilter *filter, filters) {
|
||||
for (ILocatorFilter *filter : filters) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
|
||||
QList<LocatorFilterEntry> filterResults = filter->matchesFor(future, searchText);
|
||||
const QList<LocatorFilterEntry> filterResults = filter->matchesFor(future, searchText);
|
||||
QVector<LocatorFilterEntry> uniqueFilterResults;
|
||||
uniqueFilterResults.reserve(filterResults.size());
|
||||
foreach (const LocatorFilterEntry &entry, filterResults) {
|
||||
for (const LocatorFilterEntry &entry : filterResults) {
|
||||
if (checkDuplicates && alreadyAdded.contains(entry))
|
||||
continue;
|
||||
uniqueFilterResults.append(entry);
|
||||
|
@@ -24,13 +24,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "locatorsettingspage.h"
|
||||
|
||||
#include "directoryfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include "locator.h"
|
||||
#include "locatorconstants.h"
|
||||
|
||||
#include "locator.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include "directoryfilter.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/categorysortfiltermodel.h>
|
||||
#include <utils/headerviewstretcher.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -64,7 +65,7 @@ public:
|
||||
ILocatorFilter *filter() const;
|
||||
|
||||
private:
|
||||
ILocatorFilter *m_filter;
|
||||
ILocatorFilter *m_filter = nullptr;
|
||||
};
|
||||
|
||||
class CategoryItem : public TreeItem
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
int m_order;
|
||||
int m_order = 0;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
@@ -269,32 +270,33 @@ void LocatorSettingsPage::setFilter(const QString &text)
|
||||
void LocatorSettingsPage::saveFilterStates()
|
||||
{
|
||||
m_filterStates.clear();
|
||||
foreach (ILocatorFilter *filter, m_filters)
|
||||
for (ILocatorFilter *filter : Utils::asConst(m_filters))
|
||||
m_filterStates.insert(filter, filter->saveState());
|
||||
}
|
||||
|
||||
void LocatorSettingsPage::restoreFilterStates()
|
||||
{
|
||||
foreach (ILocatorFilter *filter, m_filterStates.keys())
|
||||
const QList<ILocatorFilter *> filterStatesKeys = m_filterStates.keys();
|
||||
for (ILocatorFilter *filter : filterStatesKeys)
|
||||
filter->restoreState(m_filterStates.value(filter));
|
||||
}
|
||||
|
||||
void LocatorSettingsPage::initializeModel()
|
||||
{
|
||||
m_model->setHeader(QStringList({tr("Name"), tr("Prefix"), tr("Default")}));
|
||||
m_model->setHeaderToolTip(QStringList({
|
||||
m_model->setHeader({tr("Name"), tr("Prefix"), tr("Default")});
|
||||
m_model->setHeaderToolTip({
|
||||
QString(),
|
||||
ILocatorFilter::msgPrefixToolTip(),
|
||||
ILocatorFilter::msgIncludeByDefaultToolTip()
|
||||
}));
|
||||
});
|
||||
m_model->clear();
|
||||
QSet<ILocatorFilter *> customFilterSet = m_customFilters.toSet();
|
||||
auto builtIn = new CategoryItem(tr("Built-in"), 0/*order*/);
|
||||
foreach (ILocatorFilter *filter, m_filters)
|
||||
for (ILocatorFilter *filter : Utils::asConst(m_filters))
|
||||
if (!filter->isHidden() && !customFilterSet.contains(filter))
|
||||
builtIn->appendChild(new FilterItem(filter));
|
||||
m_customFilterRoot = new CategoryItem(tr("Custom"), 1/*order*/);
|
||||
foreach (ILocatorFilter *customFilter, m_customFilters)
|
||||
for (ILocatorFilter *customFilter : Utils::asConst(m_customFilters))
|
||||
m_customFilterRoot->appendChild(new FilterItem(customFilter));
|
||||
|
||||
m_model->rootItem()->appendChild(builtIn);
|
||||
@@ -305,7 +307,7 @@ void LocatorSettingsPage::updateButtonStates()
|
||||
{
|
||||
const QModelIndex currentIndex = m_proxyModel->mapToSource(m_ui.filterList->currentIndex());
|
||||
bool selected = currentIndex.isValid();
|
||||
ILocatorFilter *filter = 0;
|
||||
ILocatorFilter *filter = nullptr;
|
||||
if (selected) {
|
||||
auto item = dynamic_cast<FilterItem *>(m_model->itemForIndex(currentIndex));
|
||||
if (item)
|
||||
|
@@ -68,11 +68,11 @@ private:
|
||||
void setFilter(const QString &text);
|
||||
|
||||
Ui::LocatorSettingsWidget m_ui;
|
||||
Locator *m_plugin;
|
||||
Locator *m_plugin = nullptr;
|
||||
QPointer<QWidget> m_widget;
|
||||
Utils::TreeModel<> *m_model;
|
||||
QSortFilterProxyModel *m_proxyModel;
|
||||
Utils::TreeItem *m_customFilterRoot;
|
||||
Utils::TreeModel<> *m_model = nullptr;
|
||||
QSortFilterProxyModel *m_proxyModel = nullptr;
|
||||
Utils::TreeItem *m_customFilterRoot = nullptr;
|
||||
QList<ILocatorFilter *> m_filters;
|
||||
QList<ILocatorFilter *> m_addedFilters;
|
||||
QList<ILocatorFilter *> m_removedFilters;
|
||||
|
@@ -23,11 +23,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "locator.h"
|
||||
#include "locatorwidget.h"
|
||||
|
||||
#include "ilocatorfilter.h"
|
||||
#include "locator.h"
|
||||
#include "locatorconstants.h"
|
||||
#include "locatorsearchutils.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
ColumnCount
|
||||
};
|
||||
|
||||
LocatorModel(QObject *parent = 0)
|
||||
LocatorModel(QObject *parent = nullptr)
|
||||
: QAbstractListModel(parent)
|
||||
, mBackgroundColor(Utils::creatorTheme()->color(Utils::Theme::TextColorHighlightBackground).name())
|
||||
{}
|
||||
@@ -113,7 +114,7 @@ public:
|
||||
class CompletionList : public Utils::TreeView
|
||||
{
|
||||
public:
|
||||
CompletionList(QWidget *parent = 0);
|
||||
CompletionList(QWidget *parent = nullptr);
|
||||
|
||||
void setModel(QAbstractItemModel *model);
|
||||
|
||||
@@ -193,7 +194,7 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant(mEntries.at(index.row()).displayName);
|
||||
else
|
||||
return QVariant(mEntries.at(index.row()).displayName
|
||||
+ QLatin1String("\n\n") + mEntries.at(index.row()).extraInfo);
|
||||
+ "\n\n" + mEntries.at(index.row()).extraInfo);
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
if (index.column() == DisplayNameColumn) {
|
||||
@@ -752,7 +753,7 @@ QList<ILocatorFilter *> LocatorWidget::filtersFor(const QString &text, QString &
|
||||
if (whiteSpace >= 0) {
|
||||
const QString prefix = text.mid(firstNonSpace, whiteSpace - firstNonSpace).toLower();
|
||||
QList<ILocatorFilter *> prefixFilters;
|
||||
foreach (ILocatorFilter *filter, filters) {
|
||||
for (ILocatorFilter *filter : filters) {
|
||||
if (prefix == filter->shortcutString()) {
|
||||
searchText = text.mid(whiteSpace).trimmed();
|
||||
prefixFilters << filter;
|
||||
@@ -798,7 +799,7 @@ void LocatorWidget::updateCompletionList(const QString &text)
|
||||
QString searchText;
|
||||
const QList<ILocatorFilter *> filters = filtersFor(text, searchText);
|
||||
|
||||
foreach (ILocatorFilter *filter, filters)
|
||||
for (ILocatorFilter *filter : filters)
|
||||
filter->prepareSearch(searchText);
|
||||
QFuture<LocatorFilterEntry> future = Utils::runAsync(&runSearch, filters, searchText);
|
||||
m_entriesWatcher->setFuture(future);
|
||||
|
@@ -86,19 +86,19 @@ private:
|
||||
QList<ILocatorFilter*> filtersFor(const QString &text, QString &searchText);
|
||||
void setProgressIndicatorVisible(bool visible);
|
||||
|
||||
LocatorModel *m_locatorModel;
|
||||
LocatorModel *m_locatorModel = nullptr;
|
||||
|
||||
QMenu *m_filterMenu;
|
||||
QAction *m_refreshAction;
|
||||
QAction *m_configureAction;
|
||||
Utils::FancyLineEdit *m_fileLineEdit;
|
||||
QMenu *m_filterMenu = nullptr;
|
||||
QAction *m_refreshAction = nullptr;
|
||||
QAction *m_configureAction = nullptr;
|
||||
Utils::FancyLineEdit *m_fileLineEdit = nullptr;
|
||||
QTimer m_showPopupTimer;
|
||||
QFutureWatcher<LocatorFilterEntry> *m_entriesWatcher;
|
||||
QFutureWatcher<LocatorFilterEntry> *m_entriesWatcher = nullptr;
|
||||
QString m_requestedCompletionText;
|
||||
bool m_needsClearResult = true;
|
||||
bool m_updateRequested = false;
|
||||
bool m_possibleToolTipRequest = false;
|
||||
QWidget *m_progressIndicator;
|
||||
QWidget *m_progressIndicator = nullptr;
|
||||
QTimer m_showProgressTimer;
|
||||
Utils::optional<int> m_rowRequestedForAccept;
|
||||
};
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
class LocatorPopup : public QWidget
|
||||
{
|
||||
public:
|
||||
LocatorPopup(LocatorWidget *locatorWidget, QWidget *parent = 0);
|
||||
LocatorPopup(LocatorWidget *locatorWidget, QWidget *parent = nullptr);
|
||||
|
||||
CompletionList *completionList() const;
|
||||
LocatorWidget *inputWidget() const;
|
||||
@@ -121,12 +121,12 @@ protected:
|
||||
virtual void inputLostFocus();
|
||||
|
||||
QPointer<QWidget> m_window;
|
||||
CompletionList *m_tree;
|
||||
CompletionList *m_tree = nullptr;
|
||||
|
||||
private:
|
||||
void updateWindow();
|
||||
|
||||
LocatorWidget *m_inputWidget;
|
||||
LocatorWidget *m_inputWidget = nullptr;
|
||||
};
|
||||
|
||||
LocatorWidget *createStaticLocatorWidget(Locator *locator);
|
||||
|
@@ -42,7 +42,7 @@ OpenDocumentsFilter::OpenDocumentsFilter()
|
||||
{
|
||||
setId("Open documents");
|
||||
setDisplayName(tr("Open Documents"));
|
||||
setShortcutString(QString(QLatin1Char('o')));
|
||||
setShortcutString("o");
|
||||
setPriority(High);
|
||||
setIncludedByDefault(true);
|
||||
|
||||
@@ -65,7 +65,8 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locat
|
||||
if (!regexp.isValid())
|
||||
return goodEntries;
|
||||
|
||||
foreach (const Entry &editorEntry, editors()) {
|
||||
const QList<Entry> editorEntries = editors();
|
||||
for (const Entry &editorEntry : editorEntries) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
QString fileName = editorEntry.fileName.toString();
|
||||
@@ -92,7 +93,8 @@ void OpenDocumentsFilter::refreshInternally()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex); Q_UNUSED(lock)
|
||||
m_editors.clear();
|
||||
foreach (DocumentModel::Entry *e, DocumentModel::entries()) {
|
||||
const QList<DocumentModel::Entry *> documentEntries = DocumentModel::entries();
|
||||
for (DocumentModel::Entry *e : documentEntries) {
|
||||
Entry entry;
|
||||
// create copy with only the information relevant to use
|
||||
// to avoid model deleting entries behind our back
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
// tr() must not be placed in .mm file.
|
||||
setId("SpotlightFileNamesLocatorFilter");
|
||||
setDisplayName(tr("Spotlight File Name Index"));
|
||||
setShortcutString(QLatin1String("md"));
|
||||
setShortcutString("md");
|
||||
}
|
||||
|
||||
void prepareSearch(const QString &entry) override;
|
||||
|
@@ -27,9 +27,9 @@
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
@@ -43,7 +43,7 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppTools::CppModelManager *ma
|
||||
{
|
||||
setId("Methods in current Document");
|
||||
setDisplayName(tr("C++ Symbols in Current Document"));
|
||||
setShortcutString(QString(QLatin1Char('.')));
|
||||
setShortcutString(".");
|
||||
setPriority(High);
|
||||
setIncludedByDefault(false);
|
||||
|
||||
@@ -70,7 +70,8 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
|
||||
if (!regexp.isValid())
|
||||
return goodEntries;
|
||||
|
||||
foreach (IndexItem::Ptr info, itemsOfCurrentDocument()) {
|
||||
const QList<IndexItem::Ptr> items = itemsOfCurrentDocument();
|
||||
for (IndexItem::Ptr info : items) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData)
|
||||
{
|
||||
setId("Methods");
|
||||
setDisplayName(tr("C++ Functions"));
|
||||
setShortcutString(QString(QLatin1Char('m')));
|
||||
setShortcutString("m");
|
||||
setIncludedByDefault(false);
|
||||
}
|
||||
|
||||
@@ -53,9 +53,7 @@ Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem:
|
||||
if (extraInfo.isEmpty()) {
|
||||
extraInfo = info->shortNativeFilePath();
|
||||
} else {
|
||||
extraInfo.append(QLatin1String(" ("))
|
||||
.append(Utils::FileName::fromString(info->fileName()).fileName())
|
||||
.append(QLatin1String(")"));
|
||||
extraInfo.append(" (" + Utils::FileName::fromString(info->fileName()).fileName() + ')');
|
||||
}
|
||||
|
||||
Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon());
|
||||
|
@@ -117,7 +117,8 @@ void CppIncludesIterator::fetchMore()
|
||||
CPlusPlus::Document::Ptr doc = m_snapshot.document(filePath);
|
||||
if (!doc)
|
||||
continue;
|
||||
foreach (const QString &includedPath, doc->includedFiles()) {
|
||||
const QStringList includedFiles = doc->includedFiles();
|
||||
for (const QString &includedPath : includedFiles ) {
|
||||
if (!m_allResultPaths.contains(includedPath)) {
|
||||
m_allResultPaths.insert(includedPath);
|
||||
m_queuedPaths.insert(includedPath);
|
||||
@@ -128,11 +129,10 @@ void CppIncludesIterator::fetchMore()
|
||||
}
|
||||
|
||||
CppIncludesFilter::CppIncludesFilter()
|
||||
: m_needsUpdate(true)
|
||||
{
|
||||
setId("All Included C/C++ Files");
|
||||
setDisplayName(tr("All Included C/C++ Files"));
|
||||
setShortcutString(QString(QLatin1Char('a')));
|
||||
setShortcutString("a");
|
||||
setIncludedByDefault(true);
|
||||
setPriority(ILocatorFilter::Low);
|
||||
|
||||
@@ -159,10 +159,12 @@ void CppIncludesFilter::prepareSearch(const QString &entry)
|
||||
m_needsUpdate = false;
|
||||
QSet<QString> seedPaths;
|
||||
for (Project *project : SessionManager::projects()) {
|
||||
foreach (const Utils::FileName &filePath, project->files(Project::AllFiles))
|
||||
const Utils::FileNameList allFiles = project->files(Project::AllFiles);
|
||||
for (const Utils::FileName &filePath : allFiles )
|
||||
seedPaths.insert(filePath.toString());
|
||||
}
|
||||
foreach (DocumentModel::Entry *entry, DocumentModel::entries()) {
|
||||
const QList<DocumentModel::Entry *> entries = DocumentModel::entries();
|
||||
for (DocumentModel::Entry *entry : entries) {
|
||||
if (entry)
|
||||
seedPaths.insert(entry->fileName().toString());
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
void markOutdated();
|
||||
|
||||
bool m_needsUpdate;
|
||||
bool m_needsUpdate = true;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -55,7 +55,7 @@ void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ei && QFileInfo(document->fileName()).suffix() != QLatin1String("moc"))
|
||||
if (i == ei && QFileInfo(document->fileName()).suffix() != "moc")
|
||||
m_pendingDocuments.append(document);
|
||||
|
||||
flushPendingDocument(false);
|
||||
|
@@ -25,21 +25,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <QHash>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include "cpptools_global.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "searchsymbols.h"
|
||||
#include "stringtable.h"
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include <QHash>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
namespace Internal {
|
||||
class CppToolsPlugin;
|
||||
} // Internal namespace
|
||||
} // namespace Internal
|
||||
|
||||
class CppLocatorData : public QObject
|
||||
{
|
||||
@@ -73,7 +74,7 @@ private:
|
||||
{ return m_strings->insert(path); }
|
||||
|
||||
private:
|
||||
Internal::StringTable *m_strings; // Used to avoid QString duplication
|
||||
Internal::StringTable *m_strings = nullptr; // Used to avoid QString duplication
|
||||
|
||||
mutable SearchSymbols m_search;
|
||||
mutable QHash<QString, IndexItem::Ptr> m_infosByFile;
|
||||
@@ -82,4 +83,4 @@ private:
|
||||
mutable QVector<CPlusPlus::Document::Ptr> m_pendingDocuments;
|
||||
};
|
||||
|
||||
} // CppTools namespace
|
||||
} // namespace CppTools
|
||||
|
@@ -41,7 +41,7 @@ CppLocatorFilter::CppLocatorFilter(CppLocatorData *locatorData)
|
||||
{
|
||||
setId("Classes and Methods");
|
||||
setDisplayName(tr("C++ Classes, Enums and Functions"));
|
||||
setShortcutString(QString(QLatin1Char(':')));
|
||||
setShortcutString(":");
|
||||
setIncludedByDefault(false);
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ protected:
|
||||
virtual Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
|
||||
|
||||
protected:
|
||||
CppLocatorData *m_data;
|
||||
CppLocatorData *m_data = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -74,8 +74,8 @@ public:
|
||||
|
||||
ResultDataList results = ResultData::fromFilterEntryList(matchesFor(searchText));
|
||||
if (debug) {
|
||||
ResultData::printFilterEntries(expectedResults, QLatin1String("Expected:"));
|
||||
ResultData::printFilterEntries(results, QLatin1String("Results:"));
|
||||
ResultData::printFilterEntries(expectedResults, "Expected:");
|
||||
ResultData::printFilterEntries(results, "Results:");
|
||||
}
|
||||
QVERIFY(!results.isEmpty());
|
||||
QCOMPARE(results, expectedResults);
|
||||
@@ -105,8 +105,8 @@ public:
|
||||
|
||||
ResultDataList results = ResultData::fromFilterEntryList(matchesFor());
|
||||
if (debug) {
|
||||
ResultData::printFilterEntries(expectedResults, QLatin1String("Expected:"));
|
||||
ResultData::printFilterEntries(results, QLatin1String("Results:"));
|
||||
ResultData::printFilterEntries(expectedResults, "Expected:");
|
||||
ResultData::printFilterEntries(results, "Results:");
|
||||
}
|
||||
QVERIFY(!results.isEmpty());
|
||||
QCOMPARE(results, expectedResults);
|
||||
@@ -162,9 +162,9 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
ILocatorFilter *cppClassesFilter = PluginManager::getObject<CppClassesFilter>();
|
||||
ILocatorFilter *cppLocatorFilter = PluginManager::getObject<CppLocatorFilter>();
|
||||
|
||||
MyTestDataDir testDirectory(QLatin1String("testdata_basic"));
|
||||
const QString testFile = testDirectory.file(QLatin1String("file1.cpp"));
|
||||
const QString objTestFile = testDirectory.file(QLatin1String("file1.mm"));
|
||||
MyTestDataDir testDirectory("testdata_basic");
|
||||
const QString testFile = testDirectory.file("file1.cpp");
|
||||
const QString objTestFile = testDirectory.file("file1.mm");
|
||||
const QString testFileShort = FileUtils::shortNativePath(FileName::fromString(testFile));
|
||||
const QString objTestFileShort = FileUtils::shortNativePath(FileName::fromString(objTestFile));
|
||||
|
||||
@@ -319,8 +319,8 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
|
||||
{
|
||||
MyTestDataDir testDirectory(QLatin1String("testdata_basic"));
|
||||
const QString testFile = testDirectory.file(QLatin1String("file1.cpp"));
|
||||
MyTestDataDir testDirectory("testdata_basic");
|
||||
const QString testFile = testDirectory.file("file1.cpp");
|
||||
|
||||
QList<ResultData> expectedResults = QList<ResultData>()
|
||||
<< ResultData(_("int myVariable"), _(""))
|
||||
|
@@ -27,13 +27,13 @@
|
||||
|
||||
#include "centralwidget.h"
|
||||
#include "helpicons.h"
|
||||
#include "topicchooser.h"
|
||||
|
||||
#include <topicchooser.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QIcon>
|
||||
@@ -48,12 +48,11 @@ using namespace Help;
|
||||
using namespace Help::Internal;
|
||||
|
||||
HelpIndexFilter::HelpIndexFilter()
|
||||
: m_needsUpdate(true)
|
||||
{
|
||||
setId("HelpIndexFilter");
|
||||
setDisplayName(tr("Help Index"));
|
||||
setIncludedByDefault(false);
|
||||
setShortcutString(QString(QLatin1Char('?')));
|
||||
setShortcutString("?");
|
||||
|
||||
m_icon = Utils::Icons::BOOKMARK.icon();
|
||||
connect(HelpManager::instance(), &HelpManager::setupFinished,
|
||||
@@ -87,7 +86,7 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
|
||||
|| !entry.contains(m_searchTermCache)) {
|
||||
int limit = entry.size() < 2 ? 200 : INT_MAX;
|
||||
QSet<QString> results;
|
||||
foreach (const QString &filePath, m_helpDatabases) {
|
||||
for (const QString &filePath : Utils::asConst(m_helpDatabases)) {
|
||||
if (future.isCanceled())
|
||||
return QList<LocatorFilterEntry>();
|
||||
QSet<QString> result;
|
||||
@@ -112,7 +111,7 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
|
||||
keywords.reserve(m_keywordCache.size());
|
||||
unsortedKeywords.reserve(m_keywordCache.size());
|
||||
QSet<QString> allresults;
|
||||
foreach (const QString &keyword, m_keywordCache) {
|
||||
for (const QString &keyword : Utils::asConst(m_keywordCache)) {
|
||||
if (future.isCanceled())
|
||||
return QList<LocatorFilterEntry>();
|
||||
if (keyword.startsWith(entry, cs)) {
|
||||
@@ -127,7 +126,7 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
|
||||
keywords << unsortedKeywords;
|
||||
m_keywordCache = allresults;
|
||||
m_searchTermCache = entry;
|
||||
foreach (const QString &keyword, keywords) {
|
||||
for (const QString &keyword : Utils::asConst(keywords)) {
|
||||
const int index = keyword.indexOf(entry, 0, cs);
|
||||
LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon);
|
||||
filterEntry.highlightInfo = {index, entry.length()};
|
||||
|
@@ -60,7 +60,7 @@ private:
|
||||
QStringList m_helpDatabases;
|
||||
QSet<QString> m_keywordCache;
|
||||
QString m_searchTermCache;
|
||||
bool m_needsUpdate;
|
||||
bool m_needsUpdate = true;
|
||||
QMutex m_mutex;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include <QUrl>
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
namespace Internal {
|
||||
|
||||
RemoteFilterOptions::RemoteFilterOptions(RemoteHelpFilter *filter, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@@ -43,7 +43,9 @@ RemoteFilterOptions::RemoteFilterOptions(RemoteHelpFilter *filter, QWidget *pare
|
||||
m_ui.includeByDefault->setToolTip(Core::ILocatorFilter::msgIncludeByDefaultToolTip());
|
||||
m_ui.shortcutEdit->setText(m_filter->shortcutString());
|
||||
m_ui.includeByDefault->setChecked(m_filter->isIncludedByDefault());
|
||||
foreach (const QString &url, m_filter->remoteUrls()) {
|
||||
|
||||
const QStringList remoteUrls = m_filter->remoteUrls();
|
||||
for (const QString &url : remoteUrls) {
|
||||
QListWidgetItem *item = new QListWidgetItem(url);
|
||||
m_ui.listWidget->addItem(item);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
@@ -132,7 +134,8 @@ RemoteHelpFilter::~RemoteHelpFilter()
|
||||
QList<Core::LocatorFilterEntry> RemoteHelpFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
|
||||
{
|
||||
QList<Core::LocatorFilterEntry> entries;
|
||||
foreach (const QString &url, remoteUrls()) {
|
||||
const QStringList urls = remoteUrls();
|
||||
for (const QString &url : urls) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
const QString name = url.arg(entry);
|
||||
@@ -164,7 +167,7 @@ QByteArray RemoteHelpFilter::saveState() const
|
||||
{
|
||||
QByteArray value;
|
||||
QDataStream out(&value, QIODevice::WriteOnly);
|
||||
out << m_remoteUrls.join(QLatin1Char('^'));
|
||||
out << m_remoteUrls.join('^');
|
||||
out << shortcutString();
|
||||
out << isIncludedByDefault();
|
||||
return value;
|
||||
@@ -176,7 +179,7 @@ void RemoteHelpFilter::restoreState(const QByteArray &state)
|
||||
|
||||
QString value;
|
||||
in >> value;
|
||||
m_remoteUrls = value.split(QLatin1Char('^'), QString::SkipEmptyParts);
|
||||
m_remoteUrls = value.split('^', QString::SkipEmptyParts);
|
||||
|
||||
QString shortcut;
|
||||
in >> shortcut;
|
||||
@@ -209,5 +212,5 @@ QStringList RemoteHelpFilter::remoteUrls() const
|
||||
return m_remoteUrls;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Internal
|
||||
} // namespace Help
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <QMutex>
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
namespace Internal {
|
||||
|
||||
class RemoteHelpFilter : public Core::ILocatorFilter
|
||||
{
|
||||
@@ -69,7 +69,7 @@ class RemoteFilterOptions : public QDialog
|
||||
friend class RemoteHelpFilter;
|
||||
|
||||
public:
|
||||
explicit RemoteFilterOptions(RemoteHelpFilter *filter, QWidget *parent = 0);
|
||||
explicit RemoteFilterOptions(RemoteHelpFilter *filter, QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void addNewItem();
|
||||
@@ -78,9 +78,9 @@ private:
|
||||
void moveItemDown();
|
||||
void updateActionButtons();
|
||||
|
||||
RemoteHelpFilter *m_filter;
|
||||
RemoteHelpFilter *m_filter = nullptr;
|
||||
Ui::RemoteFilterOptions m_ui;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Internal
|
||||
} // namespace Help
|
||||
|
@@ -24,12 +24,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "macrolocatorfilter.h"
|
||||
#include "macromanager.h"
|
||||
#include "macro.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include "macro.h"
|
||||
#include "macromanager.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
@@ -37,11 +38,11 @@ using namespace Macros;
|
||||
using namespace Macros::Internal;
|
||||
|
||||
MacroLocatorFilter::MacroLocatorFilter():
|
||||
m_icon(QPixmap(QLatin1String(":/macros/images/macro.png")))
|
||||
m_icon(QPixmap(":/macros/images/macro.png"))
|
||||
{
|
||||
setId("Macros");
|
||||
setDisplayName(tr("Text Editing Macros"));
|
||||
setShortcutString(QLatin1String("rm"));
|
||||
setShortcutString("rm");
|
||||
}
|
||||
|
||||
MacroLocatorFilter::~MacroLocatorFilter()
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmljsfunctionfilter.h"
|
||||
|
||||
#include "qmljslocatordata.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -41,7 +42,7 @@ FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent)
|
||||
{
|
||||
setId("Functions");
|
||||
setDisplayName(tr("QML Functions"));
|
||||
setShortcutString(QString(QLatin1Char('m')));
|
||||
setShortcutString("m");
|
||||
setIncludedByDefault(false);
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(
|
||||
it.next();
|
||||
|
||||
const QList<LocatorData::Entry> items = it.value();
|
||||
foreach (const LocatorData::Entry &info, items) {
|
||||
for (const LocatorData::Entry &info : items) {
|
||||
if (info.type != LocatorData::Function)
|
||||
continue;
|
||||
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
void refresh(QFutureInterface<void> &future) override;
|
||||
|
||||
private:
|
||||
LocatorData *m_data;
|
||||
LocatorData *m_data = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "linenumberfilter.h"
|
||||
|
||||
#include "texteditor.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -48,7 +49,7 @@ LineNumberFilter::LineNumberFilter(QObject *parent)
|
||||
setId("Line in current document");
|
||||
setDisplayName(tr("Line in Current Document"));
|
||||
setPriority(High);
|
||||
setShortcutString(QString(QLatin1Char('l')));
|
||||
setShortcutString("l");
|
||||
setIncludedByDefault(true);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ void LineNumberFilter::prepareSearch(const QString &entry)
|
||||
QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &, const QString &entry)
|
||||
{
|
||||
QList<LocatorFilterEntry> value;
|
||||
const QVector<QStringRef> lineAndColumn = entry.splitRef(QLatin1Char(':'));
|
||||
const QVector<QStringRef> lineAndColumn = entry.splitRef(':');
|
||||
int sectionCount = lineAndColumn.size();
|
||||
int line = 0;
|
||||
int column = 0;
|
||||
|
Reference in New Issue
Block a user