BaseFileFind: Replace files() with fileContainerProvider()

The fileContainerProvider() is called only once per
SearchResult instance, and the result (the provider)
is stored inside FileFindParameters.
In this way the extra data, like the name filters or
the search directory, are set just once. Whenever the
search is started (or started again), the stored provider
recreates the FileContainer according to the data that
has been captured by the lambda when the provider was created.

This patch eliminates the need for retrieving the custom
data from QVariant. It also eliminates the set of arbitrary
arguments for the removed files() method.

Remove the BaseFileFind * argument from the
SearchEngine::executeSearch() method.

Change-Id: I7211f503f82db12b5a99c9d342466daaaae0839f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2023-06-28 17:03:58 +02:00
parent 6e16512eba
commit de5efffeff
18 changed files with 85 additions and 104 deletions

View File

@@ -58,12 +58,13 @@ QString FindInFiles::displayName() const
return Tr::tr("Files in File System");
}
FileContainer FindInFiles::files(const QStringList &nameFilters,
const QStringList &exclusionFilters,
const QVariant &additionalParameters) const
FileContainerProvider FindInFiles::fileContainerProvider() const
{
return SubDirFileContainer({FilePath::fromVariant(additionalParameters)}, nameFilters,
exclusionFilters, EditorManager::defaultTextCodec());
return [nameFilters = fileNameFilters(), exclusionFilters = fileExclusionFilters(),
filePath = path()] {
return SubDirFileContainer({filePath}, nameFilters, exclusionFilters,
EditorManager::defaultTextCodec());
};
}
QVariant FindInFiles::additionalParameters() const