QmlDesigner: Cleanups to the AbstractView class

Change-Id: Ic8f82342cd6cb8ff14b3239efa7add62112898a6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2023-03-20 17:25:18 +02:00
parent b63cb2603e
commit 53657b1e3c
8 changed files with 111 additions and 144 deletions

View File

@@ -4,6 +4,7 @@
#pragma once #pragma once
#include "materialeditorview.h" #include "materialeditorview.h"
#include "rewritertransaction.h"
namespace QmlDesigner { namespace QmlDesigner {
@@ -12,7 +13,7 @@ class MaterialEditorTransaction : public QObject
Q_OBJECT Q_OBJECT
public: public:
MaterialEditorTransaction(QmlDesigner::MaterialEditorView *materialEditor); MaterialEditorTransaction(MaterialEditorView *materialEditor);
Q_INVOKABLE void start(); Q_INVOKABLE void start();
Q_INVOKABLE void end(); Q_INVOKABLE void end();
@@ -23,8 +24,8 @@ protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
private: private:
QmlDesigner::MaterialEditorView *m_materialEditor = nullptr; MaterialEditorView *m_materialEditor = nullptr;
QmlDesigner::RewriterTransaction m_rewriterTransaction; RewriterTransaction m_rewriterTransaction;
int m_timerId = -1; int m_timerId = -1;
}; };

View File

@@ -4,6 +4,7 @@
#pragma once #pragma once
#include "propertyeditorview.h" #include "propertyeditorview.h"
#include "rewritertransaction.h"
namespace QmlDesigner { namespace QmlDesigner {
@@ -11,7 +12,7 @@ class PropertyEditorTransaction : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
PropertyEditorTransaction(QmlDesigner::PropertyEditorView *propertyEditor); PropertyEditorTransaction(PropertyEditorView *propertyEditor);
Q_INVOKABLE void start(); Q_INVOKABLE void start();
Q_INVOKABLE void end(); Q_INVOKABLE void end();
@@ -22,8 +23,8 @@ protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
private: private:
QmlDesigner::PropertyEditorView *m_propertyEditor; PropertyEditorView *m_propertyEditor;
QmlDesigner::RewriterTransaction m_rewriterTransaction; RewriterTransaction m_rewriterTransaction;
int m_timerId; int m_timerId;
}; };

View File

@@ -3,6 +3,7 @@
#pragma once #pragma once
#include "rewritertransaction.h"
#include "textureeditorview.h" #include "textureeditorview.h"
namespace QmlDesigner { namespace QmlDesigner {

View File

@@ -3,43 +3,35 @@
#pragma once #pragma once
#include <qmldesignercorelib_global.h> #include "model.h"
#include "modelnode.h"
#include <model.h> #include "qmldesignercorelib_global.h"
#include <modelnode.h>
#include <abstractproperty.h>
#include <documentmessage.h>
#include <rewritertransaction.h>
#include <commondefines.h> #include <commondefines.h>
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
#include <QVector3D>
#include <functional>
#include <memory>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QStyle;
class QToolButton;
class QImage; class QImage;
class QPixmap; class QPixmap;
class QVector3D;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class InternalNode;
using InternalNodePointer = std::shared_ptr<InternalNode>;
}
}
namespace QmlDesigner { namespace QmlDesigner {
class AbstractProperty;
class DocumentMessage;
class ExternalDependenciesInterface;
class NodeInstanceView; class NodeInstanceView;
class RewriterView;
class QmlModelState; class QmlModelState;
class QmlTimeline; class QmlTimeline;
class ExternalDependenciesInterface; class RewriterTransaction;
class RewriterView;
namespace Internal {
class InternalNode;
using InternalNodePointer = std::shared_ptr<InternalNode>;
}
enum DesignerWidgetFlags { enum DesignerWidgetFlags {
DisableOnError, DisableOnError,
@@ -75,18 +67,19 @@ public:
Q_FLAGS(PropertyChangeFlag PropertyChangeFlags) Q_FLAGS(PropertyChangeFlag PropertyChangeFlags)
enum PropertyChangeFlag { enum PropertyChangeFlag {
NoAdditionalChanges = 0x0, NoAdditionalChanges = 0x0,
PropertiesAdded = 0x1, PropertiesAdded = 0x1,
EmptyPropertiesRemoved = 0x2 EmptyPropertiesRemoved = 0x2
}; };
Q_DECLARE_FLAGS(PropertyChangeFlags, PropertyChangeFlag) Q_DECLARE_FLAGS(PropertyChangeFlags, PropertyChangeFlag)
AbstractView(ExternalDependenciesInterface &externalDependencies) AbstractView(ExternalDependenciesInterface &externalDependencies)
: m_externalDependencies{externalDependencies} : m_externalDependencies{externalDependencies}
{} {}
~AbstractView() override; ~AbstractView() override;
Model* model() const; Model *model() const;
bool isAttached() const; bool isAttached() const;
RewriterTransaction beginRewriterTransaction(const QByteArray &identifier); RewriterTransaction beginRewriterTransaction(const QByteArray &identifier);
@@ -128,7 +121,7 @@ public:
QList<ModelNode> allModelNodes() const; QList<ModelNode> allModelNodes() const;
QList<ModelNode> allModelNodesOfType(const NodeMetaInfo &typeName) const; QList<ModelNode> allModelNodesOfType(const NodeMetaInfo &typeName) const;
void emitDocumentMessage(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &warnings = QList<DocumentMessage>()); void emitDocumentMessage(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &warnings = {});
void emitDocumentMessage(const QString &error); void emitDocumentMessage(const QString &error);
void emitCustomNotification(const QString &identifier); void emitCustomNotification(const QString &identifier);
void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList); void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList);
@@ -156,19 +149,25 @@ public:
virtual void nodeCreated(const ModelNode &createdNode); virtual void nodeCreated(const ModelNode &createdNode);
virtual void nodeAboutToBeRemoved(const ModelNode &removedNode); virtual void nodeAboutToBeRemoved(const ModelNode &removedNode);
virtual void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange); virtual void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty,
virtual void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); PropertyChangeFlags propertyChange);
virtual void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); virtual void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent,
virtual void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); const NodeAbstractProperty &oldPropertyParent, PropertyChangeFlags propertyChange);
virtual void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList); virtual void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent,
virtual void propertiesRemoved(const QList<AbstractProperty>& propertyList); const NodeAbstractProperty &oldPropertyParent, PropertyChangeFlags propertyChange);
virtual void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); virtual void nodeIdChanged(const ModelNode &node, const QString &newId, const QString &oldId);
virtual void propertiesAboutToBeRemoved(const QList<AbstractProperty> &propertyList);
virtual void propertiesRemoved(const QList<AbstractProperty> &propertyList);
virtual void variantPropertiesChanged(const QList<VariantProperty> &propertyList,
PropertyChangeFlags propertyChange);
virtual void bindingPropertiesAboutToBeChanged(const QList<BindingProperty> &propertyList); virtual void bindingPropertiesAboutToBeChanged(const QList<BindingProperty> &propertyList);
virtual void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); virtual void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags propertyChange);
virtual void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty>& propertyList, PropertyChangeFlags propertyChange); virtual void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &propertyList,
virtual void signalDeclarationPropertiesChanged(const QVector<SignalDeclarationProperty>& propertyList, PropertyChangeFlags propertyChange); PropertyChangeFlags propertyChange);
virtual void signalDeclarationPropertiesChanged(const QVector<SignalDeclarationProperty> &propertyList,
PropertyChangeFlags propertyChange);
virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
virtual void nodeTypeChanged(const ModelNode& node, const TypeName &type, int majorVersion, int minorVersion); virtual void nodeTypeChanged(const ModelNode &node, const TypeName &type, int majorVersion, int minorVersion);
virtual void instancePropertyChanged(const QList<QPair<ModelNode, PropertyName> > &propertyList); virtual void instancePropertyChanged(const QList<QPair<ModelNode, PropertyName> > &propertyList);
virtual void instanceErrorChanged(const QVector<ModelNode> &errorNodeList); virtual void instanceErrorChanged(const QVector<ModelNode> &errorNodeList);
@@ -245,7 +244,6 @@ public:
int minorQtQuickVersion() const; int minorQtQuickVersion() const;
void resetView(); void resetView();
void resetPuppet(); void resetPuppet();
virtual bool hasWidget() const; virtual bool hasWidget() const;
@@ -296,10 +294,9 @@ protected:
const QString &feedbackDisplayName = QString(), const QString &feedbackDisplayName = QString(),
DesignerWidgetFlags widgetFlags = DesignerWidgetFlags::DisableOnError); DesignerWidgetFlags widgetFlags = DesignerWidgetFlags::DisableOnError);
private: //functions private:
QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const; QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const;
private:
QPointer<Model> m_model; QPointer<Model> m_model;
ExternalDependenciesInterface &m_externalDependencies; ExternalDependenciesInterface &m_externalDependencies;
bool m_enabled = true; bool m_enabled = true;
@@ -308,5 +305,4 @@ private:
QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList); QMLDESIGNERCORE_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList, AbstractView *view); QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList, AbstractView *view);
} // namespace QmlDesigner
}

View File

@@ -6,6 +6,7 @@
#include "qmldesignercorelib_global.h" #include "qmldesignercorelib_global.h"
#include "abstractview.h" #include "abstractview.h"
#include "modelcache.h" #include "modelcache.h"
#include "rewritertransaction.h"
#include <modelnode.h> #include <modelnode.h>
#include <nodeinstance.h> #include <nodeinstance.h>

View File

@@ -4,9 +4,9 @@
#pragma once #pragma once
#include "qmldesignercorelib_global.h" #include "qmldesignercorelib_global.h"
#include "exception.h"
#include "abstractview.h" #include "abstractview.h"
#include "documentmessage.h" #include "documentmessage.h"
#include "rewritertransaction.h"
#include <QScopedPointer> #include <QScopedPointer>
#include <QTimer> #include <QTimer>

View File

@@ -4,24 +4,23 @@
#include "abstractview.h" #include "abstractview.h"
#include "auxiliarydataproperties.h" #include "auxiliarydataproperties.h"
#include "bindingproperty.h"
#include "internalnode_p.h"
#include "model.h" #include "model.h"
#include "model_p.h" #include "model_p.h"
#include "internalnode_p.h"
#include "nodeinstanceview.h" #include "nodeinstanceview.h"
#include <qmlstate.h> #include "nodelistproperty.h"
#include <qmltimeline.h> #include "nodemetainfo.h"
#include <nodemetainfo.h> #include "qmlstate.h"
#include <qmldesignerconstants.h> #include "qmltimeline.h"
#include <nodelistproperty.h> #include "qmldesignerconstants.h"
#include <variantproperty.h> #include "rewritertransaction.h"
#include <bindingproperty.h> #include "variantproperty.h"
#include <coreplugin/helpmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <QWidget> #include <QWidget>
#include <QtGui/qimage.h>
namespace QmlDesigner { namespace QmlDesigner {
@@ -78,35 +77,27 @@ ModelNode AbstractView::createModelNode(const TypeName &typeName,
ModelNode::NodeSourceType nodeSourceType, ModelNode::NodeSourceType nodeSourceType,
const QString &behaviorPropertyName) const QString &behaviorPropertyName)
{ {
return ModelNode(model()->d->createNode(typeName, majorVersion, minorVersion, propertyList, auxPropertyList, nodeSource, nodeSourceType, behaviorPropertyName), model(), this); return ModelNode(model()->d->createNode(typeName, majorVersion, minorVersion, propertyList,
auxPropertyList, nodeSource, nodeSourceType,
behaviorPropertyName), model(), this);
} }
/*! // Returns the constant root model node.
Returns the constant root model node.
*/
ModelNode AbstractView::rootModelNode() const ModelNode AbstractView::rootModelNode() const
{ {
Q_ASSERT(model()); Q_ASSERT(model());
return ModelNode(model()->d->rootNode(), model(), const_cast<AbstractView*>(this)); return ModelNode(model()->d->rootNode(), model(), const_cast<AbstractView *>(this));
} }
// Returns the root model node.
/*!
Returns the root model node.
*/
ModelNode AbstractView::rootModelNode() ModelNode AbstractView::rootModelNode()
{ {
Q_ASSERT(model()); Q_ASSERT(model());
return ModelNode(model()->d->rootNode(), model(), this); return ModelNode(model()->d->rootNode(), model(), this);
} }
/*! // Sets the reference to a model to a null pointer.
Sets the reference to a model to a null pointer.
*/
void AbstractView::removeModel() void AbstractView::removeModel()
{ {
m_model.clear(); m_model.clear();
@@ -133,9 +124,7 @@ WidgetInfo AbstractView::createWidgetInfo(QWidget *widget,
return widgetInfo; return widgetInfo;
} }
/*! // Returns the model of the view.
Returns the model of the view.
*/
Model* AbstractView::model() const Model* AbstractView::model() const
{ {
return m_model.data(); return m_model.data();
@@ -187,7 +176,6 @@ void AbstractView::modelAboutToBeDetached(Model *)
\value EmptyPropertiesRemoved \value EmptyPropertiesRemoved
Empty properties were removed. Empty properties were removed.
*/ */
void AbstractView::instancePropertyChanged(const QList<QPair<ModelNode, PropertyName> > &/*propertyList*/) void AbstractView::instancePropertyChanged(const QList<QPair<ModelNode, PropertyName> > &/*propertyList*/)
{ {
} }
@@ -261,72 +249,60 @@ void AbstractView::nodeOrderChanged(const NodeListProperty &listProperty, const
nodeOrderChanged(listProperty); nodeOrderChanged(listProperty);
} }
/*!
\fn void AbstractView::nodeAboutToBeRemoved(const ModelNode &removedNode)
Called when the node specified by \a removedNode will be removed.
*/
void AbstractView::nodeAboutToBeRemoved(const ModelNode &/*removedNode*/) void AbstractView::nodeAboutToBeRemoved(const ModelNode &/*removedNode*/)
{ {
} }
void AbstractView::nodeRemoved(const ModelNode &/*removedNode*/, const NodeAbstractProperty &/*parentProperty*/, PropertyChangeFlags /*propertyChange*/) void AbstractView::nodeRemoved(const ModelNode &/*removedNode*/, const NodeAbstractProperty &/*parentProperty*/,
PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& /*propertyList*/) void AbstractView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &/*propertyList*/)
{ {
} }
/*! void AbstractView::propertiesRemoved(const QList<AbstractProperty> &/*propertyList*/)
Called when the properties specified by \a propertyList are removed.
*/
void AbstractView::propertiesRemoved(const QList<AbstractProperty>& /*propertyList*/)
{ {
} }
/*!
\fn void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
Called when the parent of \a node will be changed from \a oldPropertyParent to
\a newPropertyParent.
*/
/*!
\fn void QmlDesigner::AbstractView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList)
Called when the selection is changed from \a lastSelectedNodeList to
\a selectedNodeList.
*/
void AbstractView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/, const QList<ModelNode> &/*lastSelectedNodeList*/) void AbstractView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/, const QList<ModelNode> &/*lastSelectedNodeList*/)
{ {
} }
void AbstractView::nodeAboutToBeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/) void AbstractView::nodeAboutToBeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/,
const NodeAbstractProperty &/*oldPropertyParent*/, PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::nodeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/) void AbstractView::nodeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/,
const NodeAbstractProperty &/*oldPropertyParent*/, PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::nodeIdChanged(const ModelNode& /*node*/, const QString& /*newId*/, const QString& /*oldId*/) void AbstractView::nodeIdChanged(const ModelNode &/*node*/, const QString &/*newId*/, const QString &/*oldId*/)
{ {
} }
void AbstractView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) void AbstractView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/,
PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::bindingPropertiesAboutToBeChanged(const QList<BindingProperty> &) {} void AbstractView::bindingPropertiesAboutToBeChanged(const QList<BindingProperty> &) {}
void AbstractView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) void AbstractView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/,
PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) void AbstractView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/,
PropertyChangeFlags /*propertyChange*/)
{ {
} }
void AbstractView::signalDeclarationPropertiesChanged(const QVector<SignalDeclarationProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) void AbstractView::signalDeclarationPropertiesChanged(const QVector<SignalDeclarationProperty> &/*propertyList*/,
PropertyChangeFlags /*propertyChange*/)
{ {
} }
@@ -351,13 +327,14 @@ void AbstractView::usedImportsChanged(const QList<Import> &/*usedImports*/)
{ {
} }
void AbstractView::auxiliaryDataChanged(const ModelNode & /*node*/, void AbstractView::auxiliaryDataChanged(const ModelNode &/*node*/,
AuxiliaryDataKeyView /*key*/, AuxiliaryDataKeyView /*key*/,
const QVariant & /*data*/) const QVariant &/*data*/)
{ {
} }
void AbstractView::customNotification(const AbstractView * /*view*/, const QString & /*identifier*/, const QList<ModelNode> & /*nodeList*/, const QList<QVariant> & /*data*/) void AbstractView::customNotification(const AbstractView * /*view*/, const QString & /*identifier*/,
const QList<ModelNode> & /*nodeList*/, const QList<QVariant> & /*data*/)
{ {
} }
@@ -369,27 +346,27 @@ void AbstractView::documentMessagesChanged(const QList<DocumentMessage> &/*error
{ {
} }
void AbstractView::currentTimelineChanged(const ModelNode & /*node*/) void AbstractView::currentTimelineChanged(const ModelNode &/*node*/)
{ {
} }
void AbstractView::renderImage3DChanged(const QImage & /*image*/) void AbstractView::renderImage3DChanged(const QImage &/*image*/)
{ {
} }
void AbstractView::updateActiveScene3D(const QVariantMap & /*sceneState*/) void AbstractView::updateActiveScene3D(const QVariantMap &/*sceneState*/)
{ {
} }
void AbstractView::updateImport3DSupport(const QVariantMap & /*supportMap*/) void AbstractView::updateImport3DSupport(const QVariantMap &/*supportMap*/)
{ {
} }
// a Quick3DNode that is picked at the requested view position in the 3D Editor and the 3D scene // a Quick3DNode that is picked at the requested view position in the 3D Editor and the 3D scene
// position of the requested view position. // position of the requested view position.
void AbstractView::nodeAtPosReady(const ModelNode & /*modelNode*/, const QVector3D &/*pos3d*/) {} void AbstractView::nodeAtPosReady(const ModelNode &/*modelNode*/, const QVector3D &/*pos3d*/) {}
void AbstractView::modelNodePreviewPixmapChanged(const ModelNode & /*node*/, const QPixmap & /*pixmap*/) void AbstractView::modelNodePreviewPixmapChanged(const ModelNode &/*node*/, const QPixmap &/*pixmap*/)
{ {
} }
@@ -448,9 +425,6 @@ void AbstractView::setSelectedModelNode(const ModelNode &modelNode)
setSelectedModelNodes({modelNode}); setSelectedModelNodes({modelNode});
} }
/*!
Clears the selection.
*/
void AbstractView::clearSelectedModelNodes() void AbstractView::clearSelectedModelNodes()
{ {
model()->d->clearSelectedNodes(); model()->d->clearSelectedNodes();
@@ -471,10 +445,6 @@ bool AbstractView::isSelectedModelNode(const ModelNode &modelNode) const
return model()->d->selectedNodes().contains(modelNode.internalNode()); return model()->d->selectedNodes().contains(modelNode.internalNode());
} }
/*!
Sets the list of nodes to the actual selected nodes. Returns a list of the
selected nodes.
*/
QList<ModelNode> AbstractView::selectedModelNodes() const QList<ModelNode> AbstractView::selectedModelNodes() const
{ {
return toModelNodeList(model()->d->selectedNodes()); return toModelNodeList(model()->d->selectedNodes());
@@ -496,18 +466,12 @@ ModelNode AbstractView::singleSelectedModelNode() const
return ModelNode(); return ModelNode();
} }
/*!
Adds \a node to the selection list.
*/
void AbstractView::selectModelNode(const ModelNode &modelNode) void AbstractView::selectModelNode(const ModelNode &modelNode)
{ {
QTC_ASSERT(modelNode.isInHierarchy(), return); QTC_ASSERT(modelNode.isInHierarchy(), return);
model()->d->selectNode(modelNode.internalNode()); model()->d->selectNode(modelNode.internalNode());
} }
/*!
Removes \a node from the selection list.
*/
void AbstractView::deselectModelNode(const ModelNode &node) void AbstractView::deselectModelNode(const ModelNode &node)
{ {
model()->d->deselectNode(node.internalNode()); model()->d->deselectNode(node.internalNode());
@@ -537,22 +501,23 @@ const NodeInstanceView *AbstractView::nodeInstanceView() const
{ {
if (model()) if (model())
return model()->d->nodeInstanceView(); return model()->d->nodeInstanceView();
else
return nullptr; return nullptr;
} }
RewriterView *AbstractView::rewriterView() const RewriterView *AbstractView::rewriterView() const
{ {
if (model()) if (model())
return model()->d->rewriterView(); return model()->d->rewriterView();
else
return nullptr; return nullptr;
} }
void AbstractView::resetView() void AbstractView::resetView()
{ {
if (!model()) if (!model())
return; return;
Model *currentModel = model(); Model *currentModel = model();
currentModel->detachView(this); currentModel->detachView(this);
@@ -630,7 +595,7 @@ void AbstractView::deactivateTimelineRecording()
model()->d->notifyCurrentTimelineChanged(ModelNode()); model()->d->notifyCurrentTimelineChanged(ModelNode());
} }
bool AbstractView::executeInTransaction(const QByteArray &identifier, const AbstractView::OperationBlock &lambda) bool AbstractView::executeInTransaction(const QByteArray &identifier, const OperationBlock &lambda)
{ {
try { try {
RewriterTransaction transaction = beginRewriterTransaction(identifier); RewriterTransaction transaction = beginRewriterTransaction(identifier);
@@ -907,7 +872,7 @@ ModelNode AbstractView::currentStateNode() const
if (model()) if (model())
return ModelNode(m_model.data()->d->currentStateNode(), m_model.data(), const_cast<AbstractView*>(this)); return ModelNode(m_model.data()->d->currentStateNode(), m_model.data(), const_cast<AbstractView*>(this));
return ModelNode(); return {};
} }
QmlModelState AbstractView::currentState() const QmlModelState AbstractView::currentState() const
@@ -917,12 +882,13 @@ QmlModelState AbstractView::currentState() const
QmlTimeline AbstractView::currentTimeline() const QmlTimeline AbstractView::currentTimeline() const
{ {
if (model()) if (model()) {
return QmlTimeline(ModelNode(m_model.data()->d->currentTimelineNode(), return QmlTimeline(ModelNode(m_model.data()->d->currentTimelineNode(),
m_model.data(), m_model.data(),
const_cast<AbstractView*>(this))); const_cast<AbstractView *>(this)));
}
return QmlTimeline(); return {};
} }
static int getMinorVersionFromImport(const Model *model) static int getMinorVersionFromImport(const Model *model)
@@ -962,13 +928,14 @@ static int getMajorVersionFromNode(const ModelNode &modelNode)
if (modelNode.metaInfo().isValid()) { if (modelNode.metaInfo().isValid()) {
for (const NodeMetaInfo &info : modelNode.metaInfo().classHierarchy()) { for (const NodeMetaInfo &info : modelNode.metaInfo().classHierarchy()) {
if (info.typeName() == "QtQml.QtObject" if (info.typeName() == "QtQml.QtObject"
|| info.typeName() == "QtQuick.QtObject" || info.typeName() == "QtQuick.QtObject"
|| info.typeName() == "QtQuick.Item") || info.typeName() == "QtQuick.Item") {
return info.majorVersion(); return info.majorVersion();
}
} }
} }
return 1; //default return 1; // default
} }
static int getMinorVersionFromNode(const ModelNode &modelNode) static int getMinorVersionFromNode(const ModelNode &modelNode)
@@ -981,7 +948,7 @@ static int getMinorVersionFromNode(const ModelNode &modelNode)
} }
} }
return 1; //default return 1; // default
} }
int AbstractView::majorQtQuickVersion() const int AbstractView::majorQtQuickVersion() const
@@ -1002,5 +969,4 @@ int AbstractView::minorQtQuickVersion() const
return getMinorVersionFromNode(rootModelNode()); return getMinorVersionFromNode(rootModelNode());
} }
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -3,6 +3,7 @@
#include "qmlchangeset.h" #include "qmlchangeset.h"
#include "bindingproperty.h" #include "bindingproperty.h"
#include "rewritertransaction.h"
#include "variantproperty.h" #include "variantproperty.h"
#include "abstractview.h" #include "abstractview.h"
#include <metainfo.h> #include <metainfo.h>