forked from qt-creator/qt-creator
Advanced search: Add exclusion patterns
All files with full file path matching one of the exclusion patterns are ignored in the search. Searching with "git grep" now requires git >= 1.9 Change-Id: Ied5d11499bc1ff21247e50f8e146e8e5011dd2c1 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -190,7 +190,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
}
|
||||
directories = m_directories;
|
||||
}
|
||||
Utils::SubDirFileIterator subDirIterator(directories, m_filters);
|
||||
Utils::SubDirFileIterator subDirIterator(directories, m_filters, {});
|
||||
future.setProgressRange(0, subDirIterator.maxProgress());
|
||||
QStringList filesFound;
|
||||
auto end = subDirIterator.end();
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <vcsbase/vcscommand.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/asconst.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/filesearch.h>
|
||||
@@ -159,7 +160,14 @@ public:
|
||||
arguments << params.ref;
|
||||
m_ref = params.ref + ':';
|
||||
}
|
||||
arguments << "--" << m_parameters.nameFilters;
|
||||
const QStringList filterArgs =
|
||||
m_parameters.nameFilters.isEmpty() ? QStringList("*") // needed for exclusion filters
|
||||
: m_parameters.nameFilters;
|
||||
const QStringList exclusionArgs =
|
||||
Utils::transform(m_parameters.exclusionFilters, [](const QString &filter) {
|
||||
return QString(":!" + filter);
|
||||
});
|
||||
arguments << "--" << filterArgs << exclusionArgs;
|
||||
QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory));
|
||||
command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage);
|
||||
command->setProgressiveOutput(true);
|
||||
|
||||
@@ -97,7 +97,7 @@ using namespace VcsBase;
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
const unsigned minimumRequiredVersion = 0x010800;
|
||||
const unsigned minimumRequiredVersion = 0x010900;
|
||||
|
||||
const VcsBaseEditorParameters editorParameters[] = {
|
||||
{
|
||||
|
||||
@@ -68,41 +68,28 @@ bool AllProjectsFind::isEnabled() const
|
||||
}
|
||||
|
||||
Utils::FileIterator *AllProjectsFind::files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
{
|
||||
Q_UNUSED(additionalParameters)
|
||||
return filesForProjects(nameFilters, SessionManager::projects());
|
||||
return filesForProjects(nameFilters, exclusionFilters, SessionManager::projects());
|
||||
}
|
||||
|
||||
Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFilters,
|
||||
const QList<Project *> &projects) const
|
||||
const QStringList &exclusionFilters,
|
||||
const QList<Project *> &projects) const
|
||||
{
|
||||
QList<QRegExp> filterRegs;
|
||||
foreach (const QString &filter, nameFilters) {
|
||||
filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
}
|
||||
QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||
std::function<QStringList(const QStringList &)> filterFiles =
|
||||
Utils::filterFilesFunction(nameFilters, exclusionFilters);
|
||||
const QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||
QMap<QString, QTextCodec *> encodings;
|
||||
foreach (const Project *project, projects) {
|
||||
QStringList projectFiles = project->files(Project::AllFiles);
|
||||
QStringList filteredFiles;
|
||||
if (!filterRegs.isEmpty()) {
|
||||
foreach (const QString &file, projectFiles) {
|
||||
if (Utils::anyOf(filterRegs,
|
||||
[&file](QRegExp reg) {
|
||||
return (reg.exactMatch(file) || reg.exactMatch(Utils::FileName::fromString(file).fileName()));
|
||||
})) {
|
||||
filteredFiles.append(file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filteredFiles = projectFiles;
|
||||
}
|
||||
const EditorConfiguration *config = project->editorConfiguration();
|
||||
QTextCodec *projectCodec = config->useGlobalSettings()
|
||||
? Core::EditorManager::defaultTextCodec()
|
||||
: config->textCodec();
|
||||
foreach (const QString &fileName, filteredFiles) {
|
||||
const QStringList filteredFiles = filterFiles(project->files(Project::AllFiles));
|
||||
for (const QString &fileName : filteredFiles) {
|
||||
QTextCodec *codec = openEditorEncodings.value(fileName);
|
||||
if (!codec)
|
||||
codec = projectCodec;
|
||||
@@ -124,8 +111,10 @@ QString AllProjectsFind::label() const
|
||||
|
||||
QString AllProjectsFind::toolTip() const
|
||||
{
|
||||
// %2 is filled by BaseFileFind::runNewSearch
|
||||
return tr("Filter: %1\n%2").arg(fileNameFilters().join(QLatin1Char(',')));
|
||||
// last arg is filled by BaseFileFind::runNewSearch
|
||||
return tr("Filter: %1\nExcluding: %2\n%3")
|
||||
.arg(fileNameFilters().join(','))
|
||||
.arg(fileExclusionFilters().join(','));
|
||||
}
|
||||
|
||||
void AllProjectsFind::handleFileListChanged()
|
||||
@@ -140,14 +129,13 @@ QWidget *AllProjectsFind::createConfigWidget()
|
||||
auto gridLayout = new QGridLayout(m_configWidget);
|
||||
gridLayout->setMargin(0);
|
||||
m_configWidget->setLayout(gridLayout);
|
||||
auto filePatternLabel = new QLabel(tr("Fi&le pattern:"));
|
||||
filePatternLabel->setMinimumWidth(80);
|
||||
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
QWidget *patternWidget = createPatternWidget();
|
||||
filePatternLabel->setBuddy(patternWidget);
|
||||
gridLayout->addWidget(filePatternLabel, 0, 0, Qt::AlignRight);
|
||||
gridLayout->addWidget(patternWidget, 0, 1);
|
||||
const QList<QPair<QWidget *, QWidget *>> patternWidgets = createPatternWidgets();
|
||||
int row = 0;
|
||||
for (const QPair<QWidget *, QWidget *> &p : patternWidgets) {
|
||||
gridLayout->addWidget(p.first, row, 0, Qt::AlignRight);
|
||||
gridLayout->addWidget(p.second, row, 1);
|
||||
++row;
|
||||
}
|
||||
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
return m_configWidget;
|
||||
@@ -163,6 +151,6 @@ void AllProjectsFind::writeSettings(QSettings *settings)
|
||||
void AllProjectsFind::readSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String("AllProjectsFind"));
|
||||
readCommonSettings(settings, QString(QLatin1Char('*')));
|
||||
readCommonSettings(settings, "*", "");
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -53,8 +53,10 @@ public:
|
||||
|
||||
protected:
|
||||
Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const override;
|
||||
Utils::FileIterator *filesForProjects(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QList<Project *> &projects) const;
|
||||
|
||||
QVariant additionalParameters() const override;
|
||||
|
||||
@@ -73,14 +73,15 @@ QVariant CurrentProjectFind::additionalParameters() const
|
||||
}
|
||||
|
||||
Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
{
|
||||
QTC_ASSERT(additionalParameters.isValid(),
|
||||
return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>()));
|
||||
QString projectFile = additionalParameters.toString();
|
||||
foreach (Project *project, SessionManager::projects()) {
|
||||
if (project->document() && projectFile == project->projectFilePath().toString())
|
||||
return filesForProjects(nameFilters, QList<Project *>() << project);
|
||||
return filesForProjects(nameFilters, exclusionFilters, QList<Project *>() << project);
|
||||
}
|
||||
return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>());
|
||||
}
|
||||
@@ -123,6 +124,6 @@ void CurrentProjectFind::writeSettings(QSettings *settings)
|
||||
void CurrentProjectFind::readSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String("CurrentProjectFind"));
|
||||
readCommonSettings(settings, QString(QLatin1Char('*')));
|
||||
readCommonSettings(settings, "*", "");
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
protected:
|
||||
Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const override;
|
||||
QVariant additionalParameters() const override;
|
||||
QString label() const override;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <coreplugin/find/ifindsupport.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/refactoringchanges.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fadingindicator.h>
|
||||
#include <utils/filesearch.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -78,7 +79,8 @@ public:
|
||||
: Utils::findInFiles;
|
||||
|
||||
return func(parameters.text,
|
||||
baseFileFind->files(parameters.nameFilters, parameters.additionalParameters),
|
||||
baseFileFind->files(parameters.nameFilters, parameters.exclusionFilters,
|
||||
parameters.additionalParameters),
|
||||
textDocumentFlagsForFindFlags(parameters.flags),
|
||||
TextDocument::openedTextDocumentContents());
|
||||
|
||||
@@ -114,9 +116,14 @@ public:
|
||||
QPointer<IFindSupport> m_currentFindSupport;
|
||||
|
||||
QLabel *m_resultLabel = 0;
|
||||
// models in native path format
|
||||
QStringListModel m_filterStrings;
|
||||
QStringListModel m_exclusionStrings;
|
||||
// current filter in portable path format
|
||||
QString m_filterSetting;
|
||||
QString m_exclusionSetting;
|
||||
QPointer<QComboBox> m_filterCombo;
|
||||
QPointer<QComboBox> m_exclusionCombo;
|
||||
QVector<SearchEngine *> m_searchEngines;
|
||||
SearchEngine *m_internalSearchEngine;
|
||||
int m_currentSearchEngineIndex = -1;
|
||||
@@ -128,9 +135,10 @@ static void syncComboWithSettings(QComboBox *combo, const QString &setting)
|
||||
{
|
||||
if (!combo)
|
||||
return;
|
||||
int index = combo->findText(setting);
|
||||
const QString &nativeSettings = QDir::toNativeSeparators(setting);
|
||||
int index = combo->findText(nativeSettings);
|
||||
if (index < 0)
|
||||
combo->setEditText(setting);
|
||||
combo->setEditText(nativeSettings);
|
||||
else
|
||||
combo->setCurrentIndex(index);
|
||||
}
|
||||
@@ -188,18 +196,27 @@ bool BaseFileFind::isEnabled() const
|
||||
return true;
|
||||
}
|
||||
|
||||
static QStringList splitFilterUiText(const QString &text)
|
||||
{
|
||||
const QStringList parts = text.split(',');
|
||||
const QStringList trimmedPortableParts = Utils::transform(parts, [](const QString &s) {
|
||||
return QDir::fromNativeSeparators(s.trimmed());
|
||||
});
|
||||
return Utils::filtered(trimmedPortableParts, [](const QString &s) { return !s.isEmpty(); });
|
||||
}
|
||||
|
||||
QStringList BaseFileFind::fileNameFilters() const
|
||||
{
|
||||
QStringList filters;
|
||||
if (d->m_filterCombo && !d->m_filterCombo->currentText().isEmpty()) {
|
||||
const QStringList parts = d->m_filterCombo->currentText().split(',');
|
||||
foreach (const QString &part, parts) {
|
||||
const QString filter = part.trimmed();
|
||||
if (!filter.isEmpty())
|
||||
filters << filter;
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
if (d->m_filterCombo)
|
||||
return splitFilterUiText(d->m_filterCombo->currentText());
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList BaseFileFind::fileExclusionFilters() const
|
||||
{
|
||||
if (d->m_exclusionCombo)
|
||||
return splitFilterUiText(d->m_exclusionCombo->currentText());
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
SearchEngine *BaseFileFind::currentSearchEngine() const
|
||||
@@ -248,6 +265,8 @@ void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags,
|
||||
d->m_currentFindSupport = 0;
|
||||
if (d->m_filterCombo)
|
||||
updateComboEntries(d->m_filterCombo, true);
|
||||
if (d->m_exclusionCombo)
|
||||
updateComboEntries(d->m_exclusionCombo, true);
|
||||
QString tooltip = toolTip();
|
||||
|
||||
SearchResult *search = SearchResultWindow::instance()->startNewSearch(
|
||||
@@ -261,6 +280,7 @@ void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags,
|
||||
parameters.text = txt;
|
||||
parameters.flags = findFlags;
|
||||
parameters.nameFilters = fileNameFilters();
|
||||
parameters.exclusionFilters = fileExclusionFilters();
|
||||
parameters.additionalParameters = additionalParameters();
|
||||
parameters.searchEngineParameters = currentSearchEngine()->parameters();
|
||||
parameters.searchEngineIndex = d->m_currentSearchEngineIndex;
|
||||
@@ -340,46 +360,93 @@ void BaseFileFind::doReplace(const QString &text,
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *BaseFileFind::createPatternWidget()
|
||||
static QComboBox *createCombo(QAbstractItemModel *model)
|
||||
{
|
||||
QString filterToolTip = tr("List of comma separated wildcard filters");
|
||||
d->m_filterCombo = new QComboBox;
|
||||
d->m_filterCombo->setEditable(true);
|
||||
d->m_filterCombo->setModel(&d->m_filterStrings);
|
||||
d->m_filterCombo->setMaxCount(10);
|
||||
d->m_filterCombo->setMinimumContentsLength(10);
|
||||
d->m_filterCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
d->m_filterCombo->setInsertPolicy(QComboBox::InsertAtBottom);
|
||||
d->m_filterCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
auto combo = new QComboBox;
|
||||
combo->setEditable(true);
|
||||
combo->setModel(model);
|
||||
combo->setMaxCount(10);
|
||||
combo->setMinimumContentsLength(10);
|
||||
combo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
combo->setInsertPolicy(QComboBox::InsertAtBottom);
|
||||
combo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
return combo;
|
||||
}
|
||||
|
||||
static QLabel *createLabel(const QString &text)
|
||||
{
|
||||
auto filePatternLabel = new QLabel(text);
|
||||
filePatternLabel->setMinimumWidth(80);
|
||||
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
return filePatternLabel;
|
||||
}
|
||||
|
||||
QList<QPair<QWidget *, QWidget *>> BaseFileFind::createPatternWidgets()
|
||||
{
|
||||
static const QString filterToolTip = tr("List of comma separated wildcard filters. "
|
||||
"Files with file name or full file path matching any filter are included.");
|
||||
QLabel *filterLabel = createLabel(tr("Fi&le pattern:"));
|
||||
d->m_filterCombo = createCombo(&d->m_filterStrings);
|
||||
d->m_filterCombo->setToolTip(filterToolTip);
|
||||
filterLabel->setBuddy(d->m_filterCombo);
|
||||
syncComboWithSettings(d->m_filterCombo, d->m_filterSetting);
|
||||
return d->m_filterCombo;
|
||||
QLabel *exclusionLabel = createLabel(tr("Exclusion pattern:"));
|
||||
d->m_exclusionCombo = createCombo(&d->m_exclusionStrings);
|
||||
d->m_exclusionCombo->setToolTip(filterToolTip);
|
||||
exclusionLabel->setBuddy(d->m_exclusionCombo);
|
||||
syncComboWithSettings(d->m_exclusionCombo, d->m_exclusionSetting);
|
||||
return { qMakePair(filterLabel, d->m_filterCombo),
|
||||
qMakePair(exclusionLabel, d->m_exclusionCombo) };
|
||||
}
|
||||
|
||||
void BaseFileFind::writeCommonSettings(QSettings *settings)
|
||||
{
|
||||
settings->setValue("filters", d->m_filterStrings.stringList());
|
||||
std::function<QStringList(const QStringList &)> fromNativeSeparators = [](const QStringList &files) {
|
||||
return Utils::transform(files, &QDir::fromNativeSeparators);
|
||||
};
|
||||
|
||||
settings->setValue("filters", fromNativeSeparators(d->m_filterStrings.stringList()));
|
||||
if (d->m_filterCombo)
|
||||
settings->setValue("currentFilter", d->m_filterCombo->currentText());
|
||||
settings->setValue("currentFilter",
|
||||
QDir::fromNativeSeparators(d->m_filterCombo->currentText()));
|
||||
settings->setValue("exclusionFilters", fromNativeSeparators(d->m_exclusionStrings.stringList()));
|
||||
if (d->m_exclusionCombo)
|
||||
settings->setValue("currentExclusionFilter",
|
||||
QDir::fromNativeSeparators(d->m_exclusionCombo->currentText()));
|
||||
|
||||
foreach (SearchEngine *searchEngine, d->m_searchEngines)
|
||||
searchEngine->writeSettings(settings);
|
||||
settings->setValue("currentSearchEngineIndex", d->m_currentSearchEngineIndex);
|
||||
}
|
||||
|
||||
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter)
|
||||
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter,
|
||||
const QString &defaultExclusionFilter)
|
||||
{
|
||||
std::function<QStringList(const QStringList &)> toNativeSeparators = [](const QStringList &files) {
|
||||
return Utils::transform(files, &QDir::toNativeSeparators);
|
||||
};
|
||||
|
||||
QStringList filters = settings->value("filters").toStringList();
|
||||
const QVariant currentFilter = settings->value("currentFilter");
|
||||
d->m_filterSetting = currentFilter.toString();
|
||||
if (filters.isEmpty())
|
||||
filters << defaultFilter;
|
||||
if (!currentFilter.isValid())
|
||||
d->m_filterSetting = filters.first();
|
||||
d->m_filterStrings.setStringList(filters);
|
||||
const QVariant currentFilter = settings->value("currentFilter");
|
||||
d->m_filterSetting = currentFilter.isValid() ? currentFilter.toString()
|
||||
: filters.first();
|
||||
d->m_filterStrings.setStringList(toNativeSeparators(filters));
|
||||
if (d->m_filterCombo)
|
||||
syncComboWithSettings(d->m_filterCombo, d->m_filterSetting);
|
||||
|
||||
QStringList exclusionFilters = settings->value("exclusionFilters").toStringList();
|
||||
if (exclusionFilters.isEmpty())
|
||||
exclusionFilters << defaultExclusionFilter;
|
||||
const QVariant currentExclusionFilter = settings->value("currentExclusionFilter");
|
||||
d->m_exclusionSetting = currentExclusionFilter.isValid() ? currentExclusionFilter.toString()
|
||||
: exclusionFilters.first();
|
||||
d->m_exclusionStrings.setStringList(toNativeSeparators(exclusionFilters));
|
||||
if (d->m_exclusionCombo)
|
||||
syncComboWithSettings(d->m_exclusionCombo, d->m_exclusionSetting);
|
||||
|
||||
foreach (SearchEngine* searchEngine, d->m_searchEngines)
|
||||
searchEngine->readSettings(settings);
|
||||
const int currentSearchEngineIndex = settings->value("currentSearchEngineIndex", 0).toInt();
|
||||
|
||||
@@ -57,11 +57,12 @@ class TEXTEDITOR_EXPORT FileFindParameters
|
||||
{
|
||||
public:
|
||||
QString text;
|
||||
Core::FindFlags flags;
|
||||
QStringList nameFilters;
|
||||
QStringList exclusionFilters;
|
||||
QVariant additionalParameters;
|
||||
int searchEngineIndex;
|
||||
QVariant searchEngineParameters;
|
||||
int searchEngineIndex;
|
||||
Core::FindFlags flags;
|
||||
};
|
||||
|
||||
class BaseFileFind;
|
||||
@@ -111,6 +112,7 @@ public:
|
||||
const QList<Core::SearchResultItem> &items,
|
||||
bool preserveCase = false);
|
||||
virtual Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const = 0;
|
||||
|
||||
protected:
|
||||
@@ -122,9 +124,10 @@ protected:
|
||||
QFuture<Utils::FileSearchResultList> executeSearch(const FileFindParameters ¶meters);
|
||||
|
||||
void writeCommonSettings(QSettings *settings);
|
||||
void readCommonSettings(QSettings *settings, const QString &defaultFilter);
|
||||
QWidget *createPatternWidget();
|
||||
void readCommonSettings(QSettings *settings, const QString &defaultFilter, const QString &defaultExclusionFilter);
|
||||
QList<QPair<QWidget *, QWidget *>> createPatternWidgets();
|
||||
QStringList fileNameFilters() const;
|
||||
QStringList fileExclusionFilters() const;
|
||||
|
||||
SearchEngine *currentSearchEngine() const;
|
||||
QVector<SearchEngine *> searchEngines() const;
|
||||
|
||||
@@ -57,9 +57,11 @@ QString FindInCurrentFile::displayName() const
|
||||
}
|
||||
|
||||
Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
{
|
||||
Q_UNUSED(nameFilters)
|
||||
Q_UNUSED(exclusionFilters)
|
||||
QString fileName = additionalParameters.toString();
|
||||
QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||
QTextCodec *codec = openEditorEncodings.value(fileName);
|
||||
@@ -116,6 +118,6 @@ void FindInCurrentFile::writeSettings(QSettings *settings)
|
||||
void FindInCurrentFile::readSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String("FindInCurrentFile"));
|
||||
readCommonSettings(settings, QLatin1String("*"));
|
||||
readCommonSettings(settings, "*", "");
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
protected:
|
||||
Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const;
|
||||
QVariant additionalParameters() const;
|
||||
QString label() const;
|
||||
|
||||
@@ -80,10 +80,12 @@ QString FindInFiles::displayName() const
|
||||
}
|
||||
|
||||
FileIterator *FindInFiles::files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
{
|
||||
return new SubDirFileIterator(QStringList() << additionalParameters.toString(),
|
||||
nameFilters,
|
||||
exclusionFilters,
|
||||
EditorManager::defaultTextCodec());
|
||||
}
|
||||
|
||||
@@ -107,9 +109,10 @@ QString FindInFiles::label() const
|
||||
QString FindInFiles::toolTip() const
|
||||
{
|
||||
//: the last arg is filled by BaseFileFind::runNewSearch
|
||||
QString tooltip = tr("Path: %1\nFilter: %2\n%3")
|
||||
QString tooltip = tr("Path: %1\nFilter: %2\nExcluding: %3\n%4")
|
||||
.arg(path().toUserOutput())
|
||||
.arg(fileNameFilters().join(QLatin1Char(',')));
|
||||
.arg(fileNameFilters().join(','))
|
||||
.arg(fileExclusionFilters().join(','));
|
||||
|
||||
const QString searchEngineToolTip = currentSearchEngine()->toolTip();
|
||||
if (!searchEngineToolTip.isEmpty())
|
||||
@@ -183,14 +186,12 @@ QWidget *FindInFiles::createConfigWidget()
|
||||
dirLabel->setBuddy(m_directory);
|
||||
gridLayout->addWidget(m_directory, row++, 1, 1, 2);
|
||||
|
||||
QLabel * const filePatternLabel = new QLabel(tr("Fi&le pattern:"));
|
||||
filePatternLabel->setMinimumWidth(80);
|
||||
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
QWidget *patternWidget = createPatternWidget();
|
||||
filePatternLabel->setBuddy(patternWidget);
|
||||
gridLayout->addWidget(filePatternLabel, row, 0);
|
||||
gridLayout->addWidget(patternWidget, row++, 1, 1, 2);
|
||||
const QList<QPair<QWidget *, QWidget *>> patternWidgets = createPatternWidgets();
|
||||
for (const QPair<QWidget *, QWidget *> &p : patternWidgets) {
|
||||
gridLayout->addWidget(p.first, row, 0, Qt::AlignRight);
|
||||
gridLayout->addWidget(p.second, row, 1, 1, 2);
|
||||
++row;
|
||||
}
|
||||
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
|
||||
// validity
|
||||
@@ -221,7 +222,7 @@ void FindInFiles::writeSettings(QSettings *settings)
|
||||
void FindInFiles::readSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String("FindInFiles"));
|
||||
readCommonSettings(settings, QLatin1String("*.cpp,*.h"));
|
||||
readCommonSettings(settings, "*.cpp,*.h", "*/.git/*,*/.cvs/*,*/.svn/*");
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ signals:
|
||||
|
||||
protected:
|
||||
Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const override;
|
||||
QVariant additionalParameters() const override;
|
||||
QString label() const override;
|
||||
|
||||
@@ -56,9 +56,11 @@ QString FindInOpenFiles::displayName() const
|
||||
}
|
||||
|
||||
Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const
|
||||
{
|
||||
Q_UNUSED(nameFilters)
|
||||
Q_UNUSED(exclusionFilters)
|
||||
Q_UNUSED(additionalParameters)
|
||||
QMap<QString, QTextCodec *> openEditorEncodings
|
||||
= TextDocument::openedTextDocumentEncodings();
|
||||
@@ -110,7 +112,7 @@ void FindInOpenFiles::writeSettings(QSettings *settings)
|
||||
void FindInOpenFiles::readSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String("FindInOpenFiles"));
|
||||
readCommonSettings(settings, QLatin1String("*"));
|
||||
readCommonSettings(settings, "*", "");
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
|
||||
protected:
|
||||
Utils::FileIterator *files(const QStringList &nameFilters,
|
||||
const QStringList &exclusionFilters,
|
||||
const QVariant &additionalParameters) const;
|
||||
QVariant additionalParameters() const;
|
||||
QString label() const;
|
||||
|
||||
Reference in New Issue
Block a user