forked from qt-creator/qt-creator
QmlDesigner: More integration cleanup
Instead of a warning we now provide different functions for the project storage. Should give better errors. Change-Id: I48cea16482950c2b3c5eea3e72d4e9c40b9e75b2 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
#include <auxiliarydataproperties.h>
|
||||
#include <externaldependenciesinterface.h>
|
||||
#include <plaintexteditmodifier.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <qmldesignerprojectmanager.h>
|
||||
#include <rewriterview.h>
|
||||
#include <signalhandlerproperty.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
@@ -192,7 +193,9 @@ Qt::CheckState checkState(const std::vector<std::string> &a, const std::vector<s
|
||||
|
||||
struct ModelBuilder
|
||||
{
|
||||
ModelBuilder(const QString &filePath, ExternalDependenciesInterface &externalDependencies)
|
||||
ModelBuilder(const QString &filePath,
|
||||
ExternalDependenciesInterface &externalDependencies,
|
||||
[[maybe_unused]] ProjectStorageDependencies projectStorageDependencies)
|
||||
{
|
||||
const QString fileContent = fileToString(filePath);
|
||||
if (fileContent.isEmpty()) {
|
||||
@@ -209,7 +212,14 @@ struct ModelBuilder
|
||||
rewriter->setCheckLinkErrors(false);
|
||||
rewriter->setTextModifier(modifier.get());
|
||||
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
model = QmlDesigner::Model::create(projectStorageDependencies,
|
||||
"Item",
|
||||
{Import::createLibraryImport("QtQuick")},
|
||||
filePath);
|
||||
#else
|
||||
model = QmlDesigner::Model::create("QtQuick.Item", 2, 1);
|
||||
#endif
|
||||
model->setRewriterView(rewriter.get());
|
||||
}
|
||||
|
||||
@@ -221,9 +231,12 @@ struct ModelBuilder
|
||||
|
||||
} // namespace
|
||||
|
||||
InsightModel::InsightModel(InsightView *view, ExternalDependenciesInterface &externalDependencies)
|
||||
InsightModel::InsightModel(InsightView *view,
|
||||
ExternalDependenciesInterface &externalDependencies,
|
||||
QmlDesignerProjectManager &projectManager)
|
||||
: m_insightView(view)
|
||||
, m_externalDependencies(externalDependencies)
|
||||
, m_projectManager(projectManager)
|
||||
, m_fileSystemWatcher(new Utils::FileSystemWatcher(this))
|
||||
{
|
||||
QObject::connect(ProjectExplorer::ProjectManager::instance(),
|
||||
@@ -446,7 +459,9 @@ void InsightModel::setEnabled(bool value)
|
||||
return;
|
||||
}
|
||||
|
||||
ModelBuilder builder(m_mainQmlInfo.absoluteFilePath(), m_externalDependencies);
|
||||
ModelBuilder builder(m_mainQmlInfo.absoluteFilePath(),
|
||||
m_externalDependencies,
|
||||
m_projectManager.projectStorageDependencies());
|
||||
|
||||
if (!builder.model) {
|
||||
qWarning() << "Could not create model" << m_mainQmlInfo.absoluteFilePath();
|
||||
@@ -613,7 +628,9 @@ int InsightModel::devicePixelRatio()
|
||||
|
||||
void InsightModel::parseMainQml()
|
||||
{
|
||||
ModelBuilder builder(m_mainQmlInfo.absoluteFilePath(), m_externalDependencies);
|
||||
ModelBuilder builder(m_mainQmlInfo.absoluteFilePath(),
|
||||
m_externalDependencies,
|
||||
m_projectManager.projectStorageDependencies());
|
||||
|
||||
if (!builder.model)
|
||||
return;
|
||||
|
@@ -39,7 +39,9 @@ class InsightModel : public QAbstractListModel
|
||||
};
|
||||
|
||||
public:
|
||||
InsightModel(InsightView *view, class ExternalDependenciesInterface &externalDependencies);
|
||||
InsightModel(InsightView *view,
|
||||
class ExternalDependenciesInterface &externalDependencies,
|
||||
class QmlDesignerProjectManager &projectManager);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
@@ -109,6 +111,7 @@ private:
|
||||
private:
|
||||
QPointer<InsightView> m_insightView;
|
||||
ExternalDependenciesInterface &m_externalDependencies;
|
||||
QmlDesignerProjectManager &m_projectManager;
|
||||
|
||||
Utils::FileSystemWatcher *m_fileSystemWatcher;
|
||||
|
||||
|
@@ -20,7 +20,8 @@ class InsightPlugin final : public ExtensionSystem::IPlugin
|
||||
auto *designerPlugin = QmlDesignerPlugin::instance();
|
||||
auto &viewManager = designerPlugin->viewManager();
|
||||
viewManager.registerView(std::make_unique<InsightView>(
|
||||
QmlDesignerPlugin::externalDependenciesForPluginInitializationOnly()));
|
||||
QmlDesignerPlugin::externalDependenciesForPluginInitializationOnly(),
|
||||
QmlDesignerPlugin::projectManagerForPluginInitializationOnly()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -14,9 +14,10 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
InsightView::InsightView(ExternalDependenciesInterface &externalDependencies)
|
||||
InsightView::InsightView(ExternalDependenciesInterface &externalDependencies,
|
||||
QmlDesignerProjectManager &projectManager)
|
||||
: AbstractView(externalDependencies)
|
||||
, m_insightModel(std::make_unique<InsightModel>(this, externalDependencies))
|
||||
, m_insightModel(std::make_unique<InsightModel>(this, externalDependencies, projectManager))
|
||||
{
|
||||
Q_ASSERT(m_insightModel);
|
||||
}
|
||||
|
@@ -15,13 +15,15 @@ namespace QmlDesigner {
|
||||
|
||||
class InsightModel;
|
||||
class InsightWidget;
|
||||
class QmlDesignerProjectManager;
|
||||
|
||||
class InsightView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InsightView(ExternalDependenciesInterface &externalDependencies);
|
||||
explicit InsightView(ExternalDependenciesInterface &externalDependencies,
|
||||
QmlDesignerProjectManager &projectManager);
|
||||
~InsightView() override;
|
||||
|
||||
// AbstractView
|
||||
|
@@ -56,9 +56,10 @@ add_qtc_plugin(QmlDesigner
|
||||
DEFINES
|
||||
IDE_LIBRARY_BASENAME=\"${IDE_LIBRARY_BASE_PATH}\"
|
||||
SHARE_QML_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../../../share/qtcreator/qmldesigner"
|
||||
$<$<BOOL:${USE_PROJECTSTORAGE}>:QDS_USE_PROJECTSTORAGE>
|
||||
$<$<BOOL:${QTC_USE_QML_DESIGNER_LITE}>:QTC_USE_QML_DESIGNER_LITE>
|
||||
$<$<BOOL:${DETACH_DISABLED_VIEWS}>:DETACH_DISABLED_VIEWS>
|
||||
PUBLIC_DEFINES
|
||||
$<$<BOOL:${USE_PROJECTSTORAGE}>:QDS_USE_PROJECTSTORAGE>
|
||||
INCLUDES
|
||||
${CMAKE_CURRENT_LIST_DIR}/libs
|
||||
${CMAKE_CURRENT_LIST_DIR}/components
|
||||
|
@@ -81,13 +81,13 @@ private:
|
||||
std::atomic<bool> m_quitDumper;
|
||||
};
|
||||
|
||||
|
||||
|
||||
AssetExporter::AssetExporter(AssetExporterView *view, ProjectExplorer::Project *project, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_currentState(*this),
|
||||
m_project(project),
|
||||
m_view(view)
|
||||
AssetExporter::AssetExporter(AssetExporterView *view,
|
||||
ProjectExplorer::Project *project,
|
||||
ProjectStorageDependencies projectStorageDependencies)
|
||||
: m_currentState(*this)
|
||||
, m_project(project)
|
||||
, m_view(view)
|
||||
, m_projectStorageDependencies{projectStorageDependencies}
|
||||
{
|
||||
connect(m_view, &AssetExporterView::loadingFinished, this, &AssetExporter::onQmlFileLoaded);
|
||||
connect(m_view, &AssetExporterView::loadingError, this, &AssetExporter::notifyLoadError);
|
||||
@@ -257,7 +257,14 @@ void AssetExporter::preprocessQmlFile(const Utils::FilePath &path)
|
||||
{
|
||||
// Load the QML file and assign UUIDs to items having none.
|
||||
// Meanwhile cache the Component UUIDs as well
|
||||
ModelPointer model(Model::create("Item", 2, 7));
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
ModelPointer model = Model::create(m_projectStorageDependencies,
|
||||
"Item",
|
||||
{Import::createLibraryImport("QtQuick")},
|
||||
path.path());
|
||||
#else
|
||||
ModelPointer model = Model::create("Item", 2, 7);
|
||||
#endif
|
||||
Utils::FileReader reader;
|
||||
if (!reader.fetch(path)) {
|
||||
ExportNotification::addError(tr("Cannot preprocess file: %1. Error %2")
|
||||
|
@@ -39,8 +39,9 @@ public:
|
||||
ExportingDone
|
||||
};
|
||||
|
||||
AssetExporter(AssetExporterView *view, ProjectExplorer::Project *project,
|
||||
QObject *parent = nullptr);
|
||||
AssetExporter(AssetExporterView *view,
|
||||
ProjectExplorer::Project *project,
|
||||
ProjectStorageDependencies projectStorageDependencies);
|
||||
~AssetExporter();
|
||||
|
||||
void exportQml(const Utils::FilePaths &qmlFiles, const Utils::FilePath &exportPath,
|
||||
@@ -96,6 +97,7 @@ private:
|
||||
QHash<QString, QString> m_componentUuidCache;
|
||||
QSet<QByteArray> m_usedHashes;
|
||||
QHash<QString, QPixmap> m_assets;
|
||||
ProjectStorageDependencies m_projectStorageDependencies;
|
||||
std::unique_ptr<AssetDumper> m_assetDumper;
|
||||
bool m_cancelled = false;
|
||||
};
|
||||
|
@@ -3,12 +3,13 @@
|
||||
|
||||
#include "assetexporterplugin.h"
|
||||
|
||||
#include "assetexportpluginconstants.h"
|
||||
#include "assetexportdialog.h"
|
||||
#include "assetexporter.h"
|
||||
#include "assetexporterview.h"
|
||||
#include "filepathmodel.h"
|
||||
#include "assetexportpluginconstants.h"
|
||||
#include "componentexporter.h"
|
||||
#include "filepathmodel.h"
|
||||
#include <qmldesignerprojectmanager.h>
|
||||
|
||||
#include "dumpers/itemnodedumper.h"
|
||||
#include "dumpers/textnodedumper.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
namespace QmlDesigner {
|
||||
|
||||
AssetExporterPlugin::AssetExporterPlugin()
|
||||
: m_projectManager{QmlDesigner::QmlDesignerPlugin::projectManagerForPluginInitializationOnly()}
|
||||
{
|
||||
ProjectExplorer::TaskHub::addCategory({Constants::TASK_CATEGORY_ASSET_EXPORT,
|
||||
tr("Asset Export"),
|
||||
@@ -44,6 +46,7 @@ AssetExporterPlugin::AssetExporterPlugin()
|
||||
false});
|
||||
|
||||
auto *designerPlugin = QmlDesigner::QmlDesignerPlugin::instance();
|
||||
|
||||
auto &viewManager = designerPlugin->viewManager();
|
||||
m_view = viewManager.registerView(std::make_unique<AssetExporterView>(
|
||||
designerPlugin->externalDependenciesForPluginInitializationOnly()));
|
||||
@@ -79,7 +82,7 @@ void AssetExporterPlugin::onExport()
|
||||
if (!exportDir.parentDir().isEmpty())
|
||||
exportDir = exportDir.parentDir();
|
||||
exportDir = exportDir.pathAppended(startupProject->displayName() + "_export");
|
||||
AssetExporter assetExporter(m_view, startupProject);
|
||||
AssetExporter assetExporter(m_view, startupProject, m_projectManager.projectStorageDependencies());
|
||||
AssetExportDialog assetExporterDialog(exportDir, assetExporter, model);
|
||||
assetExporterDialog.exec();
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ private:
|
||||
void updateActions();
|
||||
|
||||
AssetExporterView *m_view = nullptr;
|
||||
class QmlDesignerProjectManager &m_projectManager;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -21,19 +21,6 @@
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(loggerInfo, "qtc.designer.assetExportPlugin.modelExporter", QtInfoMsg)
|
||||
|
||||
static QByteArrayList populateLineage(const QmlDesigner::ModelNode &node)
|
||||
{
|
||||
QByteArrayList lineage;
|
||||
if (!node.isValid() || node.type().isEmpty())
|
||||
return {};
|
||||
|
||||
for (auto &info : node.metaInfo().prototypes())
|
||||
lineage.append(info.typeName());
|
||||
|
||||
return lineage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -78,10 +65,9 @@ const QString &Component::name() const
|
||||
|
||||
NodeDumper *Component::createNodeDumper(const ModelNode &node) const
|
||||
{
|
||||
QByteArrayList lineage = populateLineage(node);
|
||||
std::unique_ptr<NodeDumper> reader;
|
||||
for (auto &dumperCreator: m_readers) {
|
||||
std::unique_ptr<NodeDumper> r(dumperCreator->instance(lineage, node));
|
||||
std::unique_ptr<NodeDumper> r(dumperCreator->instance(node));
|
||||
if (r->isExportable()) {
|
||||
if (reader) {
|
||||
if (reader->priority() < r->priority())
|
||||
|
@@ -27,7 +27,7 @@ class NodeDumperCreatorBase
|
||||
public:
|
||||
virtual ~NodeDumperCreatorBase() {}
|
||||
protected:
|
||||
virtual NodeDumper *instance(const QByteArrayList &, const ModelNode &) const = 0;
|
||||
virtual NodeDumper *instance(const ModelNode &) const = 0;
|
||||
friend Component;
|
||||
};
|
||||
|
||||
@@ -39,9 +39,7 @@ public:
|
||||
~NodeDumperCreator() = default;
|
||||
|
||||
protected:
|
||||
NodeDumper *instance(const QByteArrayList &lineage, const ModelNode &node) const {
|
||||
return new T(lineage, node);
|
||||
}
|
||||
NodeDumper *instance(const ModelNode &node) const { return new T(node); }
|
||||
};
|
||||
} //Internal
|
||||
|
||||
|
@@ -14,18 +14,18 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
using namespace Constants;
|
||||
AssetNodeDumper::AssetNodeDumper(const QByteArrayList &lineage, const ModelNode &node) :
|
||||
ItemNodeDumper(lineage, node)
|
||||
|
||||
AssetNodeDumper::AssetNodeDumper(const ModelNode &node)
|
||||
: ItemNodeDumper(node)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool AssetNodeDumper::isExportable() const
|
||||
{
|
||||
auto hasType = [this](const QByteArray &type) {
|
||||
return lineage().contains(type);
|
||||
};
|
||||
return hasType("QtQuick.Image") || hasType("QtQuick.Rectangle");
|
||||
auto qtQuickImageMetaInfo = model()->qtQuickImageMetaInfo();
|
||||
auto qtQuickRectangleMetaInfo = model()->qtQuickRectangleMetaInfo();
|
||||
return metaInfo().isBasedOn(qtQuickImageMetaInfo, qtQuickRectangleMetaInfo);
|
||||
}
|
||||
|
||||
QJsonObject AssetNodeDumper::json(Component &component) const
|
||||
|
@@ -10,7 +10,7 @@ class Component;
|
||||
class AssetNodeDumper : public ItemNodeDumper
|
||||
{
|
||||
public:
|
||||
AssetNodeDumper(const QByteArrayList &lineage, const ModelNode &node);
|
||||
AssetNodeDumper(const ModelNode &node);
|
||||
~AssetNodeDumper() override = default;
|
||||
|
||||
bool isExportable() const override;
|
||||
|
@@ -22,16 +22,16 @@ static QString capitalize(const QString &str)
|
||||
|
||||
namespace QmlDesigner {
|
||||
using namespace Constants;
|
||||
ItemNodeDumper::ItemNodeDumper(const QByteArrayList &lineage,
|
||||
const ModelNode &node) :
|
||||
NodeDumper(lineage, node)
|
||||
|
||||
ItemNodeDumper::ItemNodeDumper(const ModelNode &node)
|
||||
: NodeDumper(node)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QmlDesigner::ItemNodeDumper::isExportable() const
|
||||
{
|
||||
return lineage().contains("QtQuick.Item");
|
||||
return metaInfo().isQtQuickItem();
|
||||
}
|
||||
|
||||
QJsonObject QmlDesigner::ItemNodeDumper::json([[maybe_unused]] QmlDesigner::Component &component) const
|
||||
|
@@ -11,7 +11,7 @@ class Component;
|
||||
class ItemNodeDumper : public NodeDumper
|
||||
{
|
||||
public:
|
||||
ItemNodeDumper(const QByteArrayList &lineage, const ModelNode &node);
|
||||
ItemNodeDumper(const ModelNode &node);
|
||||
|
||||
~ItemNodeDumper() override = default;
|
||||
|
||||
|
@@ -6,10 +6,11 @@
|
||||
#include <auxiliarydataproperties.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
NodeDumper::NodeDumper(const QByteArrayList &lineage, const ModelNode &node) :
|
||||
m_node(node),
|
||||
m_objectNode(node),
|
||||
m_lineage(lineage)
|
||||
NodeDumper::NodeDumper(const ModelNode &node)
|
||||
: m_node(node)
|
||||
, m_objectNode(node)
|
||||
, m_metaInfo(node.metaInfo())
|
||||
, m_model{node.model()}
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ class ModelNode;
|
||||
class NodeDumper
|
||||
{
|
||||
public:
|
||||
NodeDumper(const QByteArrayList &lineage, const ModelNode &node);
|
||||
NodeDumper(const ModelNode &node);
|
||||
|
||||
virtual ~NodeDumper() = default;
|
||||
|
||||
@@ -22,16 +22,19 @@ public:
|
||||
virtual bool isExportable() const = 0;
|
||||
virtual QJsonObject json(Component& component) const = 0;
|
||||
|
||||
const QByteArrayList& lineage() const { return m_lineage; }
|
||||
const NodeMetaInfo &metaInfo() const { return m_metaInfo; }
|
||||
const QmlObjectNode& objectNode() const { return m_objectNode; }
|
||||
QVariant propertyValue(const PropertyName &name) const;
|
||||
QString uuid() const;
|
||||
|
||||
Model *model() const { return m_model; }
|
||||
|
||||
protected:
|
||||
const ModelNode &m_node;
|
||||
|
||||
private:
|
||||
QmlObjectNode m_objectNode;
|
||||
QByteArrayList m_lineage;
|
||||
NodeMetaInfo m_metaInfo;
|
||||
Model *m_model = nullptr;
|
||||
};
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@
|
||||
#include "textnodedumper.h"
|
||||
#include "assetexportpluginconstants.h"
|
||||
|
||||
#include <model.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFontInfo>
|
||||
#include <QFontMetricsF>
|
||||
@@ -35,18 +37,18 @@ QString toJsonAlignEnum(QString value) {
|
||||
|
||||
namespace QmlDesigner {
|
||||
using namespace Constants;
|
||||
TextNodeDumper::TextNodeDumper(const QByteArrayList &lineage, const ModelNode &node) :
|
||||
ItemNodeDumper(lineage, node)
|
||||
|
||||
TextNodeDumper::TextNodeDumper(const ModelNode &node)
|
||||
: ItemNodeDumper(node)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TextNodeDumper::isExportable() const
|
||||
{
|
||||
const QByteArrayList &baseClasses = lineage();
|
||||
return std::any_of(baseClasses.cbegin(), baseClasses.cend(), [](const QByteArray &type) {
|
||||
return type == "QtQuick.Text" || type == "QtQuick.Controls.Label";
|
||||
});
|
||||
auto qtQuickTextMetaInfo = model()->qtQuickTextMetaInfo();
|
||||
auto qtQuickControlsLabelMetaInfo = model()->qtQuickControlsLabelMetaInfo();
|
||||
return metaInfo().isBasedOn(qtQuickTextMetaInfo, qtQuickControlsLabelMetaInfo);
|
||||
}
|
||||
|
||||
QJsonObject TextNodeDumper::json([[maybe_unused]] Component &component) const
|
||||
|
@@ -10,7 +10,7 @@ class Component;
|
||||
class TextNodeDumper : public ItemNodeDumper
|
||||
{
|
||||
public:
|
||||
TextNodeDumper(const QByteArrayList &lineage, const ModelNode &node);
|
||||
TextNodeDumper(const ModelNode &node);
|
||||
~TextNodeDumper() override = default;
|
||||
|
||||
bool isExportable() const override;
|
||||
|
@@ -376,10 +376,11 @@ void ItemLibraryModel::update(Model *model)
|
||||
for (const ItemLibraryEntry &entry : itemLibEntries) {
|
||||
NodeMetaInfo metaInfo;
|
||||
|
||||
if constexpr (useProjectStorage())
|
||||
metaInfo = NodeMetaInfo{entry.typeId(), model->projectStorage()};
|
||||
else
|
||||
metaInfo = model->metaInfo(entry.typeName());
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
metaInfo = NodeMetaInfo{entry.typeId(), model->projectStorage()};
|
||||
#else
|
||||
metaInfo = model->metaInfo(entry.typeName());
|
||||
#endif
|
||||
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
bool valid = metaInfo.isValid();
|
||||
|
@@ -24,13 +24,6 @@
|
||||
|
||||
#include <variant>
|
||||
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
# define DEPRECATED_OLD_CREATE_MODELNODE \
|
||||
[[deprecated("Use unqualified type names and no versions!")]]
|
||||
#else
|
||||
# define DEPRECATED_OLD_CREATE_MODELNODE
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPixmap;
|
||||
class QUrl;
|
||||
@@ -91,31 +84,32 @@ public:
|
||||
Imports imports,
|
||||
const QUrl &fileUrl,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {});
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
Model(const TypeName &typeName,
|
||||
int major = 1,
|
||||
int minor = 1,
|
||||
Model *metaInfoProxyModel = nullptr,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {});
|
||||
|
||||
#endif
|
||||
~Model();
|
||||
|
||||
DEPRECATED_OLD_CREATE_MODELNODE static ModelPointer create(
|
||||
const TypeName &typeName,
|
||||
int major = 1,
|
||||
int minor = 1,
|
||||
Model *metaInfoProxyModel = nullptr,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
static ModelPointer create(const TypeName &typeName,
|
||||
int major = 1,
|
||||
int minor = 1,
|
||||
Model *metaInfoProxyModel = nullptr,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
{
|
||||
return ModelPointer(
|
||||
new Model(typeName, major, minor, metaInfoProxyModel, std::move(resourceManagement)));
|
||||
}
|
||||
#endif
|
||||
|
||||
static ModelPointer create(
|
||||
ProjectStorageDependencies projectStorageDependencies,
|
||||
Utils::SmallStringView typeName,
|
||||
Imports imports,
|
||||
const QUrl &fileUrl,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
static ModelPointer create(ProjectStorageDependencies projectStorageDependencies,
|
||||
Utils::SmallStringView typeName,
|
||||
Imports imports,
|
||||
const QUrl &fileUrl,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
{
|
||||
return ModelPointer(new Model(projectStorageDependencies,
|
||||
typeName,
|
||||
@@ -124,12 +118,12 @@ public:
|
||||
std::move(resourceManagement)));
|
||||
}
|
||||
|
||||
DEPRECATED_OLD_CREATE_MODELNODE static ModelPointer create(
|
||||
ProjectStorageDependencies projectStorageDependencies,
|
||||
const TypeName &typeName,
|
||||
int major = 1,
|
||||
int minor = 1,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
static ModelPointer create(ProjectStorageDependencies projectStorageDependencies,
|
||||
const TypeName &typeName,
|
||||
int major = 1,
|
||||
int minor = 1,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {})
|
||||
{
|
||||
return ModelPointer(new Model(projectStorageDependencies,
|
||||
typeName,
|
||||
@@ -138,6 +132,7 @@ public:
|
||||
nullptr,
|
||||
std::move(resourceManagement)));
|
||||
}
|
||||
#endif
|
||||
|
||||
ModelPointer createModel(const TypeName &typeName,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement = {});
|
||||
@@ -188,6 +183,7 @@ public:
|
||||
NodeMetaInfo qtQuick3DTextureMetaInfo() const;
|
||||
NodeMetaInfo qtQuick3DTextureInputMetaInfo() const;
|
||||
NodeMetaInfo qtQuickBorderImageMetaInfo() const;
|
||||
NodeMetaInfo qtQuickControlsLabelMetaInfo() const;
|
||||
NodeMetaInfo qtQuickControlsTextAreaMetaInfo() const;
|
||||
NodeMetaInfo qtQuickImageMetaInfo() const;
|
||||
NodeMetaInfo qtQuickItemMetaInfo() const;
|
||||
|
@@ -23,22 +23,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QDeclarativeContext;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
# define DEPRECATED_TYPENAME [[deprecated("Don't use string based types anymore!")]]
|
||||
# define DEPRECATED_VERSION_NUMBER \
|
||||
[[deprecated( \
|
||||
"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_IMPORT_DIRECTORY_PATH [[deprecated("Use allExportedTypeNames().")]]
|
||||
# define DEPRECATED_REQUIRED_IMPORT_STRING [[deprecated("Use allExportedTypeNames().")]]
|
||||
#else
|
||||
# define DEPRECATED_TYPENAME
|
||||
# define DEPRECATED_VERSION_NUMBER
|
||||
# define DEPRECATED_COMPONENT_FILE_NAME
|
||||
# define DEPRECATED_IMPORT_DIRECTORY_PATH
|
||||
# define DEPRECATED_REQUIRED_IMPORT_STRING
|
||||
#endif
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class MetaInfo;
|
||||
@@ -54,7 +38,9 @@ class QMLDESIGNERCORE_EXPORT NodeMetaInfo
|
||||
|
||||
public:
|
||||
NodeMetaInfo();
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
NodeMetaInfo(Model *model, const TypeName &typeName, int majorVersion, int minorVersion);
|
||||
#else
|
||||
NodeMetaInfo(TypeId typeId, NotNullPointer<const ProjectStorageType> projectStorage)
|
||||
: m_typeId{typeId}
|
||||
, m_projectStorage{projectStorage}
|
||||
@@ -62,6 +48,7 @@ public:
|
||||
NodeMetaInfo(NotNullPointer<const ProjectStorageType> projectStorage)
|
||||
: m_projectStorage{projectStorage}
|
||||
{}
|
||||
#endif
|
||||
|
||||
NodeMetaInfo(const NodeMetaInfo &);
|
||||
NodeMetaInfo &operator=(const NodeMetaInfo &);
|
||||
@@ -69,6 +56,7 @@ public:
|
||||
NodeMetaInfo &operator=(NodeMetaInfo &&);
|
||||
~NodeMetaInfo();
|
||||
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
static NodeMetaInfo create(NotNullPointer<const ProjectStorageType> projectStorage, TypeId typeId)
|
||||
{
|
||||
return {typeId, projectStorage};
|
||||
@@ -78,6 +66,7 @@ public:
|
||||
{
|
||||
return std::bind_front(&NodeMetaInfo::create, projectStorage);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isValid() const;
|
||||
explicit operator bool() const { return isValid(); }
|
||||
@@ -118,11 +107,12 @@ public:
|
||||
bool defaultPropertyIsComponent() const;
|
||||
|
||||
QString displayName() const;
|
||||
DEPRECATED_TYPENAME TypeName typeName() const;
|
||||
DEPRECATED_TYPENAME TypeName simplifiedTypeName() const;
|
||||
DEPRECATED_VERSION_NUMBER int majorVersion() const;
|
||||
DEPRECATED_VERSION_NUMBER int minorVersion() const;
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
TypeName typeName() const;
|
||||
TypeName simplifiedTypeName() const;
|
||||
int majorVersion() const;
|
||||
int minorVersion() const;
|
||||
#endif
|
||||
Storage::Info::ExportedTypeNames allExportedTypeNames() const;
|
||||
Storage::Info::ExportedTypeNames exportedTypeNamesForSourceId(SourceId sourceId) const;
|
||||
|
||||
@@ -131,7 +121,9 @@ public:
|
||||
Storage::Info::ItemLibraryEntries itemLibrariesEntries() const;
|
||||
|
||||
SourceId sourceId() const;
|
||||
DEPRECATED_COMPONENT_FILE_NAME QString componentFileName() const;
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
QString componentFileName() const;
|
||||
#endif
|
||||
|
||||
bool isBasedOn(const NodeMetaInfo &metaInfo) const;
|
||||
bool isBasedOn(const NodeMetaInfo &metaInfo1, const NodeMetaInfo &metaInfo2) const;
|
||||
@@ -214,6 +206,7 @@ public:
|
||||
bool isQtQuick3DCubeMapTexture() const;
|
||||
bool isQtQuick3DView3D() const;
|
||||
bool isQtQuickBorderImage() const;
|
||||
bool isQtQuickControlsLabel() const;
|
||||
bool isQtQuickControlsSwipeView() const;
|
||||
bool isQtQuickControlsTabBar() const;
|
||||
bool isQtQuickExtrasPicture() const;
|
||||
@@ -226,6 +219,7 @@ public:
|
||||
bool isQtQuickPositioner() const;
|
||||
bool isQtQuickPropertyAnimation() const;
|
||||
bool isQtQuickPropertyChanges() const;
|
||||
bool isQtQuickRectangle() const;
|
||||
bool isQtQuickRepeater() const;
|
||||
bool isQtQuickState() const;
|
||||
bool isQtQuickStateOperation() const;
|
||||
@@ -251,9 +245,10 @@ public:
|
||||
bool usesCustomParser() const;
|
||||
|
||||
bool isEnumeration() const;
|
||||
DEPRECATED_IMPORT_DIRECTORY_PATH QString importDirectoryPath() const;
|
||||
DEPRECATED_REQUIRED_IMPORT_STRING QString requiredImportString() const;
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
QString importDirectoryPath() const;
|
||||
QString requiredImportString() const;
|
||||
#endif
|
||||
friend bool operator==(const NodeMetaInfo &first, const NodeMetaInfo &second)
|
||||
{
|
||||
if constexpr (useProjectStorage())
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1788,6 +1788,7 @@ Model::Model(ProjectStorageDependencies projectStorageDependencies,
|
||||
std::move(resourceManagement)))
|
||||
{}
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
Model::Model(const TypeName &typeName,
|
||||
int major,
|
||||
int minor,
|
||||
@@ -1796,6 +1797,7 @@ Model::Model(const TypeName &typeName,
|
||||
: d(std::make_unique<Internal::ModelPrivate>(
|
||||
this, typeName, major, minor, metaInfoProxyModel, std::move(resourceManagement)))
|
||||
{}
|
||||
#endif
|
||||
|
||||
ModelPointer Model::createModel(const TypeName &typeName,
|
||||
std::unique_ptr<ModelResourceManagementInterface> resourceManagement)
|
||||
@@ -2480,6 +2482,16 @@ NodeMetaInfo Model::qtQuickTextEditMetaInfo() const
|
||||
}
|
||||
}
|
||||
|
||||
NodeMetaInfo Model::qtQuickControlsLabelMetaInfo() const
|
||||
{
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
using namespace Storage::Info;
|
||||
return createNodeMetaInfo<QtQuick_Controls, Label>();
|
||||
#else
|
||||
return metaInfo("QtQuick.Controls.Label");
|
||||
#endif
|
||||
}
|
||||
|
||||
NodeMetaInfo Model::qtQuickControlsTextAreaMetaInfo() const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
@@ -2773,24 +2785,26 @@ namespace {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
NodeMetaInfo Model::metaInfo(const TypeName &typeName, int majorVersion, int minorVersion) const
|
||||
NodeMetaInfo Model::metaInfo(const TypeName &typeName,
|
||||
[[maybe_unused]] int majorVersion,
|
||||
[[maybe_unused]] int minorVersion) const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
return NodeMetaInfo(d->projectStorage->typeId(d->importedTypeNameId(typeName)),
|
||||
d->projectStorage);
|
||||
} else {
|
||||
return NodeMetaInfo(metaInfoProxyModel(), typeName, majorVersion, minorVersion);
|
||||
}
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
return NodeMetaInfo(d->projectStorage->typeId(d->importedTypeNameId(typeName)), d->projectStorage);
|
||||
#else
|
||||
return NodeMetaInfo(metaInfoProxyModel(), typeName, majorVersion, minorVersion);
|
||||
#endif
|
||||
}
|
||||
|
||||
NodeMetaInfo Model::metaInfo(Module module, Utils::SmallStringView typeName, Storage::Version version) const
|
||||
NodeMetaInfo Model::metaInfo([[maybe_unused]] Module module,
|
||||
[[maybe_unused]] Utils::SmallStringView typeName,
|
||||
[[maybe_unused]] Storage::Version version) const
|
||||
{
|
||||
if constexpr (useProjectStorage()) {
|
||||
return NodeMetaInfo(d->projectStorage->typeId(module.id(), typeName, version),
|
||||
d->projectStorage);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
return NodeMetaInfo(d->projectStorage->typeId(module.id(), typeName, version), d->projectStorage);
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QDS_USE_PROJECTSTORAGE
|
||||
|
@@ -687,14 +687,14 @@ NodeMetaInfo ModelNode::metaInfo() const
|
||||
if (!isValid())
|
||||
return {};
|
||||
|
||||
if constexpr (useProjectStorage()) {
|
||||
return NodeMetaInfo(m_internalNode->typeId, m_model->projectStorage());
|
||||
} else {
|
||||
return NodeMetaInfo(m_model->metaInfoProxyModel(),
|
||||
m_internalNode->typeName,
|
||||
m_internalNode->majorVersion,
|
||||
m_internalNode->minorVersion);
|
||||
}
|
||||
#ifdef QDS_USE_PROJECTSTORAGE
|
||||
return NodeMetaInfo(m_internalNode->typeId, m_model->projectStorage());
|
||||
#else
|
||||
return NodeMetaInfo(m_model->metaInfoProxyModel(),
|
||||
m_internalNode->typeName,
|
||||
m_internalNode->majorVersion,
|
||||
m_internalNode->minorVersion);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ModelNode::hasMetaInfo() const
|
||||
|
@@ -58,6 +58,7 @@ inline constexpr char Item[] = "Item";
|
||||
inline constexpr char JsonListModel[] = "JsonListModel";
|
||||
inline constexpr char KeyframeGroup[] = "KeyframeGroup";
|
||||
inline constexpr char Keyframe[] = "Keyframe";
|
||||
inline constexpr char Label[] = "Label";
|
||||
inline constexpr char Layout[] = "Layout";
|
||||
inline constexpr char Light[] = "Light";
|
||||
inline constexpr char ListElement[] = "ListElement";
|
||||
@@ -236,6 +237,7 @@ class CommonTypeCache
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::QmlLibrary, SpriteParticle3D>,
|
||||
CacheType<QtQuick3D_Particles3D, ModuleKind::CppLibrary, QQuick3DParticleAbstractShape>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, Control>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, Label>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, Popup>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, SplitView>,
|
||||
CacheType<QtQuick_Controls, ModuleKind::QmlLibrary, SwipeView>,
|
||||
|
@@ -705,6 +705,11 @@ Internal::DesignModeWidget *QmlDesignerPlugin::mainWidget() const
|
||||
return d ? &d->mainWidget : nullptr;
|
||||
}
|
||||
|
||||
QmlDesignerProjectManager &QmlDesignerPlugin::projectManagerForPluginInitializationOnly()
|
||||
{
|
||||
return m_instance->d->projectManager;
|
||||
}
|
||||
|
||||
QWidget *QmlDesignerPlugin::createProjectExplorerWidget(QWidget *parent) const
|
||||
{
|
||||
return Internal::DesignModeWidget::createProjectExplorerWidget(parent);
|
||||
|
@@ -60,6 +60,8 @@ public:
|
||||
DesignDocument *currentDesignDocument() const;
|
||||
Internal::DesignModeWidget *mainWidget() const;
|
||||
|
||||
static QmlDesignerProjectManager &projectManagerForPluginInitializationOnly();
|
||||
|
||||
QWidget *createProjectExplorerWidget(QWidget *parent) const;
|
||||
|
||||
void switchToTextModeDeferred();
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "modelfwd.h"
|
||||
#include <projectstoragefwd.h>
|
||||
#include <qmldesigner_global.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
@@ -28,7 +29,7 @@ namespace QmlDesigner {
|
||||
|
||||
class ExternalDependenciesInterface;
|
||||
|
||||
class QmlDesignerProjectManager
|
||||
class QMLDESIGNER_EXPORT QmlDesignerProjectManager
|
||||
{
|
||||
class QmlDesignerProjectManagerProjectData;
|
||||
class PreviewImageCacheData;
|
||||
|
Reference in New Issue
Block a user