From 7868a665eb6c14b41b514635d76fb2864ea14309 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 12 Aug 2009 15:38:52 +1000 Subject: Minor code cleanups. --- src/declarative/fx/qfxlayoutitem.cpp | 2 +- src/declarative/widgets/graphicslayouts.cpp | 30 ++++++++++++++--------------- src/declarative/widgets/graphicslayouts.h | 4 ++-- src/declarative/widgets/graphicswidgets.cpp | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/declarative/fx/qfxlayoutitem.cpp b/src/declarative/fx/qfxlayoutitem.cpp index 1f814e8..61998e7 100644 --- a/src/declarative/fx/qfxlayoutitem.cpp +++ b/src/declarative/fx/qfxlayoutitem.cpp @@ -78,7 +78,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,LayoutItem,QFxLayoutItem) */ QFxLayoutItem::QFxLayoutItem(QFxItem* parent) - : QFxItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(100,100) + : QFxItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(0,0) { setGraphicsItem(this); } diff --git a/src/declarative/widgets/graphicslayouts.cpp b/src/declarative/widgets/graphicslayouts.cpp index 34d18e4..8707b94 100644 --- a/src/declarative/widgets/graphicslayouts.cpp +++ b/src/declarative/widgets/graphicslayouts.cpp @@ -48,6 +48,10 @@ QT_BEGIN_NAMESPACE QML_DEFINE_INTERFACE(QGraphicsLayoutItem) QML_DEFINE_INTERFACE(QGraphicsLayout) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsLinearLayoutStretchItem,QGraphicsLinearLayoutStretchItemObject) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsLinearLayout,QGraphicsLinearLayoutObject) +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsGridLayout,QGraphicsGridLayoutObject) + class LinearLayoutAttached : public QObject { Q_OBJECT @@ -89,7 +93,6 @@ private: Qt::Alignment _alignment; }; -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsLinearLayoutStretchItem,QGraphicsLinearLayoutStretchItemObject) QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) : QObject(parent) @@ -103,7 +106,6 @@ QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, cons return QSizeF(); } -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsLinearLayout,QGraphicsLinearLayoutObject) QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) : QObject(parent), _children(this) @@ -119,9 +121,9 @@ void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutIte insertItem(index, item); //connect attached properties - if (QObject *obj = attachedProperties.value(item)) { - setStretchFactor(item, static_cast(obj)->stretchFactor()); - setAlignment(item, static_cast(obj)->alignment()); + if (LinearLayoutAttached *obj = attachedProperties.value(item)) { + setStretchFactor(item, obj->stretchFactor()); + setAlignment(item, obj->alignment()); QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), @@ -147,7 +149,7 @@ void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt: QGraphicsLinearLayout::setAlignment(item, alignment); } -QHash QGraphicsLinearLayoutObject::attachedProperties; +QHash QGraphicsLinearLayoutObject::attachedProperties; LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) { // ### This is not allowed - you must attach to any object @@ -246,8 +248,6 @@ private: Qt::Alignment _alignment; }; -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsGridLayout,QGraphicsGridLayoutObject) - QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) : QObject(parent), _children(this) @@ -277,12 +277,12 @@ void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) { //use attached properties - if (QObject *obj = attachedProperties.value(item)) { - int row = static_cast(obj)->row(); - int column = static_cast(obj)->column(); - int rowSpan = static_cast(obj)->rowSpan(); - int columnSpan = static_cast(obj)->columnSpan(); - Qt::Alignment alignment = static_cast(obj)->alignment(); + if (GridLayoutAttached *obj = attachedProperties.value(item)) { + int row = obj->row(); + int column = obj->column(); + int rowSpan = obj->rowSpan(); + int columnSpan = obj->columnSpan(); + Qt::Alignment alignment = obj->alignment(); if (row == -1 || column == -1) { qWarning() << "Must set row and column for an item in a grid layout"; return; @@ -307,7 +307,7 @@ qreal QGraphicsGridLayoutObject::spacing() const return -1; //XXX } -QHash QGraphicsGridLayoutObject::attachedProperties; +QHash QGraphicsGridLayoutObject::attachedProperties; GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) { // ### This is not allowed - you must attach to any object diff --git a/src/declarative/widgets/graphicslayouts.h b/src/declarative/widgets/graphicslayouts.h index 13811eb..863f846 100644 --- a/src/declarative/widgets/graphicslayouts.h +++ b/src/declarative/widgets/graphicslayouts.h @@ -92,7 +92,7 @@ private: friend class LinearLayoutAttached; void clearChildren(); void insertLayoutItem(int, QGraphicsLayoutItem *); - static QHash attachedProperties; + static QHash attachedProperties; class ChildList : public QmlList { @@ -150,7 +150,7 @@ private: void addWidget(QGraphicsWidget *); void clearChildren(); void addLayoutItem(QGraphicsLayoutItem *); - static QHash attachedProperties; + static QHash attachedProperties; class ChildList : public QmlList { diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp index 4c6dcf9..cfcc87b 100644 --- a/src/declarative/widgets/graphicswidgets.cpp +++ b/src/declarative/widgets/graphicswidgets.cpp @@ -59,7 +59,6 @@ public: static_cast(parent())->setScene(scene); } }; -QML_DEFINE_EXTENDED_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI) class QGraphicsSceneDeclarativeUI : public QObject { @@ -111,7 +110,6 @@ private: }; Children _children; }; -QML_DEFINE_EXTENDED_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsScene,QGraphicsScene,QGraphicsSceneDeclarativeUI) class QGraphicsWidgetDeclarativeUI : public QObject { @@ -164,6 +162,8 @@ private: QmlConcreteList _data; }; +QML_DEFINE_EXTENDED_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI) +QML_DEFINE_EXTENDED_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsScene,QGraphicsScene,QGraphicsSceneDeclarativeUI) QML_DEFINE_EXTENDED_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarativeUI) QML_DEFINE_INTERFACE(QGraphicsItem) -- cgit v0.12