diff options
author | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-11-04 22:52:44 -0300 |
---|---|---|
committer | Luiz Agostini <luiz.agostini@openbossa.org> | 2009-11-05 00:42:09 -0300 |
commit | c3213274dad3c3e9d4e65bd4989fdb6aab8e12fb (patch) | |
tree | 8b3a506f86512acea56a70798aa9fb49ddf33896 /weather | |
parent | 74f78d0bf40ae9951d69c4939185bca231a5d464 (diff) |
Weather: Bug fixing.
Signed-off-by: Luiz Agostini <luiz.agostini@openbossa.org>
Diffstat (limited to 'weather')
-rw-r--r-- | weather/contentlist.cpp | 10 | ||||
-rw-r--r-- | weather/contentlist.h | 5 |
2 files changed, 8 insertions, 7 deletions
diff --git a/weather/contentlist.cpp b/weather/contentlist.cpp index 378fc5e..8b054aa 100644 --- a/weather/contentlist.cpp +++ b/weather/contentlist.cpp @@ -37,22 +37,24 @@ ContentListItem::ContentListItem(QGraphicsItem *parent) : QGraphicsItem(parent) , m_geometry(QRectF(0.0, 0.0, 0.0, 0.0)) + , m_geometryReady(false) { setFlag(QGraphicsItem::ItemHasNoContents, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - updateGeometry(); } QRectF ContentListItem::boundingRect() const { + if (!m_geometryReady) + return QRectF(0.0, 0.0, 0.0, contentHeight()); return m_geometry; } void ContentListItem::updateGeometry() { - if (!parentItem()) - return; - QRectF geometry(0.0, 0.0, parentItem()->boundingRect().width() - pos().x(), contentHeight()); + m_geometryReady = parentItem() != 0; + qreal width = parentItem() ? parentItem()->boundingRect().width() - pos().x() : 0.0; + QRectF geometry(0.0, 0.0, width, contentHeight()); if (m_geometry != geometry) { prepareGeometryChange(); m_geometry = geometry; diff --git a/weather/contentlist.h b/weather/contentlist.h index a1d948e..8f37c7f 100644 --- a/weather/contentlist.h +++ b/weather/contentlist.h @@ -60,6 +60,7 @@ protected: private: friend class ContentList; QRectF m_geometry; + bool m_geometryReady; qreal getTop() { return pos().y(); } void setTop(qreal top) { setPos(pos().x(), top); } @@ -69,9 +70,7 @@ class ContentListActivity; class RemoveActivity; class InsertActivity; -class ContentList - : public QObject - , public QGraphicsItem +class ContentList : public QObject, public QGraphicsItem { Q_OBJECT Q_INTERFACES(QGraphicsItem); |