forked from qt-creator/qt-creator
QmlDesigner.NodeInstances: Improve SceneGraph support
Change-Id: Ia5111f972836a1123fe857511325a82aef855449 Reviewed-on: http://codereview.qt.nokia.com/3967 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <QDeclarativeError>
|
||||
#include <QDeclarativeEngine>
|
||||
#include <QDeclarativeProperty>
|
||||
#include <QDeclarativeComponent>
|
||||
#include <QSharedPointer>
|
||||
#include <QFileInfo>
|
||||
#include <QFileSystemWatcher>
|
||||
@@ -55,8 +56,6 @@
|
||||
#include <private/qdeclarativebinding_p.h>
|
||||
#include <private/qdeclarativemetatype_p.h>
|
||||
#include <private/qdeclarativevaluetype_p.h>
|
||||
#include <private/qdeclarativetext_p.h>
|
||||
#include <private/qdeclarativetext_p_p.h>
|
||||
#include <private/qdeclarativetransition_p.h>
|
||||
#include <private/qdeclarativeanimation_p.h>
|
||||
#include <private/qdeclarativetimer_p.h>
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
|
||||
@@ -223,7 +224,7 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
|
||||
|
||||
if ((object == 0) && (instanceContainer.metaType() == InstanceContainer::ItemMetaType)) //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead.
|
||||
#if QT_VERSION >= 0x050000
|
||||
object = Internal::ObjectNodeInstance::createPrimitive("QSGItem", 2, 0, nodeInstanceServer->context())
|
||||
object = Internal::ObjectNodeInstance::createPrimitive("QSGItem", 2, 0, nodeInstanceServer->context());
|
||||
#else
|
||||
object = Internal::ObjectNodeInstance::createPrimitive("QDeclarativeItem", 2, 0, nodeInstanceServer->context());
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
#include "designersupportfunctions.h"
|
||||
#include "private/designersupport.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <QSGItem>
|
||||
#include <QSGView>
|
||||
|
||||
#include <designersupportfunctions.h>
|
||||
#include <private/designersupport.h>
|
||||
#include <addimportcontainer.h>
|
||||
#include <createscenecommand.h>
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
#include "designersupportfunctions.h"
|
||||
#include "private/designersupport.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -90,13 +90,13 @@ void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
|
||||
}
|
||||
|
||||
clearChangedPropertyList();
|
||||
resetAllItems();
|
||||
|
||||
if (!m_dirtyInstanceSet.isEmpty() && nodeInstanceClient()->bytesToWrite() < 10000) {
|
||||
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList()));
|
||||
m_dirtyInstanceSet.clear();
|
||||
}
|
||||
|
||||
resetAllItems();
|
||||
// if (adjustSceneRect) {
|
||||
// QRectF boundingRect = rootNodeInstance().boundingRect();
|
||||
// if (boundingRect.isValid()) {
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
|
||||
#include "sgitemnodeinstance.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
#include "qt5nodeinstanceserver.h"
|
||||
|
||||
#include <QDeclarativeExpression>
|
||||
@@ -188,11 +186,20 @@ bool SGItemNodeInstance::equalSGItem(QSGItem *item) const
|
||||
|
||||
QImage SGItemNodeInstance::renderImage() const
|
||||
{
|
||||
return designerSupport()->renderImageForItem(sgItem());
|
||||
QImage image = designerSupport()->renderImageForItem(sgItem());
|
||||
|
||||
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
|
||||
qDebug() << __FUNCTION__ << image.size();
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
bool SGItemNodeInstance::isMovable() const
|
||||
{
|
||||
if (isRootNodeInstance())
|
||||
return false;
|
||||
|
||||
return m_isMovable && sgItem() && sgItem()->parentItem();
|
||||
}
|
||||
|
||||
@@ -214,7 +221,7 @@ SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object)
|
||||
|
||||
static_cast<QDeclarativeParserStatus*>(sgItem)->classBegin();
|
||||
|
||||
instance->populateResetValueHash();
|
||||
instance->populateResetHashes();
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -241,7 +248,7 @@ QSizeF SGItemNodeInstance::size() const
|
||||
{
|
||||
double width;
|
||||
|
||||
if (QSGItemPrivate::get(sgItem())->widthValid) {
|
||||
if (DesignerSupport::isValidWidth(sgItem())) {
|
||||
width = sgItem()->width();
|
||||
} else {
|
||||
width = sgItem()->implicitWidth();
|
||||
@@ -249,7 +256,7 @@ QSizeF SGItemNodeInstance::size() const
|
||||
|
||||
double height;
|
||||
|
||||
if (QSGItemPrivate::get(sgItem())->heightValid) {
|
||||
if (DesignerSupport::isValidHeight(sgItem())) {
|
||||
height = sgItem()->height();
|
||||
} else {
|
||||
height = sgItem()->implicitHeight();
|
||||
@@ -259,14 +266,20 @@ QSizeF SGItemNodeInstance::size() const
|
||||
return QSizeF(width, height);
|
||||
}
|
||||
|
||||
static inline bool isRectangleSane(const QRectF &rect)
|
||||
{
|
||||
return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000);
|
||||
}
|
||||
|
||||
QRectF SGItemNodeInstance::boundingRectWithStepChilds(QSGItem *parentItem) const
|
||||
{
|
||||
QRectF boundingRect = parentItem->boundingRect();
|
||||
|
||||
foreach (QSGItem *childItem, parentItem->childItems()) {
|
||||
if (nodeInstanceServer()->hasInstanceForObject(childItem)) {
|
||||
QRectF transformedRect = childItem->mapRectToItem(parentItem, childItemBoundingRect(childItem));
|
||||
boundingRect = boundingRect.united(transformedRect);
|
||||
QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem));
|
||||
if (isRectangleSane(transformedRect))
|
||||
boundingRect = boundingRect.united(transformedRect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +292,7 @@ QRectF SGItemNodeInstance::boundingRect() const
|
||||
if (sgItem()->clip()) {
|
||||
return sgItem()->boundingRect();
|
||||
} else {
|
||||
return boundingRectWithStepChilds();
|
||||
return boundingRectWithStepChilds(sgItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +395,9 @@ void SGItemNodeInstance::doComponentComplete()
|
||||
|
||||
bool SGItemNodeInstance::isResizable() const
|
||||
{
|
||||
if (isRootNodeInstance())
|
||||
return false;
|
||||
|
||||
return m_isResizable && sgItem() && sgItem()->parentItem();
|
||||
}
|
||||
|
||||
@@ -560,4 +576,3 @@ Qt5NodeInstanceServer *SGItemNodeInstance::qt5NodeInstanceServer() const
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif //QT_VERSION
|
||||
|
||||
@@ -35,12 +35,10 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
#include "objectnodeinstance.h"
|
||||
|
||||
#include <QSGItem>
|
||||
#include <designersupportfunctions.h>
|
||||
#include <private/designersupport.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Internal {
|
||||
@@ -134,6 +132,5 @@ private: //variables
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // QT_VERSION
|
||||
#endif // SGITEMNODEINSTANCE_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user