src/hbwidgets/itemviews/hbtumbleview.cpp
changeset 30 80e4d18b72f5
parent 21 4633027730f5
--- a/src/hbwidgets/itemviews/hbtumbleview.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbwidgets/itemviews/hbtumbleview.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -27,17 +27,20 @@
 #include "hblistitemcontainer_p.h"
 #include "hblistitemcontainer_p_p.h"
 #include "hbmodeliterator.h"
+#include "hbstyleprimitivedata.h"
 
 #include <hbtumbleview.h>
 #include <hbtumbleviewitem.h>
 #include <hbevent.h>
 #include <hbstyleoption_p.h>
+#include <hbstyleframeprimitivedata.h>
 
 #include <QGraphicsSceneMouseEvent>
 #include <QStringListModel>
 #include <QItemSelectionModel>
 #include <QTapGesture>
 
+
 #define HB_TUMBLE_ITEM_ANIMATION_TIME 500
 #define HB_TUMBLE_PREFERRED_ITEMS 3
 
@@ -113,12 +116,13 @@
     QTimer mDelayedSelectTimer;
 
     //primitives
-    QGraphicsItem   *mBackground;
-    QGraphicsItem   *mFrame;//overlay
-    QGraphicsItem   *mHighlight;
+    QGraphicsObject   *mBackground;
+    QGraphicsObject   *mFrame;//overlay
+    QGraphicsObject   *mHighlight;
+    QGraphicsObject   *mDivider;
     int             mSelected;
     bool mNeedScrolling;
-    QGraphicsItem   *mDivider;
+    
 };
 
 
@@ -394,9 +398,9 @@
     ,mBackground(0)
     ,mFrame(0)
     ,mHighlight(0)
+    ,mDivider(0)
     ,mSelected(-1)
-    ,mNeedScrolling(true)
-    ,mDivider(0)
+    ,mNeedScrolling(true) 
 {
 }
 
@@ -572,16 +576,20 @@
     Q_Q(HbTumbleView);
 
     //this is the highlight which is placed at center
+    
     if(!mHighlight) {
-        mHighlight = HbStylePrivate::createPrimitive(HbStylePrivate::P_TumbleView_highlight,q);
-        HbStyle::setItemName(mHighlight,"highlight");
-    }
-    if(!mDivider){
-        mDivider = HbStylePrivate::createPrimitive(HbStylePrivate::P_DateTimePicker_separator,q);
-        HbStyle::setItemName(mDivider,"separator");
+        mHighlight = q->style()->createPrimitive(HbStyle::PT_FrameItem,"highlight",q);
+        }
+    if(!mDivider) {
+        mDivider = q->style()->createPrimitive(HbStyle::PT_FrameItem,"separator",q);
         mDivider->hide();
-    }
-
+        }
+    if(!mFrame) {
+        mFrame = q->style()->createPrimitive(HbStyle::PT_FrameItem,"frame",q);
+        }
+    if(!mBackground) {
+        mBackground = q->style()->createPrimitive(HbStyle::PT_FrameItem,"background",q);
+        }
 }
 
 
@@ -806,29 +814,70 @@
     }
 }
 
+void HbTumbleView::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive)
+{
+    HbWidget::initPrimitiveData(primitiveData, primitive);
+    QString itemName = HbStyle::itemName(primitive);
+        
+    if(itemName == QLatin1String("separator")) {
+        HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
+        frameItem->frameGraphicsName= QLatin1String("qtg_graf_tumbler_divider");
+        frameItem->frameType = HbFrameDrawer::OnePiece;
+        (const_cast<QGraphicsObject *> (primitive))->setZValue(2);
+        }
+        
+    if(itemName == QLatin1String("highlight")) {
+       HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
+       frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_highlight_pri");
+       frameItem->frameType = HbFrameDrawer::ThreePiecesHorizontal;
+       (const_cast<QGraphicsObject *> (primitive))->setZValue(-1);
+       }
+
+    if (itemName == QLatin1String("frame")) {
+        HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
+        frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_overlay");
+        frameItem->frameType = HbFrameDrawer::NinePieces;
+        (const_cast<QGraphicsObject *> (primitive))->setZValue(-4);
+        }
+
+    if (itemName == QLatin1String("background")) {
+        HbStyleFramePrimitiveData *frameItem  = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
+        frameItem->frameGraphicsName= QLatin1String("qtg_fr_tumbler_bg");
+        frameItem->frameType = HbFrameDrawer::NinePieces;
+        (const_cast<QGraphicsObject *> (primitive))->setZValue(-5);
+        }
+}
+
 /*!
     \reimp
 */
 void HbTumbleView::updatePrimitives()
 {                   
     Q_D(HbTumbleView);
-
-    HbStyleOption opt;
-    initStyleOption(&opt);
+    HbListView::updatePrimitives();
+    if(d->mBackground){
+        HbStyleFramePrimitiveData data;
+        initPrimitiveData(&data,d->mBackground);
+        style()->updatePrimitive(d->mBackground,&data,this);
+       }
 
-    if(d->mBackground) {
-        HbStylePrivate::updatePrimitive(d->mBackground,HbStylePrivate::P_TumbleView_background,&opt);
-    }
     if(d->mFrame) {
-        HbStylePrivate::updatePrimitive(d->mFrame,HbStylePrivate::P_TumbleView_frame,&opt);
-    } 
+        HbStyleFramePrimitiveData data;
+        initPrimitiveData(&data,d->mFrame);
+        style()->updatePrimitive(d->mFrame,&data,this);
+       }
+
     if(d->mHighlight) {
-        HbStylePrivate::updatePrimitive(d->mHighlight,HbStylePrivate::P_TumbleView_highlight,&opt);
-    }
-    if(d->mDivider){
-        HbStylePrivate::updatePrimitive(d->mDivider, HbStylePrivate::P_DateTimePicker_separator, &opt);
-    }
-    HbListView::updatePrimitives();
+        HbStyleFramePrimitiveData data;
+        initPrimitiveData (&data,d->mHighlight);
+        style()->updatePrimitive(d->mHighlight,&data,this);
+       }
+
+    if (d->mDivider) {
+        HbStyleFramePrimitiveData data;
+        initPrimitiveData (&data,d->mDivider);
+        style()->updatePrimitive(d->mDivider,&data,this);
+        }
 
 }