forked from qt-creator/qt-creator
QmlDesigner: Cleanup of NodeInstanceView
Reviewed-by: Marco Bubke
This commit is contained in:
@@ -401,7 +401,6 @@ QPixmap StatesEditorView::renderState(int i)
|
|||||||
return QPixmap();
|
return QPixmap();
|
||||||
|
|
||||||
Q_ASSERT(i >= 0 && i < m_modelStates.size());
|
Q_ASSERT(i >= 0 && i < m_modelStates.size());
|
||||||
nodeInstanceView()->setBlockChangeSignal(true);
|
|
||||||
QmlModelState oldState = currentState();
|
QmlModelState oldState = currentState();
|
||||||
setCurrentStateSilent(i);
|
setCurrentStateSilent(i);
|
||||||
|
|
||||||
@@ -430,7 +429,6 @@ QPixmap StatesEditorView::renderState(int i)
|
|||||||
nodeInstanceView()->render(&painter, pixmap.rect(), nodeInstanceView()->sceneRect());
|
nodeInstanceView()->render(&painter, pixmap.rect(), nodeInstanceView()->sceneRect());
|
||||||
|
|
||||||
setCurrentState(m_modelStates.indexOf(oldState));
|
setCurrentState(m_modelStates.indexOf(oldState));
|
||||||
nodeInstanceView()->setBlockChangeSignal(false);
|
|
||||||
|
|
||||||
Q_ASSERT(oldState == currentState());
|
Q_ASSERT(oldState == currentState());
|
||||||
|
|
||||||
|
|||||||
@@ -27,25 +27,20 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef ABSTRACTNODEINSTANCEVIEW_H
|
#ifndef NODEINSTANCEVIEW_H
|
||||||
#define ABSTRACTNODEINSTANCEVIEW_H
|
#define NODEINSTANCEVIEW_H
|
||||||
|
|
||||||
#include "corelib_global.h"
|
#include "corelib_global.h"
|
||||||
#include "abstractview.h"
|
#include "abstractview.h"
|
||||||
#include <QtGui/QWidget>
|
|
||||||
#include <QtCore/QHash>
|
|
||||||
#include <QtScript/QScriptEngine>
|
|
||||||
#include <QWeakPointer>
|
|
||||||
#include <QtCore/QHash>
|
|
||||||
|
|
||||||
#include <modelnode.h>
|
#include <modelnode.h>
|
||||||
#include <nodeinstance.h>
|
#include <nodeinstance.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
#include <QHash>
|
||||||
|
#include <QWeakPointer>
|
||||||
|
|
||||||
class QDeclarativeEngine;
|
class QDeclarativeEngine;
|
||||||
class QGraphicsScene;
|
|
||||||
class QGraphicsView;
|
class QGraphicsView;
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -61,6 +56,7 @@ class CORESHARED_EXPORT NodeInstanceView : public AbstractView
|
|||||||
friend class NodeInstance;
|
friend class NodeInstance;
|
||||||
friend class Internal::ObjectNodeInstance;
|
friend class Internal::ObjectNodeInstance;
|
||||||
friend class Internal::QmlStateNodeInstance;
|
friend class Internal::QmlStateNodeInstance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QWeakPointer<NodeInstanceView> Pointer;
|
typedef QWeakPointer<NodeInstanceView> Pointer;
|
||||||
|
|
||||||
@@ -79,21 +75,9 @@ public:
|
|||||||
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
|
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
|
||||||
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
|
||||||
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
|
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
|
||||||
|
|
||||||
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
|
||||||
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
|
||||||
|
|
||||||
void modelStateAboutToBeRemoved(const ModelState &modelState);
|
|
||||||
void modelStateAdded(const ModelState &modelState);
|
|
||||||
|
|
||||||
void nodeStatesAboutToBeRemoved(const QList<ModelNode> &nodeStateList);
|
|
||||||
void nodeStatesAdded(const QList<ModelNode> &nodeStateList);
|
|
||||||
|
|
||||||
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
|
||||||
|
|
||||||
NodeInstance rootNodeInstance() const;
|
|
||||||
NodeInstance viewNodeInstance() const;
|
|
||||||
|
|
||||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
|
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
|
||||||
|
|
||||||
QList<NodeInstance> instances() const;
|
QList<NodeInstance> instances() const;
|
||||||
@@ -103,13 +87,9 @@ public:
|
|||||||
NodeInstance instanceForObject(QObject *object);
|
NodeInstance instanceForObject(QObject *object);
|
||||||
bool hasInstanceForObject(QObject *object);
|
bool hasInstanceForObject(QObject *object);
|
||||||
|
|
||||||
void anchorsChanged(const ModelNode &nodeState);
|
|
||||||
|
|
||||||
void render(QPainter *painter, const QRectF &target=QRectF(), const QRectF &source=QRect(), Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio);
|
void render(QPainter *painter, const QRectF &target=QRectF(), const QRectF &source=QRect(), Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio);
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
|
||||||
QRectF sceneRect() const;
|
QRectF sceneRect() const;
|
||||||
void setBlockChangeSignal(bool block);
|
|
||||||
|
|
||||||
void notifyPropertyChange(const ModelNode &modelNode, const QString &propertyName);
|
void notifyPropertyChange(const ModelNode &modelNode, const QString &propertyName);
|
||||||
|
|
||||||
@@ -123,13 +103,12 @@ public:
|
|||||||
void activateState(const NodeInstance &instance);
|
void activateState(const NodeInstance &instance);
|
||||||
void activateBaseState();
|
void activateBaseState();
|
||||||
|
|
||||||
signals:
|
|
||||||
void instanceRemoved(const NodeInstance &nodeInstance);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitParentChanged(QObject *child);
|
void emitParentChanged(QObject *child);
|
||||||
|
|
||||||
private: // functions
|
private: // functions
|
||||||
|
NodeInstance rootNodeInstance() const;
|
||||||
|
|
||||||
NodeInstance loadNode(const ModelNode &rootNode, QObject *objectToBeWrapped = 0);
|
NodeInstance loadNode(const ModelNode &rootNode, QObject *objectToBeWrapped = 0);
|
||||||
void loadModel(Model *model);
|
void loadModel(Model *model);
|
||||||
void loadNodes(const QList<ModelNode> &nodeList);
|
void loadNodes(const QList<ModelNode> &nodeList);
|
||||||
@@ -164,10 +143,9 @@ private: //variables
|
|||||||
|
|
||||||
QWeakPointer<QmlModelView> m_qmlModelView;
|
QWeakPointer<QmlModelView> m_qmlModelView;
|
||||||
|
|
||||||
bool m_blockChangeSignal;
|
|
||||||
bool m_blockStatePropertyChanges;
|
bool m_blockStatePropertyChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace NodeInstanceView
|
||||||
|
|
||||||
#endif // ABSTRACTNODEINSTANCEVIEW_H
|
#endif // NODEINSTANCEVIEW_H
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ NodeInstanceView::NodeInstanceView(QObject *parent)
|
|||||||
: AbstractView(parent),
|
: AbstractView(parent),
|
||||||
m_graphicsView(new QGraphicsView),
|
m_graphicsView(new QGraphicsView),
|
||||||
m_engine(new QDeclarativeEngine(this)),
|
m_engine(new QDeclarativeEngine(this)),
|
||||||
m_blockChangeSignal(false),
|
|
||||||
m_blockStatePropertyChanges(false)
|
m_blockStatePropertyChanges(false)
|
||||||
{
|
{
|
||||||
m_graphicsView->setAttribute(Qt::WA_DontShowOnScreen, true);
|
m_graphicsView->setAttribute(Qt::WA_DontShowOnScreen, true);
|
||||||
@@ -550,7 +549,6 @@ void NodeInstanceView::removeInstanceNodeRelationship(const ModelNode &node)
|
|||||||
NodeInstance instance = instanceForNode(node);
|
NodeInstance instance = instanceForNode(node);
|
||||||
m_objectInstanceHash.remove(instanceForNode(node).internalObject());
|
m_objectInstanceHash.remove(instanceForNode(node).internalObject());
|
||||||
m_nodeInstanceHash.remove(node);
|
m_nodeInstanceHash.remove(node);
|
||||||
emit instanceRemoved(instance);
|
|
||||||
instance.makeInvalid();
|
instance.makeInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,13 +653,6 @@ void NodeInstanceView::render(QPainter * painter, const QRectF &target, const QR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF NodeInstanceView::boundingRect() const
|
|
||||||
{
|
|
||||||
if (m_graphicsView)
|
|
||||||
return m_graphicsView->scene()->itemsBoundingRect();
|
|
||||||
|
|
||||||
return QRectF();
|
|
||||||
}
|
|
||||||
QRectF NodeInstanceView::sceneRect() const
|
QRectF NodeInstanceView::sceneRect() const
|
||||||
{
|
{
|
||||||
if (m_graphicsView)
|
if (m_graphicsView)
|
||||||
@@ -670,9 +661,4 @@ QRectF NodeInstanceView::sceneRect() const
|
|||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInstanceView::setBlockChangeSignal(bool block)
|
|
||||||
{
|
|
||||||
m_blockChangeSignal = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user