Add "Files in All Project Directories" global search

Similar to the corresponding locator filter.

It searches in the project directories, not limited to the files that
are actually mentioned in the project itself. That is helpful if
projects don't mention resources, or README's, or header files, or
"alien" project files in case the project supports multiple build
systems.

In principle, for single projects, this can be achieved with the "Files
in File System" filter, but that is less convenient because one needs to
specify the directory.

Change-Id: I94bc664cadd0881274ae709b00b8576c696cc325
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2021-09-24 15:39:48 +02:00
parent 95f7c5f256
commit fdb5c7a8a3
6 changed files with 195 additions and 44 deletions

View File

@@ -79,6 +79,8 @@ add_qtc_plugin(ProjectExplorer
extraabi.cpp extraabi.h extraabi.cpp extraabi.h
extracompiler.cpp extracompiler.h extracompiler.cpp extracompiler.h
fileinsessionfinder.cpp fileinsessionfinder.h fileinsessionfinder.cpp fileinsessionfinder.h
filesinallprojectsfind.h
filesinallprojectsfind.cpp
filterkitaspectsdialog.cpp filterkitaspectsdialog.h filterkitaspectsdialog.cpp filterkitaspectsdialog.h
foldernavigationwidget.cpp foldernavigationwidget.h foldernavigationwidget.cpp foldernavigationwidget.h
gccparser.cpp gccparser.h gccparser.cpp gccparser.h

View File

@@ -0,0 +1,92 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "filesinallprojectsfind.h"
#include "project.h"
#include "session.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/algorithm.h>
#include <utils/filesearch.h>
#include <QSettings>
using namespace Utils;
namespace ProjectExplorer {
namespace Internal {
QString FilesInAllProjectsFind::id() const
{
return QLatin1String("Files in All Project Directories");
}
QString FilesInAllProjectsFind::displayName() const
{
return tr("Files in All Project Directories");
}
const char kSettingsKey[] = "FilesInAllProjectDirectories";
void FilesInAllProjectsFind::writeSettings(QSettings *settings)
{
settings->beginGroup(kSettingsKey);
writeCommonSettings(settings);
settings->endGroup();
}
void FilesInAllProjectsFind::readSettings(QSettings *settings)
{
settings->beginGroup(kSettingsKey);
readCommonSettings(
settings,
"CMakeLists.txt,*.cmake,*.pro,*.pri,*.qbs,*.cpp,*.h,*.mm,*.qml,*.md,*.txt,*.qdoc",
"*/.git/*,*/.cvs/*,*/.svn/*,*.autosave");
settings->endGroup();
}
Utils::FileIterator *FilesInAllProjectsFind::files(const QStringList &nameFilters,
const QStringList &exclusionFilters,
const QVariant &additionalParameters) const
{
Q_UNUSED(additionalParameters)
const QSet<FilePath> dirs = Utils::transform<QSet>(SessionManager::projects(), [](Project *p) {
return p->projectFilePath().parentDir();
});
const QStringList dirStrings = Utils::transform<QStringList>(dirs, &FilePath::toString);
return new SubDirFileIterator(dirStrings,
nameFilters,
exclusionFilters,
Core::EditorManager::defaultTextCodec());
}
QString FilesInAllProjectsFind::label() const
{
return tr("Files in All Project Directories:");
}
} // namespace Internal
} // namespace ProjectExplorer

View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "allprojectsfind.h"
namespace ProjectExplorer {
namespace Internal {
class FilesInAllProjectsFind : public AllProjectsFind
{
Q_OBJECT
public:
QString id() const override;
QString displayName() const override;
void writeSettings(QSettings *settings) override;
void readSettings(QSettings *settings) override;
protected:
Utils::FileIterator *files(const QStringList &nameFilters,
const QStringList &exclusionFilters,
const QVariant &additionalParameters) const override;
QString label() const override;
};
} // namespace Internal
} // namespace ProjectExplorer

View File

@@ -43,62 +43,62 @@
#ifdef WITH_JOURNALD #ifdef WITH_JOURNALD
#include "journaldwatcher.h" #include "journaldwatcher.h"
#endif #endif
#include "jsonwizard/jsonwizardfactory.h"
#include "jsonwizard/jsonwizardgeneratorfactory.h"
#include "jsonwizard/jsonwizardpagefactory_p.h"
#include "namedwidget.h"
#include "project.h"
#include "projectexplorersettings.h"
#include "projectexplorersettingspage.h"
#include "projectmanager.h"
#include "removetaskhandler.h"
#include "runconfigurationaspects.h"
#include "kitfeatureprovider.h"
#include "kitmanager.h"
#include "kitoptionspage.h"
#include "parseissuesdialog.h"
#include "target.h"
#include "toolchainmanager.h"
#include "toolchainoptionspage.h"
#include "copytaskhandler.h"
#include "showineditortaskhandler.h"
#include "vcsannotatetaskhandler.h"
#include "allprojectsfilter.h" #include "allprojectsfilter.h"
#include "allprojectsfind.h" #include "allprojectsfind.h"
#include "appoutputpane.h"
#include "buildconfiguration.h"
#include "buildmanager.h" #include "buildmanager.h"
#include "buildsettingspropertiespage.h" #include "buildsettingspropertiespage.h"
#include "currentprojectfind.h"
#include "currentprojectfilter.h"
#include "editorsettingspropertiespage.h"
#include "codestylesettingspropertiespage.h" #include "codestylesettingspropertiespage.h"
#include "dependenciespanel.h" #include "copytaskhandler.h"
#include "foldernavigationwidget.h" #include "currentprojectfilter.h"
#include "appoutputpane.h" #include "currentprojectfind.h"
#include "processstep.h"
#include "kitinformation.h"
#include "projectfilewizardextension.h"
#include "projectmanager.h"
#include "projecttreewidget.h"
#include "projectwindow.h"
#include "runsettingspropertiespage.h"
#include "session.h"
#include "projectnodes.h"
#include "sessiondialog.h"
#include "buildconfiguration.h"
#include "miniprojecttargetselector.h"
#include "taskhub.h"
#include "customtoolchain.h" #include "customtoolchain.h"
#include "selectablefilesmodel.h"
#include "customwizard/customwizard.h" #include "customwizard/customwizard.h"
#include "dependenciespanel.h"
#include "devicesupport/desktopdevice.h" #include "devicesupport/desktopdevice.h"
#include "devicesupport/desktopdevicefactory.h" #include "devicesupport/desktopdevicefactory.h"
#include "devicesupport/devicemanager.h" #include "devicesupport/devicemanager.h"
#include "devicesupport/devicesettingspage.h" #include "devicesupport/devicesettingspage.h"
#include "devicesupport/sshsettingspage.h" #include "devicesupport/sshsettingspage.h"
#include "targetsettingspanel.h" #include "editorsettingspropertiespage.h"
#include "projectpanelfactory.h" #include "filesinallprojectsfind.h"
#include "foldernavigationwidget.h"
#include "jsonwizard/jsonwizardfactory.h"
#include "jsonwizard/jsonwizardgeneratorfactory.h"
#include "jsonwizard/jsonwizardpagefactory_p.h"
#include "kitfeatureprovider.h"
#include "kitinformation.h"
#include "kitmanager.h"
#include "kitoptionspage.h"
#include "miniprojecttargetselector.h"
#include "namedwidget.h"
#include "parseissuesdialog.h"
#include "processstep.h"
#include "project.h"
#include "projectexplorericons.h" #include "projectexplorericons.h"
#include "projectexplorersettings.h"
#include "projectexplorersettingspage.h"
#include "projectfilewizardextension.h"
#include "projectmanager.h"
#include "projectnodes.h"
#include "projectpanelfactory.h"
#include "projecttreewidget.h"
#include "projectwindow.h"
#include "removetaskhandler.h"
#include "runconfigurationaspects.h"
#include "runsettingspropertiespage.h"
#include "selectablefilesmodel.h"
#include "session.h"
#include "sessiondialog.h"
#include "showineditortaskhandler.h"
#include "simpleprojectwizard.h" #include "simpleprojectwizard.h"
#include "target.h"
#include "targetsettingspanel.h"
#include "taskhub.h"
#include "toolchainmanager.h"
#include "toolchainoptionspage.h"
#include "vcsannotatetaskhandler.h"
#include "windebuginterface.h" #include "windebuginterface.h"
#include "msvctoolchain.h" #include "msvctoolchain.h"
@@ -642,6 +642,7 @@ public:
AllProjectsFind m_allProjectsFind; AllProjectsFind m_allProjectsFind;
CurrentProjectFind m_curretProjectFind; CurrentProjectFind m_curretProjectFind;
FilesInAllProjectsFind m_filesInAllProjectsFind;
CustomExecutableRunConfigurationFactory m_customExecutableRunConfigFactory; CustomExecutableRunConfigurationFactory m_customExecutableRunConfigFactory;
CustomExecutableRunWorkerFactory m_customExecutableRunWorkerFactory; CustomExecutableRunWorkerFactory m_customExecutableRunWorkerFactory;

View File

@@ -163,7 +163,8 @@ HEADERS += projectexplorer.h \
parseissuesdialog.h \ parseissuesdialog.h \
treescanner.h \ treescanner.h \
rawprojectpart.h \ rawprojectpart.h \
simpleprojectwizard.h simpleprojectwizard.h \
filesinallprojectsfind.h
SOURCES += projectexplorer.cpp \ SOURCES += projectexplorer.cpp \
abi.cpp \ abi.cpp \
@@ -309,7 +310,8 @@ SOURCES += projectexplorer.cpp \
parseissuesdialog.cpp \ parseissuesdialog.cpp \
treescanner.cpp \ treescanner.cpp \
rawprojectpart.cpp \ rawprojectpart.cpp \
simpleprojectwizard.cpp simpleprojectwizard.cpp \
filesinallprojectsfind.cpp
FORMS += \ FORMS += \
editorsettingspropertiespage.ui \ editorsettingspropertiespage.ui \

View File

@@ -72,6 +72,7 @@ Project {
"extraabi.cpp", "extraabi.h", "extraabi.cpp", "extraabi.h",
"extracompiler.cpp", "extracompiler.h", "extracompiler.cpp", "extracompiler.h",
"fileinsessionfinder.cpp", "fileinsessionfinder.h", "fileinsessionfinder.cpp", "fileinsessionfinder.h",
"filesinallprojectsfind.cpp", "filesinallprojectsfind.h",
"filterkitaspectsdialog.cpp", "filterkitaspectsdialog.h", "filterkitaspectsdialog.cpp", "filterkitaspectsdialog.h",
"foldernavigationwidget.cpp", "foldernavigationwidget.h", "foldernavigationwidget.cpp", "foldernavigationwidget.h",
"gccparser.cpp", "gccparser.h", "gccparser.cpp", "gccparser.h",