From 7fcda24112d690575007ddcb11e097a9c33e0f19 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 12 May 2011 13:41:11 +0200 Subject: QmlDirParser: Fix typeInfo accessor. Reviewed-by: Kai Koehne --- src/declarative/qml/qdeclarativedirparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp index 362b99c..48ff46a 100644 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ b/src/declarative/qml/qdeclarativedirparser.cpp @@ -240,7 +240,7 @@ QList QDeclarativeDirParser::components() cons } #ifdef QT_CREATOR -QList QDeclarativeDirParser::typeInfos() const +QList QDeclarativeDirParser::typeInfos() const { return _typeInfos; } -- cgit v0.12 From 01a374fe8a6ac0b6e374081c07720e77c61effff Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 16 May 2011 11:08:38 +1000 Subject: Doc Change-Id: I25f1885ef285fb3bd14c1f499b9f42e38bba5ec6 Task-number: QTBUG-19265 --- src/declarative/qml/qdeclarativeproperty.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 0dd0edb..f058af1 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -183,6 +183,9 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name) /*! Creates a QDeclarativeProperty for the property \a name of \a obj using the \l{QDeclarativeContext} {context} \a ctxt. + + Creating a QDeclarativeProperty without a context will render some + properties - like attached properties - inaccessible. */ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt) : d(new QDeclarativePropertyPrivate) -- cgit v0.12 From d03065da2999b8539d8c5160b58d56dd94373d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 17 May 2011 12:12:52 +0200 Subject: Fixed crashes in Observer mode related to infinite bounding rects Bug fixed by avoiding uniting or subtracting QPolygonF with potentially infinite coordinates. The LiveSelectionIndicator now uses a QGraphicsRectItem rather than a QGraphicsPolygonItem and displays only the boundaries of selected objects, not including their children. The SubcomponentMaskLayerItem now works with rectangles and uses a QRegion to determine the area around the current context, converting this to a polygon only as a last step. Reviewed-by: Kai Koehne Task-number: QTCREATORBUG-4559 Change-Id: I266f5387fa67017fc50215282a95b4ee6498be6d --- .../editor/liveselectionindicator.cpp | 73 +++++++--------------- .../editor/liveselectionindicator_p.h | 10 +-- .../editor/subcomponentmasklayeritem.cpp | 22 ++++--- 3 files changed, 38 insertions(+), 67 deletions(-) diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp index 96e9dbf..ecd768e 100644 --- a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp +++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp @@ -44,20 +44,17 @@ #include "../qdeclarativeviewobserver_p_p.h" #include "../qmlobserverconstants_p.h" -#include - -#include +#include #include #include #include -#include - QT_BEGIN_NAMESPACE -LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *editorView, - QGraphicsObject *layerItem) - : m_layerItem(layerItem), m_view(editorView) +LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *viewObserver, + QGraphicsObject *layerItem) + : m_layerItem(layerItem) + , m_view(viewObserver) { } @@ -68,24 +65,23 @@ LiveSelectionIndicator::~LiveSelectionIndicator() void LiveSelectionIndicator::show() { - foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values()) + foreach (QGraphicsRectItem *item, m_indicatorShapeHash) item->show(); } void LiveSelectionIndicator::hide() { - foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values()) + foreach (QGraphicsRectItem *item, m_indicatorShapeHash) item->hide(); } void LiveSelectionIndicator::clear() { if (!m_layerItem.isNull()) { - QHashIterator iter(m_indicatorShapeHash); - while (iter.hasNext()) { - iter.next(); - m_layerItem.data()->scene()->removeItem(iter.value()); - delete iter.value(); + QGraphicsScene *scene = m_layerItem.data()->scene(); + foreach (QGraphicsRectItem *item, m_indicatorShapeHash) { + scene->removeItem(item); + delete item; } } @@ -93,56 +89,29 @@ void LiveSelectionIndicator::clear() } -QPolygonF LiveSelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon) -{ - // ### remove this if statement when QTBUG-12172 gets fixed - if (item->boundingRect() != QRectF(0,0,0,0)) { - QPolygonF bounding = item->mapToScene(item->boundingRect()); - if (bounding.isClosed()) //avoid crashes if there is an infinite scale. - polygon = polygon.united(bounding); - } - - foreach (QGraphicsItem *child, item->childItems()) { - if (!QDeclarativeViewObserverPrivate::get(m_view)->isEditorItem(child)) - addBoundingRectToPolygon(child, polygon); - } - return polygon; -} - void LiveSelectionIndicator::setItems(const QList > &itemList) { clear(); - // set selections to also all children if they are not editor items - foreach (const QWeakPointer &object, itemList) { if (object.isNull()) continue; QGraphicsItem *item = object.data(); - QGraphicsPolygonItem *newSelectionIndicatorGraphicsItem - = new QGraphicsPolygonItem(m_layerItem.data()); if (!m_indicatorShapeHash.contains(item)) { - m_indicatorShapeHash.insert(item, newSelectionIndicatorGraphicsItem); - - QPolygonF boundingShapeInSceneSpace; - addBoundingRectToPolygon(item, boundingShapeInSceneSpace); - - QRectF boundingRect - = m_view->adjustToScreenBoundaries(boundingShapeInSceneSpace.boundingRect()); - QPolygonF boundingRectInLayerItemSpace = m_layerItem.data()->mapFromScene(boundingRect); - - QPen pen; - pen.setColor(QColor(108, 141, 221)); - newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey, - QVariant(true)); - newSelectionIndicatorGraphicsItem->setFlag(QGraphicsItem::ItemIsSelectable, false); - newSelectionIndicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace); - newSelectionIndicatorGraphicsItem->setPen(pen); + QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data()); + m_indicatorShapeHash.insert(item, selectionIndicator); + + const QRectF boundingRect = m_view->adjustToScreenBoundaries(item->mapRectToScene(item->boundingRect())); + const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect); + + selectionIndicator->setData(Constants::EditorItemDataKey, true); + selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false); + selectionIndicator->setRect(boundingRectInLayerItemSpace); + selectionIndicator->setPen(QColor(108, 141, 221)); } } } QT_END_NAMESPACE - diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h index da95955..85deb75 100644 --- a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h +++ b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator_p.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QGraphicsObject; -class QGraphicsPolygonItem; +class QGraphicsRectItem; class QGraphicsItem; class QPolygonF; QT_END_NAMESPACE @@ -63,7 +63,7 @@ class QDeclarativeViewObserver; class LiveSelectionIndicator { public: - LiveSelectionIndicator(QDeclarativeViewObserver* editorView, QGraphicsObject *layerItem); + LiveSelectionIndicator(QDeclarativeViewObserver *viewObserver, QGraphicsObject *layerItem); ~LiveSelectionIndicator(); void show(); @@ -74,13 +74,9 @@ public: void setItems(const QList > &itemList); private: - QPolygonF addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon); - -private: - QHash m_indicatorShapeHash; + QHash m_indicatorShapeHash; QWeakPointer m_layerItem; QDeclarativeViewObserver *m_view; - }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp index 15d2a2c..3543160 100644 --- a/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp +++ b/src/plugins/qmltooling/declarativeobserver/editor/subcomponentmasklayeritem.cpp @@ -86,6 +86,13 @@ static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect) return result; } +static QPolygonF regionToPolygon(const QRegion ®ion) +{ + QPainterPath path; + foreach (const QRect &rect, region.rects()) + path.addRect(rect); + return path.toFillPolygon(); +} void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item) { @@ -95,25 +102,24 @@ void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item) if (!m_currentItem) return; - QPolygonF viewPoly(QRectF(m_observer->declarativeView()->rect())); - viewPoly = m_observer->declarativeView()->mapToScene(viewPoly.toPolygon()); + QRect viewRect = m_observer->declarativeView()->rect(); + viewRect = m_observer->declarativeView()->mapToScene(viewRect).boundingRect().toRect(); QRectF itemRect = item->boundingRect() | item->childrenBoundingRect(); - QPolygonF itemPoly(itemRect); - itemPoly = item->mapToScene(itemPoly); + itemRect = item->mapRectToScene(itemRect); // if updating the same item as before, resize the rectangle only bigger, not smaller. if (prevItem == item && prevItem != 0) { - m_itemPolyRect = resizeRect(itemPoly.boundingRect(), m_itemPolyRect); + m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect); } else { - m_itemPolyRect = itemPoly.boundingRect(); + m_itemPolyRect = itemRect; } QRectF borderRect = m_itemPolyRect; borderRect.adjust(-1, -1, 1, 1); m_borderRect->setRect(borderRect); - itemPoly = viewPoly.subtracted(QPolygonF(m_itemPolyRect)); - setPolygon(itemPoly); + const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect()); + setPolygon(regionToPolygon(externalRegion)); } QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const -- cgit v0.12 From bdd8f188ac352c99ee218318a59089f387a31d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 17 May 2011 11:23:10 +0200 Subject: Pass QList as const reference when possible Avoids some reference counting. Reviewed-by: Kai Koehne Change-Id: I4de83aa4df6833fa2287ac1854bbb0052d15cee9 --- .../qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp | 9 +++++---- .../qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h | 2 +- .../declarativeobserver/qdeclarativeviewobserver_p_p.h | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp index 2286990..d9ff9db 100644 --- a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp +++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp @@ -557,7 +557,7 @@ void QDeclarativeViewObserverPrivate::changeTool(Constants::DesignTool tool, } } -void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QList items) +void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(const QList &items) { foreach (const QWeakPointer &obj, currentSelection) { if (QGraphicsItem *item = obj.data()) { @@ -582,7 +582,7 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(QListupdateSelectedItems(); } -void QDeclarativeViewObserverPrivate::setSelectedItems(QList items) +void QDeclarativeViewObserverPrivate::setSelectedItems(const QList &items) { QList > oldList = currentSelection; setSelectedItemsForTools(items); @@ -633,7 +633,8 @@ void QDeclarativeViewObserverPrivate::highlight(QGraphicsObject * item, ContextF highlight(QList() << item, flags); } -void QDeclarativeViewObserverPrivate::highlight(QList items, ContextFlags flags) +void QDeclarativeViewObserverPrivate::highlight(const QList &items, + ContextFlags flags) { if (items.isEmpty()) return; @@ -1064,7 +1065,7 @@ void QDeclarativeViewObserver::sendDesignModeBehavior(bool inDesignMode) data->debugService->sendMessage(message); } -void QDeclarativeViewObserver::sendCurrentObjects(QList objects) +void QDeclarativeViewObserver::sendCurrentObjects(const QList &objects) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h index 6e986c2..0ad447c 100644 --- a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h +++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p.h @@ -78,7 +78,7 @@ public: bool showAppOnTop() const; void sendDesignModeBehavior(bool inDesignMode); - void sendCurrentObjects(QList items); + void sendCurrentObjects(const QList &); void sendAnimationSpeed(qreal slowDownFactor); void sendAnimationPaused(bool paused); void sendCurrentTool(Constants::DesignTool toolId); diff --git a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h index 6022555..eba71d4 100644 --- a/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h +++ b/src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver_p_p.h @@ -117,15 +117,16 @@ public: QList selectableItems(const QPointF &scenePos) const; QList selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const; - void setSelectedItemsForTools(QList items); - void setSelectedItems(QList items); + void setSelectedItemsForTools(const QList &items); + void setSelectedItems(const QList &items); QList selectedItems() const; void changeTool(Constants::DesignTool tool, Constants::ToolFlags flags = Constants::NoToolFlags); void clearHighlight(); - void highlight(QList item, ContextFlags flags = ContextSensitive); + void highlight(const QList &item, + ContextFlags flags = ContextSensitive); void highlight(QGraphicsObject *item, ContextFlags flags = ContextSensitive); bool mouseInsideContextItem() const; -- cgit v0.12 From acea7c9f5ece102f22d264834b6eece21020adf4 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 20 May 2011 14:25:24 +0200 Subject: QDeclarativeDebug: Fix autotest --- tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index d3c7032..9582f09 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -1012,7 +1012,7 @@ void tst_QDeclarativeDebug::setBindingForObject() // set handler // rootObject = findRootObject(); - QCOMPARE(rootObject.children().size(), 4); // Rectangle, Text, MouseArea, QDeclarativeComponentAttached + QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement QDeclarativeDebugObjectReference mouseAreaObject = rootObject.children().at(2); QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this); waitForQuery(q_obj); -- cgit v0.12