forked from qt-creator/qt-creator
QmlDesigner: Add notifier for state change
This commit is contained in:
@@ -173,7 +173,7 @@ void ComponentView::instancesChildrenChanged(const QVector<ModelNode> &/*nodeLis
|
||||
|
||||
void ComponentView::rewriterBeginTransaction() {}
|
||||
void ComponentView::rewriterEndTransaction() {}
|
||||
|
||||
void ComponentView::actualStateChanged(const ModelNode &/*node*/) {}
|
||||
void ComponentView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/,
|
||||
const QList<ModelNode> &/*lastSelectedNodeList*/) {}
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> &lastSelectedNodeList);
|
||||
|
||||
|
||||
@@ -101,9 +101,11 @@ void DesignDocumentControllerView::rewriterBeginTransaction()
|
||||
|
||||
void DesignDocumentControllerView::rewriterEndTransaction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DesignDocumentControllerView::actualStateChanged(const ModelNode &/*node*/)
|
||||
{
|
||||
}
|
||||
|
||||
static QStringList arrayToStringList(const QByteArray &byteArray)
|
||||
{
|
||||
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
ModelNode insertModel(const ModelNode &modelNode)
|
||||
{ return m_modelMerger.insertModel(modelNode); }
|
||||
void replaceModel(const ModelNode &modelNode)
|
||||
|
||||
@@ -153,6 +153,10 @@ void ItemLibraryView::rewriterEndTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
void ItemLibraryView::actualStateChanged(const ModelNode &/*node*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ItemLibraryView::updateImports()
|
||||
{
|
||||
m_widget->updateModel();
|
||||
|
||||
@@ -90,6 +90,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
protected:
|
||||
void updateImports();
|
||||
|
||||
|
||||
@@ -245,6 +245,10 @@ void NavigatorView::rewriterEndTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
void NavigatorView::actualStateChanged(const ModelNode &/*node*/)
|
||||
{
|
||||
}
|
||||
|
||||
void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex)
|
||||
{
|
||||
if (m_treeModel->isInTree(node))
|
||||
|
||||
@@ -98,6 +98,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
private slots:
|
||||
// void handleChangedItem(QStandardItem * item);
|
||||
void changeSelection(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
|
||||
@@ -118,6 +118,7 @@ public:
|
||||
void emitInstancesChildrenChanged(const QVector<ModelNode> &nodeList);
|
||||
void emitRewriterBeginTransaction();
|
||||
void emitRewriterEndTransaction();
|
||||
void emitActualStateChanged(const ModelNode &node);
|
||||
|
||||
virtual void modelAttached(Model *model);
|
||||
virtual void modelAboutToBeDetached(Model *model);
|
||||
@@ -144,6 +145,8 @@ public:
|
||||
virtual void rewriterBeginTransaction() = 0;
|
||||
virtual void rewriterEndTransaction() = 0;
|
||||
|
||||
virtual void actualStateChanged(const ModelNode &node) = 0; // base state is a invalid model node
|
||||
|
||||
virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> &lastSelectedNodeList) = 0;
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
QList<NodeInstance> instances() const;
|
||||
NodeInstance instanceForNode(const ModelNode &node) const ;
|
||||
bool hasInstanceForNode(const ModelNode &node) const;
|
||||
|
||||
@@ -87,8 +87,6 @@ public:
|
||||
|
||||
QmlObjectNode fxObjectNodeForId(const QString &id);
|
||||
|
||||
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
|
||||
|
||||
void modelAttached(Model *model);
|
||||
void modelAboutToBeDetached(Model *model);
|
||||
|
||||
@@ -104,6 +102,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
void nodeCreated(const ModelNode &createdNode);
|
||||
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
|
||||
void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
||||
@@ -129,7 +129,6 @@ protected:
|
||||
virtual void stateChanged(const QmlModelState &newQmlModelState, const QmlModelState &oldQmlModelState);
|
||||
|
||||
void activateState(const QmlModelState &state);
|
||||
void changeToState(const ModelNode &node, const QString &stateName);
|
||||
|
||||
private:
|
||||
QmlModelState m_state;
|
||||
|
||||
@@ -148,6 +148,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
void importAdded(const Import &import);
|
||||
void importRemoved(const Import &import);
|
||||
|
||||
|
||||
@@ -474,6 +474,11 @@ void NodeInstanceView::rewriterEndTransaction()
|
||||
|
||||
}
|
||||
|
||||
void NodeInstanceView::actualStateChanged(const ModelNode &/*node*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//\}
|
||||
|
||||
|
||||
|
||||
@@ -439,6 +439,12 @@ void AbstractView::emitRewriterEndTransaction()
|
||||
model()->m_d->notifyRewriterEndTransaction();
|
||||
}
|
||||
|
||||
void AbstractView::emitActualStateChanged(const ModelNode &node)
|
||||
{
|
||||
if (model())
|
||||
model()->m_d->notifyActualStateChanged(node);
|
||||
}
|
||||
|
||||
void AbstractView::changeRootNodeType(const QString &type, int majorVersion, int minorVersion)
|
||||
{
|
||||
Internal::WriteLocker locker(m_model.data());
|
||||
|
||||
@@ -567,6 +567,33 @@ void ModelPrivate::notifyInstancesChildrenChanged(const QVector<ModelNode> &node
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyActualStateChanged(const ModelNode &node)
|
||||
{
|
||||
bool resetModel = false;
|
||||
QString description;
|
||||
|
||||
try {
|
||||
if (rewriterView())
|
||||
rewriterView()->actualStateChanged(ModelNode(node.internalNode(), model(), rewriterView()));
|
||||
} catch (RewritingException &e) {
|
||||
description = e.description();
|
||||
resetModel = true;
|
||||
}
|
||||
|
||||
foreach (const QWeakPointer<AbstractView> &view, m_viewList) {
|
||||
Q_ASSERT(view != 0);
|
||||
view->actualStateChanged(ModelNode(node.internalNode(), model(), view.data()));
|
||||
}
|
||||
|
||||
if (nodeInstanceView()) {
|
||||
nodeInstanceView()->actualStateChanged(ModelNode(node.internalNode(), model(), nodeInstanceView()));
|
||||
}
|
||||
|
||||
if (resetModel) {
|
||||
resetModelByRewriter(description);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyRewriterBeginTransaction()
|
||||
{
|
||||
bool resetModel = false;
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
void notifyInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
|
||||
void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
|
||||
void notifyInstancesChildrenChanged(const QVector<ModelNode> &nodeList);
|
||||
void notifyActualStateChanged(const ModelNode &node);
|
||||
|
||||
void notifyRewriterBeginTransaction();
|
||||
void notifyRewriterEndTransaction();
|
||||
|
||||
@@ -57,7 +57,7 @@ void QmlModelView::setCurrentState(const QmlModelState &state)
|
||||
if (!state.isValid())
|
||||
return;
|
||||
|
||||
emitCustomNotification("__state changed__", QList<ModelNode>() << state.modelNode());
|
||||
emitActualStateChanged(state.modelNode());
|
||||
}
|
||||
|
||||
QmlModelState QmlModelView::currentState() const
|
||||
@@ -281,24 +281,6 @@ QmlObjectNode QmlModelView::fxObjectNodeForId(const QString &id)
|
||||
return QmlObjectNode(modelNodeForId(id));
|
||||
}
|
||||
|
||||
void QmlModelView::customNotification(const AbstractView * /* view */, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> & /* data */)
|
||||
{
|
||||
if (identifier == "__state changed__") { // TODO: Is this still needed?
|
||||
QmlModelState newState(nodeList.first());
|
||||
QmlModelState oldState = currentState();
|
||||
|
||||
if (!newState.isValid())
|
||||
newState = baseState();
|
||||
|
||||
activateState(newState);
|
||||
|
||||
m_state = newState;
|
||||
|
||||
if (newState != oldState)
|
||||
stateChanged(newState, oldState);
|
||||
}
|
||||
}
|
||||
|
||||
NodeInstance QmlModelView::instanceForModelNode(const ModelNode &modelNode)
|
||||
{
|
||||
return nodeInstanceView()->instanceForNode(modelNode);
|
||||
@@ -401,6 +383,23 @@ void QmlModelView::rewriterEndTransaction()
|
||||
|
||||
}
|
||||
|
||||
void QmlModelView::actualStateChanged(const ModelNode &node)
|
||||
{
|
||||
QmlModelState newState(node);
|
||||
QmlModelState oldState = currentState();
|
||||
|
||||
if (!newState.isValid())
|
||||
newState = baseState();
|
||||
|
||||
activateState(newState);
|
||||
|
||||
m_state = newState;
|
||||
|
||||
if (newState != oldState)
|
||||
stateChanged(newState, oldState);
|
||||
|
||||
}
|
||||
|
||||
void QmlModelView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName)
|
||||
{
|
||||
QmlObjectNode qmlObjectNode(node);
|
||||
@@ -438,25 +437,6 @@ void QmlModelView::activateState(const QmlModelState &state)
|
||||
}
|
||||
}
|
||||
|
||||
void QmlModelView::changeToState(const ModelNode &node, const QString &stateName)
|
||||
{
|
||||
QmlItemNode itemNode(node);
|
||||
|
||||
QmlModelState newState;
|
||||
if (stateName.isEmpty())
|
||||
newState = baseState();
|
||||
else
|
||||
newState = itemNode.states().state(stateName);
|
||||
|
||||
QmlModelState oldState = m_state;
|
||||
|
||||
if (newState.isValid() && oldState != newState) {
|
||||
m_state = newState;
|
||||
stateChanged(newState, oldState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QmlModelView::transformChanged(const QmlObjectNode &/*qmlObjectNode*/, const QString &/*propertyName*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -415,6 +415,10 @@ void RewriterView::rewriterEndTransaction()
|
||||
}
|
||||
}
|
||||
|
||||
void RewriterView::actualStateChanged(const ModelNode &/*node*/)
|
||||
{
|
||||
}
|
||||
|
||||
void RewriterView::selectedNodesChanged(const QList<ModelNode> & /* selectedNodeList, */, const QList<ModelNode> & /*lastSelectedNodeList */)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -267,5 +267,9 @@ void ViewLogger::rewriterEndTransaction()
|
||||
m_output << time() << indent("rewriterEndTransaction:") << endl;
|
||||
}
|
||||
|
||||
void ViewLogger::actualStateChanged(const ModelNode &node)
|
||||
{
|
||||
m_output << time() << indent("actualStateChanged:") << node << endl;
|
||||
}
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -86,6 +86,8 @@ public:
|
||||
void rewriterBeginTransaction();
|
||||
void rewriterEndTransaction();
|
||||
|
||||
void actualStateChanged(const ModelNode &node);
|
||||
|
||||
protected:
|
||||
QString time() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user