src/hbwidgets/itemviews/hbabstractviewitem_p.h
changeset 23 e6ad4ef83b23
parent 21 4633027730f5
child 30 80e4d18b72f5
--- a/src/hbwidgets/itemviews/hbabstractviewitem_p.h	Wed Aug 18 10:05:37 2010 +0300
+++ b/src/hbwidgets/itemviews/hbabstractviewitem_p.h	Thu Sep 02 20:44:51 2010 +0300
@@ -61,6 +61,11 @@
         setZValue(zValue);
     }
 
+    ~HbViewItemPixmapPainter()
+    {
+        delete mPixmap;
+    }
+
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
     {
         Q_UNUSED(option);
@@ -83,17 +88,25 @@
     
     void setPixmap(QPixmap *pixmap) 
     {
-        if (pixmap) {
-            if (!mPixmap) {
-                setFlag(QGraphicsItem::ItemHasNoContents, false);
+        if (pixmap != mPixmap) {
+            if (pixmap) {
+                if (!mPixmap) {
+                    setFlag(QGraphicsItem::ItemHasNoContents, false);
+                }
+            } else {
+                if (mPixmap) {
+                    setFlag(QGraphicsItem::ItemHasNoContents, true);
+                }
             }
-        } else {
-            if (mPixmap) {
-                setFlag(QGraphicsItem::ItemHasNoContents, true);
-            }
+
+            delete mPixmap;
+            mPixmap = pixmap;
         }
+    }
 
-        mPixmap = pixmap;
+    inline QPixmap *pixmap() const
+    {
+        return mPixmap;
     }
 
     void setDeviceRect(const QRect &deviceRect) {
@@ -105,6 +118,11 @@
         mBoundingRect = QRectF(QPointF(), size);
     }
 
+    inline QSize pixmapSize() const
+    {
+        return mDeviceRect.size();
+    }
+
 private:
 
     QPixmap *mPixmap;
@@ -189,8 +207,6 @@
           mSharedData(shared),
           mBackPixmapPainter(0),
           mFrontPixmapPainter(0),
-          mBackCachePixmap(0),
-          mFrontCachePixmap(0),
           mInPaintItems(false),
           mNonCachableItem(0),
           mResetPixmapCache(true)
@@ -218,8 +234,6 @@
             mSharedData(source.mSharedData),
             mBackPixmapPainter(0),
             mFrontPixmapPainter(0),
-            mBackCachePixmap(0),
-            mFrontCachePixmap(0),
             mInPaintItems(false),
             mNonCachableItem(source.mNonCachableItem),
             mResetPixmapCache(true)
@@ -244,8 +258,6 @@
             mMultiSelectionTouchArea = 0;
             mBackPixmapPainter = 0;
             mFrontPixmapPainter = 0;
-            mBackCachePixmap = 0;
-            mFrontCachePixmap = 0;
             mInPaintItems = false;
             mNonCachableItem = source.mNonCachableItem;
             mResetPixmapCache = true;
@@ -278,8 +290,10 @@
         void setPressed(bool pressed, bool animate);
 
         void paintItems(QPainter *painter, QStyleOptionGraphicsItem *option, QGraphicsItem *startItem, QGraphicsItem *endItem);
+        void paintChildItemsRecursively(QGraphicsItem *child, QPainter *painter,QStyleOptionGraphicsItem *option);
 
         void setChildFlags(QGraphicsItem *child, bool pixmapCacheEnabled);
+        void setChildFlagRecursively(bool pixmapCacheEnabled);
 
         inline bool usePixmapCache() const;
 
@@ -321,9 +335,6 @@
         HbViewItemPixmapPainter *mBackPixmapPainter;
         HbViewItemPixmapPainter *mFrontPixmapPainter;
 
-        QPixmap *mBackCachePixmap;
-        QPixmap *mFrontCachePixmap;
-
         bool mInPaintItems;
 
         QGraphicsItem *mNonCachableItem;