src/hbcore/gui/hbwidgetbase.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
--- a/src/hbcore/gui/hbwidgetbase.cpp	Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbcore/gui/hbwidgetbase.cpp	Wed Aug 18 10:05:37 2010 +0300
@@ -25,9 +25,7 @@
 
 #include <QApplication>
 #include <QGraphicsWidget>
-#include <QPainter>
 #include <QDebug>
-#include <hbtextitem.h>
 #ifdef HB_EFFECTS
 #include <hbeffect.h>
 #include <hbeffectinternal_p.h>
@@ -37,6 +35,8 @@
 #include "hbwidgetbase.h"
 #include "hbwidgetbase_p.h"
 #include "hbevent.h"
+#include <hbwidget.h>
+#include <QGraphicsLayout>
 
 
 /*!
@@ -51,13 +51,20 @@
     and transform changes.You should enable ItemUsesExtendedStyleOption if widget uses QStyleOptionGraphicsItem
     i.eduring painting.
 
+    HbWidgetBase is optimized to work with layout. ParentWidget is always reponsible
+    of layouting its children. If widget doesnot have a layout than it is responsible for
+    taking care of it's children geometries.HbWidgetBase doesnot guarantee that adjustSize will
+    be called before widget is shown.
+
     Currently HbWidgetBase offers the following functionality:
         - Layout direction locking                 
 */
 
 HbWidgetBasePrivate::HbWidgetBasePrivate() :
         mApiProtectionFlags(0),
-        attributes(0)
+        attributes(0),
+        polished(0)
+
 {
     q_ptr = 0;
 }
@@ -95,6 +102,19 @@
     }
 }
 
+//Optimizes updateGeometry calls for hbwidget and its descendents.
+bool HbWidgetBasePrivate::ignoreGeometryUpdate()
+{
+
+    return false;
+}
+
+
+void HbWidgetBasePrivate::activateParentLayout()
+{
+
+}
+
 void HbWidgetBasePrivate::setInsidePopup(bool insidePopup)
 {
     Q_Q( HbWidgetBase );
@@ -176,10 +196,7 @@
 {
     if (e->type() == HbEvent::ThemeChanged) {
         changeEvent(e);
-    }
-
-    // This class will be rebased to QGraphicsWidget
-    // that is why direct ancestor is not called
+    } 
     return QGraphicsWidget::event(e);
 }
 
@@ -204,13 +221,13 @@
 {
     Q_D(HbWidgetBase);
 
-    if( change == QGraphicsItem::ItemVisibleChange) {
+    if (change == QGraphicsItem::ItemVisibleChange) {
         if (value.toBool()) {
-            // Applies same initialisation for Hb widgets as QGraphicsWidget.
-            // For Hb primitives size is not set as they will be later layouted by Hb widgets.
-            // This is done to avoid flickering as primitives tend to paint themselves before layouting, 
-            // if they are added to existing layout.
-            // If Hb primitives are used standalone, their size and position must be set explicitly.
+            //For HbWidget/Primitives size is not set as they will be layouted
+            //after being polished.This is done to avoid flickering as primitives tend
+            //to paint themselves before layouting, if they are added to existing layout.
+            // If HbWidgets/primitives are used as standalone widgets, 
+            //their size and position must be set explicitly.
 
             // Send Show event before the item has been shown.
             QShowEvent event;
@@ -219,10 +236,10 @@
             if (!resized && testAttribute(Hb::Widget)) {
                 adjustSize();
                 setAttribute(Qt::WA_Resized, false);
-            } 
+            }
             return QGraphicsItem::itemChange(change, value);
         }
-    } else if( change == QGraphicsItem::ItemParentChange) {
+    } else if (change == QGraphicsItem::ItemParentChange) {
         d->handleInsidePopup(value.value<QGraphicsItem *>());
     }
     return QGraphicsWidget::itemChange(change, value);
@@ -421,3 +438,17 @@
         event->ignore(g);
     }
 }
+
+
+/*!
+    \reimp
+ */
+void HbWidgetBase::updateGeometry()
+{
+    QGraphicsWidget::updateGeometry();
+}
+
+
+
+
+