forked from qt-creator/qt-creator
QmlDesigner: cleanups on the Model class
Change-Id: I61764f5ea829b3a59d55b341d02aedfda7b87b84 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -71,16 +71,16 @@ class ModelPrivate;
|
|||||||
class WriteLocker
|
class WriteLocker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~WriteLocker();
|
|
||||||
WriteLocker(ModelPrivate *model);
|
|
||||||
WriteLocker(Model *model);
|
WriteLocker(Model *model);
|
||||||
private: // variables
|
WriteLocker(ModelPrivate *model);
|
||||||
|
~WriteLocker();
|
||||||
|
|
||||||
|
private:
|
||||||
QPointer<ModelPrivate> m_model;
|
QPointer<ModelPrivate> m_model;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModelPrivate : public QObject {
|
class ModelPrivate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_DISABLE_COPY(ModelPrivate)
|
Q_DISABLE_COPY(ModelPrivate)
|
||||||
|
|
||||||
friend class QmlDesigner::Model;
|
friend class QmlDesigner::Model;
|
||||||
@@ -97,20 +97,19 @@ public:
|
|||||||
void setFileUrl(const QUrl &url);
|
void setFileUrl(const QUrl &url);
|
||||||
|
|
||||||
InternalNodePointer createNode(const TypeName &typeName,
|
InternalNodePointer createNode(const TypeName &typeName,
|
||||||
int majorVersion,
|
int majorVersion,
|
||||||
int minorVersion,
|
int minorVersion,
|
||||||
const QList<QPair<PropertyName, QVariant> > &propertyList,
|
const QList<QPair<PropertyName, QVariant> > &propertyList,
|
||||||
const QList<QPair<PropertyName, QVariant> > &auxPropertyList,
|
const QList<QPair<PropertyName, QVariant> > &auxPropertyList,
|
||||||
const QString &nodeSource,
|
const QString &nodeSource,
|
||||||
ModelNode::NodeSourceType nodeSourceType,
|
ModelNode::NodeSourceType nodeSourceType,
|
||||||
bool isRootNode = false);
|
bool isRootNode = false);
|
||||||
|
|
||||||
|
|
||||||
/*factory methods for internal use in model and rewriter*/
|
/*factory methods for internal use in model and rewriter*/
|
||||||
|
|
||||||
void removeNode(const InternalNodePointer &node);
|
void removeNode(const InternalNodePointer &node);
|
||||||
void changeNodeId(const InternalNodePointer& internalNodePointer, const QString& id);
|
void changeNodeId(const InternalNodePointer &node, const QString &id);
|
||||||
void changeNodeType(const InternalNodePointer& internalNodePointer, const TypeName &typeName, int majorVersion, int minorVersion);
|
void changeNodeType(const InternalNodePointer &node, const TypeName &typeName, int majorVersion, int minorVersion);
|
||||||
|
|
||||||
InternalNodePointer rootNode() const;
|
InternalNodePointer rootNode() const;
|
||||||
InternalNodePointer findNode(const QString &id) const;
|
InternalNodePointer findNode(const QString &id) const;
|
||||||
@@ -122,9 +121,6 @@ public:
|
|||||||
void detachView(AbstractView *view, bool notifyView);
|
void detachView(AbstractView *view, bool notifyView);
|
||||||
void detachAllViews();
|
void detachAllViews();
|
||||||
|
|
||||||
Model *model() const { return m_model; }
|
|
||||||
void setModel(Model *model) { m_model = model; }
|
|
||||||
|
|
||||||
template<typename Callable>
|
template<typename Callable>
|
||||||
void notifyNodeInstanceViewLast(Callable call);
|
void notifyNodeInstanceViewLast(Callable call);
|
||||||
template<typename Callable>
|
template<typename Callable>
|
||||||
@@ -132,36 +128,47 @@ public:
|
|||||||
template<typename Callable>
|
template<typename Callable>
|
||||||
void notifyInstanceChanges(Callable call);
|
void notifyInstanceChanges(Callable call);
|
||||||
|
|
||||||
void notifyNodeCreated(const InternalNodePointer &newInternalNodePointer);
|
void notifyNodeCreated(const InternalNodePointer &newNode);
|
||||||
void notifyNodeAboutToBeReparent(const InternalNodePointer &internalNodePointer, const InternalNodeAbstractPropertyPointer &newPropertyParent, const InternalNodePointer &oldParent, const PropertyName &oldPropertyName, AbstractView::PropertyChangeFlags propertyChange);
|
void notifyNodeAboutToBeReparent(const InternalNodePointer &node,
|
||||||
void notifyNodeReparent(const InternalNodePointer &internalNodePointer, const InternalNodeAbstractPropertyPointer &newPropertyParent, const InternalNodePointer &oldParent, const PropertyName &oldPropertyName, AbstractView::PropertyChangeFlags propertyChange);
|
const InternalNodeAbstractPropertyPointer &newPropertyParent,
|
||||||
void notifyNodeAboutToBeRemoved(const InternalNodePointer &internalNodePointer);
|
const InternalNodePointer &oldParent,
|
||||||
void notifyNodeRemoved(const InternalNodePointer &internalNodePointer, const InternalNodePointer &parentNodePointer, const PropertyName &parentPropertyName, AbstractView::PropertyChangeFlags propertyChange);
|
const PropertyName &oldPropertyName,
|
||||||
void notifyNodeIdChanged(const InternalNodePointer& internalNodePointer, const QString& newId, const QString& oldId);
|
AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void notifyNodeTypeChanged(const InternalNodePointer& internalNodePointer, const TypeName &type, int majorVersion, int minorVersion);
|
void notifyNodeReparent(const InternalNodePointer &node,
|
||||||
|
const InternalNodeAbstractPropertyPointer &newPropertyParent,
|
||||||
|
const InternalNodePointer &oldParent,
|
||||||
|
const PropertyName &oldPropertyName,
|
||||||
|
AbstractView::PropertyChangeFlags propertyChange);
|
||||||
|
void notifyNodeAboutToBeRemoved(const InternalNodePointer &node);
|
||||||
|
void notifyNodeRemoved(const InternalNodePointer &removedNode,
|
||||||
|
const InternalNodePointer &parentNode,
|
||||||
|
const PropertyName &parentPropertyName,
|
||||||
|
AbstractView::PropertyChangeFlags propertyChange);
|
||||||
|
void notifyNodeIdChanged(const InternalNodePointer &node, const QString &newId, const QString &oldId);
|
||||||
|
void notifyNodeTypeChanged(const InternalNodePointer &node, const TypeName &type, int majorVersion, int minorVersion);
|
||||||
|
|
||||||
void notifyPropertiesRemoved(const QList<PropertyPair> &propertyList);
|
void notifyPropertiesRemoved(const QList<PropertyPair> &propertyList);
|
||||||
void notifyPropertiesAboutToBeRemoved(const QList<InternalPropertyPointer> &internalPropertyList);
|
void notifyPropertiesAboutToBeRemoved(const QList<InternalPropertyPointer> &internalPropertyList);
|
||||||
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &internalPropertyList, AbstractView::PropertyChangeFlags propertyChange);
|
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &internalPropertyList, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void notifySignalHandlerPropertiesChanged(const QVector<InternalSignalHandlerPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
|
void notifySignalHandlerPropertiesChanged(const QVector<InternalSignalHandlerPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const PropertyNameList &propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
|
void notifyVariantPropertiesChanged(const InternalNodePointer &node, const PropertyNameList &propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void notifyScriptFunctionsChanged(const InternalNodePointer &internalNodePointer, const QStringList &scriptFunctionList);
|
void notifyScriptFunctionsChanged(const InternalNodePointer &node, const QStringList &scriptFunctionList);
|
||||||
|
|
||||||
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex);
|
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListProperty, const InternalNodePointer &node, int oldIndex);
|
||||||
void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const PropertyName &name, const QVariant &data);
|
void notifyAuxiliaryDataChanged(const InternalNodePointer &node, const PropertyName &name, const QVariant &data);
|
||||||
void notifyNodeSourceChanged(const InternalNodePointer &internalNode, const QString &newNodeSource);
|
void notifyNodeSourceChanged(const InternalNodePointer &node, const QString &newNodeSource);
|
||||||
|
|
||||||
void notifyRootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
|
void notifyRootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
|
||||||
|
|
||||||
void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
|
void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &modelNodeList, const QList<QVariant> &data);
|
||||||
void notifyInstancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
|
void notifyInstancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
|
||||||
void notifyInstanceErrorChange(const QVector<qint32> &instanceIds);
|
void notifyInstanceErrorChange(const QVector<qint32> &instanceIds);
|
||||||
void notifyInstancesCompleted(const QVector<ModelNode> &nodeList);
|
void notifyInstancesCompleted(const QVector<ModelNode> &modelNodeVector);
|
||||||
void notifyInstancesInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
|
void notifyInstancesInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
|
||||||
void notifyInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
|
void notifyInstancesRenderImageChanged(const QVector<ModelNode> &modelNodeVector);
|
||||||
void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
|
void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &modelNodeVector);
|
||||||
void notifyInstancesChildrenChanged(const QVector<ModelNode> &nodeList);
|
void notifyInstancesChildrenChanged(const QVector<ModelNode> &modelNodeVector);
|
||||||
void notifyInstanceToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
|
void notifyInstanceToken(const QString &token, int number, const QVector<ModelNode> &modelNodeVector);
|
||||||
|
|
||||||
void notifyCurrentStateChanged(const ModelNode &node);
|
void notifyCurrentStateChanged(const ModelNode &node);
|
||||||
void notifyCurrentTimelineChanged(const ModelNode &node);
|
void notifyCurrentTimelineChanged(const ModelNode &node);
|
||||||
@@ -178,13 +185,13 @@ public:
|
|||||||
void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
|
void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
|
||||||
void clearSelectedNodes();
|
void clearSelectedNodes();
|
||||||
QList<InternalNodePointer> selectedNodes() const;
|
QList<InternalNodePointer> selectedNodes() const;
|
||||||
void selectNode(const InternalNodePointer &internalNodePointer);
|
void selectNode(const InternalNodePointer &node);
|
||||||
void deselectNode(const InternalNodePointer &internalNodePointer);
|
void deselectNode(const InternalNodePointer &node);
|
||||||
void changeSelectedNodes(const QList<InternalNodePointer> &newSelectedsNodeList,
|
void changeSelectedNodes(const QList<InternalNodePointer> &newSelectedNodeList,
|
||||||
const QList<InternalNodePointer> &oldSelectedsNodeList);
|
const QList<InternalNodePointer> &oldSelectedNodeList);
|
||||||
|
|
||||||
void setAuxiliaryData(const InternalNodePointer& node, const PropertyName &name, const QVariant &data);
|
void setAuxiliaryData(const InternalNodePointer &node, const PropertyName &name, const QVariant &data);
|
||||||
void removeAuxiliaryData(const InternalNodePointer& node, const PropertyName &name);
|
void removeAuxiliaryData(const InternalNodePointer &node, const PropertyName &name);
|
||||||
[[noreturn]] void resetModelByRewriter(const QString &description);
|
[[noreturn]] void resetModelByRewriter(const QString &description);
|
||||||
|
|
||||||
// Imports:
|
// Imports:
|
||||||
@@ -196,28 +203,24 @@ public:
|
|||||||
void notifyPossibleImportsChanged(const QList<Import> &possibleImports);
|
void notifyPossibleImportsChanged(const QList<Import> &possibleImports);
|
||||||
void notifyUsedImportsChanged(const QList<Import> &usedImportsChanged);
|
void notifyUsedImportsChanged(const QList<Import> &usedImportsChanged);
|
||||||
|
|
||||||
|
|
||||||
//node state property manipulation
|
//node state property manipulation
|
||||||
|
|
||||||
void addProperty(const InternalNodePointer &node, const PropertyName &name);
|
void addProperty(const InternalNodePointer &node, const PropertyName &name);
|
||||||
void setPropertyValue(const InternalNodePointer &node,const PropertyName &name, const QVariant &value);
|
void setPropertyValue(const InternalNodePointer &node,const PropertyName &name, const QVariant &value);
|
||||||
void removeProperty(const InternalPropertyPointer &property);
|
void removeProperty(const InternalPropertyPointer &property);
|
||||||
|
|
||||||
void setBindingProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QString &expression);
|
void setBindingProperty(const InternalNodePointer &node, const PropertyName &name, const QString &expression);
|
||||||
void setSignalHandlerProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QString &source);
|
void setSignalHandlerProperty(const InternalNodePointer &node, const PropertyName &name, const QString &source);
|
||||||
void setVariantProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QVariant &value);
|
void setVariantProperty(const InternalNodePointer &node, const PropertyName &name, const QVariant &value);
|
||||||
void setDynamicVariantProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const TypeName &propertyType, const QVariant &value);
|
void setDynamicVariantProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &propertyType, const QVariant &value);
|
||||||
void setDynamicBindingProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression);
|
void setDynamicBindingProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression);
|
||||||
void reparentNode(const InternalNodePointer &internalNodePointer,
|
void reparentNode(const InternalNodePointer &parentNode, const PropertyName &name, const InternalNodePointer &childNode,
|
||||||
const PropertyName &name,
|
|
||||||
const InternalNodePointer &internalNodeToBeAppended,
|
|
||||||
bool list = true, const TypeName &dynamicTypeName = TypeName());
|
bool list = true, const TypeName &dynamicTypeName = TypeName());
|
||||||
void changeNodeOrder(const InternalNodePointer &internalParentNode, const PropertyName &listPropertyName, int from, int to);
|
void changeNodeOrder(const InternalNodePointer &parentNode, const PropertyName &listPropertyName, int from, int to);
|
||||||
void checkPropertyName(const PropertyName &propertyName);
|
void checkPropertyName(const PropertyName &propertyName);
|
||||||
void clearParent(const InternalNodePointer &internalNodePointer);
|
void clearParent(const InternalNodePointer &node);
|
||||||
void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion);
|
void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion);
|
||||||
void setScriptFunctions(const InternalNodePointer &internalNode, const QStringList &scriptFunctionList);
|
void setScriptFunctions(const InternalNodePointer &node, const QStringList &scriptFunctionList);
|
||||||
void setNodeSource(const InternalNodePointer &internalNode, const QString &nodeSource);
|
void setNodeSource(const InternalNodePointer &node, const QString &nodeSource);
|
||||||
|
|
||||||
InternalNodePointer nodeForId(const QString &id) const;
|
InternalNodePointer nodeForId(const QString &id) const;
|
||||||
bool hasId(const QString &id) const;
|
bool hasId(const QString &id) const;
|
||||||
@@ -234,7 +237,6 @@ public:
|
|||||||
void setRewriterView(RewriterView *rewriterView);
|
void setRewriterView(RewriterView *rewriterView);
|
||||||
RewriterView *rewriterView() const;
|
RewriterView *rewriterView() const;
|
||||||
|
|
||||||
|
|
||||||
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
|
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
|
||||||
NodeInstanceView *nodeInstanceView() const;
|
NodeInstanceView *nodeInstanceView() const;
|
||||||
|
|
||||||
@@ -243,19 +245,17 @@ public:
|
|||||||
|
|
||||||
void updateEnabledViews();
|
void updateEnabledViews();
|
||||||
|
|
||||||
private: //functions
|
private:
|
||||||
void removePropertyWithoutNotification(const InternalPropertyPointer &property);
|
void removePropertyWithoutNotification(const InternalPropertyPointer &property);
|
||||||
void removeAllSubNodes(const InternalNodePointer &internalNodePointer);
|
void removeAllSubNodes(const InternalNodePointer &node);
|
||||||
void removeNodeFromModel(const InternalNodePointer &internalNodePointer);
|
void removeNodeFromModel(const InternalNodePointer &node);
|
||||||
QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &internalNodeList) const;
|
QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &modelNodeList) const;
|
||||||
QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &internalNodeList, AbstractView *view) const;
|
QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &nodeList, AbstractView *view) const;
|
||||||
QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &internalNodeVector, AbstractView *view) const;
|
QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &nodeVector, AbstractView *view) const;
|
||||||
QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &internalNodeVector) const;
|
QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &modelNodeVector) const;
|
||||||
|
|
||||||
const QList<QPointer<AbstractView>> enabledViews() const;
|
const QList<QPointer<AbstractView>> enabledViews() const;
|
||||||
|
|
||||||
private:
|
Model *m_model = nullptr;
|
||||||
Model *m_model;
|
|
||||||
MetaInfo m_metaInfo;
|
MetaInfo m_metaInfo;
|
||||||
QList<Import> m_imports;
|
QList<Import> m_imports;
|
||||||
QList<Import> m_possibleImportList;
|
QList<Import> m_possibleImportList;
|
||||||
@@ -275,9 +275,9 @@ private:
|
|||||||
QPointer<TextModifier> m_textModifier;
|
QPointer<TextModifier> m_textModifier;
|
||||||
QPointer<Model> m_metaInfoProxyModel;
|
QPointer<Model> m_metaInfoProxyModel;
|
||||||
QHash<TypeName, QSharedPointer<NodeMetaInfoPrivate>> m_nodeMetaInfoCache;
|
QHash<TypeName, QSharedPointer<NodeMetaInfoPrivate>> m_nodeMetaInfoCache;
|
||||||
bool m_writeLock;
|
bool m_writeLock = false;
|
||||||
qint32 m_internalIdCounter;
|
qint32 m_internalIdCounter = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Internal
|
||||||
}
|
} // namespace QmlDesigner
|
||||||
|
|||||||
Reference in New Issue
Block a user