src/hbwidgets/itemviews/hbabstractitemview.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
--- a/src/hbwidgets/itemviews/hbabstractitemview.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbwidgets/itemviews/hbabstractitemview.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -28,6 +28,7 @@
 #include "hbabstractitemcontainer_p_p.h"
 
 #include <hbabstractviewitem.h>
+#include <hbabstractviewitem_p.h>
 #include <hbevent.h>
 #include <hbabstractitemcontainer_p.h>
 #include <hbwidgetfeedback.h>
@@ -225,6 +226,42 @@
 */
 
 /*!
+    \enum HbAbstractItemView::IconLoadPolicy
+
+    Icon load policies that can be used to control how icon data is loaded to items.
+*/
+
+/*!
+    \var HbAbstractItemView::LoadSynchronously
+
+    Icon items data is loaded always synchronously. In this mode the icon items data fetch will block the processing.
+    This can lead to longer item creation and data update times and poor performance while scrolling when fetching data 
+    takes long time. 
+    
+    But on the other hand icon content is guaranteed to be painted immediately and no empty areas caused
+    by asynchronous data fetch are visible.
+*/
+
+/*!
+    \var HbAbstractItemView::LoadAsynchronouslyWhenScrolling
+
+    Icon data is loaded asynchronously while scrolling but otherwise it will be fetched synchronously. 
+*/
+
+/*!
+    \var HbAbstractItemView::LoadAsynchronouslyAlways
+
+    Icon data is loaded always asynchronously. In this mode the icon data fetch will not block the processing 
+    so it will not cause delays to item creation or data updated times. This can also lead to better scrolling 
+    performance when item recycling delay will be shared between different frames. 
+
+    But on the other hand icon content is not guaranteed to be painted immediately and this can cause empty areas 
+    to be painted while asynchronous data is being fetched.
+
+    This is the default mode.
+*/
+
+/*!
     Here are the main properties of the class:
 
     \li HbAbstractItemView::itemRecycling: ItemRecycling.
@@ -1045,8 +1082,7 @@
     
     QList<HbAbstractViewItem *> items = d->mContainer->items();
     foreach (HbAbstractViewItem *item, items) {
-        QEvent* polishEvent = new QEvent( QEvent::Polish );
-        QCoreApplication::postEvent(item, polishEvent);
+        HbAbstractViewItemPrivate::d_ptr(item)->repolishItem();
     }
 } 
 
@@ -1311,6 +1347,36 @@
 }
 
 /*!
+    Sets the value of the iconLoadPolicy property.
+
+    The default value is HbAbstractItemView::LoadAsynchronouslyAlways.
+
+    \sa HbAbstractItemView::iconLoadPolicy(), HbAbstractItemView::IconLoadPolicy
+*/
+void HbAbstractItemView::setIconLoadPolicy(IconLoadPolicy policy)
+{
+    Q_D(HbAbstractItemView);
+    if (d->mIconLoadPolicy != policy) {
+        d->mIconLoadPolicy = policy;
+        
+        foreach (HbAbstractViewItem *prototype, itemPrototypes()) {
+            HbAbstractViewItemPrivate::d_ptr(prototype)->mSharedData->updateIconItemsAsyncMode();
+        }
+    }
+}
+
+/*!
+    Returns current icon load policy used by view.
+
+    \sa HbAbstractItemView::setIconLoadPolicy()
+*/
+HbAbstractItemView::IconLoadPolicy HbAbstractItemView::iconLoadPolicy() const
+{
+    Q_D(const HbAbstractItemView);
+    return d->mIconLoadPolicy;
+}
+
+/*!
     Slot handles QAbstractItemModel::layoutChanged() signal. 
     Default implementation sets first model item visible as first view item if the 
     buffer items needed to be modified. QSortFilterProxyModel sends layoutChanged