forked from qt-creator/qt-creator
QmlDesigner: Deprecate more NodeMetaInfo
There is now allExportedTypeNames which provides the same information. Maybe we have to add more information to the modules like a flag for the module type. Change-Id: I1a8c0b33fc70a157d16a153102331447f370a032 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -446,8 +446,13 @@ void QmlDesigner::MaterialBrowserView::loadPropertyGroups()
|
|||||||
if (!m_hasQuick3DImport || m_propertyGroupsLoaded || !model())
|
if (!m_hasQuick3DImport || m_propertyGroupsLoaded || !model())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
|
// TODO
|
||||||
|
QString matPropsPath;
|
||||||
|
#else
|
||||||
QString matPropsPath = model()->metaInfo("QtQuick3D.Material").importDirectoryPath()
|
QString matPropsPath = model()->metaInfo("QtQuick3D.Material").importDirectoryPath()
|
||||||
+ "/designer/propertyGroups.json";
|
+ "/designer/propertyGroups.json";
|
||||||
|
#endif
|
||||||
m_propertyGroupsLoaded = m_widget->materialBrowserModel()->loadPropertyGroups(matPropsPath);
|
m_propertyGroupsLoaded = m_widget->materialBrowserModel()->loadPropertyGroups(matPropsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,10 +28,14 @@ QT_END_NAMESPACE
|
|||||||
[[deprecated( \
|
[[deprecated( \
|
||||||
"In most cases you don't need them anymore because the import is setting them!")]]
|
"In most cases you don't need them anymore because the import is setting them!")]]
|
||||||
# define DEPRECATED_COMPONENT_FILE_NAME [[deprecated("Use sourceId() instead.")]]
|
# define DEPRECATED_COMPONENT_FILE_NAME [[deprecated("Use sourceId() instead.")]]
|
||||||
|
# define DEPRECATED_IMPORT_DIRECTORY_PATH [[deprecated("Use allExportedTypeNames().")]]
|
||||||
|
# define DEPRECATED_REQUIRED_IMPORT_STRING [[deprecated("Use allExportedTypeNames().")]]
|
||||||
#else
|
#else
|
||||||
# define DEPRECATED_TYPENAME
|
# define DEPRECATED_TYPENAME
|
||||||
# define DEPRECATED_VERSION_NUMBER
|
# define DEPRECATED_VERSION_NUMBER
|
||||||
# define DEPRECATED_COMPONENT_FILE_NAME
|
# define DEPRECATED_COMPONENT_FILE_NAME
|
||||||
|
# define DEPRECATED_IMPORT_DIRECTORY_PATH
|
||||||
|
# define DEPRECATED_REQUIRED_IMPORT_STRING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -237,8 +241,8 @@ public:
|
|||||||
bool usesCustomParser() const;
|
bool usesCustomParser() const;
|
||||||
|
|
||||||
bool isEnumeration() const;
|
bool isEnumeration() const;
|
||||||
QString importDirectoryPath() const;
|
DEPRECATED_IMPORT_DIRECTORY_PATH QString importDirectoryPath() const;
|
||||||
QString requiredImportString() const;
|
DEPRECATED_REQUIRED_IMPORT_STRING QString requiredImportString() const;
|
||||||
|
|
||||||
friend bool operator==(const NodeMetaInfo &first, const NodeMetaInfo &second)
|
friend bool operator==(const NodeMetaInfo &first, const NodeMetaInfo &second)
|
||||||
{
|
{
|
||||||
|
@@ -16,12 +16,14 @@
|
|||||||
#include <filemanager/objectlengthcalculator.h>
|
#include <filemanager/objectlengthcalculator.h>
|
||||||
#include <modelnode.h>
|
#include <modelnode.h>
|
||||||
#include <modelnodepositionstorage.h>
|
#include <modelnodepositionstorage.h>
|
||||||
|
#include <nodemetainfo.h>
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
|
#include <projectstorage/projectstorage.h>
|
||||||
|
#include <qmlobjectnode.h>
|
||||||
|
#include <qmltimelinekeyframegroup.h>
|
||||||
#include <rewritingexception.h>
|
#include <rewritingexception.h>
|
||||||
#include <signalhandlerproperty.h>
|
#include <signalhandlerproperty.h>
|
||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <qmlobjectnode.h>
|
|
||||||
#include <qmltimelinekeyframegroup.h>
|
|
||||||
|
|
||||||
#include <qmljs/parser/qmljsengine_p.h>
|
#include <qmljs/parser/qmljsengine_p.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
@@ -1004,6 +1006,45 @@ QSet<QPair<QString, QString> > RewriterView::qrcMapping() const
|
|||||||
return m_textToModelMerger->qrcMapping();
|
return m_textToModelMerger->qrcMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
|
|
||||||
|
ModuleIds generateModuleIds(const ModelNodes &nodes)
|
||||||
|
{
|
||||||
|
ModuleIds moduleIds;
|
||||||
|
moduleIds.reserve(Utils::usize(nodes));
|
||||||
|
for (const auto &node : nodes) {
|
||||||
|
auto exportedNames = node.metaInfo().allExportedTypeNames();
|
||||||
|
if (exportedNames.size())
|
||||||
|
moduleIds.push_back(exportedNames.front().moduleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(moduleIds.begin(), moduleIds.end());
|
||||||
|
moduleIds.erase(std::unique(moduleIds.begin(), moduleIds.end()), moduleIds.end());
|
||||||
|
|
||||||
|
return moduleIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList generateImports(ModuleIds moduleIds, const ProjectStorageType &projectStorage)
|
||||||
|
{
|
||||||
|
return Utils::transform<QStringList>(moduleIds, [&](auto id) {
|
||||||
|
return "import " + projectStorage.moduleName(id).toQString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList generateImports(const ModelNodes &nodes)
|
||||||
|
{
|
||||||
|
if (nodes.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto moduleIds = generateModuleIds(nodes);
|
||||||
|
|
||||||
|
return generateImports(moduleIds, *nodes.front().model()->projectStorage());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void RewriterView::moveToComponent(const ModelNode &modelNode)
|
void RewriterView::moveToComponent(const ModelNode &modelNode)
|
||||||
{
|
{
|
||||||
if (!modelNode.isValid())
|
if (!modelNode.isValid())
|
||||||
@@ -1012,20 +1053,26 @@ void RewriterView::moveToComponent(const ModelNode &modelNode)
|
|||||||
int offset = nodeOffset(modelNode);
|
int offset = nodeOffset(modelNode);
|
||||||
|
|
||||||
const QList<ModelNode> nodes = modelNode.allSubModelNodesAndThisNode();
|
const QList<ModelNode> nodes = modelNode.allSubModelNodesAndThisNode();
|
||||||
QSet<QString> directPaths;
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
|
auto directPaths = generateImports(nodes);
|
||||||
|
#else
|
||||||
|
QSet<QString> directPathsSet;
|
||||||
|
|
||||||
// Always add QtQuick import
|
// Always add QtQuick import
|
||||||
QString quickImport = model()->qtQuickItemMetaInfo().requiredImportString();
|
QString quickImport = model()->qtQuickItemMetaInfo().requiredImportString();
|
||||||
if (!quickImport.isEmpty())
|
if (!quickImport.isEmpty())
|
||||||
directPaths.insert(quickImport);
|
directPathsSet.insert(quickImport);
|
||||||
|
|
||||||
for (const ModelNode &partialNode : nodes) {
|
for (const ModelNode &partialNode : nodes) {
|
||||||
QString importStr = partialNode.metaInfo().requiredImportString();
|
QString importStr = partialNode.metaInfo().requiredImportString();
|
||||||
if (importStr.size())
|
if (importStr.size())
|
||||||
directPaths << importStr;
|
directPathsSet << importStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString importData = Utils::sorted(directPaths.values()).join(QChar::LineFeed);
|
auto directPaths = directPathsSet.values();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString importData = Utils::sorted(directPaths).join(QChar::LineFeed);
|
||||||
if (importData.size())
|
if (importData.size())
|
||||||
importData.append(QString(2, QChar::LineFeed));
|
importData.append(QString(2, QChar::LineFeed));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user