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:
Mahmoud Badri
2020-10-21 21:55:12 +03:00
parent 4498c12ddc
commit 9e8d88c90b
2 changed files with 329 additions and 387 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -71,16 +71,16 @@ class ModelPrivate;
class WriteLocker
{
public:
~WriteLocker();
WriteLocker(ModelPrivate *model);
WriteLocker(Model *model);
private: // variables
WriteLocker(ModelPrivate *model);
~WriteLocker();
private:
QPointer<ModelPrivate> m_model;
};
class ModelPrivate : public QObject {
Q_OBJECT
Q_DISABLE_COPY(ModelPrivate)
friend class QmlDesigner::Model;
@@ -107,10 +107,9 @@ public:
/*factory methods for internal use in model and rewriter*/
void removeNode(const InternalNodePointer &node);
void changeNodeId(const InternalNodePointer& internalNodePointer, const QString& id);
void changeNodeType(const InternalNodePointer& internalNodePointer, const TypeName &typeName, int majorVersion, int minorVersion);
void changeNodeId(const InternalNodePointer &node, const QString &id);
void changeNodeType(const InternalNodePointer &node, const TypeName &typeName, int majorVersion, int minorVersion);
InternalNodePointer rootNode() const;
InternalNodePointer findNode(const QString &id) const;
@@ -122,9 +121,6 @@ public:
void detachView(AbstractView *view, bool notifyView);
void detachAllViews();
Model *model() const { return m_model; }
void setModel(Model *model) { m_model = model; }
template<typename Callable>
void notifyNodeInstanceViewLast(Callable call);
template<typename Callable>
@@ -132,36 +128,47 @@ public:
template<typename Callable>
void notifyInstanceChanges(Callable call);
void notifyNodeCreated(const InternalNodePointer &newInternalNodePointer);
void notifyNodeAboutToBeReparent(const InternalNodePointer &internalNodePointer, const InternalNodeAbstractPropertyPointer &newPropertyParent, const InternalNodePointer &oldParent, const PropertyName &oldPropertyName, AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeReparent(const InternalNodePointer &internalNodePointer, const InternalNodeAbstractPropertyPointer &newPropertyParent, const InternalNodePointer &oldParent, const PropertyName &oldPropertyName, AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeAboutToBeRemoved(const InternalNodePointer &internalNodePointer);
void notifyNodeRemoved(const InternalNodePointer &internalNodePointer, const InternalNodePointer &parentNodePointer, const PropertyName &parentPropertyName, AbstractView::PropertyChangeFlags propertyChange);
void notifyNodeIdChanged(const InternalNodePointer& internalNodePointer, const QString& newId, const QString& oldId);
void notifyNodeTypeChanged(const InternalNodePointer& internalNodePointer, const TypeName &type, int majorVersion, int minorVersion);
void notifyNodeCreated(const InternalNodePointer &newNode);
void notifyNodeAboutToBeReparent(const InternalNodePointer &node,
const InternalNodeAbstractPropertyPointer &newPropertyParent,
const InternalNodePointer &oldParent,
const PropertyName &oldPropertyName,
AbstractView::PropertyChangeFlags propertyChange);
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 notifyPropertiesAboutToBeRemoved(const QList<InternalPropertyPointer> &internalPropertyList);
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &internalPropertyList, AbstractView::PropertyChangeFlags propertyChange);
void notifySignalHandlerPropertiesChanged(const QVector<InternalSignalHandlerPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const PropertyNameList &propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
void notifyScriptFunctionsChanged(const InternalNodePointer &internalNodePointer, const QStringList &scriptFunctionList);
void notifyVariantPropertiesChanged(const InternalNodePointer &node, const PropertyNameList &propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
void notifyScriptFunctionsChanged(const InternalNodePointer &node, const QStringList &scriptFunctionList);
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex);
void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const PropertyName &name, const QVariant &data);
void notifyNodeSourceChanged(const InternalNodePointer &internalNode, const QString &newNodeSource);
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListProperty, const InternalNodePointer &node, int oldIndex);
void notifyAuxiliaryDataChanged(const InternalNodePointer &node, const PropertyName &name, const QVariant &data);
void notifyNodeSourceChanged(const InternalNodePointer &node, const QString &newNodeSource);
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 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 notifyInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
void notifyInstancesChildrenChanged(const QVector<ModelNode> &nodeList);
void notifyInstanceToken(const QString &token, int number, const QVector<ModelNode> &nodeVector);
void notifyInstancesRenderImageChanged(const QVector<ModelNode> &modelNodeVector);
void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &modelNodeVector);
void notifyInstancesChildrenChanged(const QVector<ModelNode> &modelNodeVector);
void notifyInstanceToken(const QString &token, int number, const QVector<ModelNode> &modelNodeVector);
void notifyCurrentStateChanged(const ModelNode &node);
void notifyCurrentTimelineChanged(const ModelNode &node);
@@ -178,13 +185,13 @@ public:
void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
void clearSelectedNodes();
QList<InternalNodePointer> selectedNodes() const;
void selectNode(const InternalNodePointer &internalNodePointer);
void deselectNode(const InternalNodePointer &internalNodePointer);
void changeSelectedNodes(const QList<InternalNodePointer> &newSelectedsNodeList,
const QList<InternalNodePointer> &oldSelectedsNodeList);
void selectNode(const InternalNodePointer &node);
void deselectNode(const InternalNodePointer &node);
void changeSelectedNodes(const QList<InternalNodePointer> &newSelectedNodeList,
const QList<InternalNodePointer> &oldSelectedNodeList);
void setAuxiliaryData(const InternalNodePointer& node, const PropertyName &name, const QVariant &data);
void removeAuxiliaryData(const InternalNodePointer& node, const PropertyName &name);
void setAuxiliaryData(const InternalNodePointer &node, const PropertyName &name, const QVariant &data);
void removeAuxiliaryData(const InternalNodePointer &node, const PropertyName &name);
[[noreturn]] void resetModelByRewriter(const QString &description);
// Imports:
@@ -196,28 +203,24 @@ public:
void notifyPossibleImportsChanged(const QList<Import> &possibleImports);
void notifyUsedImportsChanged(const QList<Import> &usedImportsChanged);
//node state property manipulation
void addProperty(const InternalNodePointer &node, const PropertyName &name);
void setPropertyValue(const InternalNodePointer &node,const PropertyName &name, const QVariant &value);
void removeProperty(const InternalPropertyPointer &property);
void setBindingProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QString &expression);
void setSignalHandlerProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QString &source);
void setVariantProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const QVariant &value);
void setDynamicVariantProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const TypeName &propertyType, const QVariant &value);
void setDynamicBindingProperty(const InternalNodePointer &internalNodePointer, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression);
void reparentNode(const InternalNodePointer &internalNodePointer,
const PropertyName &name,
const InternalNodePointer &internalNodeToBeAppended,
void setBindingProperty(const InternalNodePointer &node, const PropertyName &name, const QString &expression);
void setSignalHandlerProperty(const InternalNodePointer &node, const PropertyName &name, const QString &source);
void setVariantProperty(const InternalNodePointer &node, const PropertyName &name, const QVariant &value);
void setDynamicVariantProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &propertyType, const QVariant &value);
void setDynamicBindingProperty(const InternalNodePointer &node, const PropertyName &name, const TypeName &dynamicPropertyType, const QString &expression);
void reparentNode(const InternalNodePointer &parentNode, const PropertyName &name, const InternalNodePointer &childNode,
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 clearParent(const InternalNodePointer &internalNodePointer);
void clearParent(const InternalNodePointer &node);
void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion);
void setScriptFunctions(const InternalNodePointer &internalNode, const QStringList &scriptFunctionList);
void setNodeSource(const InternalNodePointer &internalNode, const QString &nodeSource);
void setScriptFunctions(const InternalNodePointer &node, const QStringList &scriptFunctionList);
void setNodeSource(const InternalNodePointer &node, const QString &nodeSource);
InternalNodePointer nodeForId(const QString &id) const;
bool hasId(const QString &id) const;
@@ -234,7 +237,6 @@ public:
void setRewriterView(RewriterView *rewriterView);
RewriterView *rewriterView() const;
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
NodeInstanceView *nodeInstanceView() const;
@@ -243,19 +245,17 @@ public:
void updateEnabledViews();
private: //functions
private:
void removePropertyWithoutNotification(const InternalPropertyPointer &property);
void removeAllSubNodes(const InternalNodePointer &internalNodePointer);
void removeNodeFromModel(const InternalNodePointer &internalNodePointer);
QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &internalNodeList) const;
QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &internalNodeList, AbstractView *view) const;
QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &internalNodeVector, AbstractView *view) const;
QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &internalNodeVector) const;
void removeAllSubNodes(const InternalNodePointer &node);
void removeNodeFromModel(const InternalNodePointer &node);
QList<InternalNodePointer> toInternalNodeList(const QList<ModelNode> &modelNodeList) const;
QList<ModelNode> toModelNodeList(const QList<InternalNodePointer> &nodeList, AbstractView *view) const;
QVector<ModelNode> toModelNodeVector(const QVector<InternalNodePointer> &nodeVector, AbstractView *view) const;
QVector<InternalNodePointer> toInternalNodeVector(const QVector<ModelNode> &modelNodeVector) const;
const QList<QPointer<AbstractView>> enabledViews() const;
private:
Model *m_model;
Model *m_model = nullptr;
MetaInfo m_metaInfo;
QList<Import> m_imports;
QList<Import> m_possibleImportList;
@@ -275,9 +275,9 @@ private:
QPointer<TextModifier> m_textModifier;
QPointer<Model> m_metaInfoProxyModel;
QHash<TypeName, QSharedPointer<NodeMetaInfoPrivate>> m_nodeMetaInfoCache;
bool m_writeLock;
qint32 m_internalIdCounter;
bool m_writeLock = false;
qint32 m_internalIdCounter = 1;
};
}
}
} // namespace Internal
} // namespace QmlDesigner