forked from qt-creator/qt-creator
FileUtils: Adds toFilePathList function
Change-Id: Ie3137751135fdb6c3161cc886f307323fcce6b72 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -451,7 +451,8 @@ QFuture<PluginDumper::DependencyInfo> PluginDumper::loadDependencies(const FileP
|
||||
|
||||
Utils::onFinished(loadQmlTypeDescription(dependenciesPaths), const_cast<PluginDumper*>(this), [=] (const QFuture<PluginDumper::QmlTypeDescription> &typesFuture) {
|
||||
PluginDumper::QmlTypeDescription typesResult = typesFuture.result();
|
||||
FilePaths newDependencies = Utils::transform(typesResult.dependencies, &FilePath::fromString);
|
||||
FilePaths newDependencies = FileUtils::toFilePathList(typesResult.dependencies);
|
||||
|
||||
newDependencies = Utils::toList(Utils::toSet(newDependencies) - *visited.data());
|
||||
if (!newDependencies.isEmpty()) {
|
||||
Utils::onFinished(loadDependencies(newDependencies, visited),
|
||||
@@ -589,7 +590,7 @@ void PluginDumper::loadQmltypesFile(const FilePaths &qmltypesFilePaths,
|
||||
PluginDumper::QmlTypeDescription typesResult = typesFuture.result();
|
||||
if (!typesResult.dependencies.isEmpty())
|
||||
{
|
||||
Utils::onFinished(loadDependencies(Utils::transform(typesResult.dependencies, &FilePath::fromString),
|
||||
Utils::onFinished(loadDependencies(FileUtils::toFilePathList(typesResult.dependencies),
|
||||
QSharedPointer<QSet<FilePath>>()), this,
|
||||
[typesResult, libraryInfo, libraryPath, this] (const QFuture<PluginDumper::DependencyInfo> &loadFuture)
|
||||
{
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "fileinprojectfinder.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "fileutils.h"
|
||||
#include "hostosinfo.h"
|
||||
#include "qrcparser.h"
|
||||
#include "qtcassert.h"
|
||||
@@ -473,7 +474,7 @@ FilePaths FileInProjectFinder::QrcUrlFinder::find(const QUrl &fileUrl) const
|
||||
qrcParser->collectFilesAtPath(QrcParser::normalizedQrcFilePath(fileUrl.toString()), &hits);
|
||||
}
|
||||
hits.removeDuplicates();
|
||||
const FilePaths result = transform(hits, &FilePath::fromString);
|
||||
const FilePaths result = FileUtils::toFilePathList(hits);
|
||||
m_fileCache.insert(fileUrl, result);
|
||||
return result;
|
||||
}
|
||||
|
@@ -1389,17 +1389,19 @@ QString FilePath::formatFilePaths(const FilePaths &files, const QString &separat
|
||||
void FilePath::removeDuplicates(FilePaths &files)
|
||||
{
|
||||
// FIXME: Improve.
|
||||
// FIXME: This drops the osType information, which is not correct.
|
||||
QStringList list = transform<QStringList>(files, &FilePath::toString);
|
||||
list.removeDuplicates();
|
||||
files = transform(list, &FilePath::fromString);
|
||||
files = FileUtils::toFilePathList(list);
|
||||
}
|
||||
|
||||
void FilePath::sort(FilePaths &files)
|
||||
{
|
||||
// FIXME: Improve.
|
||||
// FIXME: This drops the osType information, which is not correct.
|
||||
QStringList list = transform<QStringList>(files, &FilePath::toString);
|
||||
list.sort();
|
||||
files = transform(list, &FilePath::fromString);
|
||||
files = FileUtils::toFilePathList(list);
|
||||
}
|
||||
|
||||
FilePath FilePath::pathAppended(const QString &path) const
|
||||
|
@@ -556,7 +556,7 @@ FilePaths FileUtils::getOpenFilePaths(QWidget *parent,
|
||||
filter,
|
||||
selectedFilter,
|
||||
options);
|
||||
return transform(result, &FilePath::fromString);
|
||||
return FileUtils::toFilePathList(result);
|
||||
}
|
||||
|
||||
FilePath FileUtils::getOpenFilePathFromDevice(QWidget *parent,
|
||||
@@ -812,4 +812,9 @@ FilePath FileUtils::homePath()
|
||||
return FilePath::fromString(doCleanPath(QDir::homePath()));
|
||||
}
|
||||
|
||||
FilePaths FileUtils::toFilePathList(const QStringList &paths) {
|
||||
return transform(paths, [](const QString &path) { return FilePath::fromString(path); });
|
||||
}
|
||||
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -97,6 +97,8 @@ public:
|
||||
static QByteArray fileId(const FilePath &fileName);
|
||||
static FilePath homePath();
|
||||
|
||||
static FilePaths toFilePathList(const QStringList &paths);
|
||||
|
||||
static void iterateLsOutput(const FilePath &base,
|
||||
const QStringList &entries,
|
||||
const FileFilter &filter,
|
||||
|
@@ -1217,8 +1217,7 @@ void AndroidConfigurations::removeUnusedDebuggers()
|
||||
uniqueNdks.append(ndkLocation);
|
||||
}
|
||||
|
||||
uniqueNdks.append(Utils::transform(currentConfig().getCustomNdkList(),
|
||||
FilePath::fromString).toVector());
|
||||
uniqueNdks.append(FileUtils::toFilePathList(currentConfig().getCustomNdkList()).toVector());
|
||||
|
||||
const QList<Debugger::DebuggerItem> allDebuggers = Debugger::DebuggerItemManager::debuggers();
|
||||
for (const Debugger::DebuggerItem &debugger : allDebuggers) {
|
||||
@@ -1346,8 +1345,7 @@ void AndroidConfigurations::registerCustomToolChainsAndDebuggers()
|
||||
const Toolchains existingAndroidToolChains = ToolChainManager::toolchains(
|
||||
Utils::equal(&ToolChain::typeId, Utils::Id(Constants::ANDROID_TOOLCHAIN_TYPEID)));
|
||||
|
||||
const FilePaths customNdks = Utils::transform(currentConfig().getCustomNdkList(),
|
||||
FilePath::fromString);
|
||||
const FilePaths customNdks = FileUtils::toFilePathList(currentConfig().getCustomNdkList());
|
||||
const Toolchains customToolchains
|
||||
= AndroidToolChainFactory::autodetectToolChainsFromNdks(existingAndroidToolChains,
|
||||
customNdks,
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -117,7 +118,7 @@ void TestTreeModel::setupParsingConnections()
|
||||
connect(cppMM, &CppEditor::CppModelManager::aboutToRemoveFiles,
|
||||
this, [this](const QStringList &files) {
|
||||
const Utils::FilePaths filesToRemove
|
||||
= Utils::transform(files, &Utils::FilePath::fromString);
|
||||
= Utils::FileUtils::toFilePathList(files);
|
||||
removeFiles(filesToRemove);
|
||||
}, Qt::QueuedConnection);
|
||||
connect(cppMM, &CppEditor::CppModelManager::projectPartsUpdated,
|
||||
|
@@ -103,8 +103,7 @@ void DirectoryFilter::restoreState(const QJsonObject &object)
|
||||
m_directories = toStringList(object.value(kDirectoriesKey).toArray());
|
||||
m_filters = toStringList(
|
||||
object.value(kFiltersKey).toArray(QJsonArray::fromStringList(kFiltersDefault)));
|
||||
m_files = Utils::transform(toStringList(object.value(kFilesKey).toArray()),
|
||||
&FilePath::fromString);
|
||||
m_files = FileUtils::toFilePathList(toStringList(object.value(kFilesKey).toArray()));
|
||||
m_exclusionFilters = toStringList(
|
||||
object.value(kExclusionFiltersKey)
|
||||
.toArray(QJsonArray::fromStringList(kExclusionFiltersDefault)));
|
||||
@@ -129,7 +128,7 @@ void DirectoryFilter::restoreState(const QByteArray &state)
|
||||
in >> shortcut;
|
||||
in >> defaultFilter;
|
||||
in >> files;
|
||||
m_files = Utils::transform(files, &Utils::FilePath::fromString);
|
||||
m_files = FileUtils::toFilePathList(files);
|
||||
if (!in.atEnd()) // Qt Creator 4.3 and later
|
||||
in >> m_exclusionFilters;
|
||||
else
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <coreplugin/testdatadir.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
@@ -74,7 +75,7 @@ void Core::Internal::CorePlugin::test_basefilefilter()
|
||||
QFETCH(QStringList, testFiles);
|
||||
QFETCH(QList<ReferenceData>, referenceDataList);
|
||||
|
||||
MyBaseFileFilter filter(Utils::transform(testFiles, &Utils::FilePath::fromString));
|
||||
MyBaseFileFilter filter(Utils::FileUtils::toFilePathList(testFiles));
|
||||
BasicLocatorFilterTest test(&filter);
|
||||
|
||||
for (const ReferenceData &reference : qAsConst(referenceDataList)) {
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -177,7 +178,7 @@ void VcsManager::extensionsInitialized()
|
||||
connect(vc, &IVersionControl::filesChanged, DocumentManager::instance(),
|
||||
[](const QStringList &fileNames) {
|
||||
DocumentManager::notifyFilesChangedInternally(
|
||||
Utils::transform(fileNames, &Utils::FilePath::fromString));
|
||||
FileUtils::toFilePathList(fileNames));
|
||||
});
|
||||
connect(vc, &IVersionControl::repositoryChanged,
|
||||
m_instance, &VcsManager::repositoryChanged);
|
||||
|
@@ -143,7 +143,7 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources)
|
||||
}
|
||||
if (!qrcPathsToBeAdded.isEmpty()) {
|
||||
m_handlingResources = true;
|
||||
projectNodeForUiFile->addFiles(Utils::transform(qrcPathsToBeAdded, &FilePath::fromString));
|
||||
projectNodeForUiFile->addFiles(FileUtils::toFilePathList(qrcPathsToBeAdded));
|
||||
m_handlingResources = false;
|
||||
projectQrcFiles += qrcPathsToBeAdded;
|
||||
}
|
||||
|
@@ -944,7 +944,7 @@ FilePaths GitClient::unmanagedFiles(const FilePaths &filePaths) const
|
||||
const QStringList filtered = Utils::filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) {
|
||||
return !managedFilePaths.contains(wd.absoluteFilePath(fp));
|
||||
});
|
||||
res += transform(filtered, &FilePath::fromString);
|
||||
res += FileUtils::toFilePathList(filtered);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -1042,8 +1043,7 @@ bool SessionManager::loadSession(const QString &session, bool initial)
|
||||
return true;
|
||||
}
|
||||
|
||||
fileList = Utils::transform(reader.restoreValue("ProjectList").toStringList(),
|
||||
&FilePath::fromString);
|
||||
fileList = FileUtils::toFilePathList(reader.restoreValue("ProjectList").toStringList());
|
||||
} else if (loadImplicitDefault) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -337,7 +337,7 @@ ProjectExplorer::DeploymentKnowledge QbsProject::deploymentKnowledge() const
|
||||
|
||||
FilePaths QbsBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
|
||||
{
|
||||
return transform(session()->filesGeneratedFrom(sourceFile.toString()), &FilePath::fromString);
|
||||
return FileUtils::toFilePathList(session()->filesGeneratedFrom(sourceFile.toString()));
|
||||
}
|
||||
|
||||
bool QbsBuildSystem::isProjectEditable() const
|
||||
@@ -380,7 +380,7 @@ bool QbsBuildSystem::addFilesToProduct(
|
||||
group.value("name").toString());
|
||||
if (result.error().hasError()) {
|
||||
MessageManager::writeDisrupting(result.error().toString());
|
||||
*notAdded = Utils::transform(result.failedFiles(), &FilePath::fromString);
|
||||
*notAdded = FileUtils::toFilePathList(result.failedFiles());
|
||||
}
|
||||
return notAdded->isEmpty();
|
||||
}
|
||||
@@ -411,7 +411,7 @@ RemovedFilesFromProject QbsBuildSystem::removeFilesFromProduct(
|
||||
product.value("name").toString(),
|
||||
group.value("name").toString());
|
||||
|
||||
*notRemoved = Utils::transform(result.failedFiles(), &FilePath::fromString);
|
||||
*notRemoved = FileUtils::toFilePathList(result.failedFiles());
|
||||
if (result.error().hasError())
|
||||
MessageManager::writeDisrupting(result.error().toString());
|
||||
const bool success = notRemoved->isEmpty();
|
||||
|
@@ -52,6 +52,7 @@
|
||||
#include <utils/QtConcurrentTools>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
@@ -737,7 +738,7 @@ FilePaths QmakePriFile::formResources(const FilePath &formFile) const
|
||||
if (reader.hasError())
|
||||
qWarning() << "Could not read form file:" << formFile;
|
||||
|
||||
return Utils::transform(resourceFiles, &FilePath::fromString);
|
||||
return FileUtils::toFilePathList(resourceFiles);
|
||||
}
|
||||
|
||||
bool QmakePriFile::ensureWriteableProFile(const QString &file)
|
||||
@@ -887,11 +888,12 @@ void QmakePriFile::changeFiles(const QString &mimeType,
|
||||
notChanged->clear();
|
||||
} else { // RemoveFromProFile
|
||||
QDir priFileDir = QDir(m_qmakeProFile->directoryPath().toString());
|
||||
*notChanged = Utils::transform(
|
||||
ProWriter::removeFiles(includeFile, &lines, priFileDir,
|
||||
*notChanged = FileUtils::toFilePathList(
|
||||
ProWriter::removeFiles(includeFile,
|
||||
&lines,
|
||||
priFileDir,
|
||||
Utils::transform(filePaths, &FilePath::toString),
|
||||
varNamesForRemoving()),
|
||||
&FilePath::fromString);
|
||||
varNamesForRemoving()));
|
||||
}
|
||||
|
||||
// save file
|
||||
|
@@ -213,7 +213,7 @@ void ExamplesWelcomePage::openProject(const ExampleItem *item)
|
||||
ProjectExplorerPlugin::OpenProjectResult result =
|
||||
ProjectExplorerPlugin::openProject(FilePath::fromString(proFile));
|
||||
if (result) {
|
||||
ICore::openFiles(Utils::transform(filesToOpen, &FilePath::fromString));
|
||||
ICore::openFiles(FileUtils::toFilePathList(filesToOpen));
|
||||
ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||
QUrl docUrl = QUrl::fromUserInput(item->docUrl);
|
||||
if (docUrl.isValid())
|
||||
|
@@ -998,7 +998,7 @@ void ResourceModel::addFiles(int prefixIndex, const QStringList &fileNames, int
|
||||
lastFile = cnt + unique_list.count() - 1;
|
||||
|
||||
Core::VcsManager::promptToAdd(m_resource_file.filePath().absolutePath(),
|
||||
Utils::transform(fileNames, &FilePath::fromString));
|
||||
FileUtils::toFilePathList(fileNames));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -143,7 +143,7 @@ SuppressionAspect::~SuppressionAspect()
|
||||
|
||||
FilePaths SuppressionAspect::value() const
|
||||
{
|
||||
return Utils::transform(BaseAspect::value().toStringList(), &FilePath::fromString);
|
||||
return FileUtils::toFilePathList(BaseAspect::value().toStringList());
|
||||
}
|
||||
|
||||
void SuppressionAspect::setValue(const FilePaths &val)
|
||||
|
Reference in New Issue
Block a user