QmlDesigner: Use C++ 20 designated initializer for update

It makes it easier to add new arguments without breaking the tests.

Change-Id: Id03053ac17e4da26a2abf2a23e6cc20848ed9af5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2024-07-31 15:32:49 +02:00
parent e3a062837d
commit 3fd89a31bc
4 changed files with 100 additions and 91 deletions

View File

@@ -260,11 +260,13 @@ std::vector<IdPaths> createIdPaths(ProjectStorageUpdater::WatchedSourceIdsIds wa
} // namespace
void ProjectStorageUpdater::update(QStringList directories,
QStringList qmlTypesPaths,
const QString &propertyEditorResourcesPath,
const QStringList &typeAnnotationPaths)
void ProjectStorageUpdater::update(Update update)
{
QStringList directories = std::move(update.directories);
QStringList qmlTypesPaths = std::move(update.qmlTypesPaths);
const QString &propertyEditorResourcesPath = update.propertyEditorResourcesPath;
const QStringList &typeAnnotationPaths = update.typeAnnotationPaths;
NanotraceHR::Tracer tracer{"update"_t,
category(),
keyValue("directories", directories),

View File

@@ -59,10 +59,15 @@ public:
, m_projectPartId{projectPartId}
{}
void update(QStringList directories,
QStringList qmlTypesPaths,
const QString &propertyEditorResourcesPath,
const QStringList &typeAnnotationPaths);
struct Update
{
QStringList directories = {};
QStringList qmlTypesPaths = {};
const QString propertyEditorResourcesPath = {};
const QStringList typeAnnotationPaths = {};
};
void update(Update update);
void pathsWithIdsChanged(const std::vector<IdPaths> &idPaths) override;
void pathsChanged(const SourceIds &filePathIds) override;

View File

@@ -586,15 +586,15 @@ void QmlDesignerProjectManager::update()
return;
if constexpr (isUsingQmlDesignerLite()) {
m_projectData->projectStorageData->updater.update(directoriesForLiteDesigner(),
qmlTypesForLiteDesigner(),
propertyEditorResourcesPath(),
{qtCreatorItemLibraryPath()});
m_projectData->projectStorageData->updater.update({directoriesForLiteDesigner(),
qmlTypesForLiteDesigner(),
propertyEditorResourcesPath(),
{qtCreatorItemLibraryPath()}});
} else {
m_projectData->projectStorageData->updater.update(directories(m_projectData->activeTarget),
qmlTypes(m_projectData->activeTarget),
propertyEditorResourcesPath(),
{qtCreatorItemLibraryPath()});
m_projectData->projectStorageData->updater.update({directories(m_projectData->activeTarget),
qmlTypes(m_projectData->activeTarget),
propertyEditorResourcesPath(),
{qtCreatorItemLibraryPath()}});
}
}