Commit bae48751 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: use one node instance view

Bauhaus now uses only one single instance view.

Done by Marco Bubke
parent 22a162a7
......@@ -51,6 +51,9 @@
#include <QDir>
#include <QAction>
#include <zoomaction.h>
#include <nodeabstractproperty.h>
#include <nodelistproperty.h>
namespace QmlDesigner {
......@@ -264,6 +267,9 @@ void FormEditorView::scriptFunctionsChanged(const ModelNode &node, const QString
QmlModelView::scriptFunctionsChanged(node, scriptFunctionList);
}
void FormEditorView::propertiesRemoved(const QList<AbstractProperty> &/*propertyList*/)
{
}
AbstractFormEditorTool* FormEditorView::currentTool() const
{
......
......@@ -78,6 +78,7 @@ public:
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void propertiesRemoved(const QList<AbstractProperty> &propertyList);
// FormEditorView
FormEditorWidget *widget() const;
......
......@@ -38,6 +38,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QtDebug>
#include <QClipboard>
#include <variantproperty.h>
namespace QmlDesigner {
......
......@@ -42,6 +42,8 @@
#include <limits>
#include <model.h>
#include <qmlanchors.h>
#include <variantproperty.h>
#include <nodeabstractproperty.h>
namespace QmlDesigner {
......
......@@ -160,7 +160,7 @@ void ComponentView::variantPropertiesChanged(const QList<VariantProperty>& /*pro
void ComponentView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {}
void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {}
void ComponentView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/) {}
void ComponentView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList) {};
void ComponentView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/,
......
......@@ -67,7 +67,7 @@ public:
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList);
......
......@@ -50,6 +50,7 @@
#include <rewritingexception.h>
#include <nodelistproperty.h>
#include <toolbox.h>
#include <variantproperty.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
......@@ -87,6 +88,7 @@ public:
QWeakPointer<AllPropertiesBox> allPropertiesBox;
QWeakPointer<StatesEditorWidget> statesEditorWidget;
QWeakPointer<QStackedWidget> stackedWidget;
QWeakPointer<NodeInstanceView> nodeInstanceView;
QWeakPointer<QmlDesigner::Model> model;
QWeakPointer<QmlDesigner::Model> subComponentModel;
......@@ -212,6 +214,11 @@ void DesignDocumentController::setFormEditorView(FormEditorView *formEditorView)
m_d->formEditorView = formEditorView;
}
void DesignDocumentController::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
{
m_d->nodeInstanceView = nodeInstanceView;
}
QString DesignDocumentController::displayName() const
{
if (fileName().isEmpty())
......@@ -344,6 +351,7 @@ void DesignDocumentController::loadCurrentModel()
Q_ASSERT(m_d->model);
m_d->model->setMasterModel(m_d->masterModel.data());
m_d->model->attachView(m_d->nodeInstanceView.data());
m_d->model->attachView(m_d->navigator.data());
m_d->itemLibrary->setItemLibraryInfo(m_d->model->metaInfo().itemLibraryInfo());
m_d->itemLibrary->setResourcePath(QFileInfo(m_d->fileName).absolutePath());
......
......@@ -94,6 +94,7 @@ public:
void setAllPropertiesBox(AllPropertiesBox* allPropertiesBox);
void setStatesEditorWidget(StatesEditorWidget* statesEditorWidget);
void setFormEditorView(FormEditorView *formEditorView);
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
signals:
void displayNameChanged(const QString &newFileName);
......
......@@ -60,6 +60,9 @@ void DesignDocumentControllerView::scriptFunctionsChanged(const ModelNode &/*nod
{
}
void DesignDocumentControllerView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/)
{
}
static QStringList arrayToStringList(const QByteArray &byteArray)
{
......
......@@ -58,6 +58,8 @@ public:
virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
ModelNode insertModel(const ModelNode &modelNode)
{ return m_modelMerger.insertModel(modelNode); }
......
......@@ -190,6 +190,9 @@ void NavigatorView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStr
{
}
void NavigatorView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/)
{
}
void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int oldIndex)
{
......
......@@ -81,7 +81,7 @@ public:
const QList<ModelNode> &lastSelectedNodeList);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
private slots:
// void handleChangedItem(QStandardItem * item);
......
......@@ -40,6 +40,10 @@
#include <variantproperty.h>
#include <propertymetainfo.h>
#include <bindingproperty.h>
#include <nodeabstractproperty.h>
#include "propertyeditorvalue.h"
#include "basiclayouts.h"
#include "basicwidgets.h"
......
......@@ -36,6 +36,9 @@
#include <QDebug>
#include <math.h>
#include <variantproperty.h>
#include <nodelistproperty.h>
enum {
debug = false
};
......@@ -434,6 +437,21 @@ void StatesEditorView::scriptFunctionsChanged(const ModelNode &node, const QStri
QmlModelView::scriptFunctionsChanged(node, scriptFunctionList);
}
void StatesEditorView::nodeIdChanged(const ModelNode &/*node*/, const QString &/*newId*/, const QString &/*oldId*/)
{
}
void StatesEditorView::bindingPropertiesChanged(const QList<BindingProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/)
{
}
void StatesEditorView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/, const QList<ModelNode> &/*lastSelectedNodeList*/)
{
}
QPixmap StatesEditorView::renderState(int i)
{
......
......@@ -76,6 +76,9 @@ public:
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void nodeIdChanged(const ModelNode &node, const QString &newId, const QString &oldId);
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags propertyChange);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
protected:
......
......@@ -54,6 +54,7 @@ namespace QmlDesigner {
namespace QmlDesigner {
class QmlModelView;
class NodeInstanceView;
class CORESHARED_EXPORT AbstractView : public QObject
{
......@@ -101,6 +102,8 @@ public:
void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList);
void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void emitInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
virtual void modelAttached(Model *model);
virtual void modelAboutToBeDetached(Model *model);
......@@ -115,6 +118,8 @@ public:
virtual void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) = 0;
virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) = 0;
virtual void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList) = 0;
virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList) = 0;
......@@ -135,6 +140,8 @@ public:
void changeRootNodeType(const QString &type, int majorVersion, int minorVersion);
NodeInstanceView *nodeInstanceView() const;
protected:
void setModel(Model * model);
void removeModel();
......
......@@ -85,6 +85,7 @@ public:
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
QList<NodeInstance> instances() const;
......@@ -100,9 +101,6 @@ public:
void notifyPropertyChange(const ModelNode &modelNode, const QString &propertyName);
void setQmlModelView(QmlModelView *qmlModelView);
QmlModelView *qmlModelView() const ;
void setBlockStatePropertyChanges(bool block);
NodeInstance activeStateInstance() const;
......
......@@ -31,7 +31,6 @@
#define QMLMODELVIEW_H
#include <corelib_global.h>
#include <forwardview.h>
#include <abstractview.h>
#include "qmlitemnode.h"
#include "qmlstate.h"
......@@ -42,7 +41,7 @@ namespace QmlDesigner {
class ItemLibraryEntry;
class CORESHARED_EXPORT QmlModelView : public ForwardView<NodeInstanceView>
class CORESHARED_EXPORT QmlModelView : public AbstractView
{
Q_OBJECT
friend CORESHARED_EXPORT class QmlObjectNode;
......@@ -90,10 +89,26 @@ public:
virtual void nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
void nodeCreated(const ModelNode &createdNode);
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
void propertiesAboutToBeRemoved(const QList<AbstractProperty> &propertyList);
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void nodeAboutToBeRemoved(const ModelNode &removedNode);
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
void propertiesRemoved(const QList<AbstractProperty>& propertyList);
void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
protected:
NodeInstance instanceForModelNode(const ModelNode &modelNode);
bool hasInstanceForModelNode(const ModelNode &modelNode);
NodeInstanceView *nodeInstanceView() const;
virtual void transformChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName) ;
virtual void parentChanged(const QmlObjectNode &qmlObjectNode);
virtual void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName);
......
......@@ -126,6 +126,8 @@ public:
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
void importAdded(const Import &import);
void importRemoved(const Import &import);
......
......@@ -379,6 +379,12 @@ void NodeInstanceView::scriptFunctionsChanged(const ModelNode &/*node*/, const Q
}
void NodeInstanceView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/)
{
}
//\}
void NodeInstanceView::loadNodes(const QList<ModelNode> &nodeList)
......@@ -557,21 +563,9 @@ void NodeInstanceView::notifyPropertyChange(const ModelNode &node, const QString
if (m_blockStatePropertyChanges)
return;
if (qmlModelView()) {
qmlModelView()->nodeInstancePropertyChanged(ModelNode(node,qmlModelView()), propertyName);
}
}
void NodeInstanceView::setQmlModelView(QmlModelView *qmlModelView)
{
m_qmlModelView = qmlModelView;
emitInstancePropertyChange(QList<QPair<ModelNode, QString> >() << qMakePair(node, propertyName));
}
QmlModelView *NodeInstanceView::qmlModelView() const
{
return m_qmlModelView.data();
}
void NodeInstanceView::setBlockStatePropertyChanges(bool block)
{
......
......@@ -339,6 +339,15 @@ QmlModelView *AbstractView::toQmlModelView()
return qobject_cast<QmlModelView*>(this);
}
NodeInstanceView *AbstractView::nodeInstanceView() const
{
if (model()) {
return model()->m_d->nodeInstanceView();
} else {
return 0;
}
}
QList<ModelNode> AbstractView::allModelNodes()
{
return toModelNodeList(model()->m_d->allNodes());
......@@ -359,6 +368,12 @@ void AbstractView::emitCustomNotification(const QString &identifier, const QList
model()->m_d->notifyCustomNotification(this, identifier, nodeList, data);
}
void AbstractView::emitInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList)
{
if (model())
model()->m_d->notifyInstancePropertyChange(propertyList);
}
void AbstractView::changeRootNodeType(const QString &type, int majorVersion, int minorVersion)
{
Internal::WriteLocker locker(m_model.data());
......
......@@ -48,7 +48,8 @@ QT_END_NAMESPACE
namespace QmlDesigner {
class AbstractProperty;
class RewriterView;
class NodeInstanceView;
namespace Internal {
......@@ -140,6 +141,7 @@ public:
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 notifyInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
......@@ -160,8 +162,8 @@ public:
QList<Import> imports() const { return m_imports; }
void addImport(const Import &import);
void removeImport(const Import &import);
void notifyImportAdded(const Import &import) const;
void notifyImportRemoved(const Import &import) const;
void notifyImportAdded(const Import &import);
void notifyImportRemoved(const Import &import);
//node state property manipulation
......@@ -190,6 +192,11 @@ public:
WriteLocker createWriteLocker() const;
void setRewriterView(RewriterView *rewriterView);
RewriterView *rewriterView() const;
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
NodeInstanceView *nodeInstanceView() const;
private: //functions
void removePropertyWithoutNotification(const InternalPropertyPointer &property);
void removeAllSubNodes(const InternalNodePointer &node);
......@@ -212,8 +219,9 @@ private:
QUrl m_fileUrl;
QWeakPointer<Model> m_masterModel;
bool m_writeLock;
QWeakPointer<RewriterView> m_rewriterView;
QWeakPointer<NodeInstanceView> m_nodeInstanceView;
bool m_writeLock;
};
}
......
......@@ -38,6 +38,8 @@
#include <QFileInfo>
#include <QDebug>
#include <QMessageBox>
#include "nodeabstractproperty.h"
#include "variantproperty.h"
enum {
debug = false
......@@ -47,11 +49,8 @@ enum {
namespace QmlDesigner {
QmlModelView::QmlModelView(QObject *parent)
: ForwardView<NodeInstanceView>(parent)
: AbstractView(parent)
{
NodeInstanceView *nodeInstanceView = new NodeInstanceView(this);
nodeInstanceView->setQmlModelView(this);
appendView(nodeInstanceView);
}
void QmlModelView::setCurrentState(const QmlModelState &state)
......@@ -302,23 +301,18 @@ bool QmlModelView::hasInstanceForModelNode(const ModelNode &modelNode)
return nodeInstanceView()->hasInstanceForNode(modelNode);
}
NodeInstanceView *QmlModelView::nodeInstanceView() const
{
return firstView();
}
void QmlModelView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
m_state = QmlModelState();
ForwardView<NodeInstanceView>::modelAttached(model);
m_state = baseState();
Q_ASSERT(m_state.isBaseState());
}
void QmlModelView::modelAboutToBeDetached(Model *model)
{
ForwardView<NodeInstanceView>::modelAboutToBeDetached(model);
m_state = QmlModelState();
AbstractView::modelAboutToBeDetached(model);
}
static bool isTransformProperty(const QString &name)
......@@ -335,6 +329,32 @@ static bool isTransformProperty(const QString &name)
return transformProperties.contains(name);
}
void QmlModelView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode &/*movedNode*/, int /*oldIndex*/)
{
}
void QmlModelView::nodeCreated(const ModelNode &/*createdNode*/) {}
void QmlModelView::nodeAboutToBeRemoved(const ModelNode &/*removedNode*/) {}
void QmlModelView::nodeRemoved(const ModelNode &/*removedNode*/, const NodeAbstractProperty &/*parentProperty*/, PropertyChangeFlags /*propertyChange*/) {}
void QmlModelView::nodeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/) {}
void QmlModelView::nodeIdChanged(const ModelNode& /*node*/, const QString& /*newId*/, const QString& /*oldId*/) {}
void QmlModelView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& /*propertyList*/) {}
void QmlModelView::propertiesRemoved(const QList<AbstractProperty>& /*propertyList*/) {}
void QmlModelView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {}
void QmlModelView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {}
void QmlModelView::rootNodeTypeChanged(const QString &/*type*/, int, int /*minorVersion*/) {}
void QmlModelView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/) {}
void QmlModelView::selectedNodesChanged(const QList<ModelNode> &/*selectedNodeList*/, const QList<ModelNode> &/*lastSelectedNodeList*/) {}
void QmlModelView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList)
{
typedef QPair<ModelNode, QString> ModelNodePropertyPair;
foreach (const ModelNodePropertyPair &propertyPair, propertyList) {
nodeInstancePropertyChanged(propertyPair.first, propertyPair.second);
}
}
void QmlModelView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName)
{
if (debug)
......
......@@ -38,6 +38,8 @@
#include "nodeinstanceview.h"
#include "nodeinstance.h"
#include "nodemetainfo.h"
#include "bindingproperty.h"
#include "nodelistproperty.h"
namespace QmlDesigner {
......
......@@ -33,6 +33,7 @@
#include <variantproperty.h>
#include <metainfo.h>
#include <invalidmodelnodeexception.h>
#include "bindingproperty.h"
namespace QmlDesigner {
......
......@@ -356,6 +356,11 @@ void RewriterView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStri
{
}
void RewriterView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/)
{
}
void RewriterView::selectedNodesChanged(const QList<ModelNode> & /* selectedNodeList, */, const QList<ModelNode> & /*lastSelectedNodeList */)
{
}
......
......@@ -195,7 +195,15 @@ void ViewLogger::customNotification(const AbstractView *view, const QString &ide
void ViewLogger::scriptFunctionsChanged(const ModelNode &node, const QStringList &/*scriptFunctionList*/)
{
m_output << time() << indent("function scripts changed:") << node << endl;
}
void ViewLogger::instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList)
{
typedef QPair<ModelNode, QString> PropertyPair;
m_output << time() << indent("instancePropertyChange:") << endl;
foreach(const PropertyPair &propertyPair, propertyList)
m_output << time() << indent("property: ") << propertyPair.first << propertyPair.second << endl;
}
......
......@@ -71,6 +71,7 @@ public:
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
protected:
QString time() const;
......
......@@ -259,12 +259,14 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
} else {
DesignDocumentController *newDocument = new DesignDocumentController(this);
newDocument->setNodeInstanceView(m_nodeInstanceView.data());
newDocument->setAllPropertiesBox(m_allPropertiesBox.data());
newDocument->setNavigator(m_navigator.data());
newDocument->setStatesEditorWidget(m_statesEditorWidget.data());
newDocument->setItemLibrary(m_itemLibrary.data());
newDocument->setFormEditorView(m_formEditorView.data());
newDocument->setFileName(fileName);
document = newDocument;
......@@ -620,6 +622,7 @@ void DesignModeWidget::setup()
}
}
m_nodeInstanceView = new NodeInstanceView(this);
// Sidebar takes ownership
m_navigator = new NavigatorView;
m_allPropertiesBox = new AllPropertiesBox;
......
......@@ -177,6 +177,7 @@ private:
QWeakPointer<AllPropertiesBox> m_allPropertiesBox;
QWeakPointer<StatesEditorWidget> m_statesEditorWidget;
QWeakPointer<FormEditorView> m_formEditorView;
QWeakPointer<NodeInstanceView> m_nodeInstanceView;
bool m_syncWithTextEdit;
......
Markdown is supported
0%