Revision: 201015
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 13:32:54 +0300
changeset 1 e48454f237ca
parent 0 89c329efa980
child 2 49c70dcc3f17
Revision: 201015 Kit: 201018
bwins/ganeswidgetsu.def
bwins/hgcacheproxymodelu.def
eabi/ganeswidgetsu.def
eabi/hgcacheproxymodelu.def
ganeswidgets/inc/HgContainer.h
ganeswidgets/inc/HgScrollBufferManager.h
ganeswidgets/inc/hgcoverflowcontainer.h
ganeswidgets/inc/hggridcontainer.h
ganeswidgets/inc/hgimage.h
ganeswidgets/inc/hgindexfeedback_p.h
ganeswidgets/inc/hgmediawall_p.h
ganeswidgets/inc/hgmediawallrenderer.h
ganeswidgets/inc/hgquadrenderer.h
ganeswidgets/inc/hgvgimage.h
ganeswidgets/inc/hgvgquadrenderer.h
ganeswidgets/inc/hgwidgetitem.h
ganeswidgets/inc/hgwidgets_p.h
ganeswidgets/src/HgContainer.cpp
ganeswidgets/src/HgScrollBufferManager.cpp
ganeswidgets/src/hgcoverflowcontainer.cpp
ganeswidgets/src/hggrid.cpp
ganeswidgets/src/hggrid_p.cpp
ganeswidgets/src/hggridcontainer.cpp
ganeswidgets/src/hgindexfeedback.cpp
ganeswidgets/src/hgindexfeedback_p.cpp
ganeswidgets/src/hgmediawall.cpp
ganeswidgets/src/hgmediawall_p.cpp
ganeswidgets/src/hgmediawallrenderer.cpp
ganeswidgets/src/hgquadrenderer.cpp
ganeswidgets/src/hgvgimage.cpp
ganeswidgets/src/hgvgquadrenderer.cpp
ganeswidgets/src/hgwidgetitem.cpp
ganeswidgets/src/hgwidgets.cpp
ganeswidgets/src/hgwidgets_p.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/hgwidgettest.pro
ganeswidgets/tsrc/fute/HgWidgetTest/inc/buffermanager.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgcoverflowwidget.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgitemsizedialog.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgtestdefs.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgtestview.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgetoptionsview.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestdatamodel.h
ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestview.h
ganeswidgets/tsrc/fute/HgWidgetTest/src/buffermanager.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgcoverflowwidget.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgitemsizedialog.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgtestview.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgetoptionsview.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestdatamodel.cpp
ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestview.cpp
ganeswidgets/tsrc/unit/unittest_ganeswidgets.cpp
hgcacheproxymodel/hgcacheproxymodel.pro
hgcacheproxymodel/inc/hgbuffermanager.h
hgcacheproxymodel/inc/hglogger.h
hgcacheproxymodel/rom/hgcacheproxymodel.iby
hgcacheproxymodel/rom/rom.pri
hgcacheproxymodel/sis/hgcacheproxymodelstub.pkg
hgcacheproxymodel/sis/hgcacheproxymodelstub.sis
hgcacheproxymodel/sis/stub.pri
hgcacheproxymodel/src/hgbuffermanager.cpp
hgcacheproxymodel/src/hgcacheproxymodel.cpp
hgcacheproxymodel/src/hgdataprovidermodel.cpp
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/default.png
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/hgcacheproxymodeltestapp.pro
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/hgcacheproxymodeltestapp.qrc
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/main.cpp
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mydataprovider.cpp
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mydataprovider.h
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mywindow.cpp
hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mywindow.h
hgcacheproxymodel/tsrc/unit/bmhelper.cpp
hgcacheproxymodel/tsrc/unit/bmhelper.h
hgcacheproxymodel/tsrc/unit/cacheproxydatamodel_tsrc.png
hgcacheproxymodel/tsrc/unit/cacheproxyhelper.cpp
hgcacheproxymodel/tsrc/unit/cacheproxyhelper.h
hgcacheproxymodel/tsrc/unit/dataproviderhelper.cpp
hgcacheproxymodel/tsrc/unit/dataproviderhelper.h
hgcacheproxymodel/tsrc/unit/test_hgcacheproxydatamodel.cpp
hgcacheproxymodel/tsrc/unit/test_hgcacheproxydatamodel.h
hgcacheproxymodel/tsrc/unit/unittest_hgcacheproxymodel.pro
hgcacheproxymodel/tsrc/unit/unittest_hgcacheproxymodel.qrc
hgwidgets.pro
hgwidgets_plat/ganeswidgets_api/ganeswidgets_api.pri
hgwidgets_plat/ganeswidgets_api/inc/hggrid.h
hgwidgets_plat/ganeswidgets_api/inc/hgmediawall.h
hgwidgets_plat/ganeswidgets_api/inc/hgwidgets.h
hgwidgets_plat/hgcacheproxymodel_api/hgcacheproxymodel_api.pri
hgwidgets_plat/hgcacheproxymodel_api/inc/hgcacheproxymodel.h
hgwidgets_plat/hgcacheproxymodel_api/inc/hgdataprovidermodel.h
hgwidgets_plat/hgwidgets_plat.pro
--- a/bwins/ganeswidgetsu.def	Mon Apr 19 14:40:06 2010 +0300
+++ b/bwins/ganeswidgetsu.def	Mon May 03 13:32:54 2010 +0300
@@ -59,7 +59,7 @@
 	??0HgMediawall@@QAE@PAVQGraphicsItem@@@Z @ 58 NONAME ; HgMediawall::HgMediawall(class QGraphicsItem *)
 	?qt_metacast@HgGrid@@UAEPAXPBD@Z @ 59 NONAME ; void * HgGrid::qt_metacast(char const *)
 	?trUtf8@HgGrid@@SA?AVQString@@PBD0H@Z @ 60 NONAME ; class QString HgGrid::trUtf8(char const *, char const *, int)
-	??0HgWidget@@IAE@PAVHbWidgetPrivate@@PAVQGraphicsItem@@@Z @ 61 NONAME ; HgWidget::HgWidget(class HbWidgetPrivate *, class QGraphicsItem *)
+	??0HgWidget@@IAE@AAVHgWidgetPrivate@@PAVQGraphicsItem@@@Z @ 61 NONAME ; HgWidget::HgWidget(class HgWidgetPrivate &, class QGraphicsItem *)
 	?trUtf8@HgMediawall@@SA?AVQString@@PBD0H@Z @ 62 NONAME ; class QString HgMediawall::trUtf8(char const *, char const *, int)
 	?trUtf8@HgGrid@@SA?AVQString@@PBD0@Z @ 63 NONAME ; class QString HgGrid::trUtf8(char const *, char const *)
 	?tr@HgGrid@@SA?AVQString@@PBD0@Z @ 64 NONAME ; class QString HgGrid::tr(char const *, char const *)
@@ -80,4 +80,18 @@
 	?descriptionFontSpec@HgMediawall@@QBE?AVHbFontSpec@@XZ @ 79 NONAME ; class HbFontSpec HgMediawall::descriptionFontSpec(void) const
 	?setIndexFeedbackPolicy@HgWidget@@QAEXW4IndexFeedbackPolicy@1@@Z @ 80 NONAME ; void HgWidget::setIndexFeedbackPolicy(enum HgWidget::IndexFeedbackPolicy)
 	?indexFeedbackPolicy@HgWidget@@QBE?AW4IndexFeedbackPolicy@1@XZ @ 81 NONAME ; enum HgWidget::IndexFeedbackPolicy HgWidget::indexFeedbackPolicy(void) const
+	?setDefaultImage@HgWidget@@QAEXVQImage@@@Z @ 82 NONAME ; void HgWidget::setDefaultImage(class QImage)
+	??0HgWidget@@QAE@PAVQGraphicsItem@@@Z @ 83 NONAME ; HgWidget::HgWidget(class QGraphicsItem *)
+	??0HgMediawall@@IAE@AAVHgMediawallPrivate@@PAVQGraphicsItem@@@Z @ 84 NONAME ; HgMediawall::HgMediawall(class HgMediawallPrivate &, class QGraphicsItem *)
+	??0HgGrid@@IAE@W4Orientation@Qt@@AAVHgGridPrivate@@PAVQGraphicsItem@@@Z @ 85 NONAME ; HgGrid::HgGrid(enum Qt::Orientation, class HgGridPrivate &, class QGraphicsItem *)
+	?setItemSizePolicy@HgWidget@@QAEXW4ItemSizePolicy@1@@Z @ 86 NONAME ; void HgWidget::setItemSizePolicy(enum HgWidget::ItemSizePolicy)
+	?itemSizePolicy@HgWidget@@QBE?AW4ItemSizePolicy@1@XZ @ 87 NONAME ; enum HgWidget::ItemSizePolicy HgWidget::itemSizePolicy(void) const
+	?setItemSize@HgWidget@@QAEXABVQSizeF@@@Z @ 88 NONAME ; void HgWidget::setItemSize(class QSizeF const &)
+	?setItemSpacing@HgWidget@@QAEXABVQSizeF@@@Z @ 89 NONAME ; void HgWidget::setItemSpacing(class QSizeF const &)
+	?itemSize@HgWidget@@QBE?AVQSizeF@@XZ @ 90 NONAME ; class QSizeF HgWidget::itemSize(void) const
+	?itemSpacing@HgWidget@@QBE?AVQSizeF@@XZ @ 91 NONAME ; class QSizeF HgWidget::itemSpacing(void) const
+	?enableReflections@HgMediawall@@QAEX_N@Z @ 92 NONAME ; void HgMediawall::enableReflections(bool)
+	?frontItemPositionDelta@HgMediawall@@QBE?AVQPointF@@XZ @ 93 NONAME ; class QPointF HgMediawall::frontItemPositionDelta(void) const
+	?reflectionsEnabled@HgMediawall@@QBE_NXZ @ 94 NONAME ; bool HgMediawall::reflectionsEnabled(void) const
+	?setFrontItemPositionDelta@HgMediawall@@QAEXABVQPointF@@@Z @ 95 NONAME ; void HgMediawall::setFrontItemPositionDelta(class QPointF const &)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bwins/hgcacheproxymodelu.def	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,92 @@
+EXPORTS
+	?headerData@HgCacheProxyModel@@UBE?AVQVariant@@HW4Orientation@Qt@@H@Z @ 1 NONAME ; class QVariant HgCacheProxyModel::headerData(int, enum Qt::Orientation, int) const
+	?insertItem@HgDataProviderModel@@IAEXHU?$QPair@VQVariant@@H@@_N@Z @ 2 NONAME ; void HgDataProviderModel::insertItem(int, struct QPair<class QVariant, int>, bool)
+	?sortRole@HgCacheProxyModel@@QBEHXZ @ 3 NONAME ; int HgCacheProxyModel::sortRole(void) const
+	?data@HgCacheProxyModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 4 NONAME ; class QVariant HgCacheProxyModel::data(class QModelIndex const &, int) const
+	?createIcon@HgDataProviderModel@@IAE?AVQVariant@@HVQPixmap@@@Z @ 5 NONAME ; class QVariant HgDataProviderModel::createIcon(int, class QPixmap)
+	?parent@HgDataProviderModel@@UBE?AVQModelIndex@@ABV2@@Z @ 6 NONAME ; class QModelIndex HgDataProviderModel::parent(class QModelIndex const &) const
+	?parent@HgCacheProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 7 NONAME ; class QModelIndex HgCacheProxyModel::parent(class QModelIndex const &) const
+	?buddy@HgCacheProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 8 NONAME ; class QModelIndex HgCacheProxyModel::buddy(class QModelIndex const &) const
+	?setDataProvider@HgCacheProxyModel@@QAEXPAVHgDataProviderModel@@HH@Z @ 9 NONAME ; void HgCacheProxyModel::setDataProvider(class HgDataProviderModel *, int, int)
+	?containsRole@HgDataProviderModel@@IBE_NHH@Z @ 10 NONAME ; bool HgDataProviderModel::containsRole(int, int) const
+	?itemData@HgDataProviderModel@@UBE?AV?$QMap@HVQVariant@@@@ABVQModelIndex@@@Z @ 11 NONAME ; class QMap<int, class QVariant> HgDataProviderModel::itemData(class QModelIndex const &) const
+	?release@HgDataProviderModel@@QAEXV?$QList@H@@_N@Z @ 12 NONAME ; void HgDataProviderModel::release(class QList<int>, bool)
+	?qt_metacast@HgDataProviderModel@@UAEPAXPBD@Z @ 13 NONAME ; void * HgDataProviderModel::qt_metacast(char const *)
+	?resizeQPixmapPool@HgDataProviderModel@@QAEXH@Z @ 14 NONAME ; void HgDataProviderModel::resizeQPixmapPool(int)
+	??0HgDataProviderModel@@QAE@PAVQObject@@@Z @ 15 NONAME ; HgDataProviderModel::HgDataProviderModel(class QObject *)
+	?dropMimeData@HgCacheProxyModel@@UAE_NPBVQMimeData@@W4DropAction@Qt@@HHABVQModelIndex@@@Z @ 16 NONAME ; bool HgCacheProxyModel::dropMimeData(class QMimeData const *, enum Qt::DropAction, int, int, class QModelIndex const &)
+	?columnCount@HgDataProviderModel@@UBEHABVQModelIndex@@@Z @ 17 NONAME ; int HgDataProviderModel::columnCount(class QModelIndex const &) const
+	?columnCount@HgCacheProxyModel@@UBEHABVQModelIndex@@@Z @ 18 NONAME ; int HgCacheProxyModel::columnCount(class QModelIndex const &) const
+	?tr@HgDataProviderModel@@SA?AVQString@@PBD0@Z @ 19 NONAME ; class QString HgDataProviderModel::tr(char const *, char const *)
+	?update@HgDataProviderModel@@IAE_NHPAV?$QList@U?$QPair@VQVariant@@H@@@@_N@Z @ 20 NONAME ; bool HgDataProviderModel::update(int, class QList<struct QPair<class QVariant, int> > *, bool)
+	?registerObserver@HgDataProviderModel@@QAEXPAVHgDataProviderModelObserver@@@Z @ 21 NONAME ; void HgDataProviderModel::registerObserver(class HgDataProviderModelObserver *)
+	??1HgCacheProxyModel@@UAE@XZ @ 22 NONAME ; HgCacheProxyModel::~HgCacheProxyModel(void)
+	?doResetModel@HgDataProviderModel@@MAEXXZ @ 23 NONAME ; void HgDataProviderModel::doResetModel(void)
+	?canFetchMore@HgCacheProxyModel@@UBE_NABVQModelIndex@@@Z @ 24 NONAME ; bool HgCacheProxyModel::canFetchMore(class QModelIndex const &) const
+	?emitDataChanged@HgDataProviderModel@@IAEXHH_N@Z @ 25 NONAME ; void HgDataProviderModel::emitDataChanged(int, int, bool)
+	?supportedDropActions@HgCacheProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 26 NONAME ; class QFlags<enum Qt::DropAction> HgCacheProxyModel::supportedDropActions(void) const
+	?staticMetaObject@HgDataProviderModel@@2UQMetaObject@@B @ 27 NONAME ; struct QMetaObject const HgDataProviderModel::staticMetaObject
+	??0HgCacheProxyModel@@QAE@PAVQObject@@@Z @ 28 NONAME ; HgCacheProxyModel::HgCacheProxyModel(class QObject *)
+	?updateIcon@HgDataProviderModel@@IAE_NHVQVariant@@_N@Z @ 29 NONAME ; bool HgDataProviderModel::updateIcon(int, class QVariant, bool)
+	?index@HgDataProviderModel@@UBE?AVQModelIndex@@HHABV2@@Z @ 30 NONAME ; class QModelIndex HgDataProviderModel::index(int, int, class QModelIndex const &) const
+	?sort@HgCacheProxyModel@@UAEXHW4SortOrder@Qt@@@Z @ 31 NONAME ; void HgCacheProxyModel::sort(int, enum Qt::SortOrder)
+	?data@HgDataProviderModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 32 NONAME ; class QVariant HgDataProviderModel::data(class QModelIndex const &, int) const
+	?releasePixmap@HgDataProviderModel@@IAEXH@Z @ 33 NONAME ; void HgDataProviderModel::releasePixmap(int)
+	?removeColumns@HgCacheProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 34 NONAME ; bool HgCacheProxyModel::removeColumns(int, int, class QModelIndex const &)
+	?insertRows@HgCacheProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 35 NONAME ; bool HgCacheProxyModel::insertRows(int, int, class QModelIndex const &)
+	?revert@HgCacheProxyModel@@UAEXXZ @ 36 NONAME ; void HgCacheProxyModel::revert(void)
+	?insertItem@HgDataProviderModel@@IAEXHPAV?$QList@U?$QPair@VQVariant@@H@@@@_N@Z @ 37 NONAME ; void HgDataProviderModel::insertItem(int, class QList<struct QPair<class QVariant, int> > *, bool)
+	?setSortCaseSensitivity@HgCacheProxyModel@@QAEXW4CaseSensitivity@Qt@@@Z @ 38 NONAME ; void HgCacheProxyModel::setSortCaseSensitivity(enum Qt::CaseSensitivity)
+	?itemData@HgCacheProxyModel@@UBE?AV?$QMap@HVQVariant@@@@ABVQModelIndex@@@Z @ 39 NONAME ; class QMap<int, class QVariant> HgCacheProxyModel::itemData(class QModelIndex const &) const
+	?dynamicSortFilter@HgCacheProxyModel@@QBE_NXZ @ 40 NONAME ; bool HgCacheProxyModel::dynamicSortFilter(void) const
+	?data@HgDataProviderModel@@IBE?AVQVariant@@HH@Z @ 41 NONAME ; class QVariant HgDataProviderModel::data(int, int) const
+	?rowCount@HgDataProviderModel@@UBEHABVQModelIndex@@@Z @ 42 NONAME ; int HgDataProviderModel::rowCount(class QModelIndex const &) const
+	?submit@HgCacheProxyModel@@UAE_NXZ @ 43 NONAME ; bool HgCacheProxyModel::submit(void)
+	?hasChildren@HgCacheProxyModel@@UBE_NABVQModelIndex@@@Z @ 44 NONAME ; bool HgCacheProxyModel::hasChildren(class QModelIndex const &) const
+	?trUtf8@HgDataProviderModel@@SA?AVQString@@PBD0H@Z @ 45 NONAME ; class QString HgDataProviderModel::trUtf8(char const *, char const *, int)
+	?tr@HgDataProviderModel@@SA?AVQString@@PBD0H@Z @ 46 NONAME ; class QString HgDataProviderModel::tr(char const *, char const *, int)
+	?sortOrder@HgCacheProxyModel@@QBE?AW4SortOrder@Qt@@XZ @ 47 NONAME ; enum Qt::SortOrder HgCacheProxyModel::sortOrder(void) const
+	?setSortLocaleAware@HgCacheProxyModel@@QAEX_N@Z @ 48 NONAME ; void HgCacheProxyModel::setSortLocaleAware(bool)
+	?removeItem@HgDataProviderModel@@IAEXH@Z @ 49 NONAME ; void HgDataProviderModel::removeItem(int)
+	?removeRows@HgCacheProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 50 NONAME ; bool HgCacheProxyModel::removeRows(int, int, class QModelIndex const &)
+	?getStaticMetaObject@HgDataProviderModel@@SAABUQMetaObject@@XZ @ 51 NONAME ; struct QMetaObject const & HgDataProviderModel::getStaticMetaObject(void)
+	?clearCache@HgDataProviderModel@@IAEXXZ @ 52 NONAME ; void HgDataProviderModel::clearCache(void)
+	?dataUpdated@HgCacheProxyModel@@UAEXHH@Z @ 53 NONAME ; void HgCacheProxyModel::dataUpdated(int, int)
+	??1HgDataProviderModel@@UAE@XZ @ 54 NONAME ; HgDataProviderModel::~HgDataProviderModel(void)
+	?isSortLocaleAware@HgCacheProxyModel@@QBE_NXZ @ 55 NONAME ; bool HgCacheProxyModel::isSortLocaleAware(void) const
+	?fetchMore@HgCacheProxyModel@@UAEXABVQModelIndex@@@Z @ 56 NONAME ; void HgCacheProxyModel::fetchMore(class QModelIndex const &)
+	?newItem@HgDataProviderModel@@IAEXU?$QPair@VQVariant@@H@@_N@Z @ 57 NONAME ; void HgDataProviderModel::newItem(struct QPair<class QVariant, int>, bool)
+	?setDynamicSortFilter@HgCacheProxyModel@@QAEX_N@Z @ 58 NONAME ; void HgCacheProxyModel::setDynamicSortFilter(bool)
+	?isIndexValid@HgDataProviderModel@@IBE_NH@Z @ 59 NONAME ; bool HgDataProviderModel::isIndexValid(int) const
+	?index@HgCacheProxyModel@@UBE?AVQModelIndex@@HHABV2@@Z @ 60 NONAME ; class QModelIndex HgCacheProxyModel::index(int, int, class QModelIndex const &) const
+	?sortColumn@HgCacheProxyModel@@QBEHXZ @ 61 NONAME ; int HgCacheProxyModel::sortColumn(void) const
+	?request@HgDataProviderModel@@QAEXV?$QList@H@@_N@Z @ 62 NONAME ; void HgDataProviderModel::request(class QList<int>, bool)
+	?removeItems@HgDataProviderModel@@IAEXHH@Z @ 63 NONAME ; void HgDataProviderModel::removeItems(int, int)
+	?doInsertItem@HgDataProviderModel@@AAEXHPAV?$QList@U?$QPair@VQVariant@@H@@@@_N@Z @ 64 NONAME ; void HgDataProviderModel::doInsertItem(int, class QList<struct QPair<class QVariant, int> > *, bool)
+	?resizeCache@HgCacheProxyModel@@QAEXHH@Z @ 65 NONAME ; void HgCacheProxyModel::resizeCache(int, int)
+	?count@HgDataProviderModel@@IBEHXZ @ 66 NONAME ; int HgDataProviderModel::count(void) const
+	?request@HgCacheProxyModel@@UAEXHHW4HgRequestOrder@HgBufferManagerObserver@@@Z @ 67 NONAME ; void HgCacheProxyModel::request(int, int, enum HgBufferManagerObserver::HgRequestOrder)
+	?mimeTypes@HgCacheProxyModel@@UBE?AVQStringList@@XZ @ 68 NONAME ; class QStringList HgCacheProxyModel::mimeTypes(void) const
+	?sortCaseSensitivity@HgCacheProxyModel@@QBE?AW4CaseSensitivity@Qt@@XZ @ 69 NONAME ; enum Qt::CaseSensitivity HgCacheProxyModel::sortCaseSensitivity(void) const
+	?setItemData@HgCacheProxyModel@@UAE_NABVQModelIndex@@ABV?$QMap@HVQVariant@@@@@Z @ 70 NONAME ; bool HgCacheProxyModel::setItemData(class QModelIndex const &, class QMap<int, class QVariant> const &)
+	?rowCount@HgCacheProxyModel@@UBEHABVQModelIndex@@@Z @ 71 NONAME ; int HgCacheProxyModel::rowCount(class QModelIndex const &) const
+	?setData@HgCacheProxyModel@@UAE_NABVQModelIndex@@ABVQVariant@@H@Z @ 72 NONAME ; bool HgCacheProxyModel::setData(class QModelIndex const &, class QVariant const &, int)
+	??_EHgDataProviderModel@@UAE@I@Z @ 73 NONAME ; HgDataProviderModel::~HgDataProviderModel(unsigned int)
+	?mimeData@HgCacheProxyModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 74 NONAME ; class QMimeData * HgCacheProxyModel::mimeData(class QList<class QModelIndex> const &) const
+	?newItem@HgDataProviderModel@@IAEXPAV?$QList@U?$QPair@VQVariant@@H@@@@_N@Z @ 75 NONAME ; void HgDataProviderModel::newItem(class QList<struct QPair<class QVariant, int> > *, bool)
+	?setHeaderData@HgCacheProxyModel@@UAE_NHW4Orientation@Qt@@ABVQVariant@@H@Z @ 76 NONAME ; bool HgCacheProxyModel::setHeaderData(int, enum Qt::Orientation, class QVariant const &, int)
+	?update@HgDataProviderModel@@IAE_NHVQVariant@@H_N@Z @ 77 NONAME ; bool HgDataProviderModel::update(int, class QVariant, int, bool)
+	?match@HgCacheProxyModel@@UBE?AV?$QList@VQModelIndex@@@@ABVQModelIndex@@HABVQVariant@@HV?$QFlags@W4MatchFlag@Qt@@@@@Z @ 78 NONAME ; class QList<class QModelIndex> HgCacheProxyModel::match(class QModelIndex const &, int, class QVariant const &, int, class QFlags<enum Qt::MatchFlag>) const
+	?release@HgCacheProxyModel@@UAEXHH@Z @ 79 NONAME ; void HgCacheProxyModel::release(int, int)
+	?resetModel@HgDataProviderModel@@QAEXXZ @ 80 NONAME ; void HgDataProviderModel::resetModel(void)
+	?span@HgCacheProxyModel@@UBE?AVQSize@@ABVQModelIndex@@@Z @ 81 NONAME ; class QSize HgCacheProxyModel::span(class QModelIndex const &) const
+	?insertColumns@HgCacheProxyModel@@UAE_NHHABVQModelIndex@@@Z @ 82 NONAME ; bool HgCacheProxyModel::insertColumns(int, int, class QModelIndex const &)
+	?metaObject@HgDataProviderModel@@UBEPBUQMetaObject@@XZ @ 83 NONAME ; struct QMetaObject const * HgDataProviderModel::metaObject(void) const
+	?resetIcon@HgDataProviderModel@@IAEXH@Z @ 84 NONAME ; void HgDataProviderModel::resetIcon(int)
+	?setSortRole@HgCacheProxyModel@@QAEXH@Z @ 85 NONAME ; void HgCacheProxyModel::setSortRole(int)
+	?getPixmap@HgDataProviderModel@@AAEPAVQPixmap@@H@Z @ 86 NONAME ; class QPixmap * HgDataProviderModel::getPixmap(int)
+	?trUtf8@HgDataProviderModel@@SA?AVQString@@PBD0@Z @ 87 NONAME ; class QString HgDataProviderModel::trUtf8(char const *, char const *)
+	?flags@HgCacheProxyModel@@UBE?AV?$QFlags@W4ItemFlag@Qt@@@@ABVQModelIndex@@@Z @ 88 NONAME ; class QFlags<enum Qt::ItemFlag> HgCacheProxyModel::flags(class QModelIndex const &) const
+	?qt_metacall@HgDataProviderModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 89 NONAME ; int HgDataProviderModel::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?DataProvider@HgCacheProxyModel@@QAEPAVHgDataProviderModel@@XZ @ 90 NONAME ; class HgDataProviderModel * HgCacheProxyModel::DataProvider(void)
+
--- a/eabi/ganeswidgetsu.def	Mon Apr 19 14:40:06 2010 +0300
+++ b/eabi/ganeswidgetsu.def	Mon May 03 13:32:54 2010 +0300
@@ -41,8 +41,8 @@
 	_ZN8HgWidget8setModelEP18QAbstractItemModel @ 40 NONAME
 	_ZN8HgWidget9activatedERK11QModelIndex @ 41 NONAME
 	_ZN8HgWidget9selectAllEv @ 42 NONAME
-	_ZN8HgWidgetC1EP15HbWidgetPrivateP13QGraphicsItem @ 43 NONAME
-	_ZN8HgWidgetC2EP15HbWidgetPrivateP13QGraphicsItem @ 44 NONAME
+	_ZN8HgWidgetC1ER15HgWidgetPrivateP13QGraphicsItem @ 43 NONAME
+	_ZN8HgWidgetC2ER15HgWidgetPrivateP13QGraphicsItem @ 44 NONAME
 	_ZN8HgWidgetD0Ev @ 45 NONAME
 	_ZN8HgWidgetD1Ev @ 46 NONAME
 	_ZN8HgWidgetD2Ev @ 47 NONAME
@@ -86,4 +86,21 @@
 	_ZNK11HgMediawall19descriptionPositionEv @ 85 NONAME
 	_ZN8HgWidget22setIndexFeedbackPolicyENS_19IndexFeedbackPolicyE @ 86 NONAME
 	_ZNK8HgWidget19indexFeedbackPolicyEv @ 87 NONAME
+	_ZN8HgWidget15setDefaultImageE6QImage @ 88 NONAME
+	_ZN11HgMediawallC1ER18HgMediawallPrivateP13QGraphicsItem @ 89 NONAME
+	_ZN11HgMediawallC2ER18HgMediawallPrivateP13QGraphicsItem @ 90 NONAME
+	_ZN6HgGridC1EN2Qt11OrientationER13HgGridPrivateP13QGraphicsItem @ 91 NONAME
+	_ZN6HgGridC2EN2Qt11OrientationER13HgGridPrivateP13QGraphicsItem @ 92 NONAME
+	_ZN8HgWidgetC1EP13QGraphicsItem @ 93 NONAME
+	_ZN8HgWidgetC2EP13QGraphicsItem @ 94 NONAME
+	_ZN8HgWidget11setItemSizeERK6QSizeF @ 95 NONAME
+	_ZN8HgWidget14setItemSpacingERK6QSizeF @ 96 NONAME
+	_ZN8HgWidget17setItemSizePolicyENS_14ItemSizePolicyE @ 97 NONAME
+	_ZNK8HgWidget11itemSpacingEv @ 98 NONAME
+	_ZNK8HgWidget14itemSizePolicyEv @ 99 NONAME
+	_ZNK8HgWidget8itemSizeEv @ 100 NONAME
+	_ZN11HgMediawall17enableReflectionsEb @ 101 NONAME
+	_ZN11HgMediawall25setFrontItemPositionDeltaERK7QPointF @ 102 NONAME
+	_ZNK11HgMediawall18reflectionsEnabledEv @ 103 NONAME
+	_ZNK11HgMediawall22frontItemPositionDeltaEv @ 104 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eabi/hgcacheproxymodelu.def	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,94 @@
+EXPORTS
+	_ZN17HgCacheProxyModel10insertRowsEiiRK11QModelIndex @ 1 NONAME
+	_ZN17HgCacheProxyModel10removeRowsEiiRK11QModelIndex @ 2 NONAME
+	_ZN17HgCacheProxyModel11dataUpdatedEii @ 3 NONAME
+	_ZN17HgCacheProxyModel11resizeCacheEii @ 4 NONAME
+	_ZN17HgCacheProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 5 NONAME
+	_ZN17HgCacheProxyModel11setSortRoleEi @ 6 NONAME
+	_ZN17HgCacheProxyModel12DataProviderEv @ 7 NONAME
+	_ZN17HgCacheProxyModel12dropMimeDataEPK9QMimeDataN2Qt10DropActionEiiRK11QModelIndex @ 8 NONAME
+	_ZN17HgCacheProxyModel13insertColumnsEiiRK11QModelIndex @ 9 NONAME
+	_ZN17HgCacheProxyModel13removeColumnsEiiRK11QModelIndex @ 10 NONAME
+	_ZN17HgCacheProxyModel13setHeaderDataEiN2Qt11OrientationERK8QVarianti @ 11 NONAME
+	_ZN17HgCacheProxyModel15setDataProviderEP19HgDataProviderModelii @ 12 NONAME
+	_ZN17HgCacheProxyModel18setSortLocaleAwareEb @ 13 NONAME
+	_ZN17HgCacheProxyModel20setDynamicSortFilterEb @ 14 NONAME
+	_ZN17HgCacheProxyModel22setSortCaseSensitivityEN2Qt15CaseSensitivityE @ 15 NONAME
+	_ZN17HgCacheProxyModel4sortEiN2Qt9SortOrderE @ 16 NONAME
+	_ZN17HgCacheProxyModel6revertEv @ 17 NONAME
+	_ZN17HgCacheProxyModel6submitEv @ 18 NONAME
+	_ZN17HgCacheProxyModel7releaseEii @ 19 NONAME
+	_ZN17HgCacheProxyModel7requestEiiN23HgBufferManagerObserver14HgRequestOrderE @ 20 NONAME
+	_ZN17HgCacheProxyModel7setDataERK11QModelIndexRK8QVarianti @ 21 NONAME
+	_ZN17HgCacheProxyModel9fetchMoreERK11QModelIndex @ 22 NONAME
+	_ZN17HgCacheProxyModelC1EP7QObject @ 23 NONAME
+	_ZN17HgCacheProxyModelC2EP7QObject @ 24 NONAME
+	_ZN17HgCacheProxyModelD0Ev @ 25 NONAME
+	_ZN17HgCacheProxyModelD1Ev @ 26 NONAME
+	_ZN17HgCacheProxyModelD2Ev @ 27 NONAME
+	_ZN19HgDataProviderModel10clearCacheEv @ 28 NONAME
+	_ZN19HgDataProviderModel10createIconEi7QPixmap @ 29 NONAME
+	_ZN19HgDataProviderModel10insertItemEi5QPairI8QVariantiEb @ 30 NONAME
+	_ZN19HgDataProviderModel10insertItemEiP5QListI5QPairI8QVariantiEEb @ 31 NONAME
+	_ZN19HgDataProviderModel10removeItemEi @ 32 NONAME
+	_ZN19HgDataProviderModel10resetModelEv @ 33 NONAME
+	_ZN19HgDataProviderModel10updateIconEi8QVariantb @ 34 NONAME
+	_ZN19HgDataProviderModel11qt_metacallEN11QMetaObject4CallEiPPv @ 35 NONAME
+	_ZN19HgDataProviderModel11qt_metacastEPKc @ 36 NONAME
+	_ZN19HgDataProviderModel11removeItemsEii @ 37 NONAME
+	_ZN19HgDataProviderModel12doInsertItemEiP5QListI5QPairI8QVariantiEEb @ 38 NONAME
+	_ZN19HgDataProviderModel13releasePixmapEi @ 39 NONAME
+	_ZN19HgDataProviderModel15emitDataChangedEiib @ 40 NONAME
+	_ZN19HgDataProviderModel16registerObserverEP27HgDataProviderModelObserver @ 41 NONAME
+	_ZN19HgDataProviderModel16staticMetaObjectE @ 42 NONAME DATA 16
+	_ZN19HgDataProviderModel17resizeQPixmapPoolEi @ 43 NONAME
+	_ZN19HgDataProviderModel19getStaticMetaObjectEv @ 44 NONAME
+	_ZN19HgDataProviderModel6updateEi8QVariantib @ 45 NONAME
+	_ZN19HgDataProviderModel6updateEiP5QListI5QPairI8QVariantiEEb @ 46 NONAME
+	_ZN19HgDataProviderModel7newItemE5QPairI8QVariantiEb @ 47 NONAME
+	_ZN19HgDataProviderModel7newItemEP5QListI5QPairI8QVariantiEEb @ 48 NONAME
+	_ZN19HgDataProviderModel7releaseE5QListIiEb @ 49 NONAME
+	_ZN19HgDataProviderModel7requestE5QListIiEb @ 50 NONAME
+	_ZN19HgDataProviderModel9getPixmapEi @ 51 NONAME
+	_ZN19HgDataProviderModel9resetIconEi @ 52 NONAME
+	_ZN19HgDataProviderModelC2EP7QObject @ 53 NONAME
+	_ZN19HgDataProviderModelD0Ev @ 54 NONAME
+	_ZN19HgDataProviderModelD1Ev @ 55 NONAME
+	_ZN19HgDataProviderModelD2Ev @ 56 NONAME
+	_ZNK17HgCacheProxyModel10headerDataEiN2Qt11OrientationEi @ 57 NONAME
+	_ZNK17HgCacheProxyModel10sortColumnEv @ 58 NONAME
+	_ZNK17HgCacheProxyModel11columnCountERK11QModelIndex @ 59 NONAME
+	_ZNK17HgCacheProxyModel11hasChildrenERK11QModelIndex @ 60 NONAME
+	_ZNK17HgCacheProxyModel12canFetchMoreERK11QModelIndex @ 61 NONAME
+	_ZNK17HgCacheProxyModel17dynamicSortFilterEv @ 62 NONAME
+	_ZNK17HgCacheProxyModel17isSortLocaleAwareEv @ 63 NONAME
+	_ZNK17HgCacheProxyModel19sortCaseSensitivityEv @ 64 NONAME
+	_ZNK17HgCacheProxyModel20supportedDropActionsEv @ 65 NONAME
+	_ZNK17HgCacheProxyModel4dataERK11QModelIndexi @ 66 NONAME
+	_ZNK17HgCacheProxyModel4spanERK11QModelIndex @ 67 NONAME
+	_ZNK17HgCacheProxyModel5buddyERK11QModelIndex @ 68 NONAME
+	_ZNK17HgCacheProxyModel5flagsERK11QModelIndex @ 69 NONAME
+	_ZNK17HgCacheProxyModel5indexEiiRK11QModelIndex @ 70 NONAME
+	_ZNK17HgCacheProxyModel5matchERK11QModelIndexiRK8QVarianti6QFlagsIN2Qt9MatchFlagEE @ 71 NONAME
+	_ZNK17HgCacheProxyModel6parentERK11QModelIndex @ 72 NONAME
+	_ZNK17HgCacheProxyModel8itemDataERK11QModelIndex @ 73 NONAME
+	_ZNK17HgCacheProxyModel8mimeDataERK5QListI11QModelIndexE @ 74 NONAME
+	_ZNK17HgCacheProxyModel8rowCountERK11QModelIndex @ 75 NONAME
+	_ZNK17HgCacheProxyModel8sortRoleEv @ 76 NONAME
+	_ZNK17HgCacheProxyModel9mimeTypesEv @ 77 NONAME
+	_ZNK17HgCacheProxyModel9sortOrderEv @ 78 NONAME
+	_ZNK19HgDataProviderModel10metaObjectEv @ 79 NONAME
+	_ZNK19HgDataProviderModel11columnCountERK11QModelIndex @ 80 NONAME
+	_ZNK19HgDataProviderModel4dataERK11QModelIndexi @ 81 NONAME
+	_ZNK19HgDataProviderModel4dataEii @ 82 NONAME
+	_ZNK19HgDataProviderModel5countEv @ 83 NONAME
+	_ZNK19HgDataProviderModel5indexEiiRK11QModelIndex @ 84 NONAME
+	_ZNK19HgDataProviderModel6parentERK11QModelIndex @ 85 NONAME
+	_ZNK19HgDataProviderModel8itemDataERK11QModelIndex @ 86 NONAME
+	_ZNK19HgDataProviderModel8rowCountERK11QModelIndex @ 87 NONAME
+	_ZTI19HgDataProviderModel @ 88 NONAME
+	_ZTV19HgDataProviderModel @ 89 NONAME
+	_ZThn12_N17HgCacheProxyModel11dataUpdatedEii @ 90 NONAME
+	_ZThn8_N17HgCacheProxyModel7releaseEii @ 91 NONAME
+	_ZThn8_N17HgCacheProxyModel7requestEiiN23HgBufferManagerObserver14HgRequestOrderE @ 92 NONAME
+
--- a/ganeswidgets/inc/HgContainer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/HgContainer.h	Mon May 03 13:32:54 2010 +0300
@@ -79,6 +79,20 @@
 
     void init(Qt::Orientation scrollDirection);
 
+    void setDefaultImage(QImage defaultImage);
+    
+    void setItemSizePolicy(HgWidget::ItemSizePolicy policy);
+    HgWidget::ItemSizePolicy itemSizePolicy() const;
+
+    void setItemSize(const QSizeF& size);
+    QSizeF itemSize() const;
+    
+    void setItemSpacing(const QSizeF& size);
+    QSizeF itemSpacing() const;
+    
+    Qt::Orientation scrollDirection() const;
+    qreal scrollPosition() const;
+    
 signals:
 
     // emit this signal when scrolling. for example scrollbar can be connected to this signal.
@@ -95,7 +109,6 @@
     void redraw();
     void updateLongPressVisualizer();
     void updateByCurrentIndex(const QModelIndex &current);
-    void onScrollingEnded();
 
 protected: // from HgMediaWallDataProvider
 
@@ -116,13 +129,14 @@
     virtual void gestureEvent(QGestureEvent *event);
 protected:
 
-    virtual HgMediaWallRenderer* createRenderer()=0;
+    virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection)=0;
     virtual qreal getCameraDistance(qreal springVelocity);
     virtual qreal getCameraRotationY(qreal springVelocity);
     virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex);
     virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex);
     virtual void onScrollPositionChanged(qreal pos);
     virtual void handleCurrentChanged(const QModelIndex &current);
+    virtual QRectF drawableRect() const;
 
 protected:
 
@@ -139,15 +153,16 @@
     void initSpringForScrollBar();
     void initSpringForScrolling();
     void boundSpring();
-    void handlePanning(QPanGesture *gesture);
-    void handleTap(Qt::GestureState state, const QPointF &pos);
-    void handleLongTap(Qt::GestureState state, const QPointF &pos);
-    void handleItemAction(const QPointF &pos, ItemActionType action);
+    bool handlePanning(QPanGesture *gesture);
+    bool handleTap(Qt::GestureState state, const QPointF &pos);
+    bool handleLongTap(Qt::GestureState state, const QPointF &pos);
+    bool handleItemAction(const QPointF &pos, ItemActionType action);
 
     void selectItem();
     void updateSelectedItem();
     void unselectItem();
 
+    bool hasItemAt(const QPointF& pos);
     HgWidgetItem* getItemAt(const QPointF& pos, int& index);
     void startLongPressWatcher(const QPointF& pos);
     void stopLongPressWatcher();
@@ -155,6 +170,10 @@
 
     QTransform qtToVgTransform() const;
     QPointF mapQtToVg(const QPointF& p) const;
+    
+    virtual void updateItemSizeAndSpacing();
+    virtual QSizeF getAutoItemSize() const;
+    virtual QSizeF getAutoItemSpacing() const;
 
 protected: // data
 
@@ -194,7 +213,12 @@
     QPointF mOffsetAtDragStart;
     QTime mLongTapDuration;
     bool mScrollBarPressed;
-        
+
+    HgWidget::ItemSizePolicy mItemSizePolicy;
+    QSizeF mUserItemSize;
+    QSizeF mUserItemSpacing;
+    
+    Qt::Orientation mOrientation;
 };
 
 #endif
--- a/ganeswidgets/inc/HgScrollBufferManager.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/HgScrollBufferManager.h	Mon May 03 13:32:54 2010 +0300
@@ -22,6 +22,41 @@
 #include <qobject>
 #include <QTimer>
 
+class UpdatePair
+{
+public:
+    UpdatePair(int start, int count);
+
+    int start() const;
+    int end() const;
+
+    bool adjacent(int start, int count) const;
+    bool contains(const UpdatePair &other) const;
+    void extend(int start, int count);
+    void subtract(int start, int count);
+
+    void shiftRight(int count);
+    void shiftLeft(int count);
+
+    bool operator== (const UpdatePair &other) const;
+    bool operator< (const UpdatePair &other) const;
+
+private:
+    int mStart;
+    int mCount;
+};
+
+class UpdateBuffer : public QList<UpdatePair>
+{
+public:
+    UpdateBuffer();
+
+    void add(int start, int count);
+    void remove(int start, int count);
+    void shiftRight(int startingFrom, int amount);
+    void shiftLeft(int startingFrom, int amount);
+};
+
 class HgScrollBufferManager: public QObject
     {
     Q_OBJECT
@@ -41,9 +76,11 @@
 
     bool positionInsideBuffer(int position);
 
-    void removeItems(int start, int end, int totalCount);
-    void addItems(int start, int end, int totalCount);
-    void moveItems(int start, int end, int target, int totalCount);
+    void addItems(int start, int count);
+    void removeItems(int start, int end);
+    void moveItems(int start, int end, int target);
+
+    void flushRequestBuffers();
 
     void currentBuffer(int& bufferStart, int& bufferEnd);
 
@@ -60,8 +97,14 @@
 
     void init();
     void asyncUpdate();
-    bool isInsideBuffer(int pos);
-    bool isInsideBuffer(int start, int end);
+
+    int changeBufferPosition(int newPos);
+
+    void simpleAddItems(int start, int end);
+    void simpleRemoveItems(int start, int end);
+
+    void appendRequestBuffer(int start, int end);
+    void appendReleaseBuffer(int start, int end);
 
 private:
 
@@ -79,6 +122,9 @@
     int mReleaseCount;
     QTimer mTimer;
 
+    UpdateBuffer mRequestBuffer;
+    UpdateBuffer mReleaseBuffer;
+
 private:
     Q_DISABLE_COPY(HgScrollBufferManager)
     };
--- a/ganeswidgets/inc/hgcoverflowcontainer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgcoverflowcontainer.h	Mon May 03 13:32:54 2010 +0300
@@ -37,7 +37,7 @@
     virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
 
     // from HgContainer
-    virtual HgMediaWallRenderer* createRenderer();
+    virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection);
     virtual qreal getCameraDistance(qreal springVelocity);
     virtual qreal getCameraRotationY(qreal springVelocity);
     virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex);
@@ -46,6 +46,11 @@
     virtual void handleCurrentChanged(const QModelIndex & current);
     virtual void itemDataChanged(const int &firstIndex, const int &lastIndex);
     virtual void scrollToPosition(const QPointF& pos, bool animate);
+    virtual QRectF drawableRect() const;
+
+    virtual QSizeF getAutoItemSize() const;
+    virtual QSizeF getAutoItemSpacing() const;
+    virtual void updateItemSizeAndSpacing();
     
     void setTitlePosition(HgMediawall::LabelPosition position);
     HgMediawall::LabelPosition titlePosition() const;
@@ -56,17 +61,33 @@
     void setDescriptionFontSpec(const HbFontSpec &fontSpec);
     HbFontSpec descriptionFontSpec() const;
 
+    void setFrontItemPositionDelta(const QPointF& position);
+    QPointF frontItemPositionDelta() const;
+
+    void enableReflections(bool enabled);
+    bool reflectionsEnabled() const;
+        
+private: // From HgContainer
+    void setDefaultImage(QImage defaultImage);
+
 private:
+
+    void updateLabels(int itemIndex);
+
+    void updatePositions();
+    
+    void calculatePositions();    
     void positionLabels();
-    void updateLabels(int itemIndex);
 
 private:
     HbLabel *mTitleLabel;
     HbLabel *mDescriptionLabel;
     HgMediawall::LabelPosition mTitlePosition;
     HgMediawall::LabelPosition mDescriptionPosition;
-    int mCenterIconTop;
     int mPrevPos;
+    qreal mAspectRatio;
+    QRectF mDrawableRect;
+    QSizeF mAutoSize;
 };
 
 #endif
--- a/ganeswidgets/inc/hggridcontainer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hggridcontainer.h	Mon May 03 13:32:54 2010 +0300
@@ -40,11 +40,12 @@
     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     
     // from HgContainer
-    virtual HgMediaWallRenderer* createRenderer();
+    virtual HgMediaWallRenderer* createRenderer(Qt::Orientation scrollDirection);
     virtual qreal getCameraDistance(qreal springVelocity);
     virtual qreal getCameraRotationY(qreal springVelocity);
     virtual void handleTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemIndex);
     virtual void handleLongTapAction(const QPointF& pos, HgWidgetItem* hitItem, int hitItemindex);
+    virtual void onScrollPositionChanged(qreal pos);
    
 };
 
--- a/ganeswidgets/inc/hgimage.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgimage.h	Mon May 03 13:32:54 2010 +0300
@@ -29,8 +29,11 @@
     virtual ~HgImage() {}
     virtual void setAlpha(qreal alpha) { mAlpha = alpha; }
     virtual qreal alpha() const { return mAlpha; }
-    virtual void setImage(QImage& image)=0;
+    virtual void setImage(const QImage& image)=0;
+    virtual QImage getQImage() const=0;
     virtual void releaseImage()=0;
+    virtual int width() const = 0;
+    virtual int height() const = 0;
 private:
     qreal mAlpha;
 };
--- a/ganeswidgets/inc/hgindexfeedback_p.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgindexfeedback_p.h	Mon May 03 13:32:54 2010 +0300
@@ -32,7 +32,7 @@
 class QItemSelectionModel;
 QT_END_NAMESPACE
 
-class HgIndexFeedbackPrivate : public HbWidgetPrivate
+class HgIndexFeedbackPrivate: public HbWidgetPrivate
 {
     Q_DECLARE_PUBLIC( HgIndexFeedback )
 
--- a/ganeswidgets/inc/hgmediawall_p.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgmediawall_p.h	Mon May 03 13:32:54 2010 +0300
@@ -32,7 +32,7 @@
     HgMediawallPrivate();
     virtual ~HgMediawallPrivate();
 
-    void init();
+    void init(Qt::Orientation orientation);
 
     void setTitlePosition(HgMediawall::LabelPosition position);
     HgMediawall::LabelPosition titlePosition() const;
@@ -43,7 +43,7 @@
     void setDescriptionFontSpec(const HbFontSpec &fontSpec);
     HbFontSpec descriptionFontSpec() const;
 
-private:
+    
     HgCoverflowContainer *container();
     const HgCoverflowContainer *container() const;
 };
--- a/ganeswidgets/inc/hgmediawallrenderer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgmediawallrenderer.h	Mon May 03 13:32:54 2010 +0300
@@ -49,7 +49,8 @@
         OpeningAnimationZoomOver
     };
             
-    explicit HgMediaWallRenderer(HgMediaWallDataProvider* provider);
+    explicit HgMediaWallRenderer(HgMediaWallDataProvider* provider, 
+        Qt::Orientation orientation, bool coverflowMode);
     
     virtual ~HgMediaWallRenderer();
 
@@ -114,8 +115,11 @@
     HgQuadRenderer* getRenderer();    
 
     bool getItemPoints(int index, QPolygonF& points) const;
+        
+    QList<HgQuad*> getVisibleQuads() const;
     
-    QList<HgQuad*> getVisibleQuads() const;
+    void setFrontItemPosition(const QPointF& position);
+    QPointF frontItemPosition() const;
     
 signals:
     void renderingNeeded();
@@ -189,6 +193,7 @@
     void setupIndicator(HgQuad* parent, 
         HgQuad* indicator, const HgImage* indicatorImage, int itemIndex);    
     bool initializeRenderer(QPainter* painter);
+    
         
 protected:
     
@@ -262,6 +267,9 @@
     
     ItemState mOpenedItemState;
     
+    QPointF mFrontItemPosition;
+    bool mFrontItemPositionSet;
+    
 private:
     Q_DISABLE_COPY(HgMediaWallRenderer)
 };
--- a/ganeswidgets/inc/hgquadrenderer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgquadrenderer.h	Mon May 03 13:32:54 2010 +0300
@@ -19,6 +19,8 @@
 #define HGQUADRENDERER_H
 
 #include <qlist>
+#include <QImage>
+#include <QVector2D>
 
 class HgQuad;
 class QPointF;
@@ -27,7 +29,6 @@
 class QMatrix4x4;
 class QPolygonF;
 class HgImage;
-class QImage;
 class HgImageFader;
 /**
  *
@@ -97,12 +98,32 @@
      * 
      */
     virtual QList<HgQuad*> getVisibleQuads(const QRectF& rect) const=0;
+    
+    virtual void setDefaultImage(QImage defaultImage);
+
+    /**
+     * 
+     */
+    virtual void setTranslation(const QVector2D& translate);
+    
+    /**
+     * 
+     */
+    virtual HgQuad* getQuadByUserData(const QVariant& userData) const;
+    
+    /**
+     * 
+     */
+    virtual QImage getDefaultImage() const;
+    
 protected:    
     HgQuadRenderer(int maxQuads);
 
     QList<HgQuad*> mQuads;
     qreal mMirroringPlaneY;
     HgImageFader* mImageFader;
+    QImage mDefaultImage;
+    QVector2D mTranslation;
 };
 
 #endif
--- a/ganeswidgets/inc/hgvgimage.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgvgimage.h	Mon May 03 13:32:54 2010 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:    
+* Description:
 *
 */
 
@@ -37,20 +37,22 @@
 
     int width() const;
     int height() const;
-    
+
     VGImage image() const;
-    
+
     int mirrorImageWidth() const;
     int mirrorImageHeight() const;
-    
+
     VGImage mirrorImage() const;
-    
-    void setImage(QImage& image);
+
+    void setImage(const QImage& image);
     void releaseImage();
     
+    QImage getQImage() const;
+
     void upload(bool mirror=false);
-  
-private:    
+
+private:
     VGImage mVgImage;
     VGImage mMirrorImage;
     QSize mMirrorSize;
--- a/ganeswidgets/inc/hgvgquadrenderer.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgvgquadrenderer.h	Mon May 03 13:32:54 2010 +0300
@@ -46,11 +46,13 @@
     virtual bool getQuadTranformedPoints(QPolygonF& points, int index) const;
     virtual HgImage* createNativeImage();
     virtual QList<HgQuad*> getVisibleQuads(const QRectF& rect) const;
-
+    virtual void setDefaultImage(QImage defaultImage);
+    
     // new functions
     HgVgImage* defaultImage();
     QSize imageSize(bool mirror=false) const;
     HgImageFader* imageFader();
+    
 private:
     
     QList<HgVgQuad*> mTransformedQuads;
--- a/ganeswidgets/inc/hgwidgetitem.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgwidgetitem.h	Mon May 03 13:32:54 2010 +0300
@@ -32,27 +32,27 @@
 {
 public:
 
-    HgWidgetItem(HgQuadRenderer* renderer);
-    HgWidgetItem( HgQuadRenderer* renderer, QImage image, QString title, QString description );
-    virtual ~HgWidgetItem();  
-    
-    void setImage( QImage image );
-    
-    void setTitle( QString title );
+    HgWidgetItem(HgQuadRenderer *renderer);
+    HgWidgetItem(HgQuadRenderer *renderer, QImage image, QString title, QString description );
+    virtual ~HgWidgetItem();
+
+    void setImage(const QImage &image);
+
+    void setTitle(QString title);
     QString title() const;
-    
+
     const HgImage* image() const;
-        
+
     void setDescription( QString description );
     QString description() const;
-    
+
     void setModelIndex( const QModelIndex& index);
     QModelIndex modelIndex() const;
-    
+
     bool validData() const;
     bool updateItemData();
     void releaseItemData();
-    
+
     bool visibility() const;
     void setVisibility(bool visible);
 
@@ -65,7 +65,7 @@
     HgImage*    mHgImage;
     HgQuadRenderer* mRenderer;
     bool mVisibility;
-    
+
     Q_DISABLE_COPY(HgWidgetItem)
 };
 
--- a/ganeswidgets/inc/hgwidgets_p.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/inc/hgwidgets_p.h	Mon May 03 13:32:54 2010 +0300
@@ -19,7 +19,6 @@
 #define HGWIDGET_P_H
 
 #include <hgwidgets/hgwidgets.h>
-#include <hbwidget_p.h>
 #include <QTimer>
 #include <QTime>
 
@@ -29,7 +28,7 @@
 class QGraphicsLinearLayout;
 class HgIndexFeedback;
 
-class HgWidgetPrivate : public HbWidgetPrivate
+class HgWidgetPrivate
 {
     Q_DECLARE_PUBLIC(HgWidget)
 
@@ -65,6 +64,18 @@
 
     void setIndexFeedbackPolicy( HgWidget::IndexFeedbackPolicy policy);
     HgWidget::IndexFeedbackPolicy indexFeedbackPolicy() const;
+    void setDefaultImage(QImage defaultImage);
+    
+    void setItemSizePolicy(HgWidget::ItemSizePolicy policy);
+    HgWidget::ItemSizePolicy itemSizePolicy() const;
+
+    void setItemSize(const QSizeF& size);
+    QSizeF itemSize() const;
+    
+    void setItemSpacing(const QSizeF& size);
+    QSizeF itemSpacing() const;
+    
+    HgWidget *q_ptr;
     
 private:
 
@@ -99,8 +110,13 @@
     void _q_moveRows(const QModelIndex &sourceParent, int sourceStart,
                      int sourceEnd, const QModelIndex &destinationParent,
                      int destinationRow);
+    void _q_modelReset();
     void _q_groovePressed(qreal value, Qt::Orientation orientation);
 
+    void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+    void initBufferManager(int itemCount);
+    
 protected:
 
     QGraphicsLinearLayout *mLayout;
@@ -115,12 +131,13 @@
     HbScrollBar *mScrollBar;
     HgWidget::ScrollBarPolicy mScrollBarPolicy;
     bool mAbleToScroll;
-    QTimer mScrollBarHideTimer;
+    QTimer* mScrollBarHideTimer;
 
     bool mHandleLongPress;
     bool mForeground;
     int mBufferSize;
     HgIndexFeedback *mIndexFeedback;
+    bool mStaticScrollDirection;
 };
 
 #endif  //HGWIDGET_p_H
--- a/ganeswidgets/src/HgContainer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/HgContainer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -57,10 +57,12 @@
     mHitItemView(NULL),
     mLongPressVisualizer(NULL),
     mLongPressTimer(NULL),
-    mHitItemIndex(NULL)
+    mHitItemIndex(NULL),
+    mItemSizePolicy(HgWidget::ItemSizeUserDefined),
+    mOrientation(Qt::Vertical)
 {
     FUNC_LOG;
-    
+
     grabGesture(Qt::PanGesture);
     grabGesture(Qt::TapGesture);
     grabGesture(Qt::TapAndHoldGesture);
@@ -70,9 +72,7 @@
 {
     FUNC_LOG;
 
-    for (QList<HgWidgetItem*>::iterator i = mItems.begin(); i != mItems.end(); ++i) {
-        delete (*i);
-    }
+    qDeleteAll(mItems);
     mItems.clear();
     delete mMarkImage;
     delete mRenderer;
@@ -82,6 +82,7 @@
 {
     FUNC_LOG;
 
+    qDeleteAll(mItems);
     mItems.clear();
     for (int i=0; i<itemCount; i++) {
         HgWidgetItem* item = new HgWidgetItem(mQuadRenderer);
@@ -207,14 +208,15 @@
 {
     FUNC_LOG;
 
-    return mRenderer->getOrientation();
+    return mOrientation;
 }
 
 void HgContainer::setOrientation(Qt::Orientation orientation, bool animate)
 {
     FUNC_LOG;
 
-    mRenderer->setOrientation(orientation, animate);
+    mOrientation = orientation;
+    mRenderer->setOrientation(orientation, false);
 }
 
 void HgContainer::scrollToPosition(qreal value, bool animate)
@@ -241,8 +243,8 @@
 {
     FUNC_LOG;
 
-    if (index.isValid()) {
-        scrollToPosition(QPointF(index.row(), index.column()), false);
+    if (index.isValid() && mRenderer->getRowCount() > 0) {
+        scrollToPosition(QPointF(index.row()/mRenderer->getRowCount(), 0), false);
     }
 }
 
@@ -264,6 +266,7 @@
 void HgContainer::addItems(int start, int end)
 {
     FUNC_LOG;
+    HANDLE_ERROR_NULL(mSelectionModel);
 
     int first = qBound(0, start, mItems.count()-1);
     int last = qBound(0, end, mItems.count()-1);
@@ -271,11 +274,13 @@
         HgWidgetItem* item = new HgWidgetItem(mQuadRenderer);
         mItems.insert(start, item);
     }
+    scrollTo(mSelectionModel->currentIndex());
 }
 
 void HgContainer::removeItems(int start, int end)
 {
     FUNC_LOG;
+    HANDLE_ERROR_NULL(mSelectionModel);
 
     int first = qBound(0, start, mItems.count()-1);
     int last = qBound(0, end, mItems.count()-1);
@@ -283,11 +288,13 @@
         delete mItems.at(i);
         mItems.removeAt(i);
     }
+    scrollTo(mSelectionModel->currentIndex());
 }
 
 void HgContainer::moveItems(int start, int end, int destination)
 {
     FUNC_LOG;
+    HANDLE_ERROR_NULL(mSelectionModel);
 
     int first = qBound(0, start, mItems.count()-1);
     int last = qBound(0, end, mItems.count()-1);
@@ -304,6 +311,7 @@
         }
     }
     // else do nothing
+    scrollTo(mSelectionModel->currentIndex());
 }
 
 int HgContainer::imageCount() const
@@ -337,14 +345,13 @@
 
 void HgContainer::updateBySpringPosition()
 {
-    update();
-
     // spring works always in one dimension, that is, x coord.
     qreal pos = mSpring.pos().x();
 
     onScrollPositionChanged(pos);
 
     emit scrollPositionChanged(pos, mAnimateUsingScrollBar);
+    update();
 }
 
 void HgContainer::redraw()
@@ -356,28 +363,35 @@
 {
     Q_UNUSED(option)
     Q_UNUSED(widget)
-
     if (mSpring.updatePositionIfNeeded())
     {
         // spring works always in one dimension, that is, x coord.
         qreal pos = mSpring.pos().x();
         onScrollPositionChanged(pos);
-        emit scrollPositionChanged(pos, mAnimateUsingScrollBar);        
+        emit scrollPositionChanged(pos, true);        
     }
-    
+
     QRectF vp = painter->viewport();
-    QRectF rts = mapRectToScene(rect());
+    QRectF rts = mapRectToScene(drawableRect());
     QRectF r;
 
     // transform rectangle to vg space &
     // rotate rendering according to orientation
-    if (mainWindow()->orientation() == Qt::Horizontal) {
+    if (mOrientation == Qt::Horizontal) {
         r = QRectF(vp.width()-(rts.height()+rts.top()), rts.left(), rts.height(), rts.width());
+
+        mRenderer->setRect(r);
+
         mRenderer->setCameraRotationZ(-90);
     }
     else {
         r = QRectF(rts.left(), vp.height()-(rts.height()+rts.top()), rts.width(), rts.height());
         mRenderer->setCameraRotationZ(0);
+
+        mRenderer->setRect(r);
+        
+        if (!mSpring.isActive() && mSpring.pos().x() > worldWidth())
+            boundSpring();
     }
 
     // interpolate spring velocity towards zero, this is done
@@ -393,10 +407,9 @@
     // setup rendering and draw the current view
     mRenderer->setCameraDistance(getCameraDistance(springVel));
     mRenderer->setCameraRotationY(getCameraRotationY(springVel));
-    mRenderer->setRect(r);
     mRenderer->draw(mSpring.startPos(), mSpring.pos(), mSpring.endPos(),
                     springVel, painter);
-        
+
 }
 
 void HgContainer::resizeEvent(QGraphicsSceneResizeEvent *event)
@@ -416,20 +429,35 @@
 {
     FUNC_LOG;
 
+    bool eventHandled(false);
     // Event may contain more than one gesture type
     if (QGesture *gesture = event->gesture(Qt::TapAndHoldGesture)) {
         QTapAndHoldGesture *tapAndHold = static_cast<QTapAndHoldGesture *>(gesture);
-        handleLongTap(tapAndHold->state(),
-            mapFromScene(event->mapToGraphicsScene(tapAndHold->position())));
+        if (handleLongTap(tapAndHold->state(),
+                mapFromScene(event->mapToGraphicsScene(tapAndHold->position())))) {
+        }
     }
     else if (QGesture *gesture = event->gesture(Qt::TapGesture)) {
         // Tap and hold is not working yet in HW, tap gesture is delivered instead
         QTapGesture *tap = static_cast<QTapGesture *>(gesture);
-        handleTap(tap->state(),
+        eventHandled = handleTap(tap->state(),
             mapFromScene(event->mapToGraphicsScene(tap->position())));
     }
     else if (QGesture *pan = event->gesture(Qt::PanGesture)) {
-        handlePanning(static_cast<QPanGesture*>(pan));
+        eventHandled = handlePanning(static_cast<QPanGesture*>(pan));
+    }
+
+    if (eventHandled) {
+        event->accept();
+        event->accept(Qt::TapAndHoldGesture);
+        event->accept(Qt::TapGesture);
+        event->accept(Qt::PanGesture);
+    }
+    else {
+        event->ignore();
+        event->ignore(Qt::TapAndHoldGesture);
+        event->ignore(Qt::TapGesture);
+        event->ignore(Qt::PanGesture);
     }
 }
 
@@ -437,12 +465,9 @@
 {
     FUNC_LOG;
 
-    mRenderer = createRenderer();
-    if (mRenderer->coverflowModeEnabled())
-        mRenderer->setOrientation(Qt::Horizontal, false);
-    else
-        mRenderer->setOrientation(scrollDirection, false);
-        
+    mRenderer = createRenderer(scrollDirection);
+    mOrientation = scrollDirection;
+
     mQuadRenderer = mRenderer->getRenderer();
 
     QImage markImage(":/images/mark.svg");
@@ -454,9 +479,8 @@
     if (mMarkImage) {
         mMarkImage->setImage(markImage);
     }
-
+    
     connect(&mSpring, SIGNAL(updated()), SLOT(updateBySpringPosition()));
-    connect(&mSpring, SIGNAL(ended()), SLOT(onScrollingEnded()));
     connect(&mSpring, SIGNAL(ended()), SIGNAL(scrollingEnded()));
     connect(&mSpring, SIGNAL(started()), SIGNAL(scrollingStarted()));
     connect(mRenderer, SIGNAL(renderingNeeded()), SLOT(redraw()));
@@ -500,7 +524,7 @@
 
 }
 
-void HgContainer::handlePanning(QPanGesture *gesture)
+bool HgContainer::handlePanning(QPanGesture *gesture)
 {
     mAnimateUsingScrollBar = false;
     initSpringForScrolling();
@@ -509,7 +533,7 @@
     qreal delta(0);
     qreal itemSide(0);
 
-    if (mRenderer->getOrientation() == mainWindow()->orientation()) {
+    if (mOrientation == mRenderer->getOrientation()) {
         delta = gesture->delta().y();
     }
     else {
@@ -544,6 +568,7 @@
             if (qAbs(newPosition - mSpring.pos().x()) > 0.01f)
             {
                 mSpring.gotoPos(QPointF(newPosition, 0));
+                emit scrollPositionChanged(newPosition,true);
                 update();
             }
         }
@@ -566,40 +591,54 @@
     else if (gesture->state() == Qt::GestureCanceled) {
         boundSpring();
     }
+
+    return true;
 }
 
-
-
-void HgContainer::handleTap(Qt::GestureState state, const QPointF &pos)
+bool HgContainer::handleTap(Qt::GestureState state, const QPointF &pos)
 {
     FUNC_LOG;
 
     if (state == Qt::GestureStarted) {
-        mTapDuration.start();
-
-        startLongPressWatcher(pos);
+        if (hasItemAt(pos)) {
+            mTapDuration.start();
+            startLongPressWatcher(pos);
+            return true;
+        }
+        return false;
     }
     else if (state == Qt::GestureCanceled)
     {
         stopLongPressWatcher();
+
+        if (hasItemAt(pos)) {
+            return true;
+        }
+        return false;
     }
     else if (state == Qt::GestureFinished) {
+        stopLongPressWatcher();
+        return handleItemAction(pos, mTapDuration.elapsed() > KLongTapDuration ? LongTap : NormalTap);
+    }
 
-        stopLongPressWatcher();
-        handleItemAction(pos, mTapDuration.elapsed() > KLongTapDuration ? LongTap : NormalTap);
-    }
+    return false;
 }
 
-void HgContainer::handleLongTap(Qt::GestureState state, const QPointF &pos)
+bool HgContainer::handleLongTap(Qt::GestureState state, const QPointF &pos)
 {
     FUNC_LOG;
 
-    mAnimateUsingScrollBar = false;
-    initSpringForScrolling();
+    if (hasItemAt(pos)) {
+        mAnimateUsingScrollBar = false;
+        initSpringForScrolling();
 
-    if (state == Qt::GestureFinished) {
-        handleItemAction(pos, LongTap);
+        if (state == Qt::GestureFinished) {
+            handleItemAction(pos, LongTap);
+        }
+        return true;
     }
+
+    return false;
 }
 
 /*!
@@ -608,25 +647,23 @@
     Sets the item as the current item and in multiselection mode toggles the
     item selection status.
 */
-void HgContainer::handleItemAction(const QPointF &pos, ItemActionType action)
+bool HgContainer::handleItemAction(const QPointF &pos, ItemActionType action)
 {
     FUNC_LOG;
 
     // If there is content, mSelectionModel must always exist - either default or client-provided
-    if (!mSelectionModel) return;
+    if (!mSelectionModel) return false;
 
     mHitItem = getItemAt(pos, mHitItemIndex);
     if (mHitItem)
     {
         int index = mHitItemIndex;
 
-
         HgWidgetItem* item = itemByIndex(index);
         if (item && action != DoubleTap) {
-            mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
-
             if (action == LongTap) {
                 INFO("Long tap:" << item->modelIndex().row());
+                mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
 
                 if (!mRenderer->coverflowModeEnabled())
                     selectItem();
@@ -634,16 +671,19 @@
                 emit longPressed(item->modelIndex(), pos);
             }
             else if (mSelectionMode == HgWidget::MultiSelection) {
+                mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
                 INFO("Select:" << item->modelIndex().row());
                 mSelectionModel->select(item->modelIndex(), QItemSelectionModel::Toggle);
                 update(); // It would be enough to update the item
             }
             else if (mSelectionMode == HgWidget::SingleSelection) {
+                mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
                 INFO("Select:" << item->modelIndex().row());
                 mSelectionModel->select(item->modelIndex(), QItemSelectionModel::ClearAndSelect);
                 update(); // It would be enough to update the item
             }
             else if (mSelectionMode == HgWidget::ContiguousSelection) {
+                mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
                 QModelIndex newSelected = item->modelIndex();
                 QModelIndexList oldSelection = mSelectionModel->selectedIndexes();
                 INFO("Select:" << newSelected.row());
@@ -669,6 +709,7 @@
                 {
                     if (qAbs(qreal(index) - mSpring.pos().x()) < 0.01f)
                     {
+                        mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
                         emit activated(item->modelIndex());
                     }
                     else
@@ -678,17 +719,20 @@
                 }
                 else
                 {
+                    mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
                     selectItem();
                     emit activated(item->modelIndex());
                 }
-
             }
         }
+
+        return true;
     }
     else {
         INFO("No quad at pos:" << pos);
 
         unselectItem();
+        return false;
     }
 }
 
@@ -722,67 +766,58 @@
 {
     FUNC_LOG;
 
+    // if screen is frequently updated no need to update now.
+    if (mSpring.isActive() || mDragged ) return;
+    
     // TODO FIX THIS FUNCTION!!!!!!!!!!!!!!!!!!!!!!
 
     int firstItemOnScreen = 0, lastItemOnScreen = 0;
     firstItemOnScreen = mSpring.pos().x();
     firstItemOnScreen *= rowCount();
 
-    // This code doesnt take into count if there is some empty space at the
-    // beginning or at the end of the widget
-
-    int itemsOnScreen = 0;
-    if (mRenderer->getOrientation() == Qt::Vertical) {
-        itemsOnScreen = this->rect().height()/mRenderer->getImageSize().height();
-        itemsOnScreen += rowCount();
-    }
-    else {
-        // Doesnt work here. Use some magic for now.
-        itemsOnScreen = this->rect().width()/mRenderer->getImageSize().width();
-        itemsOnScreen += 4;
-    }
-    itemsOnScreen *= rowCount();
+    int itemsOnScreen = mRenderer->getVisibleQuads().count();
     lastItemOnScreen = firstItemOnScreen+itemsOnScreen;
 
-    if ((firstIndex >= firstItemOnScreen && firstIndex <= lastItemOnScreen) ||
-        (lastIndex >= firstItemOnScreen && lastIndex <= lastItemOnScreen)) {
-        update( this->rect() );
+    if ((firstIndex >= firstItemOnScreen && firstIndex < lastItemOnScreen) ||
+        (lastIndex >= firstItemOnScreen && lastIndex < lastItemOnScreen)) {
+        update();
     }
 }
 
 void HgContainer::selectItem()
 {
     // TODO: replace this with own selection implementation
-
+    if (mHitItemIndex < 0 && mHitItemIndex >= mItems.count())
+        return;
+    
     if (mHitItemView)
     {
         delete mHitItemView;
         mHitItemView = NULL;
     }
-
+    
     mHitItemView = new HbGridViewItem(this);
     mHitItemView->setVisible(false);
+    mHitItemView->setPos(QPointF(0,0));
+    mHitItemView->setPressed(true, false);
 
-    QModelIndex modelIndex = mItems[mHitItemIndex]->modelIndex();
-    const QAbstractItemModel* model = modelIndex.model();
-    mHitItemView->resize(mRenderer->getImageSize().width() + 10,
-        mRenderer->getImageSize().height() + 10);
-
-    QVariant iconVariant = model->data(modelIndex, Qt::DecorationRole);
-    mHitItemPixmap = iconVariant.value<QPixmap>();
-    HbIcon icon(mHitItemPixmap);
-
+    const QImage& image = mItems[mHitItemIndex]->image()->getQImage();
+    if (image.isNull())
+    {
+        mHitItemView->setVisible(false);
+        return;
+    }
+    
+    QPixmap pixmap = QPixmap::fromImage(image);        
+    HbIcon icon(pixmap.scaled(mRenderer->getImageSize().toSize(), Qt::IgnoreAspectRatio));    
     QGraphicsItem* item = mHitItemView->style()->createPrimitive(HbStyle::P_GridViewItem_icon, mHitItemView);
     HbIconItem *iconItem = static_cast<HbIconItem*>(item);
+    iconItem->setAlignment(Qt::AlignCenter);
+    iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);    
     iconItem->setIcon(icon);
-    iconItem->setAlignment(Qt::AlignCenter);
-    iconItem->setAspectRatioMode(Qt::KeepAspectRatio);
 
-    mHitItemView->setModelIndex(modelIndex);
-    mHitItemView->setPos(QPointF(-10,-10));
-    mHitItemView->setPressed(true, false);
-    mHitItemView->updatePrimitives();
-
+    mHitItemView->resize(mRenderer->getImageSize().width(),
+        mRenderer->getImageSize().height());
 }
 
 void HgContainer::updateSelectedItem()
@@ -798,17 +833,11 @@
         mHitItemView->setVisible(false);
     }
 
-    if (mHitItemPixmap.isNull())
-    {
-        mHitItemView->setVisible(false);
-        return;
-    }
-
     QPolygonF img;
-    img.append(QPointF(0,mHitItemPixmap.height()));
-    img.append(QPointF(mHitItemPixmap.width(),mHitItemPixmap.height()));
-    img.append(QPointF(mHitItemPixmap.width(),0));
-    img.append(QPointF(0,0));
+    img.append(QPointF(3,mHitItemView->boundingRect().height()-3));
+    img.append(QPointF(mHitItemView->boundingRect().width()-3,mHitItemView->boundingRect().height()-3));
+    img.append(QPointF(mHitItemView->boundingRect().width()-3,3));
+    img.append(QPointF(3,3));
 
     QTransform t;
     QTransform::quadToQuad(img, points, t);
@@ -822,7 +851,6 @@
     mHitItemIndex = -1;
     if (mHitItemView)
     {
-        mHitItemView->setPressed(false, false);
         mHitItemView->setVisible(false);
     }
 }
@@ -830,9 +858,9 @@
 void HgContainer::updateLongPressVisualizer()
 {
     int elapsed = mLongTapDuration.elapsed();
-    
+
     if (elapsed > 80)
-    {    
+    {
         int frame = 100.0f * qreal(elapsed - 80) / qreal(KLongTapDuration - 80);
         mLongPressVisualizer->setFrame(frame);
     }
@@ -843,6 +871,16 @@
     handleCurrentChanged(current);
 }
 
+bool HgContainer::hasItemAt(const QPointF& pos)
+{
+    int dummy;
+    HgWidgetItem *item = getItemAt(pos, dummy);
+    if (item) {
+        return item->modelIndex().isValid();
+    }
+    return false;
+}
+
 HgWidgetItem* HgContainer::getItemAt(const QPointF& pos, int& index)
 {
     QPointF p = mapQtToVg(pos);
@@ -891,16 +929,16 @@
 QTransform HgContainer::qtToVgTransform() const
 {
     QTransform t;
-    if (mainWindow()->orientation() == Qt::Vertical)
+    if (mOrientation == Qt::Vertical)
     {
-        t.translate(0, rect().height());
+        t.translate(0, drawableRect().bottom());
         t.scale(1, -1);
     }
     else // horizontal
     {
-        t.translate(rect().height(), 0);
+        t.translate(drawableRect().bottom(), 0);
         t.scale(-1, 1);
-        t.translate(0, rect().width());
+        t.translate(0, drawableRect().right());
         t.rotate(-90, Qt::ZAxis);
     }
     return t;
@@ -949,12 +987,83 @@
     // By default do nothing
 }
 
-void HgContainer::onScrollingEnded()
+QRectF HgContainer::drawableRect() const
+{
+    return rect();
+}
+
+void HgContainer::setDefaultImage(QImage defaultImage)
+{
+    HgQuadRenderer *renderer = mRenderer->getRenderer();
+    if (renderer) {
+        QImage scaled = defaultImage.scaled(mRenderer->getImageSize().toSize());
+        renderer->setDefaultImage(scaled);
+    }
+}
+
+void HgContainer::setItemSizePolicy(HgWidget::ItemSizePolicy policy)
 {
-/*    int index;
-    HgWidgetItem* item = getItemAt(rect().center(), index);
-    if (item && item->modelIndex() != mSelectionModel->currentIndex()) {
-        mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
-    }*/    
+    if (policy != mItemSizePolicy)
+    {
+        mItemSizePolicy = policy;
+        
+        updateItemSizeAndSpacing();
+    }
+}
+
+HgWidget::ItemSizePolicy HgContainer::itemSizePolicy() const
+{
+    return mItemSizePolicy;
+}
+
+void HgContainer::setItemSize(const QSizeF& size)
+{
+    mUserItemSize = size;
+    updateItemSizeAndSpacing();
+}
+
+QSizeF HgContainer::itemSize() const
+{
+    return mRenderer->getImageSize();
 }
 
+void HgContainer::setItemSpacing(const QSizeF& spacing)
+{
+    mUserItemSpacing = spacing;
+    updateItemSizeAndSpacing();
+}
+
+QSizeF HgContainer::itemSpacing() const
+{
+    return mRenderer->getSpacing();
+}
+
+void HgContainer::updateItemSizeAndSpacing()
+{    
+    if (mItemSizePolicy == HgWidget::ItemSizeUserDefined)
+    {
+        mRenderer->setImageSize(mUserItemSize);
+        mRenderer->setSpacing(mUserItemSpacing);
+    }
+}
+
+QSizeF HgContainer::getAutoItemSize() const
+{
+    return mUserItemSize;
+}
+
+QSizeF HgContainer::getAutoItemSpacing() const
+{
+    return mUserItemSpacing;
+}
+
+Qt::Orientation HgContainer::scrollDirection() const
+{
+    return mRenderer->getOrientation();
+}
+
+qreal HgContainer::scrollPosition() const
+{
+    return mSpring.pos().x();
+}
+
--- a/ganeswidgets/src/HgScrollBufferManager.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/HgScrollBufferManager.cpp	Mon May 03 13:32:54 2010 +0300
@@ -216,145 +216,368 @@
         mTotalCount-1 : mBufferPosition+mBufferSize;
 }
 
-void HgScrollBufferManager::removeItems(int start, int end, int totalCount)
+void HgScrollBufferManager::addItems(int start, int end)
 {
-    int oldTotalCount = mTotalCount;
-    mTotalCount = totalCount;
+    FUNC_LOG;
+
+    mTotalCount += (end-start+1);
+    int lastBufferItem = mBufferPosition+mBufferSize-1;
 
-    if (isInsideBuffer(start, end)) {
-        if (mTotalCount > mBufferSize && mBufferPosition+mBufferSize == oldTotalCount) {
-            // We are at the end of items, move buffer
-            int oldBufferPos = mBufferPosition;
-            mBufferPosition = qMax(0, totalCount-mBufferSize);
+    if (start < mBufferPosition) {
+        simpleAddItems(start, end);
+        // New items push the buffer forward, items inside the buffer do not change
+    }
+    // Check buffer higher limit
+    else if (start <= lastBufferItem && end > lastBufferItem) {
+        simpleAddItems(start, lastBufferItem);
+        // Items added after the buffer are ignored
+    }
+    else {
+        simpleAddItems(start, end);
+    }
+}
+
+void HgScrollBufferManager::removeItems(int start, int end)
+{
+    FUNC_LOG;
+
+    int lastBufferItem = mBufferPosition+mBufferSize-1;
+    int removedItemCount = end-start+1;
 
-            if (start < oldBufferPos) { // Removed items are partially inside buffer
-                emit requestItems(mBufferPosition, start-1);
-            }
-            else {
-                emit requestItems(mBufferPosition, oldBufferPos-1);
-            }
-        }
-        else {
-            int first = qBound(mBufferPosition, start, mBufferPosition+mBufferSize-1);
-            int last = qBound(mBufferPosition, end, mBufferPosition+mBufferSize-1);
+    if (mTotalCount < mBufferSize) {
+        // Do nothing
+    }
+    else if (start > lastBufferItem) {
+        // Do nothing
+    }
+    else if (end < mBufferPosition) {
+        mTotalCount = mTotalCount-removedItemCount;
+        simpleRemoveItems(start, end);
+    }
+    else if (start < mBufferPosition && end > lastBufferItem) {
+        mTotalCount = mTotalCount-removedItemCount;
+        mBufferPosition = qBound(0, mBufferPosition, mTotalCount-mBufferSize);
+        resetBuffer(mBufferPosition, mTotalCount);
+    }
+    // Check buffer higher limit
+    else if (start <= lastBufferItem && end > lastBufferItem) {
+        mTotalCount = mTotalCount-(end-lastBufferItem);
+        simpleRemoveItems(lastBufferItem+1, end);
+        mTotalCount = mTotalCount-(lastBufferItem-start+1);
+        simpleRemoveItems(start, lastBufferItem);
+        // Order does matter
+        mTotalCount = mTotalCount-(end-lastBufferItem);
+        simpleRemoveItems(lastBufferItem+1, end);
+        mTotalCount = mTotalCount-(lastBufferItem-start+1);
+        simpleRemoveItems(start, lastBufferItem);
+    }
+    // Check buffer lower limit
+    else if (start < mBufferPosition && end >= mBufferPosition) {
+        // Order does matter
+        mTotalCount = mTotalCount-(end-mBufferPosition+1);
+        simpleRemoveItems(mBufferPosition, end);
+        mTotalCount = mTotalCount-(mBufferPosition-start);
+        simpleRemoveItems(start, mBufferPosition-1);
+    }
+    else {
+        mTotalCount = mTotalCount-removedItemCount;
+        simpleRemoveItems(start, end);
+    }
+}
 
-            // Requested from the end
-            emit requestItems(mBufferPosition+mBufferSize-(last-first+1),
-                              qMin(mBufferPosition+mBufferSize-1, mTotalCount));
-        }
+void HgScrollBufferManager::moveItems(int start, int end, int target)
+{
+    int lastBufferItem = mBufferPosition+mBufferSize-1;
+
+    INFO("Move" << start << "-" << end << "to" << target << ",buffer:" << mBufferPosition << "-" << lastBufferItem << "total count:" << mTotalCount);
+
+    if (mTotalCount < mBufferSize) {
+        // Do nothing
+    }
+    else if (start < mBufferPosition && end > lastBufferItem) {
+        resetBuffer(mBufferPosition, mTotalCount);
+    }
+    else if (start > lastBufferItem && target > lastBufferItem) {
+        // Do nothing
+    }
+    else if (start > lastBufferItem && target < mBufferPosition) {
+        simpleAddItems(start, end);
+    }
+    else if (end < mBufferPosition && target < mBufferPosition) {
+        // Do nothing
+    }
+    else if (end < mBufferPosition && target > lastBufferItem) {
+        simpleRemoveItems(start, end);
+    }
+    else if (start >= mBufferPosition && end <= lastBufferItem &&
+             target >= mBufferPosition && target <= lastBufferItem) {
+        // Do nothing
+    }
+    else {
+        // Rare and complicated use cases: reset the whole buffer
+        resetBuffer(mBufferPosition, mTotalCount);
     }
 }
 
-void HgScrollBufferManager::addItems(int start, int end, int totalCount)
+void HgScrollBufferManager::flushRequestBuffers()
 {
-    int oldTotalCount = mTotalCount;
-    mTotalCount = totalCount;
+    FUNC_LOG;
+
+    qSort(mReleaseBuffer);
+    int releaseCount = mReleaseBuffer.count();
+    int lastReleased = -1;
+    for (int i = 0; i < releaseCount; i++) {
+        UpdatePair update = mReleaseBuffer.at(i);
+        emit releaseItems(qMax(lastReleased+1, update.start()), update.end());
+        lastReleased = update.end();
+    }
+    mReleaseBuffer.clear();
 
-    if (isInsideBuffer(start, end)) {
-        int first = start;
-        int last = end;
+    qSort(mRequestBuffer);
+    int requestCount = mRequestBuffer.count();
+    int lastRequested = -1;
+    for (int i = 0; i < requestCount; i++) {
+        UpdatePair update = mRequestBuffer.at(i);
+        emit requestItems(qMax(lastRequested+1, update.start()), update.end());
+        lastRequested = update.end();
+    }
+    mRequestBuffer.clear();
+}
+
+int HgScrollBufferManager::changeBufferPosition(int newPos)
+{
+    FUNC_LOG;
+    INFO("Change buffer position to" << newPos << "total count:" << mTotalCount);
+    HANDLE_ERROR_BOOL((newPos >= 0));
+    HANDLE_ERROR_BOOL((newPos+mBufferSize <= mTotalCount));
+
+    int bufferShift = newPos-mBufferPosition;
+    if (bufferShift > 0) {
+        mRequestBuffer.shiftRight(mBufferPosition, bufferShift);
+        mReleaseBuffer.shiftRight(mBufferPosition, bufferShift);
+    }
+    else if (bufferShift < 0) {
+        mRequestBuffer.shiftLeft(mBufferPosition, -bufferShift);
+        mReleaseBuffer.shiftLeft(mBufferPosition, -bufferShift);
+    }
+    mBufferPosition = newPos;
+    return bufferShift;
+}
 
-        if (mTotalCount > mBufferSize && mBufferPosition+mBufferSize == oldTotalCount) {
-            // We are at the end of items, keep it that way
-            int oldBufferPos = mBufferPosition;
-            mBufferPosition = qMin(mBufferPosition+(end-start+1), totalCount-mBufferSize);
+/**
+    This function manages only simple item additions: all items are either
+    outside the buffer or inside it.
+    Firs call prepare, then update model, then call fecth.
+*/
+void HgScrollBufferManager::simpleAddItems(int start, int end)
+{
+    FUNC_LOG;
+
+    int lastBufferItem = mBufferPosition+mBufferSize-1;
+    int numAddedItems = end-start+1; // [start, end] inclusive
 
-            if (oldBufferPos < mBufferPosition) {
-                // Release from the beginning
-                emit releaseItems(oldBufferPos, mBufferPosition-1);
-            }
+    if (mTotalCount < mBufferSize) {
+        appendRequestBuffer(start, numAddedItems);
+    }
+    else if (start > lastBufferItem) {
+        // Do nothing
+    }
+    else if (start <= mBufferPosition) {
+        changeBufferPosition(mBufferPosition+numAddedItems);
+        // No need to fetch items, the indexes just change
+    }
+    else {
+        // free from end
+        appendReleaseBuffer(lastBufferItem+1-numAddedItems, numAddedItems);
+        mReleaseBuffer.shiftRight(start, numAddedItems);
+        mRequestBuffer.shiftRight(start, numAddedItems);
+        appendRequestBuffer(start, numAddedItems);
+    }
+}
 
-            // Added items may fall outside the buffer as the buffer is moved
-            if (isInsideBuffer(start, end)) {
-                first = qBound(mBufferPosition, start, mBufferPosition+mBufferSize-1);
-                last = qBound(mBufferPosition, end, mBufferPosition+mBufferSize-1);
-                emit requestItems(first, last);
-            }
+/**
+    This function manages only simple item removals: all items are either
+    outside the buffer or inside it.
+    Firs call prepare, then update model, then call fecth.
+*/
+void HgScrollBufferManager::simpleRemoveItems(int start, int end)
+{
+    FUNC_LOG;
+
+    int lastBufferItem = mBufferPosition+mBufferSize-1;
+    int numRemovedItems = end-start+1; // [start, end] inclusive
+
+    if (start > lastBufferItem) {
+        // Do nothing
+    }
+    else if (end < mBufferPosition) {
+        changeBufferPosition(qMax(0, mBufferPosition-numRemovedItems));
+        // No need to fetch items, the indexes just change
+    }
+    else {
+        if (mTotalCount < mBufferPosition+mBufferSize) {
+            // Buffer is at the end of items
+            int bufferShift = changeBufferPosition(qMax(0, mTotalCount-mBufferSize));
+            // Fetch from beginning
+            // Releasing removed items has been done outside this class
+            appendRequestBuffer(mBufferPosition, qAbs(bufferShift));
         }
         else {
-            first = qBound(mBufferPosition, start, mBufferPosition+mBufferSize-1);
-            last = qBound(mBufferPosition, end, mBufferPosition+mBufferSize-1);
-
-            if (mTotalCount > mBufferSize) {
-                // Release from the end
-                emit releaseItems(mBufferPosition+mBufferSize,
-                                  mBufferPosition+mBufferSize+(last-first+1)-1);
-            }
-            // If all the items fit in the buffer no need to release items
-
-            emit requestItems(first, last);
+            // Fetch from end
+            appendRequestBuffer(lastBufferItem+1-numRemovedItems, numRemovedItems);
         }
     }
 }
 
-void HgScrollBufferManager::moveItems(int start, int end, int target, int totalCount)
+void HgScrollBufferManager::appendRequestBuffer(int start, int count)
+{
+    FUNC_LOG;
+    INFO("Request items" << start << ":" << count)
+
+    mRequestBuffer.add(start, count);
+    mReleaseBuffer.remove(start, count);
+}
+
+void HgScrollBufferManager::appendReleaseBuffer(int start, int count)
+{
+    FUNC_LOG;
+    INFO("Release items" << start << ":" << count)
+
+    mReleaseBuffer.add(start, count);
+    mRequestBuffer.remove(start, count);
+}
+
+UpdatePair::UpdatePair(int start, int count) : mStart(start), mCount(count)
 {
-    if (isInsideBuffer(start) && isInsideBuffer(end) && isInsideBuffer(target)) {
-        return;
-    }
+    HANDLE_ERROR_BOOL(mCount > 0);
+}
+
+int UpdatePair::start() const
+{
+    return mStart;
+}
+
+int UpdatePair::end() const
+{
+    return mStart+mCount-1;
+}
 
-    if (!isInsideBuffer(start, end) && !isInsideBuffer(target)) {
-        return;
-    }
+bool UpdatePair::adjacent(int start, int count) const
+{
+    if (start+count < mStart) return false;
+    if (start > mStart+mCount) return false;
+    return true;
+}
+
+bool UpdatePair::contains(const UpdatePair &other) const
+{
+    if (other.mStart+other.mCount-1 < mStart) return false;
+    if (other.mStart > mStart+mCount-1) return false;
+    return true;
+}
 
-    if (!isInsideBuffer(target)) {
-        if (isInsideBuffer(start) && isInsideBuffer(end)) {
-            if (mBufferPosition+mBufferSize == mTotalCount) {
-                // Fetch from beginning
-                emit requestItems(mBufferPosition, mBufferPosition+end-start);
-            }
-            else {
-                // Fetch from end
-                emit requestItems(mBufferPosition+mBufferSize-(end-start+1),
-                                  qMin(mBufferPosition+mBufferSize-1, mTotalCount));
-            }
+void UpdatePair::extend(int start, int count)
+{
+    int end = qMax(mStart+mCount, start+count);
+    mStart = qMin(mStart, start);
+    mCount = end-mStart;
+    INFO("Pair extended to:" << mStart << ":" << mCount);
+}
+
+void UpdatePair::subtract(int start, int count)
+{
+    int end = qMin(mStart+mCount, start+count);
+    mStart = qMax(mStart, start);
+    mCount = end-mStart;
+    INFO("Pair reduced to:" << mStart << ":" << mCount);
+}
+
+void UpdatePair::shiftRight(int count)
+{
+    mStart += count;
+    INFO("Pair shifted to:" << mStart << ":" << mCount);
+}
+
+void UpdatePair::shiftLeft(int count)
+{
+    mStart -= count;
+    HANDLE_ERROR_BOOL((mStart >= 0));
+    INFO("Pair shifted to:" << mStart << ":" << mCount);
+}
+
+bool UpdatePair::operator== (const UpdatePair &other) const
+{
+    return mStart == other.mStart && mCount == other.mCount;
+}
+
+bool UpdatePair::operator< (const UpdatePair &other) const
+{
+    return (mStart < other.mStart || mStart == other.mStart && mCount < other.mCount);
+}
+
+UpdateBuffer::UpdateBuffer()
+{
+    FUNC_LOG;
+}
+
+void UpdateBuffer::add(int start, int count)
+{
+    FUNC_LOG;
+
+    int itemCount = this->count();
+    for (int i = 0; i < itemCount; i++) {
+        if (at(i).contains(UpdatePair(start, count))) {
+            // It is already there
+            return;
         }
-        else if (isInsideBuffer(start) && end >= mBufferPosition+mBufferSize-1) {
-            emit requestItems(start, mBufferPosition+mBufferSize-1);
-        }
-        else if (start <= mBufferPosition && isInsideBuffer(end)) {
-            emit requestItems(mBufferPosition, end);
-        }
-        else {
-            emit requestItems(mBufferPosition, mBufferPosition+mBufferSize-1);
+        if (at(i).adjacent(start, count)) {
+            (*this)[i].extend(start, count);
+            return;
         }
     }
+    append(UpdatePair(start, count));
+}
 
-    if (isInsideBuffer(target)) {
-        // start-end may be partially inside buffer
-        if (!isInsideBuffer(start, end)) {
-            addItems(target, target+end-start, totalCount);
+void UpdateBuffer::remove(int start, int count)
+{
+    FUNC_LOG;
+
+    int itemCount = this->count();
+    for (int i = itemCount-1; i >= 0; i--) {
+        UpdatePair pair = at(i);
+        UpdatePair comp = UpdatePair(start, count);
+        if (comp.contains(pair)) {
+            INFO("Removing pair" << pair.start() << "-" << pair.end());
+            removeAt(i);
         }
-        else if (isInsideBuffer(start)) {
-            addItems(target+(mBufferPosition+mBufferSize-start), target+end-start, totalCount);
+        else if (pair.contains(comp)) {
+            // Subtraction from middle is not applicable in mediawall use cases
+            (*this)[i].subtract(start, count);
         }
-        else { // end is inside buffer
-            addItems(target, target+mBufferPosition-start-1, totalCount);
+        // Item may be present in multiple pairs.
+    }
+}
+
+void UpdateBuffer::shiftRight(int startingFrom, int amount)
+{
+    FUNC_LOG;
+
+    int itemCount = this->count();
+    for (int i = 0; i < itemCount; i++) {
+        if (at(i).start() >= startingFrom) {
+            (*this)[i].shiftRight(amount);
         }
     }
 }
 
-bool HgScrollBufferManager::isInsideBuffer(int pos)
+void UpdateBuffer::shiftLeft(int startingFrom, int amount)
 {
-    return (pos >= mBufferPosition && pos < mBufferPosition+mBufferSize);
-}
-
-bool HgScrollBufferManager::isInsideBuffer(int start, int end)
-{
-    INFO("Buffer:" << mBufferPosition << "-" << mBufferPosition+mBufferSize-1);
-    INFO("Change:" << start << "-" << end);
+    FUNC_LOG;
 
-    if (isInsideBuffer(start)) {
-        return true;
-    }
-    if (isInsideBuffer(end)) {
-        return true;
+    int itemCount = this->count();
+    for (int i = 0; i < itemCount; i++) {
+        if (at(i).start() >= startingFrom) {
+            (*this)[i].shiftLeft(amount);
+        }
     }
-    if (start < mBufferPosition && end >= mBufferPosition+mBufferSize) {
-        return true;
-    }
-
-    INFO("Buffer not affected");
-    return false;
 }
-
--- a/ganeswidgets/src/hgcoverflowcontainer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgcoverflowcontainer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -16,6 +16,7 @@
 */
 
 #include <QGesture>
+#include <QGraphicsSceneResizeEvent>
 #include <QPainter>
 #include <hblabel.h>
 #include "hgcoverflowcontainer.h"
@@ -34,8 +35,9 @@
     mDescriptionLabel(0),
     mTitlePosition(HgMediawall::PositionAboveImage),
     mDescriptionPosition(HgMediawall::PositionNone),
-    mCenterIconTop(0),
-    mPrevPos(-1)
+    mPrevPos(-1),
+    mAspectRatio(1),
+    mDrawableRect(rect())
 {
     mTitleLabel = new HbLabel(this);
     mTitleLabel->setZValue(zValue()+1);
@@ -46,6 +48,9 @@
     mDescriptionLabel->setZValue(zValue()+1);
     mDescriptionLabel->setAlignment(Qt::AlignCenter);
     mDescriptionLabel->setVisible(false);
+    
+    mUserItemSize = QSize(250,250);
+    mUserItemSpacing = QSize(1,1);
 }
 
 HgCoverflowContainer::~HgCoverflowContainer()
@@ -64,24 +69,18 @@
 
     HbWidget::resizeEvent(event);
 
-    QSizeF s(size());
-    qreal side = qMin(s.height()/1.8, s.width()/1.8);
-    INFO("Setting image size to:" << side << "," << side);
-    mRenderer->setImageSize(QSizeF(side, side));
-    mCenterIconTop = (s.height()-side)/2;
-
-    positionLabels();
+    updatePositions();    
 }
 
 // from HgContainer
-HgMediaWallRenderer* HgCoverflowContainer::createRenderer()
+HgMediaWallRenderer* HgCoverflowContainer::createRenderer(Qt::Orientation scrollDirection)
 {
-    HgMediaWallRenderer* renderer = new HgMediaWallRenderer(this);
-    renderer->setImageSize(QSizeF(200, 200));
+    HgMediaWallRenderer* renderer = new HgMediaWallRenderer(this, scrollDirection, true);
+    renderer->setImageSize(mUserItemSize);
     renderer->enableCoverflowMode(true);
     renderer->setRowCount(1, renderer->getImageSize(), false);
     renderer->enableReflections(true);
-    renderer->setSpacing(QSizeF(1,1));
+    renderer->setSpacing(mUserItemSpacing);
     renderer->setFrontCoverElevationFactor(0.5);
     return renderer;
 }
@@ -121,12 +120,16 @@
 {
     HgContainer::onScrollPositionChanged(pos);
 
-    if (mPrevPos != (int)pos) {
-        mPrevPos = (int)pos;
-        HgWidgetItem* item = itemByIndex((int)pos);
+    qreal ipos = floorf(pos);
+    qreal frac = pos - ipos;
+    qreal p = frac > 0.5 ? ipos + 1.0f : ipos;
+
+    if (mPrevPos != (int)p) {
+        mPrevPos = (int)p;        
+        HgWidgetItem* item = itemByIndex((int)p);
         if (item && item->modelIndex() != mSelectionModel->currentIndex()) {
             mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
-        }            
+        }
     }
 }
 
@@ -152,6 +155,15 @@
             updateLabels(current);
         }
     }
+
+    if (firstIndex == 0) {
+        // Take preferred aspect ratio from the first image
+        const HgImage *firstImage = image(0);
+        if (firstImage && firstImage->height() != 0) {
+            mAspectRatio = qMax((qreal)0.1, (qreal)firstImage->width()/firstImage->height()); // Don't let aspect ratio go to 0
+            updatePositions();
+        }
+    }
 }
 
 void HgCoverflowContainer::setTitlePosition(HgMediawall::LabelPosition position)
@@ -160,7 +172,7 @@
 
     if (mTitlePosition != position) {
         mTitlePosition = position;
-        positionLabels();
+        updatePositions();
     }
 }
 
@@ -177,7 +189,7 @@
 
     if (mDescriptionPosition != position) {
         mDescriptionPosition = position;
-        positionLabels();
+        updatePositions();
     }
 }
 
@@ -195,7 +207,7 @@
     if (!mTitleLabel) return;
     if (mTitleLabel->fontSpec() != fontSpec) {
         mTitleLabel->setFontSpec(fontSpec);
-        positionLabels();
+        updatePositions();
     }
 }
 
@@ -214,7 +226,7 @@
     if (!mDescriptionLabel) return;
     if (mDescriptionLabel->fontSpec() != fontSpec) {
         mDescriptionLabel->setFontSpec(fontSpec);
-        positionLabels();
+        updatePositions();
     }
 }
 
@@ -226,6 +238,106 @@
     return mDescriptionLabel->fontSpec();
 }
 
+void HgCoverflowContainer::calculatePositions()
+{
+    FUNC_LOG;
+    HANDLE_ERROR_NULL(mTitleLabel);
+    HANDLE_ERROR_NULL(mDescriptionLabel);
+    
+    int height = size().height();
+    int width = size().width();
+    int titleHeight = QFontMetrics(mTitleLabel->effectiveFontSpec().font()).height();
+    int descriptionHeight = QFontMetrics(mDescriptionLabel->effectiveFontSpec().font()).height();
+    qreal usableHeight = height-KLabelMargin;
+    if (mTitlePosition != HgMediawall::PositionNone) {
+        usableHeight -= (titleHeight+KLabelMargin);
+    }
+    if (mDescriptionPosition != HgMediawall::PositionNone) {
+        usableHeight -= (descriptionHeight+KLabelMargin);
+    }
+
+    usableHeight *= 0.8; // Leave some space for the reflection
+    if (usableHeight <= 0) return;
+
+    qreal usableWidth = width/2;
+    if (usableWidth <= 0) return;
+
+    mDrawableRect = rect();
+    QSizeF imageSize;
+    if (usableWidth/usableHeight > mAspectRatio) {
+        imageSize.setHeight(usableHeight);
+        imageSize.setWidth(mAspectRatio*usableHeight);
+    }
+    else {
+        imageSize.setWidth(usableWidth);
+        imageSize.setHeight(usableWidth/mAspectRatio);
+        mDrawableRect.setTop((usableHeight-imageSize.height())/2);
+    }
+
+    QRectF titleGeometry(0, mDrawableRect.top()+KLabelMargin, width, titleHeight);
+    QRectF descriptionGeometry(0, mDrawableRect.top()+KLabelMargin, width, descriptionHeight);
+
+    if (mTitlePosition == HgMediawall::PositionAboveImage &&
+        mDescriptionPosition == HgMediawall::PositionAboveImage) {
+        // titleGeometry default is ok
+        descriptionGeometry.moveTop(titleGeometry.bottom()+KLabelMargin);
+        mDrawableRect.setTop(descriptionGeometry.bottom()+KLabelMargin);
+    }
+    else if (mTitlePosition == HgMediawall::PositionBelowImage &&
+             mDescriptionPosition == HgMediawall::PositionBelowImage) {
+        titleGeometry.moveTop(mDrawableRect.top()+imageSize.height()+KLabelMargin);
+        descriptionGeometry.moveTop(titleGeometry.bottom()+KLabelMargin);
+    }
+    else {
+        if (mTitlePosition == HgMediawall::PositionAboveImage) {
+            // titleGeometry default is ok
+            mDrawableRect.setTop(titleGeometry.bottom()+KLabelMargin);
+        }
+        else if (mDescriptionPosition == HgMediawall::PositionAboveImage) {
+            // descriptionGeometry default is ok
+            mDrawableRect.setTop(descriptionGeometry.bottom()+KLabelMargin);
+        }
+
+        if (mTitlePosition == HgMediawall::PositionBelowImage) {
+            titleGeometry.moveTop(mDrawableRect.top()+imageSize.height()+KLabelMargin);
+        }
+        else if (mDescriptionPosition == HgMediawall::PositionBelowImage) {
+            descriptionGeometry.moveTop(mDrawableRect.top()+imageSize.height()+KLabelMargin);
+        }
+    }
+
+    INFO("Setting image size to:" << imageSize << "(total size:" << QSize(width, height)
+        << "usable size:" << QSizeF(usableWidth, usableHeight) << ", aspect ratio is:" << mAspectRatio << ")" << "Drawable rect:" << mDrawableRect);
+    mRenderer->setImageSize(imageSize);
+    mAutoSize = imageSize;
+    mDrawableRect.setHeight(imageSize.height()/0.8);
+
+    if (mTitlePosition != HgMediawall::PositionNone) {
+        INFO("Title geometry:" << titleGeometry);
+        mTitleLabel->setGeometry(titleGeometry);
+        mTitleLabel->setVisible(true);
+    }
+    else {
+        mTitleLabel->setVisible(false);
+    }
+    if (mDescriptionPosition != HgMediawall::PositionNone) {
+        INFO("Description geometry:" << descriptionGeometry);
+        mDescriptionLabel->setGeometry(descriptionGeometry);
+        mDescriptionLabel->setVisible(true);
+    }
+    else {
+        mDescriptionLabel->setVisible(false);
+    }
+
+    // This may be called before selection model is set.
+    if (mSelectionModel && mSelectionModel->currentIndex().isValid()) {
+        updateLabels(mSelectionModel->currentIndex().row());
+    }
+    
+    mRenderer->setSpacing(QSizeF(1,1));
+        
+}
+
 void HgCoverflowContainer::positionLabels()
 {
     FUNC_LOG;
@@ -233,6 +345,8 @@
     HANDLE_ERROR_NULL(mDescriptionLabel);
     HANDLE_ERROR_NULL(mSelectionModel);
 
+    int centerIconTop = (size().height() - mRenderer->getImageSize().height()) / 2;
+
     int height = size().height();
     int width = size().width();
     int titleHeight = QFontMetrics(mTitleLabel->effectiveFontSpec().font()).height();
@@ -242,7 +356,7 @@
         mDescriptionPosition == HgMediawall::PositionAboveImage) {
         mTitleLabel->setGeometry(QRectF(
             0,
-            qMax(KLabelMargin, mCenterIconTop-2*KLabelMargin-titleHeight-descriptionHeight),
+            qMax(KLabelMargin, centerIconTop-2*KLabelMargin-titleHeight-descriptionHeight),
             width, titleHeight));
         mDescriptionLabel->setGeometry(QRectF(
             0,
@@ -264,7 +378,7 @@
         if (mTitlePosition == HgMediawall::PositionAboveImage) {
             mTitleLabel->setGeometry(QRectF(
                 0,
-                qMax(KLabelMargin, mCenterIconTop-KLabelMargin-titleHeight),
+                qMax(KLabelMargin, centerIconTop-KLabelMargin-titleHeight),
                 width, titleHeight));
         }
         else if (mTitlePosition == HgMediawall::PositionBelowImage) {
@@ -277,7 +391,7 @@
         if (mDescriptionPosition == HgMediawall::PositionAboveImage) {
             mDescriptionLabel->setGeometry(QRectF(
                 0,
-                qMax(KLabelMargin, mCenterIconTop-KLabelMargin-descriptionHeight),
+                qMax(KLabelMargin, centerIconTop-KLabelMargin-descriptionHeight),
                 width, descriptionHeight));
         }
         else if (mDescriptionPosition == HgMediawall::PositionBelowImage) {
@@ -294,11 +408,12 @@
     INFO("Title geometry:" << mTitleLabel->geometry() << "visible:" << mTitleLabel->isVisible());
     INFO("Description geometry:" << mDescriptionLabel->geometry() << "visible:" << mDescriptionLabel->isVisible());
 
-    if (mSelectionModel->currentIndex().isValid()) {
+    if ( mSelectionModel &&  mSelectionModel->currentIndex().isValid()) {
         updateLabels(mSelectionModel->currentIndex().row());
     }
 }
 
+
 void HgCoverflowContainer::updateLabels(int itemIndex)
 {
     FUNC_LOG;
@@ -317,3 +432,75 @@
     p.setX((int)pos.x());
     HgContainer::scrollToPosition(p,animate);
 }
+
+QRectF HgCoverflowContainer::drawableRect() const
+{
+    if (mItemSizePolicy == HgWidget::ItemSizeAutomatic)
+        return mDrawableRect;
+    
+    return rect();
+}
+
+void HgCoverflowContainer::setDefaultImage(QImage defaultImage)
+{
+    HgContainer::setDefaultImage(defaultImage);
+
+    if (!defaultImage.isNull()) {
+        mAspectRatio = qMax((qreal)0.1, (qreal)defaultImage.width()/defaultImage.height()); // Don't let aspect ratio go to 0
+        updatePositions();
+    }
+}
+
+QSizeF HgCoverflowContainer::getAutoItemSize() const
+{
+    return mAutoSize;
+}
+
+QSizeF HgCoverflowContainer::getAutoItemSpacing() const
+{    
+    return QSizeF(1,1);
+}
+
+void HgCoverflowContainer::updateItemSizeAndSpacing()
+{
+    HgContainer::updateItemSizeAndSpacing();
+    
+    updatePositions();
+}
+
+
+void HgCoverflowContainer::updatePositions()
+{
+    if (mItemSizePolicy == HgWidget::ItemSizeAutomatic)
+        calculatePositions();
+    else
+    {
+        positionLabels();
+    }
+}
+
+void HgCoverflowContainer::setFrontItemPositionDelta(const QPointF& position)
+{
+    if (!mRenderer)
+        return;
+    
+    mRenderer->setFrontItemPosition(position);
+}
+
+QPointF HgCoverflowContainer::frontItemPositionDelta() const
+{
+    return mRenderer ? mRenderer->frontItemPosition() : QPointF();
+}
+
+void HgCoverflowContainer::enableReflections(bool enabled)
+{
+    if (mRenderer)
+        mRenderer->enableReflections(enabled);
+}
+
+bool HgCoverflowContainer::reflectionsEnabled() const
+{
+    return mRenderer ? mRenderer->reflectionsEnabled() : false;
+}
+
+
--- a/ganeswidgets/src/hggrid.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hggrid.cpp	Mon May 03 13:32:54 2010 +0300
@@ -20,7 +20,7 @@
 #include "hggridcontainer.h"
 
 HgGrid::HgGrid( Qt::Orientation scrollDirection, QGraphicsItem *parent ):
-    HgWidget(new HgGridPrivate, parent)
+    HgWidget( *new HgGridPrivate, parent )
 {
     Q_D(HgGrid);
     d->q_ptr = this;
@@ -28,6 +28,16 @@
     d->init(scrollDirection);
 }
 
+HgGrid::HgGrid( Qt::Orientation scrollDirection, HgGridPrivate &dd, QGraphicsItem *parent) : 
+    HgWidget( dd, parent )
+{
+    Q_D( HgGrid );
+    d->q_ptr = this;    
+    
+    d->init(scrollDirection);
+}
+
+
 HgGrid::~HgGrid()
 {
 }
--- a/ganeswidgets/src/hggrid_p.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hggrid_p.cpp	Mon May 03 13:32:54 2010 +0300
@@ -20,7 +20,7 @@
 
 static const int BUFFERSIZE(120);
 
-HgGridPrivate::HgGridPrivate() 
+HgGridPrivate::HgGridPrivate() : HgWidgetPrivate()
 {
 
 }
--- a/ganeswidgets/src/hggridcontainer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hggridcontainer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -41,7 +41,10 @@
 
 HgGridContainer::HgGridContainer(QGraphicsItem *parent) : HgContainer(parent)
 {
-    
+
+    mUserItemSize = QSize(120,120);
+    mUserItemSpacing = QSize(1,1);
+
 }
 
 HgGridContainer::~HgGridContainer()
@@ -56,15 +59,15 @@
     updateSelectedItem();
 }
 
-HgMediaWallRenderer* HgGridContainer::createRenderer()
+HgMediaWallRenderer* HgGridContainer::createRenderer(Qt::Orientation scrollDirection)
 {
 
-    HgMediaWallRenderer* renderer = new HgMediaWallRenderer(this);
+    HgMediaWallRenderer* renderer = new HgMediaWallRenderer(this, scrollDirection, false);
     renderer->enableCoverflowMode(false);
-    renderer->setImageSize(QSizeF(105, 80));
+    renderer->setImageSize(mUserItemSize);
     renderer->setRowCount(3, renderer->getImageSize(), false);    
     renderer->enableReflections(false);
-    renderer->setSpacing(QSizeF(1,1));
+    renderer->setSpacing(mUserItemSpacing);
     renderer->setFrontCoverElevationFactor(0.5);    
 
     return renderer;
@@ -102,3 +105,18 @@
     selectItem();
     emit longPressed(hitItem->modelIndex(), pos);    
 }
+
+void HgGridContainer::onScrollPositionChanged(qreal pos)
+{
+    HgContainer::onScrollPositionChanged(pos);
+
+    if (pos < 0) return;    
+    const int index = ((int)pos)*rowCount();
+    if (index > itemCount()) return;
+    
+    HgWidgetItem* item = itemByIndex(index);
+    if (item && item->modelIndex() != mSelectionModel->currentIndex()) {
+        qDebug() << "CURRENT CHANGE" << QString::number(item->modelIndex().row());
+        mSelectionModel->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Current);
+    }    
+}
--- a/ganeswidgets/src/hgindexfeedback.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgindexfeedback.cpp	Mon May 03 13:32:54 2010 +0300
@@ -59,13 +59,13 @@
 */
 HgIndexFeedback::HgIndexFeedback(QGraphicsItem *parent)
     : HbWidget( *new HgIndexFeedbackPrivate, parent, 0)
-    
+
 {
     Q_D( HgIndexFeedback );
     d->q_ptr = this;
 
     HbStyleLoader::registerFilePath(":/hgindexfeedback.css");
-    
+
     d->init();
 }
 
@@ -134,7 +134,7 @@
     }
 
     d->connectModelToIndexFeedback(d->mWidget->selectionModel());
-    
+
     d->connectScrollBarToIndexFeedback(d->mWidget->scrollBar());
 
     connect(d->mWidget, SIGNAL(destroyed(QObject*)),
@@ -178,7 +178,7 @@
         case HbStyle::P_IndexFeedback_popup_text:
             retVal = d->mTextItem;
             break;
-            
+
         case HbStyle::P_IndexFeedback_popup_background:
             retVal = d->mPopupItem;
             break;
@@ -203,12 +203,12 @@
     if (ev->type() == QEvent::GraphicsSceneResize) {
         d->calculatePopupRects();
     }
-    
+
     return QGraphicsItem::sceneEventFilter(watched, ev);
 }
 
 /*
-    Rather than adding signals to HbScrollBar specifically to implement 
+    Rather than adding signals to HbScrollBar specifically to implement
     index feedback, an event filter is used.
 
     Specifically, if a scrollbar which is interactive is pressed or released
@@ -235,7 +235,7 @@
                     d->scrollBarReleased();
                 }
                 break;
-        
+
             case QEvent::GraphicsSceneResize:
             case QEvent::Resize:
                     d->_q_hideIndexFeedbackNow();
@@ -276,14 +276,14 @@
         case HgWidget::IndexFeedbackSingleCharacter:
             {
                 fontSpec = HbFontSpec(HbFontSpec::Primary);
-                fontSpec.setTextPaneHeight(d->textHeight());
+                fontSpec.setTextHeight(d->textHeight());
             }
             break;
-            
+
         case HgWidget::IndexFeedbackThreeCharacter:
             {
                 fontSpec = HbFontSpec(HbFontSpec::Primary);
-                fontSpec.setTextPaneHeight(d->textHeight());
+                fontSpec.setTextHeight(d->textHeight());
             }
             break;
 
@@ -292,7 +292,7 @@
                 fontSpec = HbFontSpec(HbFontSpec::Primary);
                 qreal textPaneHeight = 0;
                 style()->parameter(QLatin1String("hb-param-text-height-primary"), textPaneHeight);
-                fontSpec.setTextPaneHeight( textPaneHeight );
+                fontSpec.setTextHeight( textPaneHeight );
             }
             break;
 
--- a/ganeswidgets/src/hgindexfeedback_p.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgindexfeedback_p.cpp	Mon May 03 13:32:54 2010 +0300
@@ -83,7 +83,8 @@
     mThreeCharHeight(1.0),
     mThreeCharWidth(1.0),
     mStringOffset(0.0),
-    mWidget(0)
+    mWidget(0),
+    mScrollBarPressed(false)
 {
 
 }
--- a/ganeswidgets/src/hgmediawall.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgmediawall.cpp	Mon May 03 13:32:54 2010 +0300
@@ -19,13 +19,22 @@
 #include "hgmediawall_p.h"
 #include "hgwidgets_p.h"
 #include "hgcoverflowcontainer.h"
+#include <hbmainwindow>
 
-HgMediawall::HgMediawall(QGraphicsItem *parent ):
-    HgWidget(new HgMediawallPrivate, parent)
+HgMediawall::HgMediawall(QGraphicsItem *parent ) :
+    HgWidget( *new HgMediawallPrivate, parent )
 {
     Q_D(HgMediawall);
     d->q_ptr = this;
-    d->init();
+    d->init(mainWindow()->orientation());
+}
+
+HgMediawall::HgMediawall(HgMediawallPrivate &dd, QGraphicsItem *parent) : 
+    HgWidget( dd, parent )
+{
+    Q_D(HgMediawall);
+    d->q_ptr = this;    
+    d->init(mainWindow()->orientation());
 }
 
 HgMediawall::~HgMediawall()
@@ -110,4 +119,40 @@
     return d->descriptionFontSpec();
 }
 
+/*!
+ *  Sets front item delta from the center of the widget.
+ */
+void HgMediawall::setFrontItemPositionDelta(const QPointF& position)
+{
+    Q_D(HgMediawall);
+    return d->container()->setFrontItemPositionDelta(position);
+}
+
+/*!
+ * Gets current front items position delta.
+ */
+QPointF HgMediawall::frontItemPositionDelta() const
+{
+    Q_D(const HgMediawall);
+    return d->container()->frontItemPositionDelta();
+}
+
+/**
+ * Enables/disables reflections in the mediawall.
+ */
+void HgMediawall::enableReflections(bool enabled)
+{
+    Q_D(HgMediawall);
+    d->container()->enableReflections(enabled);
+}
+
+/**
+ * Returns true if reflections are enabled.
+ */
+bool HgMediawall::reflectionsEnabled() const
+{
+    Q_D(const HgMediawall);
+    return d->container()->reflectionsEnabled();
+}
+
 // EOF
--- a/ganeswidgets/src/hgmediawall_p.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgmediawall_p.cpp	Mon May 03 13:32:54 2010 +0300
@@ -19,9 +19,10 @@
 #include "hgcoverflowcontainer.h"
 #include "trace.h"
 
-HgMediawallPrivate::HgMediawallPrivate()
+HgMediawallPrivate::HgMediawallPrivate() : HgWidgetPrivate()
 {
     FUNC_LOG;
+    mStaticScrollDirection = true;
 }
 
 HgMediawallPrivate::~HgMediawallPrivate()
@@ -29,14 +30,14 @@
     FUNC_LOG;
 }
 
-void HgMediawallPrivate::init()
+void HgMediawallPrivate::init(Qt::Orientation orientation)
 {
     FUNC_LOG;
 
     Q_Q(HgMediawall);
     HgCoverflowContainer* container = new HgCoverflowContainer(q);
     // Mediawall supports only horizontal scrolling.
-    container->init(Qt::Horizontal);
+    container->init(orientation);
     HgWidgetPrivate::init(container);
 }
 
--- a/ganeswidgets/src/hgmediawallrenderer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgmediawallrenderer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -35,7 +35,6 @@
 #include <qpainter>
 #include <qpaintengine>
 
-const Qt::Orientation KDefaultOrientation(Qt::Vertical);
 const qreal KPi = 3.1415926535897932384626433832795;
 
 static qreal lerp(qreal start, qreal end, qreal t)
@@ -99,13 +98,14 @@
     MyVectorAnimation mScaleAnimation;
 };
 
-HgMediaWallRenderer::HgMediaWallRenderer(HgMediaWallDataProvider* provider) :
+HgMediaWallRenderer::HgMediaWallRenderer(HgMediaWallDataProvider* provider, 
+    Qt::Orientation scrollDirection, bool coverflowMode) :
     mDataProvider(provider),
     mRenderer(NULL),
     mIndicatorRenderer(NULL),
     mRendererInitialized(false),
-    mOrientation(KDefaultOrientation),
-    mNextOrientation(KDefaultOrientation),
+    mOrientation(scrollDirection),
+    mNextOrientation(scrollDirection),
     mStateAnimationAlpha(0),
     mStateAnimationOnGoing(false),
     mAnimationAlpha(0),
@@ -113,7 +113,7 @@
     mOpenedItem(-1),
     mFlipAngle(qreal(360)),
     mZoomAmount(qreal(0.5)),
-    mCoverflowMode(false),
+    mCoverflowMode(coverflowMode),
     mRowCount(1),
     mNextRowCount(1),
     mStateAnimationDuration(300),
@@ -127,12 +127,18 @@
     mFrontCoverElevation(0.4),
     mReflectionsEnabled(true),
     mItemCountChanged(false),
-    mOpenedItemState(ItemClosed)
+    mOpenedItemState(ItemClosed),
+    mFrontItemPosition(0,0),
+    mFrontItemPositionSet(false)    
 {
     createStateMachine();
     mImageFader = new HgImageFader();    
     mRenderer = new HgVgQuadRenderer(256);
     mRendererInitialized = true;
+    if (mCoverflowMode) {
+        mOrientation = Qt::Horizontal;
+        mNextOrientation = mOrientation;
+    }
 }
 
 HgMediaWallRenderer::~HgMediaWallRenderer()
@@ -369,6 +375,14 @@
 
 void HgMediaWallRenderer::setOrientation(Qt::Orientation orientation, bool animate)
 {
+    // coverflow is always horizontal
+    if (mCoverflowMode)
+    {
+        mOrientation = Qt::Horizontal;
+        mNextOrientation = mOrientation;
+        return;
+    }
+    
     if (mOrientation != orientation)
     {
         mStateMachine->setAnimated(animate);
@@ -390,6 +404,7 @@
 
 void HgMediaWallRenderer::drawQuads(QPainter* painter)
 {
+    
     mRenderer->transformQuads(mViewMatrix, mProjMatrix, mRect);
 
     mRenderer->drawQuads(mRect, painter);    
@@ -530,11 +545,21 @@
 
     mViewMatrix = view;
     mProjMatrix = proj;
-    
-    qreal mirrorPlaneY = getRowPosY(mRowCount-1)-mImageSize3D.height()/2;
+
+    qreal mirrorPlaneY;
+    if (mCoverflowMode)
+    {
+        mirrorPlaneY = -mImageSize3D.height()/2;
+    }
+    else // grid
+    {
+        mirrorPlaneY = getRowPosY(mRowCount-1)-mImageSize3D.height()/2;
+    }
+
     mRenderer->setMirroringPlaneY(mirrorPlaneY);
 }
 
+
 void HgMediaWallRenderer::updateSpacingAndImageSize()
 {
     qreal div = mRect.width() <= mRect.height() ? mRect.width() : mRect.height();
@@ -645,14 +670,16 @@
 
 qreal HgMediaWallRenderer::getWorldWidth() const
 {   
-    qreal width = (qreal)mDataProvider->imageCount() / (qreal)mRowCount - 1.0f;
+    qreal width = ceil((qreal)mDataProvider->imageCount() / (qreal)mRowCount - 1.0f);
     
+    // if we are in vertical orientation we want last and first item
+    // to place at the top and bottom of the screen instead of center
     if (mOrientation == Qt::Vertical)
     {
         qreal step = mSpacing2D.height() + mImageSize2D.height(); 
         width -= (mRect.height() / step - 1.0f);
     }
-   
+       
     return width;
 }
 
@@ -731,8 +758,8 @@
     qreal frac = (position.x() - ipos) * step;
     qreal posX = -(qreal)(selectedItemIndex + 0) * step - frac;
     qreal zFar = -mFrontCoverElevation;
-    qreal posY = 0;    
-    
+    qreal posY = 0;
+
     int count = mDataProvider->imageCount();
     int quadIndex = 0;
     int itemIndex = ((int)(ipos - (qreal)selectedItemIndex));
@@ -974,4 +1001,15 @@
     return mRenderer->getVisibleQuads(QRectF(0, 0, mRect.width(), mRect.height()));
 }
 
+void HgMediaWallRenderer::setFrontItemPosition(const QPointF& position)
+{
+    mFrontItemPosition = position;
+    
+    mRenderer->setTranslation(
+        QVector2D(position.x(), position.y()));    
+}
 
+QPointF HgMediaWallRenderer::frontItemPosition() const
+{
+    return mFrontItemPosition;
+}
--- a/ganeswidgets/src/hgquadrenderer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgquadrenderer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -54,3 +54,29 @@
     mImageFader = fader;
 }
 
+void HgQuadRenderer::setDefaultImage(QImage defaultImage)
+{    
+    mDefaultImage = defaultImage;
+}
+
+void HgQuadRenderer::setTranslation(const QVector2D& translate)
+{
+    mTranslation = translate;
+}
+
+HgQuad* HgQuadRenderer::getQuadByUserData(const QVariant& userData) const
+{
+    for (int i = 0; i < mQuads.count(); i++)
+    {
+        HgQuad* quad = mQuads[i];
+        if (quad->userData() == userData)
+            return quad;
+    }
+    return NULL;
+}
+
+QImage HgQuadRenderer::getDefaultImage() const
+{
+    return mDefaultImage;
+}
+
--- a/ganeswidgets/src/hgvgimage.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgvgimage.cpp	Mon May 03 13:32:54 2010 +0300
@@ -75,7 +75,7 @@
 }
 
 
-void HgVgImage::setImage(QImage& image)
+void HgVgImage::setImage(const QImage& image)
 {
     if (image.isNull())
         return;
@@ -89,6 +89,12 @@
 
 }
 
+QImage HgVgImage::getQImage() const
+{
+    return mQImage;
+}
+
+
 void HgVgImage::releaseImage()
 {
     if (mVgImage != VG_INVALID_HANDLE)
@@ -108,6 +114,8 @@
 
 void HgVgImage::upload(bool mirror)
 {
+    if( mQImage.isNull())
+        return;    
     
     if (mVgImage == VG_INVALID_HANDLE)
     {            
@@ -140,8 +148,12 @@
             return;
         }
         
-        vgImageSubData(mVgImage, mQImage.bits(), mQImage.bytesPerLine(), 
-            format, 0, 0, mQImage.width(), mQImage.height() );        
+        // bits function performs deep copy if we dont fetch data with const specifier.
+        const uchar *bits = mQImage.bits();
+        
+        vgImageSubData(mVgImage, bits, mQImage.bytesPerLine(), 
+            format, 0, 0, mQImage.width(), mQImage.height() );
+        
     }
     
     if (mirror && mMirrorImage == VG_INVALID_HANDLE)
@@ -162,10 +174,10 @@
         {
             qreal t = qreal(i) / qreal(mirrorImage.height());
             int a = (int)(t * 255.0);
+            uchar* scanline = mirrorImage.scanLine(i);
             for (int j = 0; j < mirrorImage.width(); j++)
             {
-                QRgb rgb = mirrorImage.pixel(j, i);
-                mirrorImage.setPixel(j, i, qRgba(qRed(rgb), qGreen(rgb), qBlue(rgb), a));
+                scanline[j*4+3] = a;
             }        
         }
         
--- a/ganeswidgets/src/hgvgquadrenderer.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgvgquadrenderer.cpp	Mon May 03 13:32:54 2010 +0300
@@ -38,18 +38,20 @@
     int index() const;
     bool isPointInside(const QPointF& point) const;
     void transformQuad(int index, const QMatrix4x4& matrix, HgQuad* quad, 
-        const QRectF& rect, qreal mirroringPlaneY);
+        const QRectF& rect, qreal mirroringPlaneY, const QVector2D& translate);
     void draw();
 
     void getTransformedPoints(QPolygonF& polygon) const;
         
     void computeMirrorMatrix(const QMatrix4x4& tm, const QMatrix4x4& projView, 
-        const QRectF& rect, qreal mirroringPlaneY);
+        const QRectF& rect, qreal mirroringPlaneY, 
+        const QVector2D& translate);
     
     bool perspectiveTransformPoints(QVector2D* points, const QMatrix4x4& matrix, 
         const QRectF& rect);
     
-    void computeWarpMatrix(VGfloat* matrix, int pxWidth, int pxHeight, const QVector2D* points);
+    void computeWarpMatrix(VGfloat* matrix, int pxWidth, int pxHeight, const QVector2D* points, 
+        const QVector2D& translate);
     
     void drawImage(HgVgImage* image, qreal alpha);
     
@@ -99,7 +101,7 @@
 
 
 void HgVgQuad::computeMirrorMatrix(const QMatrix4x4& trans, const QMatrix4x4& projView, 
-    const QRectF& rect, qreal mirroringPlaneY)
+    const QRectF& rect, qreal mirroringPlaneY, const QVector2D& translate)
 {
     HgQuad* quad = mQuad;
 
@@ -122,16 +124,19 @@
     if (image == NULL)
     {
         image = mRenderer->defaultImage();
+        if (!image) {
+            return;
+        }
     }
     
     int pxWidth = image->mirrorImageWidth();
     int pxHeight = image->mirrorImageHeight();
 
-    computeWarpMatrix(mMirrorMatrix, pxWidth, pxHeight, temp);
+    computeWarpMatrix(mMirrorMatrix, pxWidth, pxHeight, temp, translate);
 }
 
 void HgVgQuad::transformQuad(int index, const QMatrix4x4& projView, HgQuad* quad, 
-    const QRectF& rect, qreal mirroringPlaneY)
+    const QRectF& rect, qreal mirroringPlaneY, const QVector2D& translate)
 {
     mIndex = index;
     mQuad = quad;
@@ -142,7 +147,7 @@
 
     if (mQuad->mirrorImageEnabled())
     {
-        computeMirrorMatrix(tm, projView, rect, mirroringPlaneY);
+        computeMirrorMatrix(tm, projView, rect, mirroringPlaneY, translate);
     }
     
     tm.translate(quad->position());    
@@ -163,12 +168,18 @@
     if (image == NULL)
     {
         image = mRenderer->defaultImage();
+        if (!image)
+            return;
     }
     
     int pxWidth = image->width();
     int pxHeight = image->height();
     
-    computeWarpMatrix(mMatrix, pxWidth, pxHeight, mTransformedPoints);
+    
+    computeWarpMatrix(mMatrix, pxWidth, pxHeight, mTransformedPoints, translate);
+    
+    for (int i = 0; i < 4; i++)
+        mTransformedPoints[i] += translate;
     
 }
 
@@ -199,13 +210,15 @@
     return true;
 }
 
-void HgVgQuad::computeWarpMatrix(VGfloat* matrix, int pxWidth, int pxHeight, const QVector2D* points)
+void HgVgQuad::computeWarpMatrix(VGfloat* matrix, int pxWidth, int pxHeight, const QVector2D* points, 
+    const QVector2D& translate)
 {        
+
     vguComputeWarpQuadToQuad(
-        points[0].x(), points[0].y(), 
-        points[1].x(), points[1].y(),
-        points[2].x(), points[2].y(),
-        points[3].x(), points[3].y(),
+        points[0].x() + translate.x(), points[0].y() + translate.y(), 
+        points[1].x() + translate.x(), points[1].y() + translate.y(),
+        points[2].x() + translate.x(), points[2].y() + translate.y(),
+        points[3].x() + translate.x(), points[3].y() + translate.y(),
         0, pxHeight,
         pxWidth, pxHeight,
         pxWidth, 0,
@@ -232,8 +245,9 @@
     
     if (image == NULL  || image->alpha() == 0)
     {
-        return;
-        //drawImage(mRenderer->defaultImage(), 1.0f);
+        if (mRenderer->defaultImage()) {
+            drawImage(mRenderer->defaultImage(), 1.0f);
+        }
     }
     else
     {
@@ -241,14 +255,18 @@
         
         if (image->image() == VG_INVALID_HANDLE)
         {
-            drawImage(mRenderer->defaultImage(), 1.0f);
+            if (mRenderer->defaultImage()) {
+                drawImage(mRenderer->defaultImage(), 1.0f);
+            }
         }
         else
         {
 
             if ( mQuad->alpha() < 1.0f )
             {
-                drawImage(mRenderer->defaultImage(), 1.0f - mQuad->alpha());            
+                if (mRenderer->defaultImage()) {
+                    drawImage(mRenderer->defaultImage(), 1.0f - mQuad->alpha());            
+                }
             }
             
             drawImage(image, mQuad->alpha());
@@ -354,7 +372,7 @@
         
         if (q->visible())
         {
-            tq->transformQuad(i, pv, q, rect, mMirroringPlaneY);   
+            tq->transformQuad(i, pv, q, rect, mMirroringPlaneY, mTranslation);   
             mSortedQuads.append(tq);
         }
     }
@@ -434,7 +452,10 @@
 
 HgVgImage* HgVgQuadRenderer::defaultImage()
 {
-    if (mDefaultVgImage == NULL)
+    if (mDefaultVgImage && mDefaultVgImage->image() == VG_INVALID_HANDLE) {
+        mDefaultVgImage->upload(true);
+    }
+/*    if (mDefaultVgImage == NULL)
     {
         QImage defaultImage(64,64,QImage::Format_RGB16);
         defaultImage.fill(qRgb(255,0,0));
@@ -442,9 +463,20 @@
         mDefaultVgImage->setImage(defaultImage);
         mDefaultVgImage->upload(true);        
     }
+    */
     return mDefaultVgImage;
 }
 
+void HgVgQuadRenderer::setDefaultImage(QImage defaultImage)
+{
+    HgQuadRenderer::setDefaultImage(defaultImage);
+    delete mDefaultVgImage;
+    mDefaultVgImage = 0;
+    mDefaultVgImage = static_cast<HgVgImage*>(createNativeImage());
+    mDefaultVgImage->setImage(mDefaultImage);
+    mDefaultVgImage->upload(true);    
+}
+
 HgImageFader* HgVgQuadRenderer::imageFader()
 {
     return mImageFader;
--- a/ganeswidgets/src/hgwidgetitem.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgwidgetitem.cpp	Mon May 03 13:32:54 2010 +0300
@@ -16,9 +16,11 @@
 */
 #include "hgwidgetitem.h"
 #include "hgquadrenderer.h"
+#include "trace.h"
 #include <hgwidgets/hgwidgets.h>
 #include <QStringList>
 #include <HbIcon>
+#include "hgvgimage.h"
 
 HgWidgetItem::HgWidgetItem(HgQuadRenderer* renderer):
 mTitle(""),
@@ -48,13 +50,15 @@
     delete mHgImage;
 }
 
-void HgWidgetItem::setImage( QImage image )
+void HgWidgetItem::setImage(const QImage &image)
 {
     if (!mHgImage)
     {
         mHgImage = mRenderer->createNativeImage();
     }
+    
     mHgImage->setImage(image);
+
     if (!mVisibility)
         mHgImage->setAlpha(0);
     
@@ -120,8 +124,11 @@
                     if (size.width() != 0 && size.height() != 0 ){
                         QPixmap pixmap = qicon.pixmap(size);
                         if (!pixmap.isNull()){
-                            setImage(pixmap.toImage());
-                            mValidData = true;        
+                            QImage tempImage = pixmap.toImage();
+                            if (!tempImage.isNull()) {
+                                setImage(tempImage);
+                                mValidData = true;        
+                            }
                         }
                     break;
                     }
@@ -133,15 +140,25 @@
             // QIcon too.
             QIcon tempIcon = image.value<QIcon>();
             QList<QSize> sizes = tempIcon.availableSizes();
-            QSize size;
-            foreach(size, sizes){
-                if (size.width() != 0 && size.height() != 0 ){
-                    QPixmap pixmap = tempIcon.pixmap(size);
-                    if (!pixmap.isNull()){
-                        setImage(pixmap.toImage());
-                        mValidData = true;        
+            if (sizes.count() == 0 && !(tempIcon.isNull())) {
+                QPixmap pixmap = tempIcon.pixmap(tempIcon.actualSize(QSize(250, 250)));
+                if (!pixmap.isNull()){
+                    INFO("Valid image found for" << mModelIndex);
+                    setImage(pixmap.toImage());
+                    mValidData = true;
+                }
+            }
+            else {
+                QSize size;
+                foreach(size, sizes){
+                    if (size.width() != 0 && size.height() != 0 ){
+                        QPixmap pixmap = tempIcon.pixmap(size);
+                        if (!pixmap.isNull()){
+                            setImage(pixmap.toImage());
+                            mValidData = true;
+                        }
+                    break;
                     }
-                break;
                 }
             }
         }
@@ -165,6 +182,9 @@
     mValidData = false;
     if (mHgImage)
         mHgImage->releaseImage();
+
+    delete mHgImage;
+    mHgImage = 0;
 }
 
 bool HgWidgetItem::validData() const
--- a/ganeswidgets/src/hgwidgets.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgwidgets.cpp	Mon May 03 13:32:54 2010 +0300
@@ -30,18 +30,31 @@
 #include "hggridcontainer.h"
 #include "trace.h"
 
-HgWidget::HgWidget(HbWidgetPrivate* widgetPrivate, QGraphicsItem *parent ):
-    HbWidget(*widgetPrivate, parent)
+
+
+HgWidget::HgWidget( QGraphicsItem *parent ) : HbWidget(parent), p_ptr( new HgWidgetPrivate )
 {
-    Q_D(HgWidget);
-    d->q_ptr = this;
-
+    
     HbStyleLoader::registerFilePath(":/hgwidget.css");
     HbStyleLoader::registerFilePath(":/hgwidget.widgetml");    
+
+    Q_D( HgWidget );
+    d->q_ptr = this;
+}
+
+HgWidget::HgWidget(HgWidgetPrivate &dd, QGraphicsItem *parent ):
+    HbWidget(parent), p_ptr( &dd )
+{
+    HbStyleLoader::registerFilePath(":/hgwidget.css");
+    HbStyleLoader::registerFilePath(":/hgwidget.widgetml");    
+    Q_D( HgWidget );
+    d->q_ptr = this;
 }
 
 HgWidget::~HgWidget()
 {
+    delete p_ptr;
+    
     HbStyleLoader::unregisterFilePath(":/hgwidget.css");
     HbStyleLoader::unregisterFilePath(":/hgwidget.widgetml");
 }
@@ -129,19 +142,7 @@
 void HgWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
 {
     Q_D( HgWidget);
-    // TODO,take columns into count
-    for( int i = topLeft.row(); i <= bottomRight.row(); i++ ){
-        // if data for item outside our current buffer has changed
-        // we just have to ignore it since we dont have resources
-        // to handle it(or we dont want to waste resources).
-        if(d->mBufferManager->positionInsideBuffer(i)){
-            HgWidgetItem* item = d->mContainer->itemByIndex( i );
-            if( item ){
-                item->updateItemData();
-            }
-        }
-    }
-    d->mContainer->itemDataChanged( topLeft, bottomRight );
+    d->dataChanged(topLeft, bottomRight);
 }
 
 /*!
@@ -322,4 +323,47 @@
     return d->indexFeedbackPolicy();
 }
 
+void HgWidget::setDefaultImage(QImage defaultImage)
+{
+    Q_D(HgWidget);
+    d->setDefaultImage(defaultImage);
+}
+
+void HgWidget::setItemSizePolicy(HgWidget::ItemSizePolicy policy)
+{
+    Q_D(HgWidget);
+    d->setItemSizePolicy(policy);
+}
+
+HgWidget::ItemSizePolicy HgWidget::itemSizePolicy() const
+{
+    Q_D(const HgWidget);
+    return d->itemSizePolicy();
+}
+
+void HgWidget::setItemSize(const QSizeF& size)
+{
+    Q_D(HgWidget);
+    d->setItemSize(size);
+}
+
+QSizeF HgWidget::itemSize() const
+{
+    Q_D(const HgWidget);
+    return d->itemSize();
+}
+
+void HgWidget::setItemSpacing(const QSizeF& spacing)
+{
+    Q_D(HgWidget);
+    d->setItemSpacing(spacing);    
+}
+
+QSizeF HgWidget::itemSpacing() const
+{
+    Q_D(const HgWidget);
+    return d->itemSpacing();
+}
+
+
 // EOF
--- a/ganeswidgets/src/hgwidgets_p.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/src/hgwidgets_p.cpp	Mon May 03 13:32:54 2010 +0300
@@ -29,7 +29,7 @@
 #include "hgindexfeedback.h"
 
 static const int INITIAL_SCROLLBAR_HIDE_TIMEOUT(4000);
-static const int DEFAULT_BUFFER_SIZE(40);
+static const int DEFAULT_BUFFER_SIZE(30);
 
 HgWidgetPrivate::HgWidgetPrivate() :
     mLayout(0),
@@ -41,7 +41,8 @@
     mScrollBar(0),
     mAbleToScroll(false),
     mHandleLongPress(false),
-    mBufferSize(DEFAULT_BUFFER_SIZE)
+    mBufferSize(DEFAULT_BUFFER_SIZE),
+    mStaticScrollDirection(false)
 {
     FUNC_LOG;
 }
@@ -50,6 +51,7 @@
 {
     FUNC_LOG;
 
+    delete mScrollBarHideTimer;
     delete mDefaultSelectionModel;
     delete mBufferManager;
 }
@@ -59,16 +61,16 @@
     FUNC_LOG;
     Q_Q(HgWidget);
 
-    mScrollBarHideTimer.setParent(q);
-    mScrollBarHideTimer.setSingleShot(true);
+    mScrollBarHideTimer = new QTimer();
+    mScrollBarHideTimer->setSingleShot(true);
 
     q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     q->setFlag( QGraphicsItem::ItemClipsChildrenToShape, true );
     q->setFocusPolicy(Qt::StrongFocus);
 
-    createScrollBar(container->orientation());
+    createScrollBar(container->scrollDirection());
     
-    QObject::connect(&(mScrollBarHideTimer), SIGNAL(timeout()), q, SLOT(_q_hideScrollBars()));
+    //QObject::connect(&(mScrollBarHideTimer), SIGNAL(timeout()), q, SLOT(_q_hideScrollBars()));
 
     mContainer = container;
 
@@ -82,6 +84,7 @@
                q, SIGNAL(longPressed(const QModelIndex&, const QPointF &)));
     q->connect(mContainer, SIGNAL(scrollingStarted()), q, SIGNAL(scrollingStarted()));
     q->connect(mContainer, SIGNAL(scrollingEnded()), q, SIGNAL(scrollingEnded()));
+    q->connect(mScrollBarHideTimer, SIGNAL(timeout()), q, SLOT(_q_hideScrollBars()));
     
     mIndexFeedback = new HgIndexFeedback(q);
     mIndexFeedback->setWidget(q);
@@ -214,6 +217,7 @@
     if (index.isValid()) {
         if (mContainer) {
             mContainer->scrollTo(index);
+            updateScrollMetrics(mContainer->scrollPosition());
         }
         if (mBufferManager) {
             mBufferManager->scrollPositionChanged(index.row());
@@ -244,28 +248,20 @@
                            SLOT(_q_removeRows(QModelIndex, int, int)));
         q->connect(mModel, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
                            SLOT(_q_moveRows(QModelIndex, int, int, QModelIndex, int)));
-
+        q->connect(mModel, SIGNAL(modelReset()),SLOT(_q_modelReset()));
+        
         mContainer->setItemCount(mModel->rowCount(QModelIndex()));
         QList<HgWidgetItem*> items = mContainer->items();
 
         // set model indexes for the items firsts
-        int itemCount = items.count();
+        const int itemCount = items.count();
         for( int i=0; i<itemCount; i++)
         {
             items.at(i)->setModelIndex(mModel->index(i, 0, QModelIndex()));
         }
 
-        if( mBufferManager )
-        {
-            delete mBufferManager;
-            mBufferManager = 0;
-        }
-
-        mBufferManager = new HgScrollBufferManager(mBufferSize,mBufferSize/4,0,itemCount);
-        q->connect( mBufferManager, SIGNAL(releaseItems(int,int)), q, SLOT(_q_releaseItems(int,int)));
-        q->connect( mBufferManager, SIGNAL(requestItems(int,int)), q, SLOT(_q_requestItems(int,int)));
-        mBufferManager->resetBuffer(0, itemCount);
-
+        initBufferManager(itemCount);
+        
         setSelectionModel(0); // Default
 
         if (mModel->rowCount() > 0)
@@ -286,9 +282,12 @@
         mModel->disconnect(q, SLOT(_q_insertRows(QModelIndex, int, int)));
         mModel->disconnect(q, SLOT(_q_removeRows(QModelIndex, int, int)));
         mModel->disconnect(q, SLOT(_q_moveRows(QModelIndex, int, int, QModelIndex, int)));
+        mModel->disconnect(q, SLOT(_q_modelReset()));
         mModel = 0;
     }
-
+    else if (mContainer) {
+        mContainer->setItemCount(0);
+    }
 //  TODO: setSelectionModel(0);
 
 }
@@ -391,8 +390,9 @@
             mScrollBar->setVisible(false);
     }
 
-    if (scrollBarsVisible && !mScrollBarHideTimer.isActive()) {
-        mScrollBarHideTimer.start(INITIAL_SCROLLBAR_HIDE_TIMEOUT);
+    if (scrollBarsVisible) {
+        mScrollBarHideTimer->stop();
+        mScrollBarHideTimer->start(INITIAL_SCROLLBAR_HIDE_TIMEOUT);
     }
 }
 
@@ -430,7 +430,7 @@
         // only scrollareaprivate is a friend class.
         if (false/*scrollBarPressed(mHorizontalScrollBar) ||
                 scrollBarPressed(mVerticalScrollBar)*/) {
-            mScrollBarHideTimer.start();
+            mScrollBarHideTimer->start();
         } else if(mScrollBarPolicy != HgWidget::ScrollBarAlwaysOn
                   && mScrollBar->isVisible()){
             mScrollBar->setVisible(false);
@@ -450,9 +450,9 @@
 
     // TODO, stop all scrolling and animations
 
-    if (mScrollBarHideTimer.isActive()) {
-        mScrollBarHideTimer.stop();
-        mScrollBarHideTimer.start();
+    if (mScrollBarHideTimer->isActive()) {
+        mScrollBarHideTimer->stop();
+        mScrollBarHideTimer->start();
     }
 }
 
@@ -464,6 +464,8 @@
     Q_Q(HgWidget);
 
     if (mContainer) {
+        int oldItemCount = mContainer->itemCount();
+        mBufferManager->addItems(start, end);
         mContainer->addItems(start, end);
         // re-set model indexes for the items including and after the added indexes
         QList<HgWidgetItem *> items = mContainer->items();
@@ -471,7 +473,10 @@
         for (int i = start; i < newItemCount; i++) {
             items.at(i)->setModelIndex(mModel->index(i, 0, QModelIndex()));
         }
-        mBufferManager->addItems(start, end, newItemCount);
+        mBufferManager->flushRequestBuffers();
+        if (oldItemCount == 0 && newItemCount > 0) {
+            setCurrentIndex(mModel->index(0, 0));
+        }
         q->update();
     }
 }
@@ -484,14 +489,19 @@
     Q_Q(HgWidget);
 
     if (mContainer && mBufferManager) {
-        mContainer->removeItems(start, end);
+        int itemCount = mContainer->itemCount();
+        int first= qBound(0, start, itemCount-1);
+        int last = qBound(0, end, itemCount-1);
+
+        mBufferManager->removeItems(first, last);
+        mContainer->removeItems(first, last);
         // re-set model indexes for the items after the removed indexes
         QList<HgWidgetItem *> items = mContainer->items();
         int newItemCount = items.count();
-        for (int i = start; i < newItemCount; i++) {
+        for (int i = first; i < newItemCount; i++) {
             items.at(i)->setModelIndex(mModel->index(i, 0, QModelIndex()));
         }
-        mBufferManager->removeItems(start, end, newItemCount);
+        mBufferManager->flushRequestBuffers();
         q->update();
     }
 }
@@ -508,17 +518,49 @@
 
     if (mContainer) {
         mContainer->moveItems(sourceStart, sourceEnd, destinationRow);
+        mBufferManager->moveItems(sourceStart, sourceEnd, destinationRow);
         // re-set model indexes for the items after the removed indexes
         QList<HgWidgetItem *> items = mContainer->items();
         int itemCount = items.count();
         for (int i = qMin(sourceStart, destinationRow); i < itemCount; i++) {
             items.at(i)->setModelIndex(mModel->index(i, 0, QModelIndex()));
         }
-        mBufferManager->moveItems(sourceStart, sourceEnd, destinationRow, itemCount);
+        mBufferManager->flushRequestBuffers();
         q->update();
     }
 }
 
+void HgWidgetPrivate::_q_modelReset()
+{
+    if (mContainer && mBufferManager) {
+        const int oldItemCount = mContainer->itemCount();
+        const int newItemCount = mModel->rowCount();
+        if (newItemCount == oldItemCount) {
+            // Model is reseted but itemcount is still the same.
+            // Just reload all data for current buffer.
+            mBufferManager->resetBuffer(mContainer->scrollPosition(), newItemCount);
+        }
+        else {
+            // Container destroyes all old items when new itemcount is set.
+            mContainer->setItemCount(newItemCount);
+
+            // set model indexes for the items
+            QList<HgWidgetItem*> items = mContainer->items();
+            const int itemCount = items.count();
+            for( int i=0; i<itemCount; i++) {
+                items.at(i)->setModelIndex(mModel->index(i, 0, QModelIndex()));
+            }
+                        
+            // Buffermanager requests items to be updated. 
+            mBufferManager->resetBuffer(0, newItemCount);
+            if (mModel->rowCount() > 0) {
+                setCurrentIndex(mModel->index(0, 0));
+                scrollTo(mModel->index(0, 0));
+            }
+        }        
+    }
+}
+
 void HgWidgetPrivate::setScrollBarMetrics(qreal pos)
 {
     Q_Q( HgWidget );
@@ -564,9 +606,6 @@
 
     QRectF scrollAreaBoundingRect = q->boundingRect();
 
-    if (!mContainer || scrollAreaBoundingRect.isNull() ||
-         !scrollAreaBoundingRect.isValid())
-        return;
 
     qreal screenSize, worldSize;
     mContainer->dimensions(screenSize,worldSize);
@@ -592,7 +631,7 @@
 
     mContainer->resize(scrollAreaBoundingRect.size());
 
-    updateScrollMetrics(0);
+    updateScrollMetrics(mContainer->scrollPosition());
 }
 
 
@@ -635,9 +674,11 @@
 {
     Q_Q(HgWidget);
     if (mContainer->orientation() != orientation) {
-        createScrollBar(orientation);
+        mContainer->setOrientation(orientation);
+        if (!mStaticScrollDirection) {
+            createScrollBar(orientation);
+        }
         q->repolish();
-        mContainer->setOrientation(orientation);
         adjustGeometry();
     }
 }
@@ -690,4 +731,74 @@
     return mIndexFeedback->indexFeedbackPolicy();
 }
 
+void HgWidgetPrivate::setDefaultImage(QImage defaultImage)
+{
+    mContainer->setDefaultImage(defaultImage);
+}
+
+void HgWidgetPrivate::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+    FUNC_LOG;
+
+    // TODO,take columns into count
+    for( int i = topLeft.row(); i <= bottomRight.row(); i++ ){
+        // if data for item outside our current buffer has changed
+        // we just have to ignore it since we dont have resources
+        // to handle it(or we dont want to waste resources).
+        if (mBufferManager->positionInsideBuffer(i)) {
+            HgWidgetItem* item = mContainer->itemByIndex( i );
+            if (item) {
+                item->updateItemData();
+            }
+        }
+    }
+    mContainer->itemDataChanged(topLeft, bottomRight);
+}
+
+void HgWidgetPrivate::setItemSizePolicy(HgWidget::ItemSizePolicy policy)
+{
+    mContainer->setItemSizePolicy(policy);
+}
+
+HgWidget::ItemSizePolicy HgWidgetPrivate::itemSizePolicy() const
+{
+    return mContainer->itemSizePolicy();
+}
+
+void HgWidgetPrivate::setItemSize(const QSizeF& size)
+{
+    mContainer->setItemSize(size);
+}
+
+QSizeF HgWidgetPrivate::itemSize() const
+{
+    return mContainer->itemSize();
+}
+
+void HgWidgetPrivate::setItemSpacing(const QSizeF& spacing)
+{
+    mContainer->setItemSpacing(spacing);
+}
+
+QSizeF HgWidgetPrivate::itemSpacing() const
+{
+    return mContainer->itemSpacing();
+}
+
+void HgWidgetPrivate::initBufferManager(int itemCount)
+{
+    Q_Q(HgWidget);
+    if (mBufferManager) {
+        q->disconnect( mBufferManager, SIGNAL(releaseItems(int,int)), q, SLOT(_q_releaseItems(int,int)));
+        q->disconnect( mBufferManager, SIGNAL(requestItems(int,int)), q, SLOT(_q_requestItems(int,int)));
+        delete mBufferManager;
+        mBufferManager = 0;
+    }
+
+    mBufferManager = new HgScrollBufferManager(mBufferSize,qMax(mContainer->rowCount()*2,3),0,itemCount);
+    q->connect( mBufferManager, SIGNAL(releaseItems(int,int)), q, SLOT(_q_releaseItems(int,int)));
+    q->connect( mBufferManager, SIGNAL(requestItems(int,int)), q, SLOT(_q_requestItems(int,int)));
+    mBufferManager->resetBuffer(0, itemCount);
+}
+
 #include "moc_hgwidgets.cpp"
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/hgwidgettest.pro	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/hgwidgettest.pro	Mon May 03 13:32:54 2010 +0300
@@ -8,39 +8,44 @@
 # Nokia Corporation - initial contribution.
 # Contributors:
 # Description:
-
-
 TEMPLATE = app
 CONFIG += hb
 TARGET = hgwidgettest
 DEPENDPATH += .
 INCLUDEPATH += .
-INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE $$APP_LAYER_SYSTEMINCLUDE
-TARGET.CAPABILITY = All -TCB
-
-INCLUDEPATH += /sf/mw/hb/src/hbwidgets/itemviews /sf/mw/hb/src/hbcore/gui
-
-symbian {
-    TARGET.EPOCHEAPSIZE = 0x10000 0x2000000
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
+    $$APP_LAYER_SYSTEMINCLUDE
+TARGET.CAPABILITY = All \
+    -TCB
+INCLUDEPATH += /sf/mw/hb/src/hbwidgets/itemviews \
+    /sf/mw/hb/src/hbcore/gui
+symbian { 
+    TARGET.EPOCHEAPSIZE = 0x10000 \
+        0x2000000
     BLD_INF_RULES.prj_exports += "rom/hgwidgettest.iby CORE_APP_LAYER_IBY_EXPORT_PATH(hgwidgettest.iby)" \
-                                 "rom/hgwidgettestresource.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(hgwidgettestresource.iby)"
+        "rom/hgwidgettestresource.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(hgwidgettestresource.iby)"
 }
-
-SOURCES += src/main.cpp \
-	src/hgwidgettestdatamodel.cpp \
-	src/hgwidgettestalbumartmanager.cpp \
-	src/hgwidgettestview.cpp \
-	src/hgtestview.cpp \
-	src/hgselectiondialog.cpp \
-	src/hgflipwidget.cpp
-HEADERS += inc/hgwidgettestdatamodel.h \
-	inc/hgwidgettestalbumartmanager.h \
-	inc/hgwidgettestview.h \
-	inc/hgtestview.h \
-	inc/hgselectiondialog.h \
-	inc/hgflipwidget.h
+SOURCES += src/hgcoverflowwidget.cpp \
+    src/hgwidgetoptionsview.cpp \
+    src/main.cpp \
+    src/hgwidgettestdatamodel.cpp \
+    src/hgwidgettestalbumartmanager.cpp \
+    src/hgwidgettestview.cpp \
+    src/hgtestview.cpp \
+    src/hgselectiondialog.cpp \
+    src/hgflipwidget.cpp \
+    src/buffermanager.cpp \
+    src/hgitemsizedialog.cpp
+HEADERS += inc/hgcoverflowwidget.h \
+	inc/hgwidgetoptionsview.h \
+    inc/hgwidgettestdatamodel.h \
+    inc/hgwidgettestalbumartmanager.h \
+    inc/hgwidgettestview.h \
+    inc/hgtestview.h \
+    inc/hgselectiondialog.h \
+    inc/hgflipwidget.h \
+    inc/buffermanager.h \
+    inc/hgitemsizedialog.h
 LIBS += -lganeswidgets.dll \
     -lthumbnailmanagerqt.dll
-
 RESOURCES += data/hgwidgettest.qrc
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/buffermanager.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef BUFFERMANAGER_H_
+#define BUFFERMANAGER_H_
+
+class AbstractDataProvider
+{
+public:
+
+    enum requestsOrder {
+            ascending,
+            descending
+    };   
+    
+    virtual void release(int start, int end) = 0;
+    virtual void request(int start, int end, requestsOrder order) = 0;    
+};
+
+
+class BufferManager
+{
+public:    
+    
+	BufferManager(
+	    AbstractDataProvider* aObserver,
+		int aBufferSize,
+		int aBufferTreshold,
+		int aInitialPosition,
+		int aTotalCount );
+
+	~BufferManager();
+
+	void setPosition( int aIndex );
+
+	void resetBuffer( int aPosition, int aTotalCount);
+
+	void itemCountChanged( int aIndex, bool aRemoved, int aNewTotalCount );
+	void resizeCache(int newSize, int newTreshold);
+	
+private:
+	void calculate();
+
+private:
+    AbstractDataProvider* mObserver; 
+    
+	int mBufferSize;
+	int mBufferTreshold;
+	int mBufferPosition;
+	int mDiff;
+	int mTotalCount;
+
+	bool mResetOrdered;
+
+	int mRequestStart;
+	int mRequestCount;
+	int mReleaseStart;
+	int mReleaseCount;
+};
+
+
+
+#endif /*BUFFERMANAGER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgcoverflowwidget.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Another view for test application.
+*
+*/
+#ifndef HGCOVERFLOWWIDGET_H_
+#define HGCOVERFLOWWIDGET_H_
+
+#include <hbwidget>
+#include <hblabel>
+#include <qgraphicssceneresizeevent>
+#include <hgwidgets/hgmediawall.h>
+#include <QAbstractListModel>
+
+/**
+ * Coverflowwidget class which adds labels to normal MediaWall
+ */
+class HgCoverflowWidget : public HgMediawall
+{
+    Q_OBJECT
+public:
+    
+	HgCoverflowWidget(QGraphicsItem *parent=0);
+	virtual ~HgCoverflowWidget();
+
+	void updateTextPositions();
+	
+private slots:
+    void frontItemChanged ( const QModelIndex & current, const QModelIndex & previous );	
+
+private:
+    void resizeEvent(QGraphicsSceneResizeEvent *event);
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+    
+private:
+    HbLabel* mTitleLabel;
+    HbLabel* mDescLabel;
+    bool mTextPositionsDirty;
+};
+
+#endif /* HGTESTVIEW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgitemsizedialog.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Another view for test application.
+*
+*/
+#ifndef HGITEMSIZEDIALOG_H_
+#define HGITEMSIZEDIALOG_H_
+
+#include <hbdialog>
+#include <hblabel>
+#include <hbwidget>
+#include <hbslider>
+
+class HgItemSizeDialog : public HbDialog
+{
+    Q_OBJECT
+public:
+    
+	HgItemSizeDialog(QSizeF size, QSizeF spacing, HbWidget *parent=0);
+    
+    QSizeF itemSize() const;
+    QSizeF itemSpacing() const;
+        
+    void setSliderLimits(int min, int max);
+    
+signals:
+    void updateItemSizeAndSpacing();
+    void closed();
+private slots:
+    void itemSizeXChanged(int);
+    void itemSizeYChanged(int);
+    void itemSpacingXChanged(int);
+    void itemSpacingYChanged(int);    
+    void buttonClosed(bool);
+private:
+    HbLabel*                mSizeXLabel;
+    HbLabel*                mSizeYLabel;
+    HbLabel*                mSpacingXLabel;
+    HbLabel*                mSpacingYLabel;
+    QSizeF                  mSize;
+    QSizeF                  mSpacing;
+    HbSlider*               mSizeXSlider;
+    HbSlider*               mSizeYSlider;
+    HbSlider*               mSpacingXSlider;
+    HbSlider*               mSpacingYSlider;
+};
+
+#endif /* HGTESTVIEW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgtestdefs.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HGTESTDEFS_H_
+#define HGTESTDEFS_H_
+
+enum HgTestWidgetType {
+    HgWidgetNone = 0,
+    HgWidgetGrid,
+    HgWidgetCoverflow,
+    HgWidgetTBone
+};
+
+enum HgTestImageType {
+    ImageTypeNone = 0,
+    ImageTypeQIcon,
+    ImageTypeHbIcon,
+    ImageTypeQImage
+};
+
+static const QString SETT_ORGANIZATION = "Nokia";
+static const QString SETT_APPLICATION = "HgWidgetTestApp";
+static const QString SETT_WIDGET_TYPE = "WidgetType";
+static const QString SETT_SCROLLBAR_VISIBILITY = "ScrollBarVisibility";
+static const QString SETT_SCROLLBAR_INTERACTIVITY = "ScrollBarInteractivity";
+static const QString SETT_MODEL_IMAGE_TYPE = "ModelImageType";
+static const QString SETT_WIDGET_HEIGHT = "WidgetHeight";
+static const QString SETT_WIDGET_WIDTH = "WidgetWidth";
+static const QString SETT_LOW_RES_IMAGES = "LowResImages";
+static const QString SETT_TITLE_POSITION = "TitlePosition";
+static const QString SETT_TITLE_FONT = "TitleFont";
+static const QString SETT_DESCRIPTION_POSITION = "DescriptionPosition";
+static const QString SETT_DESCRIPTION_FONT = "DescriptionFont";
+static const QString SETT_REFLECTIONS_ENABLED = "Reflections enabled";
+
+#endif /* HGTESTDEFS_H_ */
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgtestview.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgtestview.h	Mon May 03 13:32:54 2010 +0300
@@ -29,14 +29,13 @@
 public:
 	HgTestView(const QString &title1, const QString &title2, const QPixmap &pixmap, QGraphicsItem *parent=0);
 
-private slots:
-    void closeView();
+signals:
+    void closeRequested();
 
 private:
     void resizeEvent(QGraphicsSceneResizeEvent *event);
 
 private:
-    HbAction *mBackAction;
     HbLabel *mIconLabel;
     QPixmap mPixmap;
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgetoptionsview.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HGWIDGETOPTIONSVIEW_H_
+#define HGWIDGETOPTIONSVIEW_H_
+
+#include <hbview.h>
+#include <hgwidgets/hgmediawall.h>
+#include "hgtestdefs.h"
+
+class HbDataForm;
+class HbDataFormModel;
+
+class HgWidgetOptionsView : public HbView
+{
+    Q_OBJECT
+
+public:
+
+    HgWidgetOptionsView(QGraphicsItem *parent = 0);
+    ~HgWidgetOptionsView();
+
+signals:
+    void optionsClosed();
+    void widgetTypeChanged(HgTestWidgetType);
+    void scrollBarVisibilityChanged(HgWidget::ScrollBarPolicy);
+    void scrollBarInteractivityChanged(bool);
+    void imageTypeChanged(HgTestImageType);
+    void lowResImageUseChanged(bool);
+    void titlePositionChanged(HgMediawall::LabelPosition);
+    void titleFontChanged(const HbFontSpec &);
+    void descriptionPositionChanged(HgMediawall::LabelPosition);
+    void descriptionFontChanged(const HbFontSpec &);
+    void widgetHeightChanged(int);
+    void widgetWidthChanged(int);
+    void reflectionsEnabledChanged(bool);
+private slots:
+    void updateData(QModelIndex startIn, QModelIndex endIn);
+
+private:
+    void setCoverflowEnabled(bool value);
+    void storeWidgetSize();
+    void setupData();
+    void resizeEvent(QGraphicsSceneResizeEvent *event);
+
+private: // data
+    HbDataForm *mForm;
+    HbDataFormModel *mModel;
+    bool mContentReady;
+    bool mUpdateWidgetSize;
+};
+
+
+#endif /* HGWIDGETOPTIONSVIEW_H_ */
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestdatamodel.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestdatamodel.h	Mon May 03 13:32:54 2010 +0300
@@ -23,11 +23,16 @@
 #include <QStringList>
 #include <hbicon>
 #include <thumbnailmanager_qt.h>
+#include <QImage>
+#include <QList>
+#include "buffermanager.h"
+#include "hgtestdefs.h"
 
 class HgWidgetTestAlbumArtManager;
+class ThumbnailManager;
 
 
-class HgWidgetTestDataModel : public QAbstractListModel
+class HgWidgetTestDataModel : public QAbstractListModel, public AbstractDataProvider
 {
     Q_OBJECT
 
@@ -37,7 +42,8 @@
     virtual ~HgWidgetTestDataModel();
 
     void setThumbnailSize(ThumbnailManager::ThumbnailSize size);
-
+    void setBuffer(int buffer, int treshhold);
+    
     int rowCount(const QModelIndex &parent=QModelIndex()) const;
     QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
     bool setData(const QModelIndex& index, const QVariant& value, int role=Qt::EditRole);
@@ -47,17 +53,21 @@
     void remove(const QItemSelection &selection);
     void move(const QItemSelection &selection, const QModelIndex &target);
     void add(const QModelIndex &target, int count);
-
-    enum ImageType{TypeQIcon, TypeHbIcon, TypeQImage};
+    void reset();
     
-    void setImageDataType(ImageType type);
-    
+    HgTestImageType imageDataType() const;
+    void setImageDataType(HgTestImageType type);
+
     void enableLowResImages(bool enabled);
     bool lowResImagesEnabled() const;
+
+public slots:
+    void thumbnailReady( QPixmap , void* , int, int ); 
     
 private:
 
     void init();
+    void getNextThumbnail();
 
 public slots:
 
@@ -65,16 +75,29 @@
     void albumCacheReady();
 
 private:
+    
+    void release(int start, int end);
+    void request(int start, int end, requestsOrder order);
+    
+private:
 
-	HgWidgetTestAlbumArtManager     *mAlbumArtManager;  // Own
     bool                            mCachingInProgress;
     QStringList                     mFiles;
-    ImageType                       mImageType;
+    HgTestImageType                 mImageType;
     HbIcon                          mHbIcon;
     QIcon                           mQIcon;
     QImage                          mDefaultIcon;
     QList<bool>                     mVisibility;
     bool                            mUseLowResImages;
+    QList<QImage>                   mImages;
+    BufferManager                   *mBufferManager;
+
+    ThumbnailManager* mWrapper;
+    QStringList mWaitingThumbnails;
+    bool mThumbnailRequestPending;
+    int mThumbnailRequestIndex;
+    int mThumbnailRequestID;
+
 };
 
 #endif // HgWidgetTestDataModel_H
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestview.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/inc/hgwidgettestview.h	Mon May 03 13:32:54 2010 +0300
@@ -19,7 +19,8 @@
 #define HGWIDGETTESTVIEW_H_
 
 #include <hbview.h>
-#include <hgwidgets/hgwidgets.h>
+#include <hgwidgets/hgmediawall.h>
+#include "hgtestdefs.h"
 
 class HbAction;
 class QGraphicsLinearLayout;
@@ -27,6 +28,9 @@
 class HbListWidget;
 class HgFlipWidget;
 class HbLabel;
+class HbDialog;
+
+class HgItemSizeDialog;
 
 class HgWidgetTestView : public HbView
 {
@@ -38,62 +42,68 @@
     ~HgWidgetTestView();
 
 private slots:
-
-    void switchWidget(HbAction* action);
+    void initWidget(HgTestWidgetType type);
+    void changeScrollBarVisibility(HgWidget::ScrollBarPolicy policy);
+    void changeScrollBarInteractivity(bool value);
+    void changeModelImageType(HgTestImageType);
+    void changeLowResImageUse(bool value);
+    void changeTitlePosition(HgMediawall::LabelPosition);
+    void changeTitleFont(const HbFontSpec &);
+    void changeDescriptionPosition(HgMediawall::LabelPosition);
+    void changeDescriptionFont(const HbFontSpec &);
+    void changeWidgetHeight(int);
+    void changeWidgetWidth(int);
     void toggleScrollDirection();
     void openDialog(const QModelIndex &index);
     void openView(const QModelIndex& index);
+    void closeCurrentView();
     void openDeleteItemsDialog();
     void openMoveItemsDialog();
     void openAddItemsDialog();
-    void autoHideScrollBar();
-    void scrollBarAlwaysOn();
-    void scrollBarAlwaysOff();
-    void interactiveScrollBar();
-    void unInteractiveScrollBar();
-    void feedqimages();
-    void feedqicons();
-    void feedhbicons();
     void flipClosed();
-    void orientationChanged();
     void onScrollingStarted();
     void onScrollingEnded();
-    void setDescriptionAboveImage();
-    void setDescriptionBelowImage();
-    void setDescriptionHidden();
-    void setTitleAboveImage();
-    void setTitleBelowImage();
-    void setTitleHidden();
-    void toggleLowResForCoverflow();
+    void showOptions();
+    void hideOptions();
+    void orientationChanged(Qt::Orientation);
+    
+    void startItemSizeChange();
+    void itemSizeDialogClosed();
+    void updateItemSizeAndSpacing();
 
+    void startItemPosChange();
+    void updateItemPos();
+    void itemPosDialogClosed();
+
+    void resetOptions();
+    void changeReflectionsEnabled(bool);
+    void resetModel();
 private:
-    
-    enum WidgetType {
-        HgWidgetGrid,
-        HgWidgetCoverflow
-    };
 
     void createMenu();
-    void initWidget( WidgetType type );
-    void setScrollBarPolicy( HgWidget::ScrollBarPolicy policy );
-    void setScrollBarInteractive( bool value );
-    HgWidget *createWidget(WidgetType type) const;
+    void setupWidget();
+    void setupWidgetOptions();
+    void setupWidgetSize();
+    HgWidget *createWidget(HgTestWidgetType type) const;
     HgWidget *copyWidget() const;
+    void resizeEvent(QGraphicsSceneResizeEvent *event);
+    Qt::Orientation orientation() const;
 
 private: // data
 
     HgWidget                *mWidget;
     QGraphicsLinearLayout   *mLayout;
     HgWidgetTestDataModel   *mModel;
-    WidgetType              mWidgetType;
+    HgTestWidgetType        mWidgetType;
     HbListWidget            *mListWidget;
     bool                    mToggleOrientation;
-    bool                    mTBone;
     QItemSelectionModel     *mSelectionModel;
     HgFlipWidget*           mFlipWidget;
     QModelIndex             mFlippedIndex;
     HbLabel*                mFrontItem;
-    HbAction*               mUseLowResAction;
+    HbView                  *mOptionsView;
+    HgItemSizeDialog       *mItemSizeDialog;
+    HgItemSizeDialog       *mItemPosDialog;
 };
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/buffermanager.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     
+*
+*/
+#include "buffermanager.h"
+#include <qglobal.h>
+
+BufferManager::BufferManager(
+    AbstractDataProvider* aObserver,
+	int aBufferSize,
+	int aBufferTreshold,
+	int aInitialPosition,
+	int aTotalCount )
+:
+mObserver(aObserver),
+mBufferSize( aBufferSize ),
+mBufferTreshold( aBufferTreshold ),
+mBufferPosition( aInitialPosition ),
+mTotalCount( aTotalCount )
+{
+    mBufferPosition -= (mBufferSize / 2);
+    
+    if( mBufferPosition + mBufferSize > mTotalCount - 1 ){
+        mBufferPosition = (mTotalCount - 1) - mBufferSize;
+    }
+    
+    if(mBufferPosition < 0 ){
+        mBufferPosition = 0;
+    }
+    
+    mDiff = 0;
+	//request Initial Buffer
+	mRequestStart = mBufferPosition;
+	mRequestCount = mBufferSize;
+
+	calculate();
+}
+
+
+BufferManager::~BufferManager()
+{
+}
+
+void BufferManager::resizeCache(int newSize, int newTreshold)
+{
+    if (newTreshold != mBufferTreshold){
+        mBufferTreshold = newTreshold;
+    }
+    
+    if (newSize!=mBufferSize){
+//        int pos = mBufferPosition + (mBufferSize / 2);
+
+        int a = qMax(0, mBufferPosition + mBufferSize/2 - newSize/2);
+        int b = qMin(a + newSize, mTotalCount);
+        if ( b == mTotalCount){
+            a = mTotalCount - newSize;
+        }
+        
+        int c = qMax(0, mBufferPosition);
+        int d = qMin(c + mBufferSize, mTotalCount);
+        if ( d == mTotalCount){
+            c = mTotalCount - mBufferSize;
+        }
+        
+        if ( newSize>mBufferSize){
+            mObserver->request(a, c-1, AbstractDataProvider::ascending);
+            mObserver->request(d, b-1, AbstractDataProvider::ascending);
+        }else if ( newSize<mBufferSize){
+            mObserver->release(c, a-1);
+            mObserver->release(b, d);
+        }
+        mBufferPosition = a;
+        mBufferSize = newSize;
+    }
+}
+
+void BufferManager::calculate()
+{  
+    AbstractDataProvider::requestsOrder direction = AbstractDataProvider::ascending;
+    
+    if(mResetOrdered){
+        mResetOrdered = false;
+    } else {
+        if(mDiff < 0){
+            mReleaseStart = mBufferPosition;
+            mRequestStart = mBufferPosition + mBufferSize;
+            direction = AbstractDataProvider::ascending; 
+        } else if( mDiff > 0) {
+            mReleaseStart = mBufferPosition + mBufferSize - mDiff;
+            mRequestStart = mBufferPosition - mDiff;
+            direction = AbstractDataProvider::descending;
+        }
+    }
+    
+    // Release 
+    int end = mReleaseStart + mReleaseCount < mTotalCount ?
+        mReleaseStart + mReleaseCount: mTotalCount; 
+    end--;
+    if(end >= mReleaseStart ){
+        mObserver->release(mReleaseStart, end);
+    }
+    
+    mReleaseCount = 0;
+    
+    // Request
+    end = mRequestStart + mRequestCount < mTotalCount ? 
+        mRequestStart + mRequestCount : mTotalCount;
+    
+    end--;
+    if(end >= mRequestStart ){
+        mObserver->request(mRequestStart, end, direction);
+	}
+      
+    mRequestCount = 0;
+    
+    // Move Buffer
+    mBufferPosition -= mDiff;
+    // Reset Diff
+    mDiff = 0;
+}
+
+// -----------------------------------------------------------------------------
+// BufferManager::SetPosition()
+// -----------------------------------------------------------------------------
+//
+void BufferManager::setPosition( int aIndex )
+{
+    // If all the items fit in the buffer no need to move the buffer
+    if(mTotalCount <= mBufferSize) return;
+	
+	bool forceUpdate = false;
+    aIndex -= mBufferSize / 2; // normalize index to Buffer start
+    
+    if(aIndex < 0){
+        aIndex = 0;
+        forceUpdate = true;
+    }else if( aIndex > mTotalCount - mBufferSize ){
+        aIndex = mTotalCount - mBufferSize;
+        forceUpdate = true;
+    }
+
+    mDiff = mBufferPosition - aIndex; 
+
+    // Too large change reset whole buffer
+    if( mDiff >= mBufferSize || -mDiff >= mBufferSize || mResetOrdered ) {
+        resetBuffer(aIndex + (mBufferSize/2), mTotalCount);
+    } else if( mDiff >= mBufferTreshold ) { // Move Up
+        mRequestCount = mDiff;
+        mReleaseCount = mDiff;
+        calculate();
+    } else if ( -mDiff >= mBufferTreshold ) {// Move Down
+        mRequestCount = -mDiff;
+        mReleaseCount = -mDiff;
+        calculate();
+    } else if( forceUpdate && mDiff ) { // Top or bottom has been reached
+        int diff = mDiff < 0 ? -mDiff : mDiff;
+        mRequestCount = diff;
+        mReleaseCount = diff;
+        calculate();
+    }
+}
+
+// -----------------------------------------------------------------------------
+// BufferManager::ResetBuffer()
+// -----------------------------------------------------------------------------
+//
+void BufferManager::resetBuffer( int aPosition, int aTotalCount)
+{
+    if( !mResetOrdered ){
+        // release Old buffer
+        mReleaseStart = mBufferPosition;
+        mReleaseCount = mBufferSize;
+    }
+    
+    // set position and count
+    mBufferPosition = aPosition - (mBufferSize / 2);
+    mTotalCount = aTotalCount;
+    mDiff = 0;
+    
+    if( mBufferPosition + mBufferSize > mTotalCount - 1 ){
+        mBufferPosition = mTotalCount - mBufferSize;
+    }
+    
+    if(mBufferPosition < 0 ){
+        mBufferPosition = 0;
+    }
+    
+    //request new Buffer
+    mRequestStart = mBufferPosition;
+    mRequestCount = mBufferSize;
+    mResetOrdered = true;
+    calculate();
+}
+
+void BufferManager::itemCountChanged( int aIndex, 
+                                      bool aRemoved,
+                                      int aNewTotalCount )
+{
+    mTotalCount = aNewTotalCount;
+    AbstractDataProvider::requestsOrder direction = AbstractDataProvider::ascending;    
+    if ( aIndex >= mBufferPosition && aIndex < mBufferPosition + mBufferSize ){
+        // Change inside the buffer
+        if( aRemoved ){
+            // Release removed item ( Item deleted already from the owner )
+			mObserver->release( aIndex, aIndex );
+            if( mTotalCount >= mBufferSize ){
+                // There are more items to keep the buffer filled
+                if( mBufferPosition + mBufferSize <= mTotalCount ){
+                    // Requested from the end
+					mObserver->request( mBufferPosition + mBufferSize, 
+                                        mBufferPosition + mBufferSize,
+                                        direction );
+                }else if( mBufferPosition > 0 ){
+                    // Move buffer and request from the beginning 
+                    mBufferPosition--;
+                    mObserver->request( mBufferPosition, mBufferPosition, direction);
+                }
+            }
+        }else{
+            if( mTotalCount > mBufferSize ){
+                // One item needs to be released
+                if( mBufferPosition + mBufferSize < mTotalCount ){
+                    // Release from the end of the buffer
+					mObserver->release(mBufferPosition + mBufferSize, mBufferPosition + mBufferSize);
+                }
+            }
+            // Request added item
+            mObserver->request(aIndex, aIndex, direction);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgcoverflowwidget.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Another view for test application.
+*
+*/
+#include "hgcoverflowwidget.h"
+#include "trace.h"
+
+#include <qgraphicslinearlayout.h>
+#include <qgraphicssceneresizeevent>
+
+
+
+HgCoverflowWidget::HgCoverflowWidget(QGraphicsItem *parent) : HgMediawall(parent), 
+mTextPositionsDirty(false)
+{
+    mTitleLabel = new HbLabel("Title", this);
+    mTitleLabel->setAlignment(Qt::AlignCenter);
+    mDescLabel = new HbLabel("Description", this);
+    mDescLabel->setAlignment(Qt::AlignCenter);    
+}
+
+HgCoverflowWidget::~HgCoverflowWidget()
+{
+    
+}
+
+void HgCoverflowWidget::frontItemChanged ( const QModelIndex & current, const QModelIndex & previous )
+{
+    if (!this->model())
+        return;
+    
+    QVariant variant = this->model()->data(current, Qt::DisplayRole);
+    QStringList texts = variant.toStringList();
+    HbLabel* labels[2];
+    labels[0] = mTitleLabel;
+    labels[1] = mDescLabel;
+    int n = texts.size() > 2 ? 2 : texts.size();
+    for (int i = 0; i < n; i++)
+        labels[i]->setPlainText(texts[i]);
+    
+    mTextPositionsDirty = true;
+}
+
+void HgCoverflowWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+    HgMediawall::resizeEvent(event);
+    
+    mTextPositionsDirty = true;
+    
+    QObject::connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), 
+        this, SLOT(frontItemChanged(const QModelIndex&, const QModelIndex&)));
+}
+
+void HgCoverflowWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+    HgMediawall::paint(painter, option, widget);
+
+    if (mTextPositionsDirty)
+    {
+        QModelIndex index = this->currentIndex();
+
+        if (index.isValid())
+        {
+            QRectF bounds;
+
+            QPointF halfSize = QPointF(itemSize().width()/2, itemSize().height()/2);
+            bounds.setTopLeft(rect().center() + frontItemPositionDelta() - halfSize);              
+            bounds.setBottomRight(rect().center() + frontItemPositionDelta() + halfSize);
+
+            mTitleLabel->resize(QSizeF(size().width(), mTitleLabel->minimumSize().height()));
+            mTitleLabel->setPos(QPointF(bounds.center().x() - size().width()/2,
+                bounds.top() - 40));
+            mDescLabel->resize(QSizeF(size().width(), mDescLabel->minimumSize().height()));
+            mDescLabel->setPos(QPointF(bounds.center().x() - size().width()/2,
+                    bounds.bottom() + 40 - mDescLabel->minimumSize().height()));
+            
+            frontItemChanged(index, index);
+            
+            mTextPositionsDirty = false;        
+        }
+        
+    }
+    
+}
+
+void HgCoverflowWidget::updateTextPositions()
+{
+    mTextPositionsDirty = true;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgitemsizedialog.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Another view for test application.
+*
+*/
+#include "hgitemsizedialog.h"
+
+#include <qgraphicslinearlayout.h>
+#include <qgraphicssceneresizeevent>
+#include <hbslider>
+#include <hbpushbutton>
+
+#include "trace.h"
+
+
+
+HgItemSizeDialog::HgItemSizeDialog(QSizeF size, QSizeF spacing, HbWidget *parent) : HbDialog(parent),
+mSize(size),
+mSpacing(spacing)
+{    
+
+    this->setAttribute(Qt::WA_DeleteOnClose);
+    this->setFlag(QGraphicsItem::ItemIsMovable);
+    this->setModal(false);
+    this->setBackgroundFaded(false);
+    this->setDismissPolicy(HbPopup::TapOutside);
+    this->setTimeout(5000);
+    this->setMinimumSize(QSizeF(200, 200));
+    
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+    
+    QSizeF itemSize = mSize;
+    QSizeF itemSpacing = mSpacing;
+
+    int maxVal = 500;
+    if (parent)
+        maxVal = qMax(parent->size().width(), parent->size().height());
+            
+    
+    HbSlider* slider1 = new HbSlider(Qt::Horizontal);
+    slider1->setMinimum(1);
+    slider1->setMaximum(maxVal);
+    slider1->setValue(itemSize.width());
+    mSizeXSlider = slider1;
+    
+    HbSlider* slider2 = new HbSlider(Qt::Horizontal);
+    slider2->setMinimum(1);
+    slider2->setMaximum(maxVal);
+    slider2->setValue(itemSize.height());
+    mSizeYSlider = slider2;
+
+    HbSlider* slider3 = new HbSlider(Qt::Horizontal);
+    slider3->setMinimum(0);
+    slider3->setMaximum(maxVal);
+    slider3->setValue(itemSpacing.width());
+    mSpacingXSlider = slider3;
+
+    HbSlider* slider4 = new HbSlider(Qt::Horizontal);
+    slider4->setMinimum(0);
+    slider4->setMaximum(maxVal);
+    slider4->setValue(itemSpacing.height());
+    mSpacingYSlider = slider4;
+
+    mSizeXLabel = new HbLabel();
+    mSizeYLabel = new HbLabel();
+    mSpacingXLabel = new HbLabel();
+    mSpacingYLabel = new HbLabel();
+    
+    layout->addItem(mSizeXLabel);
+    layout->addItem(slider1);
+    layout->addItem(mSizeYLabel);
+    layout->addItem(slider2);
+    layout->addItem(mSpacingXLabel);
+    layout->addItem(slider3);
+    layout->addItem(mSpacingYLabel);
+    layout->addItem(slider4);
+    
+    mSizeXLabel->setNumber(itemSize.width());
+    mSizeYLabel->setNumber(itemSize.height());
+    mSpacingXLabel->setNumber(itemSpacing.width());
+    mSpacingYLabel->setNumber(itemSpacing.height());
+    
+    QObject::connect(slider1, SIGNAL(valueChanged(int)), this, SLOT(itemSizeXChanged(int)));
+    QObject::connect(slider2, SIGNAL(valueChanged(int)), this, SLOT(itemSizeYChanged(int)));
+    QObject::connect(slider3, SIGNAL(valueChanged(int)), this, SLOT(itemSpacingXChanged(int)));
+    QObject::connect(slider4, SIGNAL(valueChanged(int)), this, SLOT(itemSpacingYChanged(int)));
+
+    HbPushButton* button = new HbPushButton("Close");
+    QObject::connect(button, SIGNAL(clicked(bool)), this, SLOT(buttonClosed(bool)));
+    layout->addItem(button);
+
+    this->setLayout(layout);
+        
+}
+
+void HgItemSizeDialog::itemSizeXChanged(int value)
+{
+    QSizeF s = mSize;
+    mSize = QSizeF(value, s.height());
+    mSizeXLabel->setNumber(value);
+    emit updateItemSizeAndSpacing();
+}
+
+void HgItemSizeDialog::itemSizeYChanged(int value)
+{
+    QSizeF s = mSize;
+    mSize = QSizeF(s.width(), value);
+    mSizeYLabel->setNumber(value);
+    emit updateItemSizeAndSpacing();
+}
+
+void HgItemSizeDialog::itemSpacingXChanged(int value)
+{
+    QSizeF s = mSpacing;
+    mSpacing = QSizeF(value, s.height());
+    mSpacingXLabel->setNumber(value);
+    emit updateItemSizeAndSpacing();
+}
+
+void HgItemSizeDialog::itemSpacingYChanged(int value)
+{
+    QSizeF s = mSpacing;
+    mSpacing = QSizeF(s.width(), value);
+    mSpacingYLabel->setNumber(value);
+    emit updateItemSizeAndSpacing();
+}
+
+void HgItemSizeDialog::buttonClosed(bool)
+{
+    close();
+    emit closed();
+}
+
+QSizeF HgItemSizeDialog::itemSize() const
+{
+    return mSize;
+}
+
+QSizeF HgItemSizeDialog::itemSpacing() const
+{
+    return mSpacing;
+}
+
+static void setSliderScale(HbSlider* slider, int min, int max)
+{
+    slider->setMinimum(min);
+    slider->setMaximum(max);
+}
+
+
+void HgItemSizeDialog::setSliderLimits(int min, int max)
+{
+    setSliderScale(mSizeXSlider, min, max);
+    setSliderScale(mSizeYSlider, min, max);
+    setSliderScale(mSpacingXSlider, min, max);
+    setSliderScale(mSpacingYSlider, min, max);
+}
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgtestview.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgtestview.cpp	Mon May 03 13:32:54 2010 +0300
@@ -34,12 +34,10 @@
         HbMainWindow *primaryWindow = mainWindows[0];
 
         setTitle(primaryWindow->currentView()->title());
-        setItemVisible(Hb::AllItems, true); // ensure that all needed view items stay visible
 
-        // set view as parent because action will be removed on view exit
-        mBackAction = new HbAction(Hb::BackAction, this);
-        primaryWindow->addSoftKeyAction(Hb::SecondarySoftKey, mBackAction);
-        connect(mBackAction, SIGNAL(triggered()), SLOT(closeView()));
+        HbAction *backAction = new HbAction(Hb::BackNaviAction);
+        connect(backAction, SIGNAL(triggered()), SIGNAL(closeRequested()));
+        setNavigationAction(backAction);
 
         QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
         HANDLE_ERROR_NULL(layout);
@@ -66,21 +64,6 @@
     }
 }
 
-void HgTestView::closeView()
-{
-    FUNC_LOG;
-
-    QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
-    if (mainWindows.count() > 0)
-    {
-        HbMainWindow *primaryWindow = mainWindows[0];
-        primaryWindow->removeView(this);
-        primaryWindow->setViewSwitchingEnabled(true);
-        primaryWindow->removeSoftKeyAction(Hb::SecondarySoftKey, mBackAction); // restores original action
-    }
-    delete this; // ownership transferred back from HbMainWindow
-}
-
 void HgTestView::resizeEvent(QGraphicsSceneResizeEvent *event)
 {
     FUNC_LOG;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgetoptionsview.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,566 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include <hbaction.h>
+#include <hbdataform.h>
+#include <hbdataformmodel.h>
+#include <hbabstractviewitem.h>
+#include <QGraphicsLinearLayout>
+#include <QGraphicsSceneResizeEvent>
+#include <QSettings>
+#include "hgwidgetoptionsview.h"
+#include "trace.h"
+
+static const QString WIDGET_TYPE = "Widget type";
+static const QString SCROLLBAR_VISIBILITY = "Scrollbar visibility";
+static const QString INTERACTIVE_SCROLLBAR = "Interactive scrollbar";
+static const QString MODEL_IMAGE_TYPE = "Datamodel image type";
+static const QString WIDGET_HEIGHT = "Widget height";
+static const QString WIDGET_WIDTH = "Widget width";
+static const QString LOW_RES_IMAGES = "Use low res images";
+static const QString TITLE_POSITION = "Title position";
+static const QString TITLE_FONT = "Title font";
+static const QString DESCRIPTION_POSITION = "Description position";
+static const QString DESCRIPTION_FONT = "Description font";
+static const QString REFLECTIONS_ENABLED = "Reflections enabled";
+
+enum DataFormItems {
+    ItemWidgetType = 0,
+    ItemScrollBarVisibility,
+    ItemScrollBarInteractivity,
+    ItemModelImageType,
+    ItemWidgetHeight,
+    ItemWidgetWidth,
+    ItemLowResImages,
+    ItemTitlePosition,
+    ItemTitleFont,
+    ItemDescriptionPosition,
+    ItemDescriptionFont,
+    ItemReflectionEnabled,
+};
+
+HgWidgetOptionsView::HgWidgetOptionsView(QGraphicsItem *parent) :
+    HbView(parent),
+    mForm(new HbDataForm(this)),
+    mModel(new HbDataFormModel(this)),
+    mContentReady(false),
+    mUpdateWidgetSize(true)
+{
+    HbAction *backAction = new HbAction(Hb::BackNaviAction);
+    connect(backAction, SIGNAL(triggered()), SIGNAL(optionsClosed()));
+    setNavigationAction(backAction);
+
+    HbDataFormModelItem *item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, WIDGET_TYPE);
+    item->setContentWidgetData(QString("items"), QStringList("Grid") << "Coverflow" << "T-Bone");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, SCROLLBAR_VISIBILITY);
+    item->setContentWidgetData(QString("items"), QStringList("Autohide") << "Always on" << "Always off");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ToggleValueItem, INTERACTIVE_SCROLLBAR);
+    item->setContentWidgetData(QString("text"), QString("no"));
+    item->setContentWidgetData(QString("additionalText"), QString("yes"));
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, MODEL_IMAGE_TYPE);
+    item->setContentWidgetData(QString("items"), QStringList("QImage") << "HbIcon" << "QIcon");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::TextItem, WIDGET_HEIGHT);
+    item->setContentWidgetData(QString("text"), QString("0"));
+    item->setContentWidgetData(QString("inputMethodHints"), Qt::ImhDigitsOnly);
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::TextItem, WIDGET_WIDTH);
+    item->setContentWidgetData(QString("text"), QString("0"));
+    item->setContentWidgetData(QString("inputMethodHints"), Qt::ImhDigitsOnly);
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ToggleValueItem, LOW_RES_IMAGES);
+    item->setContentWidgetData(QString("text"), QString("no"));
+    item->setContentWidgetData(QString("additionalText"), QString("yes"));
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, TITLE_POSITION);
+    item->setContentWidgetData(QString("items"), QStringList("Hidden") << "Above" << "Below");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, TITLE_FONT);
+    item->setContentWidgetData(QString("items"), QStringList("Primary") << "Secondary" << "Title" << "Primary small" << "Digital");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, DESCRIPTION_POSITION);
+    item->setContentWidgetData(QString("items"), QStringList("Hidden") << "Above" << "Below");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ComboBoxItem, DESCRIPTION_FONT);
+    item->setContentWidgetData(QString("items"), QStringList("Primary") << "Secondary" << "Title" << "Primary small" << "Digital");
+
+    item = mModel->appendDataFormItem(
+        HbDataFormModelItem::ToggleValueItem, REFLECTIONS_ENABLED);
+    item->setContentWidgetData(QString("text"), QString("no"));
+    item->setContentWidgetData(QString("additionalText"), QString("yes"));
+
+    connect(mModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(updateData(QModelIndex, QModelIndex)));
+    mForm->setModel(mModel);
+
+    setupData();
+    mContentReady = true;
+
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+    layout->addItem(mForm);
+    setLayout(layout);
+}
+
+HgWidgetOptionsView::~HgWidgetOptionsView()
+{
+}
+
+void HgWidgetOptionsView::updateData(QModelIndex startIn, QModelIndex endIn)
+{
+    Q_UNUSED(endIn);
+
+    if (!mContentReady) return;
+
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+
+    HbDataFormModelItem *item = mModel->itemFromIndex(startIn);
+    if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_TYPE) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HgTestWidgetType type = HgWidgetNone;
+        switch (index) {
+            case 0:
+                type = HgWidgetGrid;
+                break;
+            case 1:
+                type = HgWidgetCoverflow;
+                break;
+            case 2:
+                type = HgWidgetTBone;
+                break;
+            default: break;
+        }
+
+        setCoverflowEnabled(index == 1 || index  == 2);
+        settings.setValue(SETT_WIDGET_TYPE, type);
+        emit widgetTypeChanged(type);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == SCROLLBAR_VISIBILITY) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HgWidget::ScrollBarPolicy visibility = HgWidget::ScrollBarAutoHide;
+        switch (index) {
+            case 0:
+                visibility = HgWidget::ScrollBarAutoHide;
+                break;
+            case 1:
+                visibility = HgWidget::ScrollBarAlwaysOn;
+                break;
+            case 2:
+                visibility = HgWidget::ScrollBarAlwaysOff;
+                break;
+            default: break;
+        }
+
+        settings.setValue(SETT_SCROLLBAR_VISIBILITY, visibility);
+        emit scrollBarVisibilityChanged(visibility);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == INTERACTIVE_SCROLLBAR) {
+        QVariant data = item->contentWidgetData(QString("text"));
+        bool value = data.toString() == "yes";
+        settings.setValue(SETT_SCROLLBAR_INTERACTIVITY, value);
+        if (value) {
+            item = mModel->itemFromIndex(mModel->index(ItemScrollBarVisibility, 0));
+            if (item) {
+                item->setContentWidgetData(QString("currentIndex"), 1); // Set scroll bar always on
+            }
+        }
+        emit scrollBarInteractivityChanged(value);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == MODEL_IMAGE_TYPE) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HgTestImageType type = ImageTypeNone;
+        switch (index) {
+            case 0:
+                type = ImageTypeQImage;
+                break;
+            case 1:
+                type = ImageTypeHbIcon;
+                break;
+            case 2:
+                type = ImageTypeQIcon;
+                break;
+            default: break;
+        }
+
+        settings.setValue(SETT_MODEL_IMAGE_TYPE, type);
+        emit imageTypeChanged(type);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_HEIGHT) {
+        emit widgetHeightChanged(item->contentWidgetData(QString("text")).toInt());
+        storeWidgetSize();
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == WIDGET_WIDTH) {
+        emit widgetWidthChanged(item->contentWidgetData(QString("text")).toInt());
+        storeWidgetSize();
+
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == LOW_RES_IMAGES) {
+        QVariant data = item->contentWidgetData(QString("text"));
+        bool value = data.toString() == "yes";
+        settings.setValue(SETT_LOW_RES_IMAGES, value);
+        emit lowResImageUseChanged(value);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == TITLE_POSITION) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HgMediawall::LabelPosition position = HgMediawall::PositionNone;
+        switch (index) {
+            case 0:
+                position = HgMediawall::PositionNone;
+                break;
+            case 1:
+                position = HgMediawall::PositionAboveImage;
+                break;
+            case 2:
+                position = HgMediawall::PositionBelowImage;
+                break;
+            default: break;
+        }
+
+        settings.setValue(SETT_TITLE_POSITION, position);
+        emit titlePositionChanged(position);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == TITLE_FONT) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HbFontSpec::Role role = HbFontSpec::Undefined;
+        switch (index) {
+            case 0:
+                role = HbFontSpec::Primary;
+                break;
+            case 1:
+                role = HbFontSpec::Secondary;
+                break;
+            case 2:
+                role = HbFontSpec::Title;
+                break;
+            case 3:
+                role = HbFontSpec::PrimarySmall;
+                break;
+            case 4:
+                role = HbFontSpec::Digital;
+                break;
+            default: break;
+        }
+        settings.setValue(SETT_TITLE_FONT, role);
+        emit titleFontChanged(HbFontSpec(role));
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == DESCRIPTION_POSITION) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HgMediawall::LabelPosition position = HgMediawall::PositionNone;
+        switch (index) {
+            case 0:
+                position = HgMediawall::PositionNone;
+                break;
+            case 1:
+                position = HgMediawall::PositionAboveImage;
+                break;
+            case 2:
+                position = HgMediawall::PositionBelowImage;
+                break;
+            default: break;
+        }
+
+        settings.setValue(SETT_DESCRIPTION_POSITION, position);
+        emit descriptionPositionChanged(position);
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == DESCRIPTION_FONT) {
+        int index = item->contentWidgetData(QString("currentIndex")).toInt();
+        HbFontSpec::Role role = HbFontSpec::Undefined;
+        switch (index) {
+            case 0:
+                role = HbFontSpec::Primary;
+                break;
+            case 1:
+                role = HbFontSpec::Secondary;
+                break;
+            case 2:
+                role = HbFontSpec::Title;
+                break;
+            case 3:
+                role = HbFontSpec::PrimarySmall;
+                break;
+            case 4:
+                role = HbFontSpec::Digital;
+                break;
+            default: break;
+        }
+        settings.setValue(SETT_DESCRIPTION_FONT, role);
+        emit descriptionFontChanged(HbFontSpec(role));
+    }
+    else if (item->data(HbDataFormModelItem::LabelRole).toString() == REFLECTIONS_ENABLED) {
+        QVariant data = item->contentWidgetData(QString("text"));
+        bool value = data.toString() == "yes";
+        settings.setValue(SETT_REFLECTIONS_ENABLED, value);
+        emit reflectionsEnabledChanged(value);
+    }
+}
+
+void HgWidgetOptionsView::setCoverflowEnabled(bool value)
+{
+    HbAbstractViewItem *item = mForm->itemByIndex(mModel->index(ItemLowResImages, 0));
+    if (item) item->setEnabled(value);
+    item = mForm->itemByIndex(mModel->index(ItemTitlePosition, 0));
+    if (item) item->setEnabled(value);
+    item = mForm->itemByIndex(mModel->index(ItemTitleFont, 0));
+    if (item) item->setEnabled(value);
+    item = mForm->itemByIndex(mModel->index(ItemDescriptionPosition, 0));
+    if (item) item->setEnabled(value);
+    item = mForm->itemByIndex(mModel->index(ItemDescriptionFont, 0));
+    if (item) item->setEnabled(value);
+    item = mForm->itemByIndex(mModel->index(ItemReflectionEnabled, 0));
+    if (item) item->setEnabled(value);    
+}
+
+void HgWidgetOptionsView::storeWidgetSize()
+{
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+
+    HbDataFormModelItem *item = item = mModel->itemFromIndex(mModel->index(ItemWidgetHeight, 0));
+    if (item) {
+        int value = item->contentWidgetData(QString("text")).toInt();
+        settings.setValue(SETT_WIDGET_HEIGHT, value);
+    }
+    item = mModel->itemFromIndex(mModel->index(ItemWidgetWidth, 0));
+    if (item) {
+        int value = item->contentWidgetData(QString("text")).toInt();
+        settings.setValue(SETT_WIDGET_WIDTH, value);
+    }
+
+    mUpdateWidgetSize = false;
+}
+
+void HgWidgetOptionsView::setupData()
+{
+    FUNC_LOG;
+
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+
+    HbDataFormModelItem *item = mModel->itemFromIndex(mModel->index(ItemWidgetType, 0));
+    QVariant value = settings.value(SETT_WIDGET_TYPE);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HgWidgetGrid:
+                index = 0;
+                break;
+            case HgWidgetCoverflow:
+                index = 1;
+                break;
+            case HgWidgetTBone:
+                index = 2;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+        setCoverflowEnabled(index == 1 || index  == 2);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemScrollBarVisibility, 0));
+    value = settings.value(SETT_SCROLLBAR_VISIBILITY);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HgWidget::ScrollBarAutoHide:
+                index = 0;
+                break;
+            case HgWidget::ScrollBarAlwaysOn:
+                index = 1;
+                break;
+            case HgWidget::ScrollBarAlwaysOff:
+                index = 2;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemScrollBarInteractivity, 0));
+    value = settings.value(SETT_SCROLLBAR_INTERACTIVITY);
+    if (item && value.isValid()) {
+        item->setContentWidgetData(QString("text"), value.toBool() ? "yes" : "no");
+        item->setContentWidgetData(QString("alternateText"), value.toBool() ? "no" : "yes");
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemModelImageType, 0));
+    value = settings.value(SETT_MODEL_IMAGE_TYPE);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case ImageTypeQImage:
+                value = 0;
+                break;
+            case ImageTypeHbIcon:
+                value = 1;
+                break;
+            case ImageTypeQIcon:
+                value = 2;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemWidgetHeight, 0));
+    value = settings.value(SETT_WIDGET_HEIGHT);
+    if (item && value.isValid()) {
+        item->setContentWidgetData(QString("text"), value.toInt());
+        mUpdateWidgetSize = false;
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemWidgetWidth, 0));
+    value = settings.value(SETT_WIDGET_WIDTH);
+    if (item && value.isValid()) {
+        item->setContentWidgetData(QString("text"), value.toInt());
+        mUpdateWidgetSize = false;
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemLowResImages, 0));
+    value = settings.value(SETT_LOW_RES_IMAGES);
+    if (item && value.isValid()) {
+        item->setContentWidgetData(QString("text"), value.toBool() ? "yes" : "no");
+        item->setContentWidgetData(QString("alternateText"), value.toBool() ? "no" : "yes");
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemTitlePosition, 0));
+    value = settings.value(SETT_TITLE_POSITION);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HgMediawall::PositionNone:
+                index = 0;
+                break;
+            case HgMediawall::PositionAboveImage:
+                index = 1;
+                break;
+            case HgMediawall::PositionBelowImage:
+                index = 2;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+    else if (item) {
+        item->setContentWidgetData(QString("currentIndex"), 1);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemTitleFont, 0));
+    value = settings.value(SETT_TITLE_FONT);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HbFontSpec::Primary:
+                index = 0;
+                break;
+            case HbFontSpec::Secondary:
+                index = 1;
+                break;
+            case HbFontSpec::Title:
+                index = 2;
+                break;
+            case HbFontSpec::PrimarySmall:
+                index = 3;
+                break;
+            case HbFontSpec::Digital:
+                index = 4;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemDescriptionPosition, 0));
+    value = settings.value(SETT_DESCRIPTION_POSITION);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HgMediawall::PositionNone:
+                index = 0;
+                break;
+            case HgMediawall::PositionAboveImage:
+                index = 1;
+                break;
+            case HgMediawall::PositionBelowImage:
+                index = 2;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemDescriptionFont, 0));
+    value = settings.value(SETT_DESCRIPTION_FONT);
+    if (item && value.isValid()) {
+        int index(0);
+        switch (value.toInt()) {
+            case HbFontSpec::Primary:
+                index = 0;
+                break;
+            case HbFontSpec::Secondary:
+                index = 1;
+                break;
+            case HbFontSpec::Title:
+                index = 2;
+                break;
+            case HbFontSpec::PrimarySmall:
+                index = 3;
+                break;
+            case HbFontSpec::Digital:
+                index = 4;
+                break;
+            default: break;
+        }
+        item->setContentWidgetData(QString("currentIndex"), index);
+    }
+
+    item = mModel->itemFromIndex(mModel->index(ItemReflectionEnabled, 0));
+    value = settings.value(SETT_REFLECTIONS_ENABLED);
+    if (item && value.isValid()) {
+        item->setContentWidgetData(QString("text"), value.toBool() ? "yes" : "no");
+        item->setContentWidgetData(QString("alternateText"), value.toBool() ? "no" : "yes");
+    }
+
+}
+
+void HgWidgetOptionsView::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+    FUNC_LOG;
+
+    if (mUpdateWidgetSize) {
+        mContentReady = false;
+        HbDataFormModelItem *item = item = mModel->itemFromIndex(mModel->index(ItemWidgetHeight, 0));
+        if (item) {
+            item->setContentWidgetData(QString("text"), event->newSize().height());
+        }
+
+        item = mModel->itemFromIndex(mModel->index(ItemWidgetWidth, 0));
+        if (item) {
+            item->setContentWidgetData(QString("text"), event->newSize().width());
+        }
+        mContentReady = true;
+    }
+}
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestdatamodel.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestdatamodel.cpp	Mon May 03 13:32:54 2010 +0300
@@ -54,15 +54,23 @@
 HgWidgetTestDataModel::HgWidgetTestDataModel(QObject *parent)
     : QAbstractListModel(parent),
       mCachingInProgress(false),
-      mImageType(TypeQImage),	  
+      mImageType(ImageTypeNone),
       mDefaultIcon((":/images/default.svg")),
-      mUseLowResImages(false)
+      mUseLowResImages(false),
+      mWrapper( new ThumbnailManager() ),
+      mThumbnailRequestPending(false),
+      mThumbnailRequestIndex(-1),
+      mThumbnailRequestID(-1),
+      mBufferManager(0)
 {
     FUNC_LOG;
+    mWrapper->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
 
-    mAlbumArtManager = new HgWidgetTestAlbumArtManager;
-    connect( mAlbumArtManager, SIGNAL(albumArtReady(int)), this, SLOT(updateAlbumArt(int)) );
-    connect( mAlbumArtManager, SIGNAL(albumCacheReady()), this, SLOT(albumCacheReady()) );
+    mWrapper->setProperty("qimageSupport","true");
+
+    QObject::connect( mWrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+                      this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
+
     init();
 }
 
@@ -73,14 +81,14 @@
 {
     FUNC_LOG;
 
-    disconnect( mAlbumArtManager, SIGNAL(albumArtReady(int)), this, SLOT(updateAlbumArt(int)) );
-    disconnect( mAlbumArtManager, SIGNAL(albumCacheReady()), this, SLOT(albumCacheReady()) );
-    delete mAlbumArtManager;
+    disconnect( mWrapper, SIGNAL(thumbnailReady( QPixmap , void* , int , int )), this, SLOT(thumbnailReady( QPixmap , void* , int , int )) );
+    delete mWrapper;
+    delete mBufferManager;
 }
 
 void HgWidgetTestDataModel::setThumbnailSize(ThumbnailManager::ThumbnailSize size)
 {
-    mAlbumArtManager->setThumbnailSize(size);
+    mWrapper->setThumbnailSize(size);
 }
 
 void HgWidgetTestDataModel::init()
@@ -103,6 +111,7 @@
             QString s = fileInfo.filePath();
             if (s.indexOf(QString(".jpg"),0,Qt::CaseInsensitive)>0){
                 mFiles.append(s);
+                mImages.append(QImage());
                 mVisibility.append(true);
             }
         }
@@ -112,7 +121,7 @@
     if (!pixmap.isNull()){
         mQIcon = QIcon(pixmap);
         if (!mQIcon.isNull()){
-            mHbIcon = HbIcon(mQIcon);    
+            mHbIcon = HbIcon(mQIcon);
         }
     }
 }
@@ -146,10 +155,13 @@
 
     int row = index.row();
 
-    if( row >= mFiles.count() ){
+    if( row < 0 && row >= mFiles.count() ){
         return returnValue;
     }
 
+    if( mBufferManager )
+        mBufferManager->setPosition( row );
+
     switch ( role )
         {
     case HgWidget::HgVisibilityRole:
@@ -175,35 +187,35 @@
                 returnValue = mDefaultIcon;
             }
             else {
-                QImage icon = mAlbumArtManager->albumArt(mFiles.at(row), row);
+                QImage icon = mImages.at(row);
                 if ( !icon.isNull() )
                     {
-                    if (mUseLowResImages) {                        
+                    if (mUseLowResImages) {
                         QSize size = icon.size();
                         icon = icon.scaled(QSize(size.width()/4, size.height()/4));
                     }
 
                     switch(mImageType)
                         {
-                        case TypeHbIcon:
+                        case ImageTypeHbIcon:
                             {
                             returnValue = mHbIcon;
                             break;
                             }
-                        case TypeQImage:
+                        case ImageTypeQImage:
                             {
                             returnValue = icon;
                             break;
                             }
-                        case TypeQIcon:
+                        case ImageTypeQIcon:
                             {
                             returnValue = mQIcon;
                             break;
                             }
                         default:
-                            break;                    
+                            break;
                         }
-                
+
                     }
                 else
                     {
@@ -231,10 +243,10 @@
             }
             break;
             }
-            
+
         case (Qt::UserRole+2):
             {
-                QImage icon = mAlbumArtManager->albumArt(mFiles.at(row), row);
+                QImage icon = mImages.at(row);
                 if (!icon.isNull())
                 {
                     returnValue = icon;
@@ -252,30 +264,9 @@
 void HgWidgetTestDataModel::refreshModel()
 {
     // Cancel all outstanding album art request first, then reset the model.
-    mAlbumArtManager->cancel();
 
-    // Before providing the new data to the view (list, grid, etc.), we want
-    // to make sure that we have enough album arts for the first screen.
-/*    mFiles.count() = mCollectionData->count();
-    if ( mFiles.count() > 0 ) {
-        int initCount = ( mFiles.count() > KInitCacheSize ) ? KInitCacheSize : mFiles.count();
-        QStringList albumArtList;
-        QString albumArtUri;
-        for ( int i = 0; i < initCount; i++ ) {
-            albumArtUri = mCollectionData->itemData(i, MpMpxCollectionData::AlbumArtUri);
-            if ( !albumArtUri.isEmpty() ) {
-                 albumArtList << albumArtUri;
-            }
-        }
-        mCachingInProgress = mAlbumArtManager->cacheAlbumArt(albumArtList);
-        if ( !mCachingInProgress ) {
-            reset();
-        }
-    }
-    else {
-        reset();
-    }
-    */
+    // TODO FIX
+
 }
 
 /*!
@@ -368,6 +359,14 @@
     }
 }
 
+void HgWidgetTestDataModel::reset()
+{
+    emit beginResetModel();
+    mImages.removeAt(0);
+    mFiles.removeAt(0);
+    emit endResetModel();
+}
+
 /*!
  Slot to be called when album art for the \a index needs to be updated.
  */
@@ -390,7 +389,12 @@
     }
 }
 
-void HgWidgetTestDataModel::setImageDataType(ImageType type)
+HgTestImageType HgWidgetTestDataModel::imageDataType() const
+{
+    return mImageType;
+}
+
+void HgWidgetTestDataModel::setImageDataType(HgTestImageType type)
 {
     mImageType = type;
 }
@@ -416,3 +420,102 @@
     return mUseLowResImages;
 }
 
+void HgWidgetTestDataModel::getNextThumbnail()
+{
+    if ( !mThumbnailRequestPending && mWaitingThumbnails.count()){
+        QString image = mWaitingThumbnails.takeFirst();
+        int index = mFiles.indexOf(image);
+        int *clientData = new int(index);
+        mThumbnailRequestID = mWrapper->getThumbnail(image, clientData, -1);
+        mThumbnailRequestIndex = index;
+        mThumbnailRequestPending = true;
+    }
+}
+
+void HgWidgetTestDataModel::setBuffer(int buffer, int treshhold)
+{
+    mWaitingThumbnails.clear();
+
+    if (mThumbnailRequestID!=-1){
+        mWrapper->cancelRequest(mThumbnailRequestID);
+    }
+
+    mThumbnailRequestID = -1;
+    mThumbnailRequestIndex = -1;
+    mThumbnailRequestPending = false;
+
+    delete mBufferManager;
+    mBufferManager = 0;
+    mBufferManager = new BufferManager(this, buffer, treshhold, 0, mFiles.count());
+    for (int i = 0; i<mImages.count();i++) {
+        mImages.replace(i, QImage());
+    }
+}
+
+void HgWidgetTestDataModel::release(int start, int end)
+{
+    bool requestNew = false;
+    int first = (start<=end)?start:end;
+    if (first<0)
+        first =0;
+
+    int last = end>=start?end:start;
+    if (last>=mFiles.count())
+        last=mFiles.count()-1;
+
+
+    for (int i(first); i<=last; i++){
+        mWaitingThumbnails.removeOne(mFiles.at(i));
+        if (mThumbnailRequestIndex==i && mThumbnailRequestID!=-1){
+            mWrapper->cancelRequest(mThumbnailRequestID);
+            requestNew = true;
+        }
+        mImages.replace(i,QImage());
+    }
+
+    if (requestNew){
+        mThumbnailRequestIndex = -1;
+        mThumbnailRequestID = -1;
+        mThumbnailRequestPending = false;
+        getNextThumbnail();
+    }
+}
+
+void HgWidgetTestDataModel::request(int start, int end, requestsOrder order)
+{
+    int first = start;
+    int last = end;
+
+    if (first<0)
+        first =0;
+
+    if (last>=mFiles.count())
+        last=mFiles.count()-1;
+
+    if (order == ascending){
+        for (int i(first); i<=last; i++){
+            mWaitingThumbnails.append(mFiles.at(i));
+        }
+    } else if (order ==descending){
+        for (int i(last); i>=first; i--){
+            mWaitingThumbnails.append(mFiles.at(i));
+        }
+    }
+
+    getNextThumbnail();
+}
+
+void HgWidgetTestDataModel::thumbnailReady( QPixmap pixmap, void* data, int /*id*/, int error )
+{
+    if (!error && !pixmap.isNull() ){
+//        int idx = reinterpret_cast<int>(data);
+        mImages.replace(mThumbnailRequestIndex,pixmap.toImage().convertToFormat(QImage::Format_RGB16));
+        QModelIndex modelIndex = QAbstractItemModel::createIndex(mThumbnailRequestIndex, 0);
+        emit dataChanged(modelIndex, modelIndex);
+    }
+    mThumbnailRequestIndex = -1;
+    mThumbnailRequestID = -1;
+    mThumbnailRequestPending = false;
+    getNextThumbnail();
+}
+
--- a/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestview.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/fute/HgWidgetTest/src/hgwidgettestview.cpp	Mon May 03 13:32:54 2010 +0300
@@ -24,35 +24,45 @@
 #include <hbscrollbar>
 #include <QActionGroup>
 #include <QGraphicsLinearLayout>
+#include <QSettings>
 #include "hgwidgettestview.h"
 #include "hgtestview.h"
+#include "hgwidgetoptionsview.h"
 #include "hgselectiondialog.h"
 #include "hgwidgettestdatamodel.h"
 #include "hgflipwidget.h"
+#include "hgitemsizedialog.h"
+#include "hgcoverflowwidget.h"
 #include "trace.h"
 #include <hgwidgets/hggrid.h>
 #include <hgwidgets/hgmediawall.h>
 
+
+static const int GRIDBUFFERSIZE(400);
+static const int COVERFLOWBUFFERSIZE(130);
+
 HgWidgetTestView::HgWidgetTestView(QGraphicsItem *parent) :
     HbView(parent),
-    mWidget(NULL),
-    mModel(NULL),
-    mListWidget(NULL),
+    mWidget(0),
+    mModel(0),
+    mWidgetType(HgWidgetNone),
+    mListWidget(0),
     mToggleOrientation(false),
-    mTBone(false),
-    mFlipWidget(NULL),
-    mFrontItem(NULL)
+    mFlipWidget(0),
+    mFrontItem(0),
+    mOptionsView(0),
+    mItemSizeDialog(0),
+    mItemPosDialog(0)
 {
     mModel = new HgWidgetTestDataModel(this);
-    mModel->setImageDataType(HgWidgetTestDataModel::TypeQImage);
     mSelectionModel = new QItemSelectionModel(mModel, this);
 
     createMenu();
 
     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
     mLayout->setContentsMargins(0,0,0,0);
-    initWidget( HgWidgetGrid );
-    setLayout( mLayout );
+    setupWidget();
+    setLayout(mLayout);
 }
 
 HgWidgetTestView::~HgWidgetTestView()
@@ -63,130 +73,18 @@
 {
     FUNC_LOG;
 
-    HbMenu* modeMenu = new HbMenu("Change widget type");
-    menu()->addMenu(modeMenu);
-
-    HbMenu* scrollBarMenu = new HbMenu("ScrollBar settings");
-    menu()->addMenu( scrollBarMenu );
-
-    HbMenu* imageTypeMenu = new HbMenu("Datamodel image type");
-    menu()->addMenu( imageTypeMenu );
-
-    HbAction* gridAction = modeMenu->addAction( "Use grid" );
-    HbAction* coverFlowAction = modeMenu->addAction( "Use coverFlow" );
-    HbAction* TBone = modeMenu->addAction( "Use TBone" );
-    connect( modeMenu, SIGNAL(triggered(HbAction*)), this, SLOT(switchWidget(HbAction*)) );
-
-    QActionGroup* ac1 = new QActionGroup( this );
-    gridAction->setCheckable( true );
-    coverFlowAction->setCheckable( true );
-    TBone->setCheckable(true);
-    gridAction->setChecked( true );
-    ac1->addAction( gridAction );
-    ac1->addAction( coverFlowAction );
-    ac1->addAction( TBone );
-
-    HbAction* scrollBarAutoHideAction = scrollBarMenu->addAction( "Autohide ScrollBar" );
-    HbAction* scrollBarAlwaysOnAction = scrollBarMenu->addAction( "ScrollBar always on" );
-    HbAction* scrollBarAlwaysOffAction = scrollBarMenu->addAction( "ScrollBar always off" );
-    scrollBarMenu->addSeparator();
-    HbAction* interactiveScrollBarAction = scrollBarMenu->addAction( "Interactive scrollbar" );
-    HbAction* uninteractiveScrollBarAction = scrollBarMenu->addAction( "Uninteractive scrollbar" );
-    connect( scrollBarAutoHideAction, SIGNAL(triggered()), this, SLOT(autoHideScrollBar()) );
-    connect( scrollBarAlwaysOnAction, SIGNAL(triggered()), this, SLOT(scrollBarAlwaysOn()) );
-    connect( scrollBarAlwaysOffAction, SIGNAL(triggered()), this, SLOT(scrollBarAlwaysOff()) );
-    connect( interactiveScrollBarAction, SIGNAL(triggered()), this, SLOT(interactiveScrollBar()) );
-    connect( uninteractiveScrollBarAction, SIGNAL(triggered()), this, SLOT(unInteractiveScrollBar()) );
-
-    QActionGroup* ac2 = new QActionGroup( this );
-    scrollBarAutoHideAction->setCheckable( true );
-    scrollBarAlwaysOnAction->setCheckable( true );
-    scrollBarAlwaysOffAction->setCheckable(true);
-    scrollBarAutoHideAction->setChecked( true );
-    ac2->addAction( scrollBarAutoHideAction );
-    ac2->addAction( scrollBarAlwaysOnAction );
-    ac2->addAction( scrollBarAlwaysOffAction );
-
-    QActionGroup* ac3 = new QActionGroup( this );
-    interactiveScrollBarAction->setCheckable( true );
-    uninteractiveScrollBarAction->setCheckable( true );
-    uninteractiveScrollBarAction->setChecked( true );
-    ac3->addAction( interactiveScrollBarAction );
-    ac3->addAction( uninteractiveScrollBarAction );
-
-    HbAction* qimageAction = imageTypeMenu->addAction( "feed QImages" );
-    HbAction* hbiconAction = imageTypeMenu->addAction( "feed HbIcons" );
-    HbAction* qiconAction = imageTypeMenu->addAction( "feed QIcons" );
-    connect( qimageAction, SIGNAL(triggered()), this, SLOT(feedqimages()) );
-    connect( hbiconAction, SIGNAL(triggered()), this, SLOT(feedhbicons()) );
-    connect( qiconAction, SIGNAL(triggered()), this, SLOT(feedqicons()) );
-
-    QActionGroup* ac4 = new QActionGroup( this );
-    qimageAction->setCheckable( true );
-    hbiconAction->setCheckable( true );
-    qiconAction->setCheckable( true );
-    qimageAction->setChecked( true );
-    ac4->addAction( qimageAction );
-    ac4->addAction( hbiconAction );
-    ac4->addAction( qiconAction );
-
+    menu()->addAction("Options", this, SLOT(showOptions()));
+    menu()->addAction("Reset Options", this, SLOT(resetOptions()));
     menu()->addAction("Toggle scrolldirection", this, SLOT(toggleScrollDirection()));
     menu()->addAction("Simulate orientation switch", this, SLOT(orientationChanged()));
-
-    mUseLowResAction = menu()->addAction( "Use low res images for coverflow" );
-    mUseLowResAction->setCheckable(true);
-    mUseLowResAction->setChecked(false);
-    mUseLowResAction->setEnabled(false);
-    connect( mUseLowResAction, SIGNAL(triggered()), this, SLOT(toggleLowResForCoverflow()) );
-    
+    menu()->addAction("Edit item size", this, SLOT(startItemSizeChange()));
+    menu()->addAction("Edit item pos", this, SLOT(startItemPosChange()));
+        
     HbMenu *modelChangeSubMenu = menu()->addMenu("Change model");
     modelChangeSubMenu->addAction("Remove items", this, SLOT(openDeleteItemsDialog()));
     modelChangeSubMenu->addAction("Move items", this, SLOT(openMoveItemsDialog()));
     modelChangeSubMenu->addAction("Add items", this, SLOT(openAddItemsDialog()));
-
-    HbMenu *labelChangeSubMenu = menu()->addMenu("Change labels");
-    HbMenu *titleSubMenu = labelChangeSubMenu->addMenu("Title");
-    HbAction *aboveAction1 = titleSubMenu->addAction("Above", this, SLOT(setTitleAboveImage()));
-    HbAction *belowAction1 = titleSubMenu->addAction("Below", this, SLOT(setTitleBelowImage()));
-    HbAction *hiddenAction1 = titleSubMenu->addAction("Hide", this, SLOT(setTitleHidden()));
-    QActionGroup* ac5 = new QActionGroup(this);
-    aboveAction1->setCheckable(true);
-    belowAction1->setCheckable(true);
-    hiddenAction1->setCheckable(true);
-    hiddenAction1->setChecked(true);
-    ac5->addAction(aboveAction1);
-    ac5->addAction(belowAction1);
-    ac5->addAction(hiddenAction1);
-
-    HbMenu *descriptionSubMenu = labelChangeSubMenu->addMenu("Description");
-    HbAction *aboveAction2 = descriptionSubMenu->addAction("Above", this, SLOT(setDescriptionAboveImage()));
-    HbAction *belowAction2 = descriptionSubMenu->addAction("Below", this, SLOT(setDescriptionBelowImage()));
-    HbAction *hiddenAction2 = descriptionSubMenu->addAction("Hide", this, SLOT(setDescriptionHidden()));
-    QActionGroup* ac6 = new QActionGroup(this);
-    aboveAction2->setCheckable(true);
-    belowAction2->setCheckable(true);
-    hiddenAction2->setCheckable(true);
-    hiddenAction2->setChecked(true);
-    ac6->addAction(aboveAction2);
-    ac6->addAction(belowAction2);
-    ac6->addAction(hiddenAction2);
-}
-
-void HgWidgetTestView::switchWidget(HbAction* action)
-{
-    FUNC_LOG;
-
-    mTBone = false;
-    if( action->text() == "Use grid"){
-        initWidget( HgWidgetGrid );
-    }
-    else if( action->text() == "Use coverFlow"){
-        initWidget( HgWidgetCoverflow );
-    }
-    else if( action->text() == "Use TBone" ){
-        mTBone = true;
-        initWidget( HgWidgetCoverflow );
-    }
+    modelChangeSubMenu->addAction("Reset model", this, SLOT(resetModel()));
 }
 
 void HgWidgetTestView::toggleScrollDirection()
@@ -194,77 +92,191 @@
     FUNC_LOG;
 
     mToggleOrientation = !mToggleOrientation;
-    initWidget( mWidgetType );
+    initWidget(mWidgetType);
 }
 
-void HgWidgetTestView::initWidget( WidgetType type )
+void HgWidgetTestView::initWidget(HgTestWidgetType type)
 {
     FUNC_LOG;
 
-    mWidgetType = type;
+    if (mWidgetType != type) {
+        mWidgetType = type;
 
-    // TODO, disconnecting signals required?
+        // TODO, disconnecting signals required?
 
-    if( mWidget )
-        mLayout->removeItem(mWidget);
-    if( mListWidget )
-        mLayout->removeItem(mListWidget);
+        if( mWidget )
+            mLayout->removeItem(mWidget);
+        if( mListWidget )
+            mLayout->removeItem(mListWidget);
 
-    delete mWidget;
-    mWidget = NULL;
+        delete mWidget;
+        mWidget = NULL;
 
-    delete mListWidget;
-    mListWidget = NULL;
+        delete mListWidget;
+        mListWidget = NULL;
 
-    mWidget = createWidget(type);
-    mLayout->addItem(mWidget);
+        mWidget = createWidget(type);
+        mLayout->addItem(mWidget);
 
-    switch (type)
-        {
-        case HgWidgetGrid:
-            {
-            mUseLowResAction->setEnabled(false);
-            mModel->enableLowResImages(false);
-            // TODO, init grid different model,
-            mModel->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
-            break;
-            }
-        case HgWidgetCoverflow:
-            {
-            mUseLowResAction->setEnabled(true);
-            mModel->enableLowResImages(mUseLowResAction->isChecked());        
-            mModel->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
-            if (mTBone) {
+        switch (type) {
+            case HgWidgetGrid:
+            	setItemVisible(Hb::AllItems, true);
+                mModel->enableLowResImages(false);
+                // TODO, init grid different model,
+                mModel->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
+                break;
+            case HgWidgetCoverflow:
+                mModel->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
+                setItemVisible(Hb::AllItems, orientation() != Qt::Horizontal);
+                break;
+            case HgWidgetTBone:
+            	setItemVisible(Hb::AllItems, true);
+                mModel->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
                 mListWidget = new HbListWidget;
                 mLayout->addItem(mListWidget);
                 mListWidget->addItem( "List item 1");
                 mListWidget->addItem( "List item 2");
                 mListWidget->addItem( "List item 3");
-                }
-            break;
-            }
-        default:
-            break;
+                break;
+            default:
+                break;
         }
 
-    HANDLE_ERROR_NULL(mWidget);
-    if (mWidget)
-    {
-        mWidget->setModel( mModel );
+        HANDLE_ERROR_NULL(mWidget);
+        mWidget->setModel(mModel);
         connect(mWidget, SIGNAL(activated(QModelIndex)), SLOT(openDialog(QModelIndex)));
         connect(mWidget, SIGNAL(longPressed(QModelIndex, QPointF)), SLOT(openView(QModelIndex)));
         QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
-        if (mainWindows.count() > 0)
-        {
+        if (mainWindows.count() > 0) {
             HbMainWindow *primaryWindow = mainWindows[0];
             connect(primaryWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
+            connect(primaryWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
         }
+        setupWidgetOptions();
+        setupWidgetSize();
+
+        connect(mWidget, SIGNAL(scrollingStarted()), SLOT(onScrollingStarted()));
+        connect(mWidget, SIGNAL(scrollingEnded()), SLOT(onScrollingEnded()));
+    }
+}
+
+void HgWidgetTestView::changeScrollBarVisibility(HgWidget::ScrollBarPolicy policy)
+{
+    FUNC_LOG;
+
+    if (mWidget->scrollBarPolicy() != policy) {
+        mWidget->setScrollBarPolicy(policy);
+    }
+}
+
+void HgWidgetTestView::changeScrollBarInteractivity(bool value)
+{
+    FUNC_LOG;
+
+    if (mWidget->scrollBar()->isInteractive() != value) {
+        mWidget->scrollBar()->setInteractive(value);
+
+        if (mWidgetType == HgWidgetCoverflow || mWidgetType == HgWidgetTBone) {
+            mWidget->setIndexFeedbackPolicy(HgWidget::IndexFeedbackSingleCharacter);
+        }
+    }
+}
+
+void HgWidgetTestView::changeModelImageType(HgTestImageType type)
+{
+    FUNC_LOG;
+
+    if (mModel->imageDataType() != type) {
+        mModel->setImageDataType(type);
+    }
+}
+
+void HgWidgetTestView::changeLowResImageUse(bool value)
+{
+    FUNC_LOG;
+
+    if (mWidgetType == HgWidgetCoverflow || mWidgetType == HgWidgetTBone) {
+        mModel->enableLowResImages(value);
+        initWidget(mWidgetType);
+    }
+}
+
+void HgWidgetTestView::changeTitlePosition(HgMediawall::LabelPosition position)
+{
+    FUNC_LOG;
+
+    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
+    if (mediawall && mediawall->titlePosition() != position) {
+        mediawall->setTitlePosition(position);
+    }
+}
 
-    connect(mWidget, SIGNAL(scrollingStarted()), SLOT(onScrollingStarted()));
-    connect(mWidget, SIGNAL(scrollingEnded()), SLOT(onScrollingEnded()));
+void HgWidgetTestView::changeTitleFont(const HbFontSpec &fontSpec)
+{
+    FUNC_LOG;
+
+    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
+    if (mediawall && mediawall->titleFontSpec() != fontSpec) {
+        mediawall->setTitleFontSpec(fontSpec);
+    }
+}
+
+void HgWidgetTestView::changeDescriptionPosition(HgMediawall::LabelPosition position)
+{
+    FUNC_LOG;
+
+    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
+    if (mediawall && mediawall->descriptionPosition() != position) {
+        mediawall->setDescriptionPosition(position);
+    }
+}
+
+void HgWidgetTestView::changeDescriptionFont(const HbFontSpec &fontSpec)
+{
+    FUNC_LOG;
+
+    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
+    if (mediawall && mediawall->descriptionFontSpec() != fontSpec) {
+        mediawall->setDescriptionFontSpec(fontSpec);
     }
 }
 
+void HgWidgetTestView::changeWidgetHeight(int value)
+{
+    FUNC_LOG;
+
+    int height(rect().height());
+    if (value < height) {
+        qreal left(0), top(0), right(0), bottom(0);
+        mLayout->getContentsMargins(&left, &top, &right, &bottom);
+
+        if (mWidgetType == HgWidgetTBone) {
+            mListWidget->setPreferredSize(mListWidget->preferredSize().width(), height-value);
+            mLayout->setContentsMargins(left, 0, right, 0);
+        }
+        else {
+            int margin(0);
+            margin = (height-value)/2;
+            mLayout->setContentsMargins(left, margin, right, margin);
+        }
+    }
+}
+
+void HgWidgetTestView::changeWidgetWidth(int value)
+{
+    FUNC_LOG;
+
+    int width(rect().width());
+    int margin(0);
+    if (value < width) {
+        margin = (width-value)/2;
+    }
+
+    qreal left(0), top(0), right(0), bottom(0);
+    mLayout->getContentsMargins(&left, &top, &right, &bottom);
+    mLayout->setContentsMargins(margin, top, margin, bottom);
+}
+
 void HgWidgetTestView::openDialog(const QModelIndex& index)
 {
     FUNC_LOG;
@@ -272,7 +284,7 @@
     QVariant image = mModel->data(index, Qt::DecorationRole);
     QVariant texts = mModel->data(index, Qt::DisplayRole);
 
-    if (mWidgetType == HgWidgetCoverflow)
+    if (mWidgetType == HgWidgetCoverflow || mWidgetType == HgWidgetTBone)
     {
         if (image.canConvert<QPixmap>() && texts.canConvert<QStringList>())
         {
@@ -281,7 +293,7 @@
             {
                 if (mFrontItem)
                     mFrontItem->setVisible(false);
-                
+
                 if (mFlipWidget)
                     delete mFlipWidget;
 
@@ -290,6 +302,7 @@
                     return;
 
                 QRectF itemRect = poly.boundingRect();
+                itemRect.moveTo(itemRect.topLeft() + mWidget->geometry().topLeft());
 
                 mFlipWidget =
                     new HgFlipWidget(
@@ -355,18 +368,31 @@
                     strList.at(0),
                     strList.at(1),
                     QPixmap::fromImage(image.value<QImage>()));
+            connect(view, SIGNAL(closeRequested()), SLOT(closeCurrentView()));
             QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
             if (mainWindows.count() > 0)
             {
                 HbMainWindow *primaryWindow = mainWindows[0];
                 primaryWindow->addView(view);
-                primaryWindow->setViewSwitchingEnabled(false);
                 primaryWindow->setCurrentView(view);
             }
         }
     }
 }
 
+void HgWidgetTestView::closeCurrentView()
+{
+    FUNC_LOG;
+
+    QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
+    if (mainWindows.count() > 0) {
+        HbMainWindow *primaryWindow = mainWindows[0];
+        HbView *currentView = primaryWindow->currentView();
+        primaryWindow->setCurrentView(this);
+        primaryWindow->removeView(currentView);
+    }
+}
+
 void HgWidgetTestView::openDeleteItemsDialog()
 {
     FUNC_LOG;
@@ -458,65 +484,180 @@
     mWidget->show();
 }
 
-void HgWidgetTestView::autoHideScrollBar()
+void HgWidgetTestView::showOptions()
 {
-    setScrollBarPolicy(HgWidget::ScrollBarAutoHide);
+    FUNC_LOG;
+
+    QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
+    if (mainWindows.count() > 0) {
+        HbMainWindow *primaryWindow = mainWindows[0];
+        if (!mOptionsView) {
+            HgWidgetOptionsView* view = new HgWidgetOptionsView;
+            connect(view, SIGNAL(optionsClosed()), SLOT(hideOptions()));
+            connect(view, SIGNAL(widgetTypeChanged(HgTestWidgetType)),
+                SLOT(initWidget(HgTestWidgetType)));
+            connect(view, SIGNAL(scrollBarVisibilityChanged(HgWidget::ScrollBarPolicy)),
+                SLOT(changeScrollBarVisibility(HgWidget::ScrollBarPolicy)));
+            connect(view, SIGNAL(scrollBarInteractivityChanged(bool)),
+                SLOT(changeScrollBarInteractivity(bool)));
+            connect(view, SIGNAL(imageTypeChanged(HgTestImageType)),
+                SLOT(changeModelImageType(HgTestImageType)));
+            connect(view, SIGNAL(lowResImageUseChanged(bool)), SLOT(changeLowResImageUse(bool)));
+            connect(view, SIGNAL(widgetHeightChanged(int)), SLOT(changeWidgetHeight(int)));
+            connect(view, SIGNAL(widgetWidthChanged(int)), SLOT(changeWidgetWidth(int)));
+            connect(view, SIGNAL(titlePositionChanged(HgMediawall::LabelPosition)),
+                SLOT(changeTitlePosition(HgMediawall::LabelPosition)));
+            connect(view, SIGNAL(titleFontChanged(HbFontSpec)),
+                SLOT(changeTitleFont(HbFontSpec)));
+            connect(view, SIGNAL(descriptionPositionChanged(HgMediawall::LabelPosition)),
+                SLOT(changeDescriptionPosition(HgMediawall::LabelPosition)));
+            connect(view, SIGNAL(descriptionFontChanged(HbFontSpec)),
+                SLOT(changeDescriptionFont(HbFontSpec)));
+            connect(view, SIGNAL(reflectionsEnabledChanged(bool)), 
+                SLOT(changeReflectionsEnabled(bool)));
+
+            mOptionsView = view;
+            primaryWindow->addView(mOptionsView);
+        }
+        primaryWindow->setCurrentView(mOptionsView);
+    }
 }
 
-void HgWidgetTestView::scrollBarAlwaysOn()
-{
-    setScrollBarPolicy(HgWidget::ScrollBarAlwaysOn);
-}
-
-void HgWidgetTestView::scrollBarAlwaysOff()
+void HgWidgetTestView::hideOptions()
 {
-    setScrollBarPolicy(HgWidget::ScrollBarAlwaysOff);
-}
+    FUNC_LOG;
 
-void HgWidgetTestView::setScrollBarPolicy( HgWidget::ScrollBarPolicy policy )
-{
-    mWidget->setScrollBarPolicy( policy );
+    QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
+    if (mainWindows.count() > 0) {
+        HbMainWindow *primaryWindow = mainWindows[0];
+        primaryWindow->setCurrentView(this);
+    }
 }
 
-void HgWidgetTestView::setScrollBarInteractive( bool value )
+void HgWidgetTestView::setupWidget()
 {
-    if( value )
-        setScrollBarPolicy(HgWidget::ScrollBarAlwaysOn);
+    FUNC_LOG;
+
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
 
-    mWidget->scrollBar()->setInteractive(value);
+    QVariant value = settings.value(SETT_WIDGET_TYPE);
+    if (value.isValid()) {
+        initWidget(static_cast<HgTestWidgetType>(value.toInt()));
+    }
+    else {
+        initWidget(HgWidgetGrid);
+    }
 
-    if (mWidgetType == HgWidgetCoverflow) {
-        mWidget->setIndexFeedbackPolicy(HgWidget::IndexFeedbackSingleCharacter);
+    value = settings.value(SETT_LOW_RES_IMAGES);
+    if (value.isValid()) {
+        changeLowResImageUse(value.toBool());
     }
-    
 }
 
-void HgWidgetTestView::interactiveScrollBar()
+void HgWidgetTestView::setupWidgetOptions()
 {
-    setScrollBarInteractive(true);
+    FUNC_LOG;
+
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+
+    QVariant value = settings.value(SETT_SCROLLBAR_VISIBILITY);
+    if (value.isValid()) {
+        changeScrollBarVisibility(static_cast<HgWidget::ScrollBarPolicy>(value.toInt()));
+    }
+
+    value = settings.value(SETT_SCROLLBAR_INTERACTIVITY);
+    if (value.isValid()) {
+        changeScrollBarInteractivity(value.toBool());
+    }
+
+    value = settings.value(SETT_MODEL_IMAGE_TYPE);
+    if (value.isValid()) {
+        changeModelImageType(static_cast<HgTestImageType>(value.toInt()));
+    }
+	else {
+        changeModelImageType(ImageTypeQImage);
+	}
+
+    value = settings.value(SETT_TITLE_POSITION);
+    if (value.isValid()) {
+        changeTitlePosition(static_cast<HgMediawall::LabelPosition>(value.toInt()));
+    }
+
+    value = settings.value(SETT_TITLE_FONT);
+    if (value.isValid()) {
+        changeTitleFont(HbFontSpec(static_cast<HbFontSpec::Role>(value.toInt())));
+    }
+
+    value = settings.value(SETT_DESCRIPTION_POSITION);
+    if (value.isValid()) {
+        changeDescriptionPosition(static_cast<HgMediawall::LabelPosition>(value.toInt()));
+    }
+
+    value = settings.value(SETT_DESCRIPTION_FONT);
+    if (value.isValid()) {
+        changeDescriptionFont(HbFontSpec(static_cast<HbFontSpec::Role>(value.toInt())));
+    }
+
+    value = settings.value(SETT_REFLECTIONS_ENABLED);
+    if (value.isValid()) {
+        changeReflectionsEnabled(value.toBool());
+    }
+
 }
 
-void HgWidgetTestView::unInteractiveScrollBar()
+void HgWidgetTestView::setupWidgetSize()
 {
-    setScrollBarInteractive(false);
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+
+    QVariant value = settings.value(SETT_WIDGET_HEIGHT);
+    if (value.isValid()) {
+        changeWidgetHeight(value.toInt());
+    }
+
+    value = settings.value(SETT_WIDGET_WIDTH);
+    if (value.isValid()) {
+        changeWidgetWidth(value.toInt());
+    }
 }
 
-HgWidget *HgWidgetTestView::createWidget(WidgetType type) const
+HgWidget *HgWidgetTestView::createWidget(HgTestWidgetType type) const
 {
     FUNC_LOG;
     HANDLE_ERROR_NULL(mModel);
     HANDLE_ERROR_NULL(mSelectionModel);
 
-    Qt::Orientation scrollDirection = !mToggleOrientation ? Qt::Vertical : Qt::Horizontal ;
+    Qt::Orientation scrollDirection = Qt::Vertical;
+    QList<HbMainWindow *> mainWindows = hbInstance->allMainWindows();
+    if (mainWindows.count() > 0)
+    {
+        HbMainWindow *primaryWindow = mainWindows[0];
+        if (primaryWindow->orientation() == Qt::Horizontal) {
+            scrollDirection = Qt::Horizontal;
+        }
+    }
 
     HgWidget* widget = 0;
-
+    HgCoverflowWidget* temp = 0;
+    
     switch (type) {
         case HgWidgetGrid:
+            mModel->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
+            mModel->setBuffer(GRIDBUFFERSIZE, GRIDBUFFERSIZE/3);
             widget = new HgGrid(scrollDirection);
             break;
         case HgWidgetCoverflow:
-            widget = new HgMediawall();
+            mModel->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
+            mModel->setBuffer(COVERFLOWBUFFERSIZE, COVERFLOWBUFFERSIZE/3);
+            widget = new HgCoverflowWidget();
+            temp = (HgCoverflowWidget*)widget;
+            temp->setTitlePosition(HgMediawall::PositionNone);
+            break;
+        case HgWidgetTBone:
+            mModel->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
+            mModel->setBuffer(COVERFLOWBUFFERSIZE, COVERFLOWBUFFERSIZE/3);
+            widget = new HgCoverflowWidget();
+            temp = (HgCoverflowWidget*)widget;
+            temp->setTitlePosition(HgMediawall::PositionNone);
             break;
         default:
             break;
@@ -552,42 +693,23 @@
     return widget;
 }
 
-void HgWidgetTestView::feedqimages()
-{
-    mModel->setImageDataType(HgWidgetTestDataModel::TypeQImage);
-}
-
-void HgWidgetTestView::feedqicons()
-{
-    mModel->setImageDataType(HgWidgetTestDataModel::TypeQIcon);
-}
-
-void HgWidgetTestView::feedhbicons()
-{
-    mModel->setImageDataType(HgWidgetTestDataModel::TypeHbIcon);
-}
-
 void HgWidgetTestView::flipClosed()
 {
     delete mFlipWidget;
     mFlipWidget = 0;
     mModel->setData(mFlippedIndex, true, Qt::UserRole+1);
-    
+
     if (mFrontItem) {
         mFrontItem->setVisible(true);
     }
-        
-}
-void HgWidgetTestView::orientationChanged()
-{
-    mWidget->orientationChanged(Qt::Horizontal);
+
 }
 
 void HgWidgetTestView::onScrollingStarted()
 {
     FUNC_LOG;
 
-    // scrolling started, need to hide 
+    // scrolling started, need to hide
     // label displaying full resolution image
     if (mFrontItem)
         mFrontItem->setVisible(false);
@@ -599,104 +721,193 @@
     FUNC_LOG;
 
     if (mModel->lowResImagesEnabled()) {
-    
+
         if (!mWidget)
             return;
-    
+
         // get index to current item
         QModelIndex index = mWidget->currentIndex();
         if (!index.isValid())
             return;
-        
+
         // get outlines of the item so we know where to render
         QPolygonF poly;
         if (!mWidget->getItemOutline(index, poly))
             return;
-        
+
         // fetch highresolution image from the model
-        QVariant imgVariant = mModel->data(index, Qt::UserRole+2);    
+        QVariant imgVariant = mModel->data(index, Qt::UserRole+2);
         if (imgVariant.isNull())
             return;
-        
+
         QRectF itemRect = poly.boundingRect();
-    
+        itemRect.moveTo(itemRect.topLeft() + mWidget->geometry().topLeft());
+
         // show it using HbLabel
-        QPixmap pixmap = imgVariant.value<QPixmap>().scaled(itemRect.width(), itemRect.height());    
-        
+        QPixmap pixmap = imgVariant.value<QPixmap>().scaled(itemRect.width(), itemRect.height());
+
         if (!mFrontItem) {
             mFrontItem = new HbLabel(this);
         }
-    
-        
+
+
         mFrontItem->setVisible(false);
         mFrontItem->setIcon(HbIcon(pixmap));
         mFrontItem->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
         mFrontItem->setPos(itemRect.center() - QPointF(itemRect.width()/2, itemRect.height()/2));
         mFrontItem->resize(itemRect.width(), itemRect.height());
         mFrontItem->setVisible(true);
-        
-    }
-    
-}
-
-void HgWidgetTestView::toggleLowResForCoverflow()
-{
-    if (mWidgetType == HgWidgetCoverflow) {
-        mModel->enableLowResImages(mUseLowResAction->isChecked());
-        initWidget(mWidgetType);
-    }
-}
-
-void HgWidgetTestView::setTitleAboveImage()
-{
-    FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setTitlePosition(HgMediawall::PositionAboveImage);
-    }
-}
-
-void HgWidgetTestView::setTitleBelowImage()
-{
-    FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setTitlePosition(HgMediawall::PositionBelowImage);
     }
 }
 
-void HgWidgetTestView::setTitleHidden()
+void HgWidgetTestView::orientationChanged(Qt::Orientation orientation)
+{
+    if (orientation == Qt::Horizontal && mWidgetType == HgWidgetCoverflow ) {
+        setItemVisible(Hb::AllItems, false);
+    }
+    else if (orientation == Qt::Horizontal && mWidgetType == HgWidgetTBone) {
+        initWidget(HgWidgetCoverflow);
+//        HbEffect::add(mWidget,":/effect1.fxml", "end");
+//        HbEffect::start(mWidget, "end");
+        setItemVisible(Hb::AllItems, false);
+    }            
+    else if (orientation == Qt::Vertical && mWidgetType == HgWidgetCoverflow) {
+        initWidget(HgWidgetTBone);
+//        HbEffect::add(mWidget,":/effect1.fxml", "end");
+//        HbEffect::start(mWidget, "end");
+        setItemVisible(Hb::AllItems, true);
+    }
+    
+    HgCoverflowWidget* wall = qobject_cast<HgCoverflowWidget*>(mWidget);
+    if (wall)
+        wall->updateTextPositions();
+}
+void HgWidgetTestView::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+    Q_UNUSED(event);
+    FUNC_LOG;
+
+    setupWidgetSize();
+
+/*    if (mWidgetType == HgWidgetCoverflow ||
+        mWidgetType == HgWidgetTBone)
+    {
+        HgMediawall* wall = qobject_cast<HgMediawall*>(mWidget);
+        wall->setFrontItemPosition(QPointF(mWidget->size().width()/2, 
+            mWidget->size().height()/2));
+    }*/
+}
+
+Qt::Orientation HgWidgetTestView::orientation() const
 {
     FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setTitlePosition(HgMediawall::PositionNone);
+
+    if (mainWindow()) {
+        return mainWindow()->orientation();
     }
+
+    return Qt::Horizontal;
 }
 
-void HgWidgetTestView::setDescriptionAboveImage()
+void HgWidgetTestView::startItemSizeChange()
 {
-    FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setDescriptionPosition(HgMediawall::PositionAboveImage);
-    }
+    if (mItemSizeDialog)
+        return;
+    
+    if (!mWidget)
+        return;
+
+    QSizeF itemSize = mWidget->itemSize();
+    QSizeF itemSpacing = mWidget->itemSpacing();
+    mItemSizeDialog = new HgItemSizeDialog(itemSize, itemSpacing, this);
+    
+    QObject::connect(mItemSizeDialog, SIGNAL(updateItemSizeAndSpacing()), this, SLOT(updateItemSizeAndSpacing()));
+    QObject::connect(mItemSizeDialog, SIGNAL(closed()), this, SLOT(itemSizeDialogClosed()));
 }
 
-void HgWidgetTestView::setDescriptionBelowImage()
+void HgWidgetTestView::startItemPosChange()
 {
-    FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setDescriptionPosition(HgMediawall::PositionBelowImage);
+    if (mItemPosDialog)
+        return;
+    
+    if (!mWidget)
+        return;
+    
+    HgMediawall* wall = qobject_cast<HgMediawall*>(mWidget);
+    if (!wall)
+        return;
+    
+    QPointF itemPos = wall->frontItemPositionDelta();
+    QSizeF s(itemPos.x(), itemPos.y());
+    mItemPosDialog = new HgItemSizeDialog(s, s, this);
+    
+    mItemPosDialog->setSliderLimits(-500, 500);
+    
+    QObject::connect(mItemPosDialog, SIGNAL(updateItemSizeAndSpacing()), this, SLOT(updateItemPos()));
+    QObject::connect(mItemPosDialog, SIGNAL(closed()), this, SLOT(itemPosDialogClosed()));
+}
+
+
+
+void HgWidgetTestView::updateItemSizeAndSpacing()
+{
+    if (!mItemSizeDialog)
+        return;
+    
+    mWidget->setItemSize(mItemSizeDialog->itemSize());
+    mWidget->setItemSpacing(mItemSizeDialog->itemSpacing());
+    
+    HgCoverflowWidget* wall = qobject_cast<HgCoverflowWidget*>(mWidget);
+    if (wall)
+    {
+        wall->updateTextPositions();
     }
+
+    mWidget->update();
+    
 }
 
-void HgWidgetTestView::setDescriptionHidden()
+void HgWidgetTestView::updateItemPos()
+{
+    if (!mItemPosDialog)
+        return;
+    
+    HgCoverflowWidget* wall = qobject_cast<HgCoverflowWidget*>(mWidget);
+    if (!wall)
+        return;
+
+    QSizeF s = mItemPosDialog->itemSize();
+    wall->setFrontItemPositionDelta(QPointF(s.width(), s.height()));
+    wall->updateTextPositions();
+    mWidget->update();
+}
+
+void HgWidgetTestView::itemSizeDialogClosed()
 {
-    FUNC_LOG;
-    HgMediawall *mediawall = qobject_cast<HgMediawall *>(mWidget);
-    if (mediawall) {
-        mediawall->setDescriptionPosition(HgMediawall::PositionNone);
-    }
+    // dialog deletes it self at close
+    mItemSizeDialog = NULL;
+}
+
+void HgWidgetTestView::itemPosDialogClosed()
+{
+    mItemPosDialog = NULL;
 }
+
+void HgWidgetTestView::resetOptions()
+{
+    QSettings settings(SETT_ORGANIZATION, SETT_APPLICATION);
+    settings.clear();
+    setupWidget();
+}
+
+void HgWidgetTestView::changeReflectionsEnabled(bool enabled)
+{
+    HgMediawall* wall = qobject_cast<HgMediawall*>(mWidget);
+    if (wall)
+        wall->enableReflections(enabled);
+}
+
+void HgWidgetTestView::resetModel()
+{
+    mModel->reset();
+}
--- a/ganeswidgets/tsrc/unit/unittest_ganeswidgets.cpp	Mon Apr 19 14:40:06 2010 +0300
+++ b/ganeswidgets/tsrc/unit/unittest_ganeswidgets.cpp	Mon May 03 13:32:54 2010 +0300
@@ -20,8 +20,10 @@
 #include <QModelIndex>
 #include "hbautotest.h"
 #include <hbapplication.h>
+#include <hblabel.h>
 #include <hbmainwindow.h>
 #include <hbscrollbar>
+#include <hbview>
 #include <hgwidgets/hgwidgets.h>
 #include <hgwidgets/hggrid.h>
 #include <hgwidgets/hgmediawall.h>
@@ -39,6 +41,16 @@
 static const QPointF grid_portrait_pos7(180, 200);
 static const QPointF grid_portrait_pos8(280, 200);
 
+// These work with 360x640 resolution
+static const QPointF expected_label_pos_above_alone(180, 144);
+static const QPointF expected_label_pos_above_top(180, 132);
+static const QPointF expected_label_pos_above_bottom(180, 163);
+static const QPointF expected_label_pos_below_alone(180, 324);
+static const QPointF expected_label_pos_below_top(180, 312);
+static const QPointF expected_label_pos_below_bottom(180, 342);
+
+static const int default_delay(1500);
+
 class TestGanesWidgets : public QObject
 {
     Q_OBJECT
@@ -55,6 +67,7 @@
     void cleanup();
 
 private slots:
+    void test_setModel();
     void test_panGridLandscape();
     void test_panGridPortrait();
     void test_panCoverFlowLandscape();
@@ -75,15 +88,22 @@
     void test_addItemsCoverFlow();
     void test_removeItemsCoverFlow();
     void test_moveItemsCoverFlow();
+    void test_labelPositionsCoverFlow();
+    void test_labelFontSpecsCoverFlow();
+    void test_resetModelCoverFlow();
+    void test_resetModelGrid();
 
 private:
 
     void pan( Qt::Orientation, TBool begin );
+    bool checkLabelAt(HbMainWindow *window, const QPointF &pos, const QString &expectedText);
+    HbLabel *findLabelAt(QGraphicsItem *parent, const QPointF &pos);
 
 private:
 
     HbMainWindow* mWindow;
     HgWidget* mWidget;
+    HgMediawall* mMediawall;
 
 };
 
@@ -105,8 +125,8 @@
     void removeItems(int index, int count=1);
     void moveItems(int from, int to, int count=1);
     void changeItem(int index);
-    void reset();
-
+    void reset(int newItemCount=0);
+    
     QImage mImage;
     QStringList mItems;
     bool mValidData;
@@ -129,7 +149,7 @@
 void TestModel::generateItems(int count)
 {
     for (int i=0; i<count; i++) {
-        mItems.append(QString("Item %0").arg(i));
+        mItems.append(QString("Item ").append(i));
     }
 }
 
@@ -143,7 +163,7 @@
     beginInsertRows(QModelIndex(), index, index+count-1); // Inclusive
     int end = index+count;
     for ( ;index<end; index++) {
-        mItems.insert(index, QString("Item %0").arg(mItems.count()));
+        mItems.insert(index, QString("Item ").append(mItems.count()));
     }
     endInsertRows();
 }
@@ -171,14 +191,16 @@
     }
 }
 
-void TestModel::reset()
+void TestModel::reset(int newItemCount)
 {
     beginResetModel();
     mItems.clear();
+    if (newItemCount > 0) {
+        generateItems(newItemCount);
+    }
     endResetModel();
 }
 
-
 void TestModel::changeItem(int index)
 {
     if ( index >= 0 && index < mItems.count() ) {
@@ -189,6 +211,8 @@
 
 int TestModel::rowCount(const QModelIndex &parent) const
 {
+    Q_UNUSED(parent);
+
     return mItems.count();
 }
 
@@ -205,14 +229,10 @@
         {
         case Qt::DisplayRole:
             {
-            QStringList texts;
-            QString text("Primary %0");
-            text.arg(row);
-            texts << text;
-            text = "Secondary %0";
-            text.arg(row);
-            texts << text;
-            returnValue = texts;
+            QStringList list;
+            list << QString("Primary %1").arg(row);
+            list << QString("Secondary %1").arg(row);
+            returnValue = list;
             break;
             }
         case Qt::DecorationRole:
@@ -284,6 +304,36 @@
     HbAutoTest::mouseRelease( (HbAutoTestMainWindow*)mWindow, mWidget, end, 100 );
 }
 
+void TestGanesWidgets::test_setModel()
+{
+    mWindow = new HbMainWindow;
+    mWidget = new HgGrid(Qt::Horizontal);
+    mWindow->addView(mWidget);
+    QVERIFY(mWidget->model() == 0);
+
+    TestModel model1;
+    model1.generateItems(10);
+    mWidget->setModel(&model1);
+    QVERIFY(&model1 == mWidget->model());
+
+    mWindow->show();
+
+    QTest::qWait(2000);
+
+    TestModel model2;
+    model2.generateItems(20);
+    mWidget->setModel(&model2);
+    QVERIFY(&model2 == mWidget->model());
+
+    QTest::qWait(2000);
+
+    mWidget->setModel(0);
+    QVERIFY(mWidget->model() == 0);
+
+    delete mWindow;
+    mWindow = 0;
+}
+
 void TestGanesWidgets::test_panGridLandscape()
 {
     mWindow = new HbMainWindow;
@@ -713,7 +763,7 @@
     qRegisterMetaType<QModelIndex>("QModelIndex");
     QSignalSpy currentItemSpy(mWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)));
 
-    QTest::qWait(2000);
+    QTest::qWait(default_delay);
 
     QVERIFY(mWidget->currentIndex() == model.index(0, 0));
 
@@ -725,7 +775,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos1, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(0, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -733,7 +783,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos2, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(1, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -741,7 +791,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos2, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(2, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -749,7 +799,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos2, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(3, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -757,7 +807,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos3, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(2, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -765,7 +815,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos3, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(1, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -773,7 +823,7 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos3, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(0, 0));
     QVERIFY(currentItemSpy.count() == 1);
     QVERIFY(currentItemSpy.at(0).count() > 0);
@@ -781,11 +831,11 @@
 
     currentItemSpy.clear();
     HbAutoTest::mouseClick((HbAutoTestMainWindow*)mWindow, mWidget, pos3, 100);
-    QTest::qWait(1000);
+    QTest::qWait(default_delay);
     QVERIFY(mWidget->currentIndex() == model.index(0, 0));
     QVERIFY(currentItemSpy.count() == 0);
 
-    QTest::qWait(2000);
+    QTest::qWait(default_delay);
 
     delete mWindow;
     mWindow = 0;
@@ -1279,73 +1329,74 @@
 
     QList<QModelIndex> requestedIndexes;
     TestModel model(&requestedIndexes);
-    model.generateItems(120);
+    model.generateItems(110);
     mWidget->setModel(&model);
     mWindow->addView(mWidget);
     mWindow->show();
 
     QTest::qWait(2000);
 
-    QVERIFY(requestedIndexes.count() == 40); // Scroll buffer size in coverflow mode is assumed to be 40
+    QVERIFY(requestedIndexes.count() == 30); // Scroll buffer size in coverflow mode is assumed to be 30
     QVERIFY(requestedIndexes.front() == model.index(0, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
 
     // Move buffer to the end of items
-    mWidget->scrollTo(model.index(119, 0));
+    mWidget->setCurrentIndex(model.index(95, 0));
+    mWidget->scrollTo(model.index(95, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Add one item to beginning of buffer
     model.insertItems(80, 1);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 0); // New item falls outside of buffer as buffer is moved up
+    QVERIFY(requestedIndexes.count() == 0); // Buffer is moved up to 81
     requestedIndexes.clear();
-    // Last item is now 120
+    // Last item is now 110
 
     // Add many items to beginning of buffer
     model.insertItems(81, 4);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 0); // New items falls outside of buffer as buffer is moved up
+    QVERIFY(requestedIndexes.count() == 0); // // Buffer is moved up to 85
     requestedIndexes.clear();
-    // Last item is now 124
+    // Last item is now 114
 
-    // Add one item to the end
-    model.insertItems(124, 1);
+    // Add one item to the end of the buffer
+    model.insertItems(114, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // The new item is requested
-    QVERIFY(requestedIndexes.front() == model.index(124, 0));
+    QVERIFY(requestedIndexes.front() == model.index(114, 0));
     requestedIndexes.clear();
-    // Last item is now 125
+    // Last item is now 115
 
     // Add many items to the end
-    model.insertItems(125, 4);
+    model.insertItems(111, 4);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 4); // The new items are requested
-    QVERIFY(requestedIndexes.front() == model.index(125, 0));
-    QVERIFY(requestedIndexes.back() == model.index(128, 0));
+    QVERIFY(requestedIndexes.front() == model.index(111, 0));
+    QVERIFY(requestedIndexes.back() == model.index(114, 0));
     requestedIndexes.clear();
-    // Last item is now 129
+    // Last item is now 119
 
     // Add one item to middle of buffer
-    model.insertItems(110, 1);
+    model.insertItems(100, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // The new item is requested
-    QVERIFY(requestedIndexes.front() == model.index(110, 0));
+    QVERIFY(requestedIndexes.front() == model.index(100, 0));
     requestedIndexes.clear();
     // Last item is now 130
 
     // Add many items to middle of buffer
-    model.insertItems(110, 4);
+    model.insertItems(100, 4);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 4); // The new items are requested
-    QVERIFY(requestedIndexes.front() == model.index(110, 0));
-    QVERIFY(requestedIndexes.back() == model.index(113, 0));
+    QVERIFY(requestedIndexes.front() == model.index(100, 0));
+    QVERIFY(requestedIndexes.back() == model.index(103, 0));
     requestedIndexes.clear();
     // Last item is now 134
 
     // Add items to the buffer limit (beginning of buffer)
-    model.insertItems(90, 20);
+    model.insertItems(70, 20);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New item falls outside of buffer as buffer is moved up
     // Last item is now 154
@@ -1357,86 +1408,79 @@
     requestedIndexes.clear();
 
     // Move buffer to the beginning of items
-    mWidget->scrollTo(model.index(0, 0));
+    mWidget->setCurrentIndex(model.index(15, 0));
+    mWidget->scrollTo(model.index(15, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Add one item to beginning
     model.insertItems(0, 1);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 1); // The new item is requested
-    QVERIFY(requestedIndexes.front() == model.index(0, 0));
-    requestedIndexes.clear();
+    QVERIFY(requestedIndexes.count() == 0); // Buffer is moved up
 
     // Add many items to beginning
-    model.insertItems(0, 5);
+    model.insertItems(1, 5);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // The new items are requested
-    QVERIFY(requestedIndexes.front() == model.index(0, 0));
-    QVERIFY(requestedIndexes.back() == model.index(4, 0));
-    requestedIndexes.clear();
+    QVERIFY(requestedIndexes.count() == 0); // Buffer is moved up
 
     // Add one item to middle of buffer
-    model.insertItems(20, 1);
+    model.insertItems(10, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // The new item is requested
-    QVERIFY(requestedIndexes.front() == model.index(20, 0));
+    QVERIFY(requestedIndexes.front() == model.index(10, 0));
     requestedIndexes.clear();
 
     // Add many items to middle of buffer
-    model.insertItems(20, 5);
+    model.insertItems(10, 5);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // The new items are requested
-    QVERIFY(requestedIndexes.front() == model.index(20, 0));
-    QVERIFY(requestedIndexes.back() == model.index(24, 0));
+    QVERIFY(requestedIndexes.front() == model.index(10, 0));
+    QVERIFY(requestedIndexes.back() == model.index(14, 0));
     requestedIndexes.clear();
 
     // Add one item to end of buffer
-    model.insertItems(39, 1);
+    model.insertItems(35, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // The new item is requested
-    QVERIFY(requestedIndexes.front() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(35, 0));
     requestedIndexes.clear();
 
     // Add many items to end of buffer
-    model.insertItems(30, 10);
+    model.insertItems(26, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 10); // The new items are requested
-    QVERIFY(requestedIndexes.front() == model.index(30, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(26, 0));
+    QVERIFY(requestedIndexes.back() == model.index(35, 0));
     requestedIndexes.clear();
 
     // Add items to outside of buffer (after buffer)
-    model.insertItems(40, 10);
+    model.insertItems(50, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // The new items are not requested
     requestedIndexes.clear();
 
     // Add items to the buffer limit (end of buffer)
-    model.insertItems(35, 10);
+    model.insertItems(31, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // The new items inside buffer are requested
-    QVERIFY(requestedIndexes.front() == model.index(35, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(31, 0));
+    QVERIFY(requestedIndexes.back() == model.index(35, 0));
 
     // Move buffer to the middle of items
+    mWidget->setCurrentIndex(model.index(60, 0));
     mWidget->scrollTo(model.index(60, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Add items to the buffer limit (beginning of buffer)
-    model.insertItems(35, 10);
+    model.insertItems(40, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // The new items inside buffer are requested
-    QVERIFY(requestedIndexes.front() == model.index(40, 0));
-    QVERIFY(requestedIndexes.back() == model.index(44, 0));
+    QVERIFY(requestedIndexes.count() == 0); // The buffer is moved up
 
     // Add items over the whole buffer
-    model.insertItems(35, 50);
+    model.insertItems(40, 50);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 40); // The new items inside buffer are requested
-    QVERIFY(requestedIndexes.front() == model.index(40, 0));
-    QVERIFY(requestedIndexes.back() == model.index(79, 0));
+    QVERIFY(requestedIndexes.count() == 0); // The buffer is moved up
 
     QTest::qWait(2000);
 
@@ -1455,20 +1499,21 @@
 
     QList<QModelIndex> requestedIndexes;
     TestModel model(&requestedIndexes);
-    model.generateItems(240);
+    model.generateItems(230);
     mWidget->setModel(&model);
     mWindow->addView(mWidget);
     mWindow->show();
 
     QTest::qWait(2000);
 
-    QVERIFY(requestedIndexes.count() == 40); // Scroll buffer size in coverflow mode is assumed to be 40
+    QVERIFY(requestedIndexes.count() == 30); // Scroll buffer size in coverflow mode is assumed to be 40
     QVERIFY(requestedIndexes.front() == model.index(0, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
 
     // Move buffer to the end of items
-    mWidget->scrollTo(model.index(239, 0));
+    mWidget->setCurrentIndex(model.index(229, 0));
+    mWidget->scrollTo(model.index(229, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
@@ -1478,7 +1523,7 @@
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
     QVERIFY(requestedIndexes.front() == model.index(199, 0));
     requestedIndexes.clear();
-    // Last item is now 238
+    // Last item is now 228
 
     // Remove many items from beginning of buffer
     model.removeItems(199, 4);
@@ -1487,24 +1532,24 @@
     QVERIFY(requestedIndexes.front() == model.index(195, 0));
     QVERIFY(requestedIndexes.back() == model.index(198, 0));
     requestedIndexes.clear();
-    // Last item is now 234
+    // Last item is now 224
 
     // Remove one item from the end
-    model.removeItems(234, 1);
+    model.removeItems(224, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
     QVERIFY(requestedIndexes.front() == model.index(194, 0));
     requestedIndexes.clear();
-    // Last item is now 233
+    // Last item is now 223
 
     // Remove many items from the end
-    model.removeItems(230, 4);
+    model.removeItems(220, 4);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 4); // New items are fetched to replace the removed ones
     QVERIFY(requestedIndexes.front() == model.index(190, 0));
     QVERIFY(requestedIndexes.back() == model.index(193, 0));
     requestedIndexes.clear();
-    // Last item is now 229
+    // Last item is now 219
 
     // Remove one item from the middle of buffer
     model.removeItems(210, 1);
@@ -1512,7 +1557,7 @@
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
     QVERIFY(requestedIndexes.front() == model.index(189, 0));
     requestedIndexes.clear();
-    // Last item is now 228
+    // Last item is now 218
 
     // Remove many items from the middle of buffer
     model.removeItems(210, 4);
@@ -1521,25 +1566,26 @@
     QVERIFY(requestedIndexes.front() == model.index(185, 0));
     QVERIFY(requestedIndexes.back() == model.index(188, 0));
     requestedIndexes.clear();
-    // Last item is now 224
+    // Last item is now 214
 
     // Remove items from the buffer limit (beginning of buffer)
     model.removeItems(180, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // New items are fetched to replace the removed ones
-    QVERIFY(requestedIndexes.front() == model.index(175, 0));
-    QVERIFY(requestedIndexes.back() == model.index(179, 0));
+    QVERIFY(requestedIndexes.front() == model.index(180, 0));
+    QVERIFY(requestedIndexes.back() == model.index(184, 0));
     requestedIndexes.clear();
-    // Last item is now 214
+    // Last item is now 204
 
     // Remove items from outside of buffer (before buffer)
     model.removeItems(0, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // Buffer is not moved
     requestedIndexes.clear();
-    // Last item is now 204
+    // Last item is now 194
 
     // Move buffer to the beginning of items
+    mWidget->setCurrentIndex(model.index(0, 0));
     mWidget->scrollTo(model.index(0, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
@@ -1548,70 +1594,71 @@
     model.removeItems(0, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
-    QVERIFY(requestedIndexes.front() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 203
+    // Last item is now 193
 
     // Remove many items from beginning
     model.removeItems(0, 5);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // New items are fetched to replace the removed ones
-    QVERIFY(requestedIndexes.front() == model.index(35, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(25, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 198
+    // Last item is now 188
 
     // Remove one item from the middle of buffer
-    model.removeItems(20, 1);
+    model.removeItems(15, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
-    QVERIFY(requestedIndexes.front() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 197
+    // Last item is now 187
 
     // Remove many items from the middle of buffer
-    model.removeItems(20, 5);
+    model.removeItems(15, 5);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // New items are fetched to replace the removed ones
-    QVERIFY(requestedIndexes.front() == model.index(35, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(25, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 192
+    // Last item is now 182
 
     // Remove one item from the end of buffer
-    model.removeItems(39, 1);
+    model.removeItems(29, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the removed one
-    QVERIFY(requestedIndexes.front() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 191
+    // Last item is now 181
 
     // Remove many items from the end of buffer
-    model.removeItems(30, 10);
+    model.removeItems(20, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 10); // New items are fetched to replace the removed ones
-    QVERIFY(requestedIndexes.front() == model.index(30, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.front() == model.index(20, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
-    // Last item is now 181
+    // Last item is now 171
 
     // Remove items from outside of buffer (after buffer)
     model.removeItems(50, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // Buffer is not updated
     requestedIndexes.clear();
-    // Last item is now 171
+    // Last item is now 161
 
     // Remove items from the buffer limit (end of buffer)
-    model.insertItems(35, 10);
+    model.removeItems(25, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 5); // The new items inside buffer are requested
-    QVERIFY(requestedIndexes.front() == model.index(35, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
-    // Last item is now 161
+    QVERIFY(requestedIndexes.front() == model.index(25, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
+    // Last item is now 151
 
     // Move buffer to the middle of items
-    mWidget->scrollTo(model.index(80, 0));
+    mWidget->setCurrentIndex(model.index(75, 0));
+    mWidget->scrollTo(model.index(75, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
@@ -1619,15 +1666,14 @@
     model.removeItems(59, 2);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 1); // New item is fetched to replace the one removed from the buffer
-    QVERIFY(requestedIndexes.front() == model.index(99, 0));
-    // Last item is now 159
+    QVERIFY(requestedIndexes.front() == model.index(88, 0)); // Buffer is moved forward, this is the last item
+    requestedIndexes.clear();
+    // Last item is now 149
 
     // Remove items over the whole buffer
     model.removeItems(55, 50);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 40); // Whole buffer is updated
-    QVERIFY(requestedIndexes.front() == model.index(60, 0));
-    QVERIFY(requestedIndexes.back() == model.index(99, 0));
+    QVERIFY(requestedIndexes.count() == 30); // Whole buffer is updated
 
     QTest::qWait(2000);
 
@@ -1653,9 +1699,9 @@
 
     QTest::qWait(2000);
 
-    QVERIFY(requestedIndexes.count() == 40); // Scroll buffer size in coverflow mode is assumed to be 40
+    QVERIFY(requestedIndexes.count() == 30); // Scroll buffer size in coverflow mode is assumed to be 40
     QVERIFY(requestedIndexes.front() == model.index(0, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.back() == model.index(29, 0));
     requestedIndexes.clear();
 
     // Move one item forward
@@ -1667,7 +1713,7 @@
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(0, 39, 1);
+    model.moveItems(0, 29, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
@@ -1677,20 +1723,20 @@
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
     // Move one item backward
-    model.moveItems(39, 20, 1);
+    model.moveItems(29, 20, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(39, 38, 1);
+    model.moveItems(29, 28, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(39, 0, 1);
+    model.moveItems(29, 0, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
     // Move many items backward
-    model.moveItems(30, 20, 10);
+    model.moveItems(20, 5, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
@@ -1700,128 +1746,275 @@
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
     // Move items from the border of the buffer forward
-    model.moveItems(35, 50, 10);
+    model.moveItems(25, 50, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // New items are fetched to replace the moved ones
-    QVERIFY(requestedIndexes.front() == model.index(35, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
     requestedIndexes.clear();
 
     // Move items from the border of the buffer backward
-    model.moveItems(35, 20, 10);
+    model.moveItems(25, 10, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // Items that were originally outside of buffer are fetched
-    QVERIFY(requestedIndexes.front() == model.index(25, 0));
-    QVERIFY(requestedIndexes.back() == model.index(29, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
     requestedIndexes.clear();
 
     // Move items from the buffer outside it
     model.moveItems(20, 90, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 10); // New items are fetched to replace the moved ones
-    QVERIFY(requestedIndexes.front() == model.index(30, 0));
-    QVERIFY(requestedIndexes.back() == model.index(39, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
     requestedIndexes.clear();
 
     // Move items from outside the buffer inside it
-    model.moveItems(90, 20, 10);
+    model.moveItems(90, 15, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 10); // Moved items are fetched
-    QVERIFY(requestedIndexes.front() == model.index(20, 0));
-    QVERIFY(requestedIndexes.back() == model.index(29, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
     requestedIndexes.clear();
 
     // Move buffer to the end of items
-    mWidget->scrollTo(model.index(119, 0));
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move one item forward
-    model.moveItems(80, 100, 1);
+    model.moveItems(90, 100, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(80, 82, 1);
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
+    model.moveItems(90, 92, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(80, 119, 1);
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
+    model.moveItems(90, 119, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
     // Move many items forward
-    model.moveItems(80, 100, 5);
+    model.moveItems(90, 100, 5);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(120, 0));
+    mWidget->scrollTo(model.index(120, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
     // Move one item backward
     model.moveItems(119, 100, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(120, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
     model.moveItems(119, 118, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    model.moveItems(119, 80, 1);
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
+    model.moveItems(119, 90, 1);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
+
     // Move many items backward
     model.moveItems(110, 95, 10);
     QTest::qWait(1000);
     QVERIFY(requestedIndexes.count() == 0); // New items are not fetched as the changes happened inside the buffer
 
-    // Move items from the border of the buffer backward
-    model.moveItems(75, 60, 10);
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // New items are fetched to replace the moved ones
-    QVERIFY(requestedIndexes.front() == model.index(80, 0));
-    QVERIFY(requestedIndexes.back() == model.index(84, 0));
+    requestedIndexes.clear();
+
+    // Move items from the border of the buffer backward
+    model.moveItems(85, 60, 10);
+    QTest::qWait(1000);
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move items from the border of the buffer forward
-    model.moveItems(75, 100, 10);
+    model.moveItems(85, 100, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 5); // Items that were originally outside of buffer are fetched
-    QVERIFY(requestedIndexes.front() == model.index(100, 0));
-    QVERIFY(requestedIndexes.back() == model.index(104, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move items from the buffer outside it
     model.moveItems(100, 10, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 10); // New items are fetched to replace the moved ones
-    QVERIFY(requestedIndexes.front() == model.index(80, 0));
-    QVERIFY(requestedIndexes.back() == model.index(89, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move items from outside the buffer inside it
     model.moveItems(10, 100, 10);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 10); // Moved items are fetched
-    QVERIFY(requestedIndexes.front() == model.index(100, 0));
-    QVERIFY(requestedIndexes.back() == model.index(109, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(110, 0));
+    mWidget->scrollTo(model.index(110, 0));
+    QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move buffer to the middle of items
+    mWidget->setCurrentIndex(model.index(60, 0));
+    mWidget->scrollTo(model.index(60, 0));
+    QTest::qWait(1000);
+
+    // Move buffer to the end of items
+    mWidget->setCurrentIndex(model.index(60, 0));
     mWidget->scrollTo(model.index(60, 0));
     QTest::qWait(1000);
     requestedIndexes.clear();
 
     // Move items over the whole buffer forward
-    model.moveItems(35, 110, 50);
+    model.moveItems(40, 110, 50);
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 40); // Whole buffer is updated
-    QVERIFY(requestedIndexes.front() == model.index(40, 0));
-    QVERIFY(requestedIndexes.back() == model.index(79, 0));
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    // Move buffer to the middle of items
+    mWidget->setCurrentIndex(model.index(60, 0));
+    mWidget->scrollTo(model.index(60, 0));
+    QTest::qWait(1000);
+    requestedIndexes.clear();
 
     // Move items over the whole buffer backward
-    model.moveItems(35, 10, 50);
+    model.moveItems(40, 10, 50);
+    QTest::qWait(1000);
+    QVERIFY(requestedIndexes.count() == 30); // The whole buffer is reset
+
+    QTest::qWait(2000);
+
+    delete mWindow;
+    mWindow = 0;
+}
+
+void TestGanesWidgets::test_labelPositionsCoverFlow()
+{
+    mWindow = new HbMainWindow;
+    mMediawall = new HgMediawall();
+
+    TestModel model;
+    model.generateItems(50);
+    mWindow->addView(mMediawall);
+    mMediawall->setModel(&model);
+    mWindow->show();
+
+    mMediawall->setTitlePosition(HgMediawall::PositionNone);
+    mMediawall->setDescriptionPosition(HgMediawall::PositionNone);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone);
+
+    // This updates the title and description label. But how to test they are in correct positions?
+    mMediawall->setCurrentIndex(model.index(1, 0));
+    QTest::qWait(1000);
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage);
+    mMediawall->setCurrentIndex(model.index(2, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Secondary 2"));
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionNone);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage);
+    mMediawall->setCurrentIndex(model.index(3, 0));
     QTest::qWait(1000);
-    QVERIFY(requestedIndexes.count() == 40); // Whole buffer is updated
-    QVERIFY(requestedIndexes.front() == model.index(40, 0));
-    QVERIFY(requestedIndexes.back() == model.index(79, 0));
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Secondary 3"));
+
+    mMediawall->setTitlePosition(HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage);
+    mMediawall->setCurrentIndex(model.index(4, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Primary 4"));
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Secondary 4"));
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage);
+    mMediawall->setCurrentIndex(model.index(5, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_top, "Primary 5"));
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_bottom, "Secondary 5"));
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionNone);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone);
+    mMediawall->setCurrentIndex(model.index(6, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Primary 6"));
+
+    mMediawall->setTitlePosition(HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionNone);
+    mMediawall->setCurrentIndex(model.index(7, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Primary 7"));
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionAboveImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionAboveImage);
+    mMediawall->setCurrentIndex(model.index(8, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_above_alone, "Secondary 8"));
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_alone, "Primary 8"));
+
+    mMediawall->setDescriptionPosition(HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->titlePosition() == HgMediawall::PositionBelowImage);
+    QVERIFY(mMediawall->descriptionPosition() == HgMediawall::PositionBelowImage);
+    mMediawall->setCurrentIndex(model.index(9, 0));
+    QTest::qWait(1000);
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_top, "Primary 9"));
+    QVERIFY(checkLabelAt(mWindow, expected_label_pos_below_bottom, "Secondary 9"));
 
     QTest::qWait(2000);
 
@@ -1829,6 +2022,129 @@
     mWindow = 0;
 }
 
+void TestGanesWidgets::test_labelFontSpecsCoverFlow()
+{
+    mWindow = new HbMainWindow;
+    mMediawall = new HgMediawall();
+
+    TestModel model;
+    model.generateItems(50);
+    mWindow->addView(mMediawall);
+    mMediawall->setModel(&model);
+    mWindow->show();
+
+    mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Primary));
+    QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Primary));
+
+    mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::Secondary));
+    QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::Secondary));
+
+    mMediawall->setTitleFontSpec(HbFontSpec(HbFontSpec::Title));
+    QVERIFY(mMediawall->titleFontSpec() == HbFontSpec(HbFontSpec::Title));
+
+    mMediawall->setDescriptionFontSpec(HbFontSpec(HbFontSpec::PrimarySmall));
+    QVERIFY(mMediawall->descriptionFontSpec() == HbFontSpec(HbFontSpec::PrimarySmall));
+
+    QTest::qWait(2000);
+
+    delete mWindow;
+    mWindow = 0;
+}
+
+void TestGanesWidgets::test_resetModelCoverFlow()
+{
+    mWindow = new HbMainWindow;
+    mMediawall = new HgMediawall();
+
+    TestModel model;
+    model.generateItems(50);
+    mWindow->addView(mMediawall);
+    mMediawall->setModel(&model);
+    mWindow->show();
+
+    // Reset with same item count
+    model.reset(50);
+    QTest::qWait(2000);
+
+    // Reset with smaller item count
+    model.reset(20);    
+    QTest::qWait(2000);
+
+    // Reset with larger item count
+    model.reset(100);    
+    QTest::qWait(2000);
+
+    delete mWindow;
+    mWindow = 0;
+
+}
+
+void TestGanesWidgets::test_resetModelGrid()
+{
+    mWindow = new HbMainWindow;
+    mWidget = new HgGrid(Qt::Vertical);
+
+    TestModel model;
+    model.generateItems(50);
+    mWindow->addView(mWidget);
+    mWidget->setModel(&model);
+    mWindow->show();
+
+    QTest::qWait(2000);
+
+    // Reset with same item count
+    model.reset(50);
+    QTest::qWait(2000);
+
+    // Reset with smaller item count
+    model.reset(20);    
+    QTest::qWait(2000);
+
+    // Reset with larger item count
+    model.reset(100);    
+    QTest::qWait(2000);
+    
+    delete mWindow;
+    mWindow = 0;
+
+}
+
+bool TestGanesWidgets::checkLabelAt(HbMainWindow *window, const QPointF &pos, const QString &expectedText)
+{
+    HbLabel *label = findLabelAt(window->currentView(), pos);
+    if (label) {
+        if (label->plainText() == expectedText) {
+            return true;
+        }
+        else {
+            qDebug() << "Label text did not match: expected" << expectedText << "got" << label->plainText();
+            return false;
+        }
+    }
+    qDebug() << "Label not found at pos" << pos;
+    return false;
+}
+
+HbLabel *TestGanesWidgets::findLabelAt(QGraphicsItem *parent, const QPointF &pos)
+{
+    QList<QGraphicsItem *> subItems = parent->childItems();
+    int count = subItems.count();
+    for (int i = 0; i < count; i++) {
+        QGraphicsItem *item = subItems.at(i);
+        QRectF itemRect(item->pos(), item->boundingRect().size());
+        if (itemRect.contains(pos)) {
+            HbLabel *label = qgraphicsitem_cast<HbLabel *>(subItems.at(i));
+            if (label) {
+                return label;
+            }
+            else {
+                return findLabelAt(subItems.at(i), pos);
+            }
+        }
+    }
+    return NULL;
+}
+
 #ifdef _UNITTEST_GANESWIDGETS_LOG_TO_C_
     int main (int argc, char* argv[])
     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/hgcacheproxymodel.pro	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,45 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description:
+
+TEMPLATE = lib
+TARGET = hgcacheproxymodel
+symbian:TARGET.UID3 = 0x2002EA2A
+
+CONFIG += qt hb
+QT -= gui
+
+symbian {
+	TARGET.EPOCALLOWDLLDATA = 1
+	TARGET.CAPABILITY = ALL -TCB
+}
+
+DEFINES += BUILD_CACHEPROXYMODEL
+INCLUDEPATH += /sf/mw/qt/src/gui/image/
+
+#DEFINES += ENABLETRACE
+#if TRACE_FILENAME not set, then RDebug is used
+DEFINES += TRACE_FILE
+
+# Input
+HEADERS +=  \
+	../hgwidgets_plat/hgcacheproxymodel_api/inc/hgcacheproxymodel.h \
+	../hgwidgets_plat/hgcacheproxymodel_api/inc/hgdataprovidermodel.h \
+	inc/hgbuffermanager.h \
+	inc/hglogger.h
+
+
+SOURCES +=  \
+	src/hgcacheproxymodel.cpp \
+	src/hgdataprovidermodel.cpp \	
+	src/hgbuffermanager.cpp
+
+include(rom/rom.pri)
+include(sis/stub.pri)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/inc/hgbuffermanager.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#ifndef HGBUFFERMANAGER_H_
+#define HGBUFFERMANAGER_H_
+
+class HgBufferManagerObserver;
+
+class HgBufferManager
+{
+public:    
+    
+    HgBufferManager(
+                    HgBufferManagerObserver* aObserver,
+                    int aBufferSize,
+                    int aBufferTreshold,
+                    int aInitialPosition,
+                    int aTotalCount );
+	~HgBufferManager();
+
+	void setPosition( int aIndex );
+	void resetBuffer( int aPosition, int aTotalCount);
+	void itemCountChanged( int aIndex, bool aRemoved, int aNewTotalCount );
+	void resizeCache(int newSize, int newTreshold);
+	
+private:
+	void calculate();
+
+private:
+	HgBufferManagerObserver* mObserver; 
+    
+	int mBufferSize;
+	int mBufferTreshold;
+	int mBufferPosition;
+	int mDiff;
+	int mTotalCount;
+
+	bool mResetOrdered;
+
+	int mRequestStart;
+	int mRequestCount;
+	int mReleaseStart;
+	int mReleaseCount;
+};
+
+#endif // HGBUFFERMANAGER_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/inc/hglogger.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#ifndef HGLOGGER_H_
+#define HGLOGGER_H_
+
+//To enable tracking define ENABLETRACE
+//if TRACE_FILENAME is set then trace will go to file, otherwise to RDebug
+
+#include <QObject>
+#include <qglobal.h>
+
+#define XQCONNECT_ASSERT(a, b, c, d) if (!(QObject::connect((a),(b), (c), (d)))) { qFatal("Connection failed: connect(%s, %s, %s, %s)", #a, #b, #c, #d); }
+
+// stolen from qt-music :)
+#ifdef ENABLETRACE
+    #include <QString>
+    #include <QDebug>
+    #include <QTime>
+    #include <stdio.h>
+    #include <stdlib.h>
+    #include <e32debug.h>
+
+    #ifdef TRACE_FILE
+        #define _TRACE_FILENAME "c:/trace.txt"
+        #define _TX_INIT void __tx_myMessageOutput(QtMsgType type, const char *msg) {\
+             static const QString timeFmt("hh:mm:ss.zzz");\
+             FILE *f = fopen(_TRACE_FILENAME, "a");\
+             fprintf(f, "%s ", QTime::currentTime().toString(timeFmt).toLatin1().data() );\
+             switch (type) {\
+             case QtDebugMsg: fprintf(f, "[DEB] [TX] %s\n", msg); break;\
+             case QtWarningMsg: fprintf(f, "[WRN] [TX] %s\n", msg); break;\
+             case QtCriticalMsg: fprintf(f, "[CRT] [TX] %s\n", msg); break;\
+             case QtFatalMsg: fprintf(f, "[FTL] [TX] %s\n", msg); fclose(f); abort();\
+             } fclose(f);\
+        }
+    #else
+        #define _TX_INIT void __tx_myMessageOutput(QtMsgType /*type*/, const char *msg) {\
+            RDebug::Printf("[TX] %s", msg);\
+            }
+    #endif // TRACE_FILE
+
+    #define _TX_INSTALL qInstallMsgHandler(__tx_myMessageOutput);
+    #define TX_MAIN(a, b) _TX_INIT \
+            int __tx__main(int, char**); int main(int (a), char **(b)) { _TX_INSTALL return __tx__main(a, b); } int __tx__main(int (a), char **(b))
+
+    #define TX_UNUSED(name);
+    #define TX_STATIC_ENTRY qDebug() << __PRETTY_FUNCTION__  << "entry";
+    #define TX_STATIC_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "entry," << args;
+    #define TX_STATIC_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit";
+    #define TX_STATIC_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args; 
+    #define TX_ENTRY qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry";
+    #define TX_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry," << args;
+    #define TX_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit";
+    #define TX_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args;
+    #define TX_LOG qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this;
+    #define TX_LOG_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << args;
+#else
+    #define TX_MAIN(a,b) int main(int (a), char **(b))
+    #define TX_UNUSED(name) Q_UNUSED(name);
+    #define TX_STATIC_ENTRY ;
+    #define TX_STATIC_ENTRY_ARGS(args) ;
+    #define TX_STATIC_EXIT ;
+    #define TX_STATIC_EXIT_ARGS(args) ;
+    #define TX_ENTRY ;
+    #define TX_ENTRY_ARGS(args) ;
+    #define TX_EXIT ;
+    #define TX_EXIT_ARGS(args) ;
+    #define TX_LOG ;
+    #define TX_LOG_ARGS(args) ;
+#endif // ENABLETRACE
+
+
+#endif // HGLOGGER_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/rom/hgcacheproxymodel.iby	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef HGCACHEPROXYMODEL_IBY
+#define HGCACHEPROXYMODEL_IBY
+
+#include <bldvariant.hrh>
+
+#include <data_caging_paths_for_iby.hrh>
+
+file=ABI_DIR\BUILD_DIR\hgcacheproxymodel.dll SHARED_LIB_DIR\hgcacheproxymodel.dll
+data=ZSYSTEM\install\hgcacheproxymodelstub.sis              System\Install\hgcacheproxymodelstub.sis
+
+#endif //HGCACHEPROXYMODEL_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/rom/rom.pri	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+symbian {
+	HGCACHEPROXYMODEL_IBY_DIR = $$section(PWD,":",1)
+
+	exists(/epoc32/include/platform_paths.hrh) {
+    	BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>"
+	} else {
+    	BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <domain\osextensions\platform_paths.hrh>"
+	}
+
+	BLD_INF_RULES.prj_exports += "$$HGCACHEPROXYMODEL_IBY_DIR/hgcacheproxymodel.iby CORE_MW_LAYER_IBY_EXPORT_PATH(hgcacheproxymodel.iby)"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/sis/hgcacheproxymodelstub.pkg	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,32 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Installation file for hgcacheproxymodel library stub for IAD
+;
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"hgcacheproxymodel"},(0x2002EA2A),10,0,0, TYPE=SA
+
+;Localised Vendor name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Files to install
+;hgcacheproxymodel
+"" - "z:\sys\bin\hgcacheproxymodel.dll"
Binary file hgcacheproxymodel/sis/hgcacheproxymodelstub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/sis/stub.pri	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+symbian {
+	HGCACHEPROXYMODEL_STUB_DIR = $$section(PWD,":",1)
+
+	BLD_INF_RULES.prj_exports += "$$HGCACHEPROXYMODEL_STUB_DIR/hgcacheproxymodelstub.sis /epoc32/data/z/system/install/hgcacheproxymodelstub.sis"
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/src/hgbuffermanager.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,221 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include "hgbuffermanager.h"
+#include <hgwidgets/hgcacheproxymodel.h>
+
+
+HgBufferManager::HgBufferManager(
+    HgBufferManagerObserver* aObserver,
+	int aBufferSize,
+	int aBufferTreshold,
+	int aInitialPosition,
+	int aTotalCount )
+:
+mObserver(aObserver),
+mBufferSize( aBufferSize ),
+mBufferTreshold( aBufferTreshold ),
+mBufferPosition( aInitialPosition ),
+mTotalCount( aTotalCount )
+{
+    ASSERT( mObserver != 0 );
+    mBufferPosition -= (mBufferSize / 2);
+    
+    if( mBufferPosition + mBufferSize > mTotalCount - 1 ){
+        mBufferPosition = (mTotalCount - 1) - mBufferSize;
+    }
+    
+    if(mBufferPosition < 0 ){
+        mBufferPosition = 0;
+    }
+    
+    mDiff = 0;
+	//request Initial Buffer
+	mRequestStart = mBufferPosition;
+	mRequestCount = mBufferSize;
+
+	calculate();
+}
+
+
+HgBufferManager::~HgBufferManager()
+{
+}
+
+void HgBufferManager::resizeCache(int newSize, int newTreshold)
+{
+    if (newTreshold != mBufferTreshold){
+        mBufferTreshold = newTreshold;
+    }
+    
+    if (newSize!=mBufferSize){
+//        int pos = mBufferPosition + (mBufferSize / 2);
+        
+        int a = Max(0, mBufferPosition + mBufferSize/2 - newSize/2);
+        int b = Min(a + newSize, mTotalCount);
+        if ( b == mTotalCount){
+            a = mTotalCount - newSize;
+        }
+        
+        int c = Max(0, mBufferPosition);
+        int d = Min(c + mBufferSize, mTotalCount);
+        if ( d == mTotalCount){
+            c = mTotalCount - mBufferSize;
+        }
+        
+        if ( newSize>mBufferSize){
+            mObserver->request(a, c-1, HgCacheProxyModel::HgRequestOrderAscending);
+            mObserver->request(d, b-1, HgCacheProxyModel::HgRequestOrderAscending);
+        }else if ( newSize<mBufferSize){
+            mObserver->release(c, a-1);
+            mObserver->release(b, d);
+        }
+        mBufferPosition = a;
+        mBufferSize = newSize;
+    }
+}
+
+void HgBufferManager::calculate()
+{  
+    HgCacheProxyModel::HgRequestOrder direction = HgCacheProxyModel::HgRequestOrderAscending;
+    
+    if(mResetOrdered){
+        mResetOrdered = false;
+    } else {
+        if(mDiff < 0){
+            mReleaseStart = mBufferPosition;
+            mRequestStart = mBufferPosition + mBufferSize;
+            direction = HgCacheProxyModel::HgRequestOrderAscending; 
+        } else if( mDiff > 0) {
+            mReleaseStart = mBufferPosition + mBufferSize - mDiff;
+            mRequestStart = mBufferPosition - mDiff;
+            direction = HgCacheProxyModel::HgRequestOrderDescending;
+        }
+    }
+    
+    // Release 
+    int end = mReleaseStart + mReleaseCount < mTotalCount ?
+        mReleaseStart + mReleaseCount: mTotalCount; 
+    end--;
+    if(end >= mReleaseStart ){
+        mObserver->release(mReleaseStart, end);
+    }
+    
+    mReleaseCount = 0;
+    
+    // Request
+    end = mRequestStart + mRequestCount < mTotalCount ? 
+        mRequestStart + mRequestCount : mTotalCount;
+    
+    end--;
+    if(end >= mRequestStart ){
+        mObserver->request(mRequestStart, end, direction);
+	}
+      
+    mRequestCount = 0;
+    
+    // Move Buffer
+    mBufferPosition -= mDiff;
+    // Reset Diff
+    mDiff = 0;
+}
+
+// -----------------------------------------------------------------------------
+// BufferManager::SetPosition()
+// -----------------------------------------------------------------------------
+//
+void HgBufferManager::setPosition( int aIndex )
+{
+    // If all the items fit in the buffer no need to move the buffer
+    if(mTotalCount <= mBufferSize)
+        return;
+	
+	bool forceUpdate = false;
+    aIndex -= mBufferSize / 2; // normalize index to Buffer start
+    
+    if(aIndex < 0){
+        aIndex = 0;
+        forceUpdate = true;
+    }else if( aIndex > mTotalCount - mBufferSize ){
+        aIndex = mTotalCount - mBufferSize;
+        forceUpdate = true;
+    }
+
+    mDiff = mBufferPosition - aIndex; 
+
+    // Too large change reset whole buffer
+    if( mDiff >= mBufferSize || -mDiff >= mBufferSize || mResetOrdered ) {
+        resetBuffer(aIndex + (mBufferSize/2), mTotalCount);
+    } else if( mDiff >= mBufferTreshold ) { // Move Up
+        mRequestCount = mDiff;
+        mReleaseCount = mDiff;
+        calculate();
+    } else if ( -mDiff >= mBufferTreshold ) {// Move Down
+        mRequestCount = -mDiff;
+        mReleaseCount = -mDiff;
+        calculate();
+    } else if( forceUpdate && mDiff ) { // Top or bottom has been reached
+        int diff = mDiff < 0 ? -mDiff : mDiff;
+        mRequestCount = diff;
+        mReleaseCount = diff;
+        calculate();
+    }
+}
+
+// -----------------------------------------------------------------------------
+// BufferManager::ResetBuffer()
+// -----------------------------------------------------------------------------
+//
+void HgBufferManager::resetBuffer( int aPosition, int aTotalCount)
+{
+    if( !mResetOrdered ){
+        // release Old buffer
+        mReleaseStart = mBufferPosition;
+        mReleaseCount = mBufferSize;
+    }
+    
+    // set position and count
+    mBufferPosition = aPosition - (mBufferSize / 2);
+    mTotalCount = aTotalCount;
+    mDiff = 0;
+    
+    if( mBufferPosition + mBufferSize > mTotalCount - 1 ){
+        mBufferPosition = mTotalCount - mBufferSize;
+    }
+    
+    if(mBufferPosition < 0 ){
+        mBufferPosition = 0;
+    }
+    
+    //request new Buffer
+    mRequestStart = mBufferPosition;
+    mRequestCount = mBufferSize;
+    mResetOrdered = true;
+    calculate();
+}
+
+void HgBufferManager::itemCountChanged( int aIndex, 
+                                      bool aRemoved,
+                                      int aNewTotalCount )
+{    
+    Q_UNUSED(aIndex);    
+    Q_UNUSED(aRemoved);
+    //release all, to make sure that no old items are skipped
+    mObserver->release(0, aNewTotalCount);
+    resetBuffer(mBufferPosition + (mBufferSize / 2), aNewTotalCount);
+}
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/src/hgcacheproxymodel.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,591 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 2 %
+*/
+#include <QList>
+#include <QAbstractItemModel>
+
+#include <hgwidgets/hgcacheproxymodel.h>
+#include <hgwidgets/hgdataprovidermodel.h>
+#include "hgbuffermanager.h"
+#include "hglogger.h"
+
+
+
+
+
+Q_DECL_EXPORT HgCacheProxyModel::HgCacheProxyModel(QObject *parent):
+QAbstractItemModel(parent),
+mBufferManager(0),
+mSortFilterProxyModel(new QSortFilterProxyModel(this)),
+mDataProviderModel(0),
+mResetNeeded(false),
+mSupressBM(false),
+mSortParameterChanged(true),
+mFilterParameterChanged(true)
+{
+    connect(mSortFilterProxyModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+            this, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(columnsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)),
+            this, SIGNAL(columnsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));    
+    
+    connect(mSortFilterProxyModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+            this, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)));    
+    
+    connect(mSortFilterProxyModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
+            this, SIGNAL(columnsInserted(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(columnsMoved(QModelIndex, int, int, QModelIndex, int)),
+            this, SIGNAL(columnsMoved(QModelIndex, int, int, QModelIndex, int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+            this, SIGNAL(columnsRemoved(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+            this, SLOT(dataUpdated(QModelIndex,QModelIndex)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+            this, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(layoutAboutToBeChanged()),
+            this, SIGNAL(layoutAboutToBeChanged()));
+    
+    connect(mSortFilterProxyModel, SIGNAL(layoutChanged()), 
+            this, SIGNAL(layoutChanged()));
+    
+    connect(mSortFilterProxyModel, SIGNAL(modelAboutToBeReset()), 
+            this, SLOT(sourceAboutToBeReset()));
+    
+    connect(mSortFilterProxyModel, SIGNAL(modelReset()), 
+            this, SLOT(sourceReset()));    
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+            this, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)),
+            this, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+            this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SIGNAL(rowsInserted(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(sourceRowsInserted(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
+            this, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+            this, SIGNAL(rowsRemoved(QModelIndex,int,int)));
+    
+    connect(mSortFilterProxyModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+            this, SLOT(sourceRowsRemoved(QModelIndex,int,int)));
+}
+
+Q_DECL_EXPORT HgCacheProxyModel::~HgCacheProxyModel()
+{
+    delete mBufferManager;
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::setDataProvider(HgDataProviderModel *dataProvider, int cacheSize, int cacheTreshold)
+{
+    TX_ENTRY
+    mDataProviderModel = dataProvider;
+    mSortFilterProxyModel->setSourceModel(mDataProviderModel);
+    if (mDataProviderModel){
+        mDataProviderModel->registerObserver(this);
+        mDataProviderModel->resizeQPixmapPool(cacheSize);
+
+        delete mBufferManager;
+        mBufferManager = NULL;
+        mBufferManager = new HgBufferManager(this, cacheSize, cacheTreshold, 0, count() );
+    }
+    TX_EXIT    
+}
+
+Q_DECL_EXPORT HgDataProviderModel* HgCacheProxyModel::DataProvider()
+{
+    return mDataProviderModel;
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::resizeCache(int newSize, int newTreshold)
+{
+    TX_ENTRY
+    if (mDataProviderModel)
+        mDataProviderModel->resizeQPixmapPool(newSize);
+    if (mBufferManager)
+        mBufferManager->resizeCache( newSize, newTreshold );
+    TX_EXIT    
+}
+
+Q_DECL_EXPORT QModelIndex HgCacheProxyModel::index(int row, int column, const QModelIndex &parent) const
+{
+    Q_UNUSED(parent);
+    if (  row >= rowCount() ){
+        row = -1;
+    }
+    if (  column >= columnCount() ){
+        column = -1;
+    }
+    
+    return QAbstractItemModel::createIndex(row, column); 
+}
+
+Q_DECL_EXPORT QModelIndex HgCacheProxyModel::parent(const QModelIndex &child) const
+{
+    return mSortFilterProxyModel->parent(mapToSource(child));
+}
+
+Q_DECL_EXPORT int HgCacheProxyModel::rowCount(const QModelIndex &parent) const
+{
+    return mSortFilterProxyModel->rowCount(mapToSource(parent));
+}
+
+Q_DECL_EXPORT int HgCacheProxyModel::columnCount(const QModelIndex &parent) const
+{
+    return mSortFilterProxyModel->columnCount(mapToSource(parent));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::hasChildren(const QModelIndex &parent) const
+{
+    return mSortFilterProxyModel->hasChildren(mapToSource(parent));
+}
+
+Q_DECL_EXPORT QVariant HgCacheProxyModel::data(const QModelIndex &index, int role) const
+{    
+    setBufferPosition(index.row());
+    QVariant res = mSortFilterProxyModel->data(mapToSource(index), role);
+    return res;
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+    return mSortFilterProxyModel->setData(mapToSource(index), value, role);
+}
+
+Q_DECL_EXPORT QVariant HgCacheProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+    return mSortFilterProxyModel->headerData(section, orientation, role);
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
+{
+    return mSortFilterProxyModel->setHeaderData(section, orientation, value, role);
+}
+
+Q_DECL_EXPORT QMap<int, QVariant> HgCacheProxyModel::itemData(const QModelIndex &index) const
+{
+    setBufferPosition(index.row());
+    return mSortFilterProxyModel->itemData(mapToSource(index));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
+{
+    return mSortFilterProxyModel->setItemData(mapToSource(index), roles);
+}
+
+Q_DECL_EXPORT QStringList HgCacheProxyModel::mimeTypes() const
+{
+    return mSortFilterProxyModel->mimeTypes();
+}
+
+Q_DECL_EXPORT QMimeData *HgCacheProxyModel::mimeData(const QModelIndexList &indexes) const
+{
+    QModelIndexList list;
+    for ( int i=0; i < indexes.count(); i++){
+        list.append(mapToSource(indexes[i]));
+    }
+    return mSortFilterProxyModel->mimeData(list);
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+    return mSortFilterProxyModel->dropMimeData(data, action, row, column, mapToSource(parent));
+}
+
+Q_DECL_EXPORT Qt::DropActions HgCacheProxyModel::supportedDropActions() const
+{
+    return mSortFilterProxyModel->supportedDropActions();
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+    return mSortFilterProxyModel->insertRows(row, count, mapToSource(parent));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::insertColumns(int column, int count, const QModelIndex &parent)
+{
+    return mSortFilterProxyModel->insertColumns(column, count, mapToSource(parent));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+    return mSortFilterProxyModel->removeRows(row, count, mapToSource(parent));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::removeColumns(int column, int count, const QModelIndex &parent)
+{
+    return mSortFilterProxyModel->removeColumns(column, count, mapToSource(parent));
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::fetchMore(const QModelIndex &parent)
+{
+    mSortFilterProxyModel->fetchMore(mapToSource(parent));
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::canFetchMore(const QModelIndex &parent) const
+{
+    return mSortFilterProxyModel->canFetchMore(mapToSource(parent));
+}        
+
+Q_DECL_EXPORT Qt::ItemFlags HgCacheProxyModel::flags(const QModelIndex &index) const
+{
+    return mSortFilterProxyModel->flags(mapToSource(index));
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::sort(int column, Qt::SortOrder order)
+{
+    if ( mSortParameterChanged || (sortColumn() != column) || (sortOrder() != order) ){
+        mSortParameterChanged = false;
+        mResetNeeded = true;
+        cleanupForBMResetIfNeeded();
+        mSortFilterProxyModel->sort(column, order);
+        resetBMIfNeeded();
+    }
+}
+
+Q_DECL_EXPORT QModelIndex HgCacheProxyModel::buddy(const QModelIndex &index) const
+{
+    return mSortFilterProxyModel->buddy(mapToSource(index));
+}
+
+Q_DECL_EXPORT QModelIndexList HgCacheProxyModel::match(const QModelIndex &start, int role,
+                              const QVariant &value, int hits,
+                              Qt::MatchFlags flags) const
+{
+    return mSortFilterProxyModel->match(mapToSource(start), role, value, hits, flags);
+}
+
+Q_DECL_EXPORT QSize HgCacheProxyModel::span(const QModelIndex &index) const
+{
+    return mSortFilterProxyModel->span(mapToSource(index));
+}
+
+Q_DECL_EXPORT Qt::CaseSensitivity HgCacheProxyModel::sortCaseSensitivity() const
+{
+    return mSortFilterProxyModel->sortCaseSensitivity();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs)
+{
+    if (sortCaseSensitivity() != cs){
+        mSortParameterChanged = true;
+        cleanupForBMResetIfNeeded();
+        mSortFilterProxyModel->setSortCaseSensitivity(cs);
+        resetBMIfNeeded();    
+    }
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::isSortLocaleAware() const
+{
+    return mSortFilterProxyModel->isSortLocaleAware();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::setSortLocaleAware(bool on)
+{
+    if (isSortLocaleAware() != on){
+        mSortParameterChanged = true;    
+        cleanupForBMResetIfNeeded();
+        mSortFilterProxyModel->setSortLocaleAware(on);
+        resetBMIfNeeded();    
+    }
+}
+
+Q_DECL_EXPORT int HgCacheProxyModel::sortColumn() const
+{
+    return mSortFilterProxyModel->sortColumn();
+}
+
+Q_DECL_EXPORT Qt::SortOrder HgCacheProxyModel::sortOrder() const
+{
+    return mSortFilterProxyModel->sortOrder();
+}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::dynamicSortFilter() const
+{
+    return mSortFilterProxyModel->dynamicSortFilter();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::setDynamicSortFilter(bool enable)
+{
+    if (dynamicSortFilter() != enable){
+        mSortParameterChanged = true;   
+        mFilterParameterChanged = true;
+        cleanupForBMResetIfNeeded();
+        mSortFilterProxyModel->setDynamicSortFilter(enable);
+        resetBMIfNeeded();
+    }
+}
+
+Q_DECL_EXPORT int HgCacheProxyModel::sortRole() const
+{
+    return mSortFilterProxyModel->sortRole();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::setSortRole(int role)
+{
+    if (sortRole() != role){
+        mSortParameterChanged = true;   
+        cleanupForBMResetIfNeeded();
+        mSortFilterProxyModel->setSortRole(role);
+        resetBMIfNeeded();    
+    }
+}
+
+//Q_DECL_EXPORT QRegExp HgCacheProxyModel::filterRegExp() const
+//{
+//    return mSortFilterProxyModel->filterRegExp();
+//}
+//
+//Q_DECL_EXPORT void HgCacheProxyModel::setFilterRegExp(const QRegExp &regExp)
+//{
+//    if (filterRegExp() != regExp){   
+//        mFilterParameterChanged = true;
+//        cleanupForBMResetIfNeeded();
+//        mSortFilterProxyModel->setFilterRegExp(regExp);
+//        resetBMIfNeeded();    
+//    }
+//}
+//
+//Q_DECL_EXPORT int HgCacheProxyModel::filterKeyColumn() const
+//{
+//    return mSortFilterProxyModel->filterKeyColumn();
+//}
+//
+//Q_DECL_EXPORT void HgCacheProxyModel::setFilterKeyColumn(int column)
+//{
+//    if (filterKeyColumn() != column){   
+//        mFilterParameterChanged = true;
+//        cleanupForBMResetIfNeeded();
+//        mSortFilterProxyModel->setFilterKeyColumn(column);
+//        resetBMIfNeeded();    
+//    }
+//}
+//
+//Q_DECL_EXPORT Qt::CaseSensitivity HgCacheProxyModel::filterCaseSensitivity() const
+//{
+//    return mSortFilterProxyModel->filterCaseSensitivity();
+//}
+//
+//Q_DECL_EXPORT void HgCacheProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
+//{
+//    if ( filterCaseSensitivity() != cs){   
+//        mFilterParameterChanged = true;
+//        cleanupForBMResetIfNeeded();
+//        mSortFilterProxyModel->setFilterCaseSensitivity(cs);
+//        resetBMIfNeeded();    
+//    }
+//}
+//
+//Q_DECL_EXPORT int HgCacheProxyModel::filterRole() const
+//{
+//    return mSortFilterProxyModel->filterRole();
+//}
+//
+//Q_DECL_EXPORT void HgCacheProxyModel::setFilterRole(int role)
+//{
+//    if ( mFilterParameterChanged || (filterRole() != role)){   
+//        mFilterParameterChanged = false;
+//        mResetNeeded = true;
+//        cleanupForBMResetIfNeeded();
+//        mSortFilterProxyModel->setFilterRole(role);
+//        resetBMIfNeeded();
+//    }
+//}
+
+Q_DECL_EXPORT bool HgCacheProxyModel::submit()
+{
+    return mSortFilterProxyModel->submit();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::revert()
+{
+    mSortFilterProxyModel->revert();
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::release(int start, int end)
+{
+    TX_ENTRY_ARGS( QString("%0-%1").arg(start).arg(end));   
+    QList<int> list;
+    int idx = 0;
+    if ( start > end){
+        idx = end;
+        end = start;
+        start = idx;
+        idx = 0;
+    }
+    for ( int i=start; i <=end; i++){
+        idx = mapToDataProviderIndex(i);
+        if ( idx >=0)
+            list.append(idx);
+    }
+    if (mDataProviderModel)
+        mDataProviderModel->release(list, true);
+    TX_EXIT    
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::request(int start, int end, HgRequestOrder order)
+{
+    TX_ENTRY_ARGS( QString("%0-%1").arg(start).arg(end));   
+    QList<int> list;
+    int idx;
+    if (order == HgRequestOrderAscending){
+        for ( int i=start; i <=end; i++){
+            idx = mapToDataProviderIndex(i);
+            if ( idx >=0)
+                list.append(idx);
+        }
+    } else {
+        for ( int i=end; i >=start; i--){
+            idx = mapToDataProviderIndex(i);
+            if ( idx >=0)
+                list.append(idx);
+        }
+    }
+    if (mDataProviderModel)
+        mDataProviderModel->request(list, mSupressBM);
+    TX_EXIT    
+}
+
+int HgCacheProxyModel::count()const
+{
+    return rowCount(index(0, 0, QModelIndex()));
+}
+
+QModelIndex HgCacheProxyModel::mapToSource(const QModelIndex &index) const
+{
+    return mapToSource(index.row(), index.column());
+}
+
+QModelIndex HgCacheProxyModel::mapToSource(int row, int col) const
+{
+    return mSortFilterProxyModel->index(row, col);
+}
+
+int HgCacheProxyModel::mapToDataProviderIndex(int myIndex) const
+{
+    return mSortFilterProxyModel->mapToSource( mapToSource(myIndex, 0)).row();
+}
+
+int HgCacheProxyModel::mapFromDataProviderIndex(int myIndex) const
+{
+    return mSortFilterProxyModel->mapFromSource( mDataProviderModel->index(myIndex, 0) ).row();
+}
+
+void HgCacheProxyModel::cleanupForBMResetIfNeeded()
+{
+    if (mResetNeeded || mSortFilterProxyModel->dynamicSortFilter()==true){
+        TX_LOG
+        mSupressBM = true;
+        mResetNeeded = true;
+        beginResetModel();
+        releaseAll();
+    }
+}
+
+void HgCacheProxyModel::resetBMIfNeeded()
+{
+    if ( mResetNeeded ){
+        if (mBufferManager)
+            mBufferManager->resetBuffer( mCurrentPos, count() );
+        mSupressBM = false;
+        mResetNeeded = false;
+        endResetModel();
+    }
+    mResetNeeded = false;
+}
+
+void HgCacheProxyModel::releaseAll()
+{
+    if ( mDataProviderModel ){
+        QList<int> list;
+        for ( int i=0; i<mDataProviderModel->rowCount(); i++){
+            list.append(i);
+        }
+        mDataProviderModel->release(list, true); //will quietly replace all icons with default ones,
+    }
+}
+
+void HgCacheProxyModel::setBufferPosition(int pos) const
+{
+    if (!mSupressBM && mBufferManager){
+        TX_LOG_ARGS(QString("idx:%1 ").arg(pos) );
+        if (mCurrentPos!=pos){
+            mCurrentPos = pos;
+            mBufferManager->setPosition(mCurrentPos);
+        }
+    }
+}
+
+void HgCacheProxyModel::sourceReset()
+{
+    mSupressBM = true;
+    mResetNeeded = true;
+    releaseAll();
+    if (mBufferManager)
+        mBufferManager->resetBuffer( 0, count() );
+    mSupressBM = false;
+    mResetNeeded = false;
+    endResetModel();
+}
+
+void HgCacheProxyModel::sourceAboutToBeReset()
+{
+    mSupressBM = true;
+    mResetNeeded = true;
+    beginResetModel();
+}
+
+void HgCacheProxyModel::sourceRowsInserted(const QModelIndex &source_parent, int start, int end)
+{
+    Q_UNUSED(source_parent);
+    Q_UNUSED(end);
+    if (mBufferManager)
+        mBufferManager->itemCountChanged(start, false, count());
+}
+
+void HgCacheProxyModel::sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)
+{
+    Q_UNUSED(source_parent);
+    Q_UNUSED(end);    
+    if (mBufferManager)
+        mBufferManager->itemCountChanged(start, true, count());   
+}
+
+void HgCacheProxyModel::dataUpdated(QModelIndex from, QModelIndex to)
+{
+    dataUpdated(from.row(), to.row());
+}
+
+Q_DECL_EXPORT void HgCacheProxyModel::dataUpdated(int from, int to)
+{
+    TX_LOG_ARGS(QString("from:%1 to:%2").arg(from).arg(to));
+    emit dataChanged(index(mapFromDataProviderIndex(from),0), index ( mapFromDataProviderIndex(to),0) );
+}
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/src/hgdataprovidermodel.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,387 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 3 %
+*/
+#include <e32debug.h>
+#include <QVariant>
+#include <HbIcon.h>
+#include <qpixmapdata_p.h>
+#include <hgwidgets/hgdataprovidermodel.h>
+#include <hgwidgets/hgcacheproxymodel.h>
+#include "hglogger.h"
+
+
+const int KQPixmapCacheEmergencyBuffer = 5;
+
+HgDataProviderModel::HgDataProviderModel(QObject *parent) : 
+    QAbstractItemModel(parent),
+    mCache(new QList<QMap<int, QVariant>*>()),
+    mCacheSize(0),
+    mUnallocatedPixmaps(0),
+    mObserver(0)
+{
+    TX_ENTRY
+    TX_EXIT
+}
+
+HgDataProviderModel::~HgDataProviderModel()
+{
+    TX_ENTRY    
+    clearCache();
+    delete mCache;
+    qDeleteAll( mFreePixmaps.begin(), mFreePixmaps.end() );
+    mFreePixmaps.clear();
+    qDeleteAll( mUsedPixmaps.begin(), mUsedPixmaps.end() );
+    mUsedPixmaps.clear();
+    TX_EXIT    
+}
+
+void HgDataProviderModel::release(QList<int> list, bool silent)
+{
+    TX_ENTRY    
+    int i=0;
+    int min = count();
+    int max = 0;
+    
+    for ( int idx = 0; idx < list.count(); idx++){
+        i = list[idx];
+        if ( i >=0 && i<count()){
+            if ( i < min)
+                min = i;
+            if ( i > max)
+                max = i;
+            resetIcon(i);
+        }
+    }
+    
+    doReleaseData(list, silent);
+    
+    if (min<max){ //min<max is true if at least one item is in range <0,count())
+        emitDataChanged(min, max, silent);
+    }
+    TX_EXIT    
+}
+
+void HgDataProviderModel::request(QList<int> list, bool silent)
+{
+    doRequestData(list, silent); 
+}
+
+void HgDataProviderModel::registerObserver(HgDataProviderModelObserver* obs)
+{
+    TX_ENTRY
+    mObserver = obs;
+    TX_EXIT    
+}
+
+QModelIndex HgDataProviderModel::index(int row, int column,
+                                     const QModelIndex &parent) const
+{   
+    Q_UNUSED(parent);
+    if (  row >= rowCount() ){
+        row = -1;
+    }
+    if (  column >= columnCount() ){
+        column = -1;
+    }
+    
+    return QAbstractItemModel::createIndex(row, column); 
+}
+
+QModelIndex HgDataProviderModel::parent(const QModelIndex &child) const
+{
+    Q_UNUSED(child);
+    return QModelIndex();   //returns always invalid model index
+}
+
+int HgDataProviderModel::rowCount(const QModelIndex &parent) const
+{
+    Q_UNUSED(parent);
+    return count();
+}
+
+int HgDataProviderModel::columnCount(const QModelIndex &parent) const
+{
+    Q_UNUSED(parent);
+    return 1;
+}
+
+QVariant HgDataProviderModel::data(const QModelIndex &index, int role) const
+{
+    return data(index.row(), role);
+}
+
+QVariant HgDataProviderModel::data(int idx, int role) const
+{
+    QVariant res;
+    if ( containsRole(idx, role)){
+        res = mCache->at(idx)->value(role);
+    } else if (role == Qt::DecorationRole ){
+        res = defaultIcon();
+    }
+    return res;
+}
+
+QMap<int, QVariant> HgDataProviderModel::itemData(const QModelIndex &index) const
+{
+    QMap<int, QVariant> res;
+    if ( index.row()>=0 && index.row()<count() ){
+        res = QMap<int, QVariant>(*mCache->at(index.row()));
+    }   
+    return res;
+}
+
+void HgDataProviderModel::clearCache()
+{
+    qDeleteAll( mCache->begin(), mCache->end() );
+    mCache->clear();
+}
+
+int HgDataProviderModel::count() const
+{
+    return mCache->count();
+}
+
+bool HgDataProviderModel::update(int pos, QList< QPair< QVariant, int > >* list, bool silent)
+{
+    bool change(false);
+    if (list && list->count() && pos >=0 && pos<count() && mCache->at(pos)) {
+        while(list->count()){
+            QPair< QVariant, int > pair = list->takeFirst();
+            change = update(pos, pair.first, pair.second, true)|change;
+        }
+        if ( !silent && change ){
+            emitDataChanged(pos, pos, false);
+        }
+    }
+    return change;
+}
+
+bool HgDataProviderModel::update(int pos, QVariant obj, int role, bool silent)
+{
+    bool change(false);
+    
+    if ( pos >=0 && pos<count() && mCache->at(pos)){
+        mCache->at(pos)->insert(role, obj); //this will remove old one if needed
+        change = true;
+    }
+    
+    if ( !silent && change ){
+        emitDataChanged(pos, pos, false);
+    }
+    return change;
+}
+
+bool HgDataProviderModel::updateIcon(int pos, QVariant obj, bool silent)
+{
+    if (obj.isValid()==false)
+        return false;
+    
+    bool change(false);
+    if ( pos >=0 && pos<count() && mCache->at(pos)){
+        mCache->at(pos)->insert(Qt::DecorationRole, obj); //will remove old if needed
+        change = true;
+    }
+    
+    if (!silent && change){
+        TX_LOG
+        if ( mObserver){
+            mObserver->dataUpdated(pos,pos);
+        } else {
+            QModelIndex topLeft = index(pos, 0);
+            QModelIndex bottomRight = index(pos, 0);
+            emit dataChanged(topLeft,bottomRight);
+        }
+    }
+    return change;
+}
+
+void HgDataProviderModel::resetIcon(int pos)
+{
+    if ( containsRole(pos, Qt::DecorationRole)){
+        mCache->at(pos)->remove(Qt::DecorationRole);
+    }
+}
+
+void HgDataProviderModel::newItem(QList< QPair< QVariant, int > >* list, bool silent)
+{
+    insertItem(mCache->count(), list, silent);
+}
+
+void HgDataProviderModel::newItem(QPair< QVariant, int > item, bool silent)
+{
+    insertItem(mCache->count(), item, silent);
+}
+
+void HgDataProviderModel::insertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent)
+{
+    doInsertItem(pos, list, silent);
+}
+
+void HgDataProviderModel::insertItem(int pos, QPair< QVariant, int > item, bool silent)
+{
+    QList< QPair< QVariant, int > > list;
+    list.append(item);
+    doInsertItem(pos, &list, silent);
+}
+
+void HgDataProviderModel::doInsertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent)
+{
+    if (pos >mCache->count()){
+        pos = mCache->count();
+    } else if (pos <0){
+        pos = 0;
+    }
+    
+    if ( !silent){
+        beginInsertRows(QModelIndex(), pos, pos);
+    }
+    
+    mCache->insert(pos, new QMap<int, QVariant>());
+    if (list && list->count()){
+        update(pos, list, true);
+    }
+    
+    if ( !silent){
+        endInsertRows();
+    } 
+}
+
+
+void HgDataProviderModel::removeItem(int pos)
+{
+    removeItems(pos, 1);
+}
+
+void HgDataProviderModel::removeItems(int pos, int size)
+{
+    if (pos >mCache->count())
+        return;
+    else if (pos <0){
+        size = size + pos; //pos <0
+        pos = 0;
+    }
+    
+    if (size >mCache->count()){
+        size = mCache->count();
+    } else if (size <0){
+        return;
+    }
+    
+    beginRemoveRows(QModelIndex(),pos, pos+size-1);
+    for (int i=0; i<size && pos<mCache->count(); i++){
+        mCache->removeAt(pos);
+    }
+    endRemoveRows();
+}
+        
+void HgDataProviderModel::resetModel() 
+{
+    beginResetModel();
+    doResetModel();
+    endResetModel();
+}
+
+void HgDataProviderModel::emitDataChanged(int from, int to, bool silent)
+{
+    if ( !silent ){
+        TX_LOG    
+        QModelIndex topLeft = index(from, 0);
+        QModelIndex bottomRight = index(to, 0);
+        emit dataChanged(topLeft,bottomRight);
+    }
+}
+
+void HgDataProviderModel::resizeQPixmapPool(int newSize)
+{
+    mQPixmapsLock.lock();
+    int currentSize = mFreePixmaps.count() + mUsedPixmaps.count();
+    int diff = currentSize - newSize - KQPixmapCacheEmergencyBuffer;
+    mUnallocatedPixmaps = 0;
+    while (diff != 0){
+        if (diff < 0){
+            mUnallocatedPixmaps++;
+            diff++;
+        }else{
+            if (mUnallocatedPixmaps>0){
+                mUnallocatedPixmaps--;
+            } else if (mFreePixmaps.count()){
+                mFreePixmaps.removeLast();
+            } //else will be deleted with releasePixmap;
+            diff--;
+        }
+    }
+    mQPixmapsLock.unlock();
+    mCacheSize = newSize;
+}
+
+void HgDataProviderModel::releasePixmap(int idx)
+{
+    mQPixmapsLock.lock();
+    if (mUsedPixmaps.contains(idx)){
+        QPixmap* pix = mUsedPixmaps.take(idx);
+        if ( mFreePixmaps.count() + mUsedPixmaps.count() + mUnallocatedPixmaps> mCacheSize + KQPixmapCacheEmergencyBuffer){
+            delete pix; //we have too many pixmaps
+        }else{
+            mFreePixmaps.append(pix);
+        }
+    }else{
+        TX_LOG_ARGS( QString("can't release pixmap for idx=%0").arg(idx));
+    }
+    mQPixmapsLock.unlock();    
+}
+
+QVariant HgDataProviderModel::createIcon(int index, QPixmap aPixmap)
+{
+	QPixmap* pix = getPixmap(index);
+	if (pix){
+		if ( pix->pixmapData() ){
+			pix->pixmapData()->fromImage(aPixmap.toImage(), Qt::AutoColor );  
+		} else {
+			*pix = aPixmap;
+		}
+		mQPixmapsLock.lock();
+		mUsedPixmaps.insert(index, pix);
+		mQPixmapsLock.unlock();
+		return HbIcon(QIcon(*pix));	
+	}
+	TX_EXIT_ARGS( QString("No pixmap avilable"));
+	return QVariant();
+}
+
+QPixmap* HgDataProviderModel::getPixmap(int idx)
+{
+    TX_ENTRY
+    QPixmap* res = NULL;
+    mQPixmapsLock.lock();
+    if ( mUsedPixmaps.contains(idx)){
+        res = mUsedPixmaps.take(idx);//let's just replace pixmapdata for that pixmap
+    } else {
+        if (!mFreePixmaps.isEmpty()){
+            res = mFreePixmaps.takeFirst();
+        }else if (mUnallocatedPixmaps){
+            mUnallocatedPixmaps--;
+            res = new QPixmap();
+        } else {
+            TX_LOG_ARGS(QString("no free pixmaps"));
+        }        
+    }
+    mQPixmapsLock.unlock();
+    TX_EXIT    
+    return res;
+}
+
+//eof
Binary file hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/default.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/hgcacheproxymodeltestapp.pro	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,48 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description:
+
+TEMPLATE = app
+CONFIG += qtestlib console hb
+
+TARGET = hgcacheproxymodeltestapp
+DEPENDPATH += . \
+    inc \
+    src
+	
+symbian { 
+	TARGET.EPOCSTACKSIZE = 0x14000
+    TARGET.EPOCALLOWDLLDATA = 1
+    TARGET.CAPABILITY = ALL \
+        -TCB
+}
+LIBS += -lhgcacheproxymodel \
+        -lharvesterclient.dll \
+        -lmdeclient.dll \ 
+		-lthumbnailmanagerqt.dll \
+		-lflogger
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE $$APP_LAYER_SYSTEMINCLUDE
+INCLUDEPATH += ../../../inc
+
+#DEFINES += ENABLETRACE
+#if TRACE_FILENAME not set, then RDebug is used
+DEFINES += TRACE_FILE
+
+
+HEADERS += src\mywindow.h \
+    src/mydataprovider.h \
+    ../../../inc/txlogger.h
+	
+SOURCES += src\mywindow.cpp \
+    src/mydataprovider.cpp \
+    src/main.cpp 
+    
+RESOURCES += hgcacheproxymodeltestapp.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/hgcacheproxymodeltestapp.qrc	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/icons" >
+        <file>default.png</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/main.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include <QtGui>
+#include <hbapplication.h>
+#include <hblistview.h>
+#include <hbicon.h>
+#include <hbgridview.h>
+#include <hbgridviewitem.h>
+#include <hbmainwindow.h>
+#include <hbmenu.h>
+#include <QDirModel>
+
+#include "mywindow.h"
+#include "hglogger.h"
+
+TX_MAIN(argc, argv) {
+    TX_STATIC_ENTRY
+    HbApplication app(argc, argv);
+    app.setApplicationName("Cache proxy model demo");
+    MyWindow mainWindow;
+    mainWindow.show();
+    // Enter event loop
+    int ret = app.exec();   
+    TX_STATIC_EXIT
+    return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mydataprovider.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,236 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include <QList>
+#include "hglogger.h"
+#include <hbicon.h>
+#include "mydataprovider.h"
+
+//#include "x:\sf\mw\qt\src\openvg\qpixmapdata_vg_p.h"
+//typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
+
+const int KItemIdRole = Qt::UserRole+1;
+
+const int KThumbnailsPriority = EPriorityLess; //standard priority
+
+
+MyDataProvider::MyDataProvider(QObject *parent) :
+HgDataProviderModel(parent),
+mDefaultIcon(new HbIcon(QIcon(QPixmap(":/icons/default.png")))),
+mScheduler(new CActiveSchedulerWait()),
+mWrapper( new ThumbnailManager() ),
+mThumbnailRequestPending(false),
+mThumbnailRequestIndex(-1),
+mThumbnailRequestID(-1),
+mThumbnailsize(ThumbnailManager::ThumbnailMedium),
+mMDSLoadInProgress(false)
+{
+//    TX_ENTRY
+    Q_UNUSED(parent);
+    mWrapper->setThumbnailSize( mThumbnailsize );
+    mWrapper->setQualityPreference( ThumbnailManager::OptimizeForPerformance );
+
+    QObject::connect( mWrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+                      this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
+    
+    doResetModel(); //will read mds data
+}
+
+MyDataProvider::~MyDataProvider()
+{
+//    TX_ENTRY
+    delete mDefaultIcon;
+    delete mWrapper;
+    delete mScheduler;
+//    TX_EXIT
+}
+
+void MyDataProvider::changeIconSize(ThumbnailManager::ThumbnailSize aThumbnailsize)
+{
+//    TX_ENTRY
+//	we could  remove all iconsfrom cache and put default ones, but probably that would be waste of time, and it's better just to load new icons with correct sizes.
+	mThumbnailsize = aThumbnailsize;
+	mWrapper->setThumbnailSize( mThumbnailsize );
+//    TX_EXIT
+}
+
+void MyDataProvider::doRequestData(QList<int> list, bool silent)
+{
+    TX_ENTRY
+	Q_UNUSED(silent);
+    QString items = "Requested items:";
+    int i = 0;
+	for (int idx=0; idx<list.count(); idx++){
+        i = list[idx];
+		if (containsRole(i, KItemIdRole) && !containsRole(i, Qt::DecorationRole)) {//if there is icon, don't request new one
+            items += QString("%0 ").arg(i);
+			mWaitingThumbnails.append(i);
+		}
+	}
+	TX_LOG_ARGS(items);
+    getNextThumbnail();
+    TX_EXIT
+}
+
+void MyDataProvider::getNextThumbnail()
+{
+//    TX_ENTRY
+    if ( !mThumbnailRequestPending && mWaitingThumbnails.count()){
+            int i = mWaitingThumbnails.takeFirst();
+            if (i >=0 && i < count() && containsRole(i, KItemIdRole)) {
+                int id = (data(i, KItemIdRole)).toInt();
+                unsigned long int uId = (unsigned long int)id;
+//                TX_LOG_ARGS(QString("getThumbnail for index:%0 uID:%1").arg(i).arg(uId));
+                void *clientData = reinterpret_cast<void *>(i);
+                mThumbnailRequestID = mWrapper->getThumbnail(uId, clientData, KThumbnailsPriority);
+                mThumbnailRequestIndex = i;
+                mThumbnailRequestPending = true;            
+        }
+    }
+//    TX_EXIT    
+}
+
+void MyDataProvider::readMDSData()
+{
+    mMDSLoadInProgress = true;
+}
+
+void MyDataProvider::thumbnailReady( QPixmap pixmap, void* data, int id, int error )
+{
+//    TX_ENTRY    
+    Q_UNUSED(id);
+    if (!error && pixmap.rect().height()>0  && pixmap.rect().width()>0 ){
+        int idx = reinterpret_cast<int>(data);
+//        TX_LOG_ARGS(QString("thumbnailReady idx = %0").arg(idx));
+        updateIcon(idx, createIcon(idx, pixmap));
+	} else {
+        TX_LOG_ARGS(QString("error:%0 id:%0").arg(error).arg(id));
+	}
+    mThumbnailRequestIndex = -1;
+    mThumbnailRequestID = -1;
+    mThumbnailRequestPending = false;            
+    getNextThumbnail();
+//    TX_EXIT
+}
+
+void MyDataProvider::doReleaseData(QList<int> list, bool silent)
+{
+//    TX_ENTRY    
+    Q_UNUSED(silent);
+    int i = 0;
+    QString items = "Released items:";
+    for (int idx=0;idx<list.count(); idx++){
+        i = list[idx];
+        if (mThumbnailRequestPending && mThumbnailRequestIndex==i ){
+            TX_LOG_ARGS( QString("Cancel also thumbnail request for item %0").arg(i));
+            mWrapper->cancelRequest(mThumbnailRequestID);
+            mThumbnailRequestIndex = -1;
+            mThumbnailRequestID = -1;
+            mThumbnailRequestPending = false;
+        }
+        items += QString("%0 ").arg(i);
+        mWaitingThumbnails.removeAll(i);
+        releasePixmap(i);
+    }
+    TX_LOG_ARGS(items);
+
+    getNextThumbnail();
+//    TX_EXIT        
+}
+
+QVariant MyDataProvider::defaultIcon() const
+{
+    return *mDefaultIcon;
+}
+
+void MyDataProvider::HandleSessionOpened(CMdESession& aSession, TInt aError)
+{
+    Q_UNUSED(aSession);
+    Q_UNUSED(aError);	
+    mScheduler->AsyncStop();
+}
+
+// ----------------------------------------------------------------------------
+// HandleQueryCompleted
+// ----------------------------------------------------------------------------
+//
+void MyDataProvider::HandleQueryCompleted(CMdEQuery& aQuery, TInt aError)
+{
+    Q_UNUSED(aError);	
+    clearCache();
+    mMDSLoadInProgress = false;
+    int size = aQuery.ResultIds().Count();
+    
+    for(int i = 0; i < size ; i++){
+        QList< QPair< QVariant, int > > list;
+        unsigned long int id = aQuery.ResultId(i);
+        QVariant v;
+        v.setValue(id);
+        list.append( QPair< QVariant, int >(v, KItemIdRole) );
+        int a = count();
+        int b = -count();
+		int c = a/4 + b/10 + i%30 + i/2;
+		QString s = QString("ITEM%1 %2 %3").arg(c).arg(a).arg(b);
+		if (i%2){
+            s = s.toLower();
+		}
+        list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
+        list.append( QPair< QVariant, int >(QVariant(a), Qt::UserRole+2) );
+        list.append( QPair< QVariant, int >(QVariant(b), Qt::UserRole+3) );
+        list.append( QPair< QVariant, int >(QVariant(c), Qt::UserRole+4) );
+        
+        newItem(&list);
+    }
+    
+    TX_LOG_ARGS( QString("size=%1").arg(count()) );
+    
+    mScheduler->AsyncStop();
+}
+
+void MyDataProvider::doResetModel()
+{
+
+    if (mThumbnailRequestPending && mThumbnailRequestID!=-1){
+        mWrapper->cancelRequest(mThumbnailRequestID);
+    }
+    mThumbnailRequestIndex = -1;
+    mThumbnailRequestID = -1;
+    mThumbnailRequestPending = false;
+    mWaitingThumbnails.clear();
+    
+    //read MDS data once again
+    TRAP_IGNORE(
+        CMdESession* session = CMdESession::NewL( *this ); 
+        mScheduler->Start();
+        
+        CMdENamespaceDef& namespaceDef = session->GetDefaultNamespaceDefL();
+                
+        CMdEObjectDef& objectDef = namespaceDef.GetObjectDefL(_L("Image"));
+    
+        CMdEObjectQuery* imageQuery = session->NewObjectQueryL( namespaceDef, objectDef, this );
+        CleanupStack::PushL( imageQuery );
+        imageQuery->SetResultMode( EQueryResultModeId );
+        imageQuery->FindL( );
+        mScheduler->Start();
+        CleanupStack::PopAndDestroy( 1 );
+        delete session;        
+    );    
+    
+    
+//    TX_EXIT    
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mydataprovider.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#ifndef MYDATAPROVIDER2_H
+#define MYDATAPROVIDER2_H
+
+#include <QtGui>
+
+#include <thumbnailmanager_qt.h>
+#include <hgwidgets/hgdataprovidermodel.h>
+#include <QList>
+#include <QPair>
+#include <mdesession.h>
+#include <mdequery.h>
+#include "flogger.h"
+
+class HbIcon;
+class CMdESession;
+class CActiveSchedulerWait;
+class QEventLoop;
+
+class MyDataProvider : public HgDataProviderModel, public MMdESessionObserver, public MMdEQueryObserver
+{
+    Q_OBJECT
+
+public:
+    MyDataProvider(QObject *parent = 0);
+    ~MyDataProvider();
+    void changeIconSize(ThumbnailManager::ThumbnailSize aThumbnailsize);
+	
+//from MMdESessionObserver and MMdEQueryObserver
+    virtual void HandleSessionOpened(CMdESession& aSession, TInt aError);
+    virtual void HandleSessionError(CMdESession& , TInt ){};
+    virtual void HandleQueryNewResults(CMdEQuery& , TInt ,TInt ){};
+    virtual void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError);
+	
+//from HgDataProviderModel
+    virtual void doReleaseData(QList<int> list, bool silent);
+    virtual void doRequestData(QList<int> list, bool silent);  
+    virtual QVariant defaultIcon() const;    
+
+protected:
+    virtual void doResetModel();
+    
+public slots:
+    void thumbnailReady( QPixmap , void* , int, int ); 
+
+private:
+    void getNextThumbnail();
+    void readMDSData();
+	
+private:
+    HbIcon* mDefaultIcon;
+    CActiveSchedulerWait* mScheduler;
+    ThumbnailManager* mWrapper;
+    QList<int> mWaitingThumbnails;
+    bool mThumbnailRequestPending;
+    int mThumbnailRequestIndex;
+    int mThumbnailRequestID;
+	ThumbnailManager::ThumbnailSize mThumbnailsize;
+	bool mMDSLoadInProgress;
+};
+
+#endif // MYDATAPROVIDER2_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mywindow.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,214 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include "mywindow.h"
+#include <hbmenu.h>
+#include <hbaction.h>
+#include <hbmainwindow.h>
+#include <hbslider.h>
+#include <QTimer>
+#include <QtGui>
+#include <QDebug>
+#include <QPushButton>
+#include <QApplication>
+#include <QGraphicsLinearLayout>
+#include <QCoreApplication>
+#include <hbgridview.h>
+#include <hbinstance.h>
+#include <QFileSystemWatcher>
+#include <hgwidgets/hgcacheproxymodel.h>
+
+#include "mydataprovider.h"
+#include "hglogger.h"
+
+
+const QStringList KViewNames = (QStringList() << "GridView" << "ListView" );
+
+MyWindow::MyWindow()
+    : HbMainWindow(), 
+    mView(0),
+    mModel(0),
+    mMyDataProvider(0),
+    mTimer(new QTimer(this))
+{
+    mMainView = new HbView();
+    addView( mMainView );
+
+    mMainView->setMenu( createMainMenu() ); 
+    
+    mMyDataProvider = new MyDataProvider(this);
+    mModel = new HgCacheProxyModel(this);
+    mModel->setDataProvider(mMyDataProvider, 120, 20);
+
+    connect(mTimer, SIGNAL(timeout()), this, SLOT(timeout()));
+    
+    HbAction action;
+	action.setData ( QVariant(1) );	//select Grid
+	processAction(&action);
+}
+
+MyWindow::~MyWindow()
+{
+//	delete mMyDataProvider;
+}
+
+HbMenu *MyWindow::createMainMenu()
+{
+    HbMenu* mainMenu = new HbMenu( );
+    connect(mainMenu, SIGNAL(triggered(HbAction*)),this, SLOT(processAction(HbAction*)));
+
+    HbMenu *viewSubMenu = mainMenu->addMenu("Change view");
+    QString temporaryString;
+    int i(0);
+    foreach (temporaryString , KViewNames) {
+        HbAction* subAction = viewSubMenu->addAction(temporaryString);
+        subAction->setData (QVariant(++i));
+    }
+    
+    HbMenu *sortSubMenu = mainMenu->addMenu("Sort");
+    HbAction* action = sortSubMenu->addAction("Sort1");
+    action->setData(QVariant(101));
+    action = sortSubMenu->addAction("Sort2");
+    action->setData(QVariant(102));    
+    action = sortSubMenu->addAction("Sort3");
+    action->setData(QVariant(103));
+    HbMenu *sort4SubMenu = sortSubMenu->addMenu("Sort4 (String)");
+    action = sort4SubMenu->addAction("CaseSensitive");
+    action->setData(QVariant(104));
+    action = sort4SubMenu->addAction("CaseInsensitive");
+    action->setData(QVariant(105));
+    
+    HbMenu *filterSubMenu = mainMenu->addMenu("Filter");
+    action = filterSubMenu->addAction("Disable filter");
+    action->setData(QVariant(201));
+    action = filterSubMenu->addAction("Filter ITEM* (Case Sensitive)");
+    action->setData(QVariant(202));
+    action = filterSubMenu->addAction("Filter ITEM1*(Case Insensitive)");
+    action->setData(QVariant(203));
+    
+    action = mainMenu->addAction("Reset");
+    action->setData(QVariant(1000));
+    action = mainMenu->addAction("Enable dynamic Sort/Filter");
+    action->setData(QVariant(1001));    
+
+    action = mainMenu->addAction("Test");
+    action->setData(QVariant(1002));
+
+    action = mainMenu->addAction("Stop Test");
+    action->setData(QVariant(1003));
+    
+    return mainMenu;
+}
+
+
+void MyWindow::processAction( HbAction* action )
+{
+    int command = action->data().toInt();
+    if ( command == 1) {
+        HbGridView* view = new HbGridView();
+		if ( orientation() == Qt::Horizontal ) {
+			view->setColumnCount( 5 );
+			view->setRowCount( 3 );
+		}else {
+			view->setColumnCount( 3 );
+			view->setRowCount( 5 );			
+		}
+        view->setTextVisible(false);
+		view->setUniformItemSizes( true );
+		view->setItemRecycling( true );
+		//this could be done to change mode, for images it doesn't make sence, becouse images thumbnails are created by default only for medium and fullsize
+//		AbstractDataProvider *data = mModel->DataProvider();
+//		MyDataProvider *prov = static_cast<MyDataProvider*>(data); //of course we have already poiter to that - mMyDataProvider, but it is example how to get it from model
+//		prov->changeIconSize(ThumbnailManager::ThumbnailMedium);
+		view->setModel(mModel);
+		mMainView->setWidget( view );
+        mView = view;
+    } else if (command == 2) {
+        HbListView* view = new HbListView();
+		view->setUniformItemSizes( true );
+		view->setItemRecycling( true );
+		//this could be done to change mode, for images it doesn't make sence, becouse images thumbnails are created by default only for medium and fullsize
+//		AbstractDataProvider *data = mModel->DataProvider();
+//		MyDataProvider *prov = static_cast<MyDataProvider*>(data); //of course we have already poiter to that - mMyDataProvider, but it is example how to get it from model
+//		prov->changeIconSize(ThumbnailManager::ThumbnailSmall);
+		view->setModel(mModel);
+		mMainView->setWidget( view );
+        mView = view;
+	} else if (command == 101) { //sort by KSort1Role
+        mModel->setSortRole(Qt::UserRole+2);
+        mModel->sort(0);
+	} else if (command == 102) { //sort by KSort2Role
+        mModel->setSortRole(Qt::UserRole+3);
+        mModel->sort(0);
+    } else if (command == 103) { //sort by KSort3Role
+        mModel->setSortRole(Qt::UserRole+4);
+        mModel->sort(0);
+    } else if (command == 104) { //sort by DisplayRole CaseSensitive
+        mModel->setSortRole(Qt::DisplayRole);
+        mModel->setSortCaseSensitivity(Qt::CaseSensitive);  
+        mModel->sort(0);
+    } else if (command == 105) { //sort by DisplayRole CaseInsensitive
+        mModel->setSortRole(Qt::DisplayRole);
+        mModel->setSortCaseSensitivity(Qt::CaseInsensitive);
+        mModel->sort(0);
+    } else if (command == 201) { //disable filter
+        QRegExp reg = QRegExp();
+//        mModel->setFilterRegExp(reg);
+    } else if (command == 202) { //Filter ITEM* (Case Sensitive)
+        QRegExp reg = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
+//        mModel->setFilterCaseSensitivity(Qt::CaseSensitive);
+//        mModel->setFilterRegExp(reg);        
+    } else if (command == 203) { //Filter ITEM1*(Case Insensitive)
+        QRegExp reg = QRegExp("ITEM1*", Qt::CaseInsensitive, QRegExp::Wildcard);
+//        mModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+//        mModel->setFilterRegExp(reg);
+    } else if (command == 1000) { //reset
+        mMyDataProvider->resetModel();
+    } else if (command == 1001) { //reset
+        bool current = !mModel->dynamicSortFilter();
+        mModel->setDynamicSortFilter(current);
+        if (current){
+            action->setText("Disable dynamic Sort/Filter");
+        }else{
+            action->setText("Enable dynamic Sort/Filter");            
+        }
+    } else if (command == 1002) {
+        mTestVal = 500;
+        timeout();
+    } else if (command == 1003) {
+        mTestVal = 0;
+    }
+}
+
+void MyWindow::setIndex(int /*index*/)
+{
+    update();
+}
+
+void MyWindow::timeout()
+{   
+    HbAction action;
+    action.setData ( QVariant(101 + mTestVal%4) );
+    processAction(&action);
+
+    if (mTestVal>0){
+        mTestVal--;
+        mTimer->start(1000);
+    }
+}
+
+//eof
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/fute/HgCacheProxyModelTestApp/src/mywindow.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#ifndef CONTENTWIDGET_H
+#define CONTENTWIDGET_H
+
+#include <hbview.h>
+#include <QGraphicsWidget>
+#include <QAbstractItemModel>
+#include <QtGui>
+#include <hbgridviewitem.h>
+
+#include <QtGui>
+#include <hbapplication.h>
+#include <hblistview.h>
+#include <hbicon.h>
+#include <hblabel.h>
+#include <hbgridview.h>
+#include <hbgridviewitem.h>
+#include <hbmainwindow.h>
+#include <hbmenu.h>
+#include <QDirModel>
+
+class QTimer;
+class HbMenu;
+class HbMainWindow;
+class HbGridView;
+class HbAction;
+class HbMenuItem;
+class QFileSystemWatcher;
+class HgCacheProxyModel;
+class HbSlider;
+class MyDataProvider;
+
+class MyWindow : public HbMainWindow
+{
+    Q_OBJECT
+
+public:
+    MyWindow();
+    ~MyWindow();
+
+private slots:
+    void processAction ( HbAction* action );
+    void setIndex(int index);
+    void timeout();
+    
+private:
+    HbMenu *createMainMenu();
+    
+private:
+    HbAbstractItemView* mView;      
+    HgCacheProxyModel *mModel;
+	
+	MyDataProvider *mMyDataProvider;
+    HbView* mMainView;	
+    int mTestVal;
+    QTimer *mTimer;
+
+};
+
+#endif // CONTENTWIDGET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/bmhelper.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include "bmhelper.h"
+#include <QDebug>
+
+BMHelper::BMHelper(int totalSize)
+{
+    for ( int i(0); i < totalSize; i++)
+        mBuffer.append(false);
+}
+
+BMHelper::~BMHelper()
+{
+}
+
+void BMHelper::release(int start, int end)
+{
+    if ( start<0)
+        start = 0;
+    if (end>mBuffer.size() - 1)
+        end = mBuffer.size() - 1;
+    
+    for ( int i = start; i <= end; i++){
+        mBuffer.replace(i, false);
+    }
+}
+
+void BMHelper::request(int start, int end, HgRequestOrder order)
+{
+    Q_UNUSED(order);
+    if ( start<0)
+        start = 0;
+    if (end>mBuffer.size() - 1)
+        end = mBuffer.size() - 1;
+
+    for ( int i = start; i <= end; i++){
+        mBuffer.replace(i, true);
+    }
+}
+
+bool BMHelper::isIntergal(int bufferSize)
+{
+    int c = mBuffer.count(true);
+    bool res = (bufferSize == c);
+    if (res){ ///check integrity ( if all items from first true, to size are true;
+        int f = mBuffer.indexOf(true);
+        for ( int i =0; i < mBuffer.count(); i++){
+            if (mBuffer[i] != (i>=f && i < f+bufferSize) ){
+                res = false;
+                break;
+            }
+        }
+    } else {
+        qWarning()<<QString("isIntergal mBuffer.count(true)=%1 bufferSize=%2").arg(c).arg(bufferSize);
+    }
+    
+    return res;
+}
+
+void BMHelper::itemCountChanged( int aIndex, bool aRemoved, int aNewTotalCount )
+{
+    Q_UNUSED(aRemoved);
+    
+    if ( aIndex < 0)
+        aIndex = 0;
+    if ( aIndex > mBuffer.count())
+        aIndex = mBuffer.count()-1;
+    
+    if ((mBuffer.count() - aNewTotalCount)>0){
+        while (mBuffer.count()!=aNewTotalCount){
+            if (aIndex > mBuffer.count() )
+                aIndex = mBuffer.count() -1;
+            mBuffer.removeAt(aIndex);
+        }
+    } else if ((mBuffer.count() - aNewTotalCount)<0){
+        while (mBuffer.count()!=aNewTotalCount){
+            mBuffer.insert(aIndex, false);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/bmhelper.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#ifndef BUFFERMANAGERHELPER_H
+#define BUFFERMANAGERHELPER_H
+
+#include <hgwidgets/hgcacheproxymodel.h>
+
+class BMHelper: public HgBufferManagerObserver
+{
+public:
+    BMHelper(int totalSize);
+    ~BMHelper();
+    
+    virtual void release(int start, int end);
+    virtual void request(int start, int end, HgRequestOrder order = HgRequestOrderAscending);  
+
+    bool isIntergal(int bufferSize);
+    void itemCountChanged( int aIndex, bool aRemoved, int aNewTotalCount );
+    void resizeCache(int newSize);
+
+    
+private:    
+    QList< bool > mBuffer;
+    
+};
+#endif // BUFFERMANAGERHELPER_H
Binary file hgcacheproxymodel/tsrc/unit/cacheproxydatamodel_tsrc.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/cacheproxyhelper.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,284 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 1 %
+*/
+#include "cacheproxyhelper.h"
+
+CacheProxyHelper::CacheProxyHelper(HgCacheProxyModel *model, QObject *parent):
+QObject(parent),
+mModel(model)
+{
+    ASSERT(mModel!=0);
+    
+    connect(mModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+            this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));
+    
+    connect(mModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+            this, SLOT(slotHeaderDataChanged(Qt::Orientation,int,int)));
+
+    connect(mModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+            this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(slotRowsInserted(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+            this, SLOT(slotColumnsAboutToBeInserted(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
+            this, SLOT(slotColumnsInserted(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+            this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+            this, SLOT(slotRowsRemoved(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+            this, SLOT(slotColumnsAboutToBeRemoved(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+            this, SLOT(slotColumnsRemoved(QModelIndex,int,int)));
+
+    connect(mModel, SIGNAL(layoutAboutToBeChanged()),
+            this, SLOT(slotLayoutAboutToBeChanged()));
+
+    connect(mModel, SIGNAL(layoutChanged()), 
+            this, SLOT(slotLayoutChanged()));
+
+    connect(mModel, SIGNAL(modelAboutToBeReset()), 
+            this, SLOT(slotModelAboutToBeReset()));
+    
+    connect(mModel, SIGNAL(modelReset()), 
+            this, SLOT(slotModelReset()));	
+    
+}
+
+CacheProxyHelper::~CacheProxyHelper()
+{
+    disconnect(mModel);
+}
+
+void CacheProxyHelper::slotDataChanged(QModelIndex from,QModelIndex to)
+{
+    QPair< int, int > p;
+    p.first = from.row();
+    p.second = to.row();    
+    mSignalDataChanged.append(p);
+}
+
+void CacheProxyHelper::slotHeaderDataChanged(Qt::Orientation orientation, int first, int last)
+{
+    Q_UNUSED(orientation);    
+    QPair< int, int > p;
+    p.first = first;
+    p.second = last;    
+    mSignalHeaderDataChanged.append(p);
+}
+
+void CacheProxyHelper::slotRowsAboutToBeInserted(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalRowsAboutToBeInserted.append(p);
+}
+
+void CacheProxyHelper::slotRowsInserted(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;     
+    mSignalRowsInserted.append(p);
+}
+
+void CacheProxyHelper::slotColumnsAboutToBeInserted(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalColumnsAboutToBeInserted.append(p);
+}
+
+void CacheProxyHelper::slotColumnsInserted(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;      
+    mSignalColumnsInserted.append(p);
+}
+
+void CacheProxyHelper::slotRowsAboutToBeRemoved(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;      
+    mSignalRowsAboutToBeRemoved.append(p);
+}
+
+void CacheProxyHelper::slotRowsRemoved(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;       
+    mSignalRowsRemoved.append(p);
+}
+
+void CacheProxyHelper::slotColumnsAboutToBeRemoved(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;       
+    mSignalColumnsAboutToBeRemoved.append(p);
+}
+
+void CacheProxyHelper::slotColumnsRemoved(QModelIndex parent,int from,int to)
+{
+    Q_UNUSED(parent);    
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;       
+    mSignalColumnsRemoved.append(p);
+}
+
+void CacheProxyHelper::slotLayoutAboutToBeChanged()
+{
+    mSignalLayoutAboutToBeChanged = true;
+}
+
+void CacheProxyHelper::slotLayoutChanged()
+{
+    mSignalLayoutChanged = true;
+}
+
+void CacheProxyHelper::slotModelAboutToBeReset()
+{
+    mSignalModelAboutToBeReset = true;
+}
+
+void CacheProxyHelper::slotModelReset()
+{
+    mSignalModelReset = true;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalDataChanged()
+{
+    QList< QPair< int, int > > res = mSignalDataChanged;
+    mSignalDataChanged.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalHeaderDataChanged()
+{
+    QList< QPair< int, int > > res = mSignalHeaderDataChanged;
+    mSignalHeaderDataChanged.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalRowsAboutToBeInserted()
+{
+    QList< QPair< int, int > > res = mSignalRowsAboutToBeInserted;
+    mSignalRowsAboutToBeInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalRowsInserted()
+{
+    QList< QPair< int, int > > res = mSignalRowsInserted;
+    mSignalRowsInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsAboutToBeInserted()
+{
+    QList< QPair< int, int > > res = mSignalColumnsAboutToBeInserted;
+    mSignalColumnsAboutToBeInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsInserted()
+{
+    QList< QPair< int, int > > res = mSignalColumnsInserted;
+    mSignalColumnsInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalRowsAboutToBeRemoved()
+{
+    QList< QPair< int, int > > res = mSignalRowsAboutToBeRemoved;
+    mSignalRowsAboutToBeRemoved.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalRowsRemoved()
+{
+    QList< QPair< int, int > > res = mSignalRowsRemoved;
+    mSignalRowsRemoved.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsAboutToBeRemoved()
+{
+    QList< QPair< int, int > > res = mSignalColumnsAboutToBeRemoved;
+    mSignalColumnsAboutToBeRemoved.clear();
+    return res;
+}
+
+QList< QPair< int, int > > CacheProxyHelper::getSignalColumnsRemoved()
+{
+    QList< QPair< int, int > > res = mSignalColumnsRemoved;
+    mSignalColumnsRemoved.clear();
+    return res;
+}
+
+bool CacheProxyHelper::getSignalLayoutAboutToBeChanged()
+{
+    bool res = mSignalLayoutAboutToBeChanged;
+    mSignalLayoutAboutToBeChanged = false;
+    return res;
+}
+
+bool CacheProxyHelper::getSignalLayoutChanged()
+{
+    bool res = mSignalLayoutChanged;
+    mSignalLayoutChanged = false;
+    return res;
+}
+
+bool CacheProxyHelper::getSignalModelAboutToBeReset()
+{
+    bool res = mSignalModelAboutToBeReset;
+    mSignalModelAboutToBeReset = false;
+    return res;
+}
+
+bool CacheProxyHelper::getSignalModelReset()
+{
+    bool res = mSignalModelReset;
+    mSignalModelReset = false;
+    return res;
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/cacheproxyhelper.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef CACHEPROXYHELPER_H
+#define CACHEPROXYHELPER_H
+
+#include <hgwidgets/hgcacheproxymodel.h>
+
+
+class CacheProxyHelper: public QObject
+{
+    Q_OBJECT
+public:
+    CacheProxyHelper(HgCacheProxyModel *model, QObject *parent = 0);
+    ~CacheProxyHelper();
+    
+private slots:
+    void slotDataChanged(QModelIndex from,QModelIndex to);
+    void slotHeaderDataChanged(Qt::Orientation orientation, int first, int last);
+    void slotRowsAboutToBeInserted(QModelIndex parent,int from,int to);
+    void slotRowsInserted(QModelIndex parent,int from,int to);
+    void slotColumnsAboutToBeInserted(QModelIndex parent,int from,int to);
+    void slotColumnsInserted(QModelIndex parent,int from,int to);
+    void slotRowsAboutToBeRemoved(QModelIndex parent,int from,int to);
+    void slotRowsRemoved(QModelIndex parent,int from,int to);
+    void slotColumnsAboutToBeRemoved(QModelIndex parent,int from,int to);
+    void slotColumnsRemoved(QModelIndex parent,int from,int to);
+    void slotLayoutAboutToBeChanged();
+    void slotLayoutChanged();
+    void slotModelAboutToBeReset();
+    void slotModelReset();
+    
+public:
+    QList< QPair< int, int > > getSignalDataChanged();
+    QList< QPair< int, int > > getSignalHeaderDataChanged();
+    QList< QPair< int, int > > getSignalRowsAboutToBeInserted();
+    QList< QPair< int, int > > getSignalRowsInserted();
+    QList< QPair< int, int > > getSignalColumnsAboutToBeInserted();
+    QList< QPair< int, int > > getSignalColumnsInserted();
+    QList< QPair< int, int > > getSignalRowsAboutToBeRemoved();
+    QList< QPair< int, int > > getSignalRowsRemoved();
+    QList< QPair< int, int > > getSignalColumnsAboutToBeRemoved();
+    QList< QPair< int, int > > getSignalColumnsRemoved();
+    bool getSignalLayoutAboutToBeChanged();
+    bool getSignalLayoutChanged();
+    bool getSignalModelAboutToBeReset();
+    bool getSignalModelReset();
+    
+private:
+	HgCacheProxyModel* mModel;
+	
+    QList< QPair< int, int > > mSignalDataChanged;
+    QList< QPair< int, int > > mSignalHeaderDataChanged;
+    QList< QPair< int, int > > mSignalRowsAboutToBeInserted;
+    QList< QPair< int, int > > mSignalRowsInserted;
+    QList< QPair< int, int > > mSignalColumnsAboutToBeInserted;
+    QList< QPair< int, int > > mSignalColumnsInserted;
+    QList< QPair< int, int > > mSignalRowsAboutToBeRemoved;
+    QList< QPair< int, int > > mSignalRowsRemoved;
+    QList< QPair< int, int > > mSignalColumnsAboutToBeRemoved;
+    QList< QPair< int, int > > mSignalColumnsRemoved;
+    bool mSignalLayoutAboutToBeChanged;
+    bool mSignalLayoutChanged;
+    bool mSignalModelAboutToBeReset;
+    bool mSignalModelReset;
+    
+};
+
+#endif // CACHEPROXYHELPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/dataproviderhelper.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,378 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 3 %
+*/
+#include "dataproviderhelper.h"
+#include <QtDebug>
+
+const int KRole1 = Qt::UserRole+1;
+const int KRole2 = Qt::UserRole+2;
+const int KRole3 = Qt::UserRole+3;
+
+DataProviderHelper::DataProviderHelper(int size, QObject *parent):
+HgDataProviderModel(parent)
+{
+    mDefaultIcon = QString("DefaultIcon");
+    
+    for ( int i(0);i<size;i++){
+        QList< QPair< QVariant, int > > list;
+        int a = i;
+        int b = -i;
+        int c = a/4 + b/10 + i%30 + i/2;
+        QString s = QString("ITEM%1 %2 %3").arg(c).arg(a).arg(b);
+        if (i%2){
+            s = s.toLower();
+        }
+        list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
+        list.append( QPair< QVariant, int >(QVariant(a), KRole1) );
+        list.append( QPair< QVariant, int >(QVariant(b), KRole2) );
+        list.append( QPair< QVariant, int >(QVariant(c), KRole3) );
+        newItem(&list, true);
+    }
+    
+    connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+            this, SLOT(slotDataUpdated(QModelIndex,QModelIndex)));
+    
+    connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+            this, SLOT(slotRowsAboutToBeInserted(QModelIndex,int,int)));
+
+    connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(slotRowsInserted(QModelIndex,int,int)));    
+    
+    connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+            this, SLOT(slotRowsAboutToBeRemoved(QModelIndex,int,int)));
+
+    connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+            this, SLOT(slotRowsRemoved(QModelIndex,int,int)));    
+    
+    connect(this, SIGNAL(modelAboutToBeReset()), 
+            this, SLOT(slotModelAboutToBeReset()));
+    
+    connect(this, SIGNAL(modelReset()), 
+            this, SLOT(slotModelReset()));
+}
+
+DataProviderHelper::~DataProviderHelper()
+{
+    
+}
+
+void DataProviderHelper::doReleaseData(QList<int> list, bool silent)
+{
+    Q_UNUSED(silent);    
+    mLastRelease = QList<int>(list);
+}
+
+void DataProviderHelper::doRequestData(QList<int> list, bool silent)
+{
+    Q_UNUSED(silent);
+    mLastRequest = QList<int>(list);
+    for ( int i=0; i<list.size(); i++){
+        updateIcon(list[i], QString("MyNiceIcon %1").arg(list[i]) );
+    }
+}
+
+QVariant DataProviderHelper::defaultIcon() const
+{
+    return mDefaultIcon;
+}
+
+void DataProviderHelper::testClearCache()
+{
+    clearCache();
+}
+
+void DataProviderHelper::testNewItem(QList< QPair< QVariant, int > >* list, bool silent)
+{
+    newItem(list, silent);
+}
+
+void DataProviderHelper::testNewItem(QPair< QVariant, int > item, bool silent)
+{
+    newItem(item, silent);
+}
+
+bool DataProviderHelper::testUpdate(int pos, QList< QPair< QVariant, int > >* list, bool silent)
+{
+    return update(pos, list, silent);
+}
+
+bool DataProviderHelper::testUpdate(int pos, QVariant obj, int role, bool silent )
+{
+    return update(pos, obj, role, silent);
+}
+
+void DataProviderHelper::testRemoveItems(int pos, int size)
+{
+    removeItems(pos, size);
+}
+
+void DataProviderHelper::testRemoveItem(int pos)
+{
+    removeItem(pos);
+}
+
+void DataProviderHelper::testInsertItem(int pos, QPair< QVariant, int > item, bool silent)
+{
+    insertItem(pos, item, silent);
+}
+
+void DataProviderHelper::doResetModel()
+{
+    clearCache();
+    for ( int i(0);i<1000;i++){
+        QList< QPair< QVariant, int > > list;
+        int a = i;
+        int b = -i;
+        int c = a/4 + b/10 + i%30 + i/2;
+        QString s = QString("NEW ITEM %1 %2 %3").arg(c).arg(a).arg(b);
+        if (i%2){
+            s = s.toLower();
+        }
+        list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
+        list.append( QPair< QVariant, int >(QVariant(a), KRole1) );
+        list.append( QPair< QVariant, int >(QVariant(b), KRole2) );
+        list.append( QPair< QVariant, int >(QVariant(c), KRole3) );
+        newItem(&list, true);
+    }
+}
+
+bool DataProviderHelper::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+    bool res = false;
+    if ( index.row()>=0 && index.row() < count() ){
+//        qWarning()<<index.row();
+        res = update(index.row(), value, role, false);
+    }
+    return res;
+}
+bool DataProviderHelper::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
+{
+    bool res = false;
+    if ( index.row()>=0 && index.row() < count() ){
+        QMapIterator<int, QVariant> i(roles);
+        while (i.hasNext()){
+            i.next();
+            res = update(index.row(), i.value(), i.key(), true) | res;
+        }
+    }
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getObserverDataUpdated()
+{
+    QList< QPair< int, int > > res = mObserverDataUpdated;
+    mObserverDataUpdated.clear();
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getSignalDataUpdated()
+{
+    QList< QPair< int, int > > res = mSignalDataUpdated;
+    mSignalDataUpdated.clear();
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getSignalRowsAboutToBeInserted()
+{
+    QList< QPair< int, int > > res = mSignalRowsAboutToBeInserted;
+    mSignalRowsAboutToBeInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getSignalRowsInserted()
+{
+    QList< QPair< int, int > > res = mSignalRowsInserted;
+    mSignalRowsInserted.clear();
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getSignalRowsAboutToBeRemoved()
+{
+    QList< QPair< int, int > > res = mSignalRowsAboutToBeRemoved;
+    mSignalRowsAboutToBeRemoved.clear();
+    return res;
+}
+
+QList< QPair< int, int > > DataProviderHelper::getSignalRowsRemoved()
+{
+    QList< QPair< int, int > > res = mSignalRowsRemoved;
+    mSignalRowsRemoved.clear();
+    return res;
+}
+
+bool DataProviderHelper::getSignalAboutToBeReset()
+{
+    bool res = mSignalAboutToBeReset;
+    mSignalAboutToBeReset = false;
+    return res;
+}
+
+bool DataProviderHelper::getSignalReset()
+{
+    bool res = mSignalReset;
+    mSignalReset = false;
+    return res;
+}
+
+QList<int> DataProviderHelper::getLastRelease()
+{
+    QList<int> res = mLastRelease;
+    mLastRelease.clear();
+    return res;
+}
+
+QList<int> DataProviderHelper::getLastRequest()
+{
+    QList<int> res = mLastRequest;
+    mLastRequest.clear();
+    return res;
+}
+
+void DataProviderHelper::testReleasePixmap(int idx)
+{
+    releasePixmap(idx);
+}
+
+QVariant DataProviderHelper::testCreateIcon(int index, QPixmap aPixmap)
+{
+    return createIcon(index, aPixmap);
+}
+
+void DataProviderHelper::testEmitDataChanged(QModelIndex from,QModelIndex to)
+{
+    emit dataChanged(from,to);
+}
+
+void DataProviderHelper::testEmitHeaderDataChanged(Qt::Orientation orientation, int first, int last)
+{
+    emit headerDataChanged(orientation, first, last);
+}
+
+void DataProviderHelper::testEmitRowsInsert(QModelIndex parent,int from,int to)
+{
+    beginInsertRows(parent, from, to);
+    endInsertRows();
+}
+
+
+void DataProviderHelper::testEmitColumnsInsert(QModelIndex parent,int from,int to)
+{
+    beginInsertColumns(parent, from, to);
+    endInsertColumns();
+}
+
+
+void DataProviderHelper::testEmitRowsRemove(QModelIndex parent,int from,int to)
+{
+    beginRemoveRows(parent, from, to);
+    endRemoveRows();
+}
+
+void DataProviderHelper::testEmitColumnsRemove(QModelIndex parent,int from,int to)
+{
+    beginRemoveColumns(parent, from, to);
+    endRemoveColumns();
+}
+
+void DataProviderHelper::testEmitLayoutAboutToBeChanged()
+{
+    emit layoutAboutToBeChanged();
+}
+
+void DataProviderHelper::testEmitLayoutChanged()
+{
+    emit layoutChanged();
+}
+
+void DataProviderHelper::testEmitModelAboutToBeReset()
+{
+    beginResetModel();
+}
+
+void DataProviderHelper::testEmitModelReset()
+{
+    endResetModel();
+}
+
+void DataProviderHelper::dataUpdated(int from, int to)
+{
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mObserverDataUpdated.append(p);
+}
+
+void DataProviderHelper::slotDataUpdated(QModelIndex from,QModelIndex to)
+{
+    QPair< int, int > p;
+    p.first = from.row();
+    p.second = to.row();    
+    mSignalDataUpdated.append(p);
+}
+
+void DataProviderHelper::slotRowsAboutToBeInserted(QModelIndex parent, int from, int to)
+{
+    Q_UNUSED(parent);
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalRowsAboutToBeInserted.append(p);
+}
+
+void DataProviderHelper::slotRowsInserted(QModelIndex parent, int from, int to)
+{
+    Q_UNUSED(parent);
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalRowsInserted.append(p);
+}
+
+void DataProviderHelper::slotRowsAboutToBeRemoved(QModelIndex parent, int from, int to)
+{
+    Q_UNUSED(parent);
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalRowsAboutToBeRemoved.append(p);
+}
+
+void DataProviderHelper::slotRowsRemoved(QModelIndex parent, int from, int to)
+{
+    Q_UNUSED(parent);    
+    Q_UNUSED(parent);
+    QPair< int, int > p;
+    p.first = from;
+    p.second = to;    
+    mSignalRowsRemoved.append(p);
+}
+
+void DataProviderHelper::slotModelAboutToBeReset()
+{
+    mSignalAboutToBeReset = true;
+}
+
+void DataProviderHelper::slotModelReset()
+{
+    mSignalReset = true;
+}
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/dataproviderhelper.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef DATAPROVIDERHELPER_H
+#define DATAPROVIDERHELPER_H
+
+#include <hgwidgets/hgdataprovidermodel.h>
+#include <QList>
+#include <QPair>
+
+class DataProviderHelper : public HgDataProviderModel, public HgDataProviderModelObserver
+{
+    Q_OBJECT
+
+public:
+    DataProviderHelper(int size =1200, QObject *parent = 0);
+    ~DataProviderHelper();
+
+//from HgDataProviderModel
+    virtual void doReleaseData(QList<int> list, bool silent);
+    virtual void doRequestData(QList<int> list, bool silent);  
+    virtual QVariant defaultIcon() const;
+    virtual void doResetModel();
+        
+//from QAbstractItemModel
+    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);    
+    virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
+    
+//for testing
+    void testClearCache();
+    void testNewItem(QList< QPair< QVariant, int > >* list, bool silent);
+    void testNewItem(QPair< QVariant, int > item, bool silent);
+    bool testUpdate(int pos, QList< QPair< QVariant, int > >* list, bool silent);
+    bool testUpdate(int pos, QVariant obj, int role, bool silent );
+    void testRemoveItems(int pos, int size = 1);
+    void testRemoveItem(int pos);
+    void testInsertItem(int pos, QPair< QVariant, int > item, bool silent);
+    
+    QList< QPair< int, int > > getObserverDataUpdated();
+    
+    QList< QPair< int, int > > getSignalDataUpdated();
+    QList< QPair< int, int > > getSignalRowsAboutToBeInserted();    
+    QList< QPair< int, int > > getSignalRowsInserted();
+    QList< QPair< int, int > > getSignalRowsAboutToBeRemoved();    
+    QList< QPair< int, int > > getSignalRowsRemoved();
+    bool getSignalAboutToBeReset();
+    bool getSignalReset();    
+    
+    QList<int> getLastRelease();
+    QList<int> getLastRequest();    
+    
+    void testReleasePixmap(int idx);
+    QVariant testCreateIcon(int index, QPixmap aPixmap);    
+    
+    void testEmitDataChanged(QModelIndex from,QModelIndex to);
+    void testEmitHeaderDataChanged(Qt::Orientation orientation, int first, int last);
+    void testEmitRowsInsert(QModelIndex parent,int from,int to);
+    void testEmitColumnsInsert(QModelIndex parent,int from,int to);
+    void testEmitRowsRemove(QModelIndex parent,int from,int to);
+    void testEmitColumnsRemove(QModelIndex parent,int from,int to);
+    void testEmitLayoutAboutToBeChanged();
+    void testEmitLayoutChanged();
+    void testEmitModelAboutToBeReset();
+    void testEmitModelReset();
+    
+//from HgDataProviderModelObserver
+public:
+    virtual void dataUpdated(int from, int to);
+
+private slots:
+    void slotDataUpdated(QModelIndex,QModelIndex);
+    void slotRowsAboutToBeInserted(QModelIndex,int,int);
+    void slotRowsInserted(QModelIndex,int,int);
+    void slotRowsAboutToBeRemoved(QModelIndex,int,int);
+    void slotRowsRemoved(QModelIndex,int,int);
+    void slotModelAboutToBeReset();
+    void slotModelReset();
+
+private:
+    QVariant mDefaultIcon;
+    QList< QPair< int, int > > mObserverDataUpdated;
+    
+    QList< QPair< int, int > > mSignalDataUpdated;
+    QList< QPair< int, int > > mSignalRowsAboutToBeInserted;    
+    QList< QPair< int, int > > mSignalRowsInserted;
+    QList< QPair< int, int > > mSignalRowsAboutToBeRemoved;    
+    QList< QPair< int, int > > mSignalRowsRemoved;
+    bool mSignalAboutToBeReset;
+    bool mSignalReset;    
+    QList<int> mLastRelease;
+    QList<int> mLastRequest;
+    
+};
+
+#endif // DATAPROVIDERHELPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/test_hgcacheproxydatamodel.cpp	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,1094 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 3 %
+*/
+#include <QtTest/QtTest>
+#include <hgwidgets/hgcacheproxymodel.h>
+#include "test_hgcacheproxydatamodel.h"
+
+#include "../../inc/hgbuffermanager.h"
+#include "bmhelper.h"
+
+#include "dataproviderhelper.h"
+#include "cacheproxyhelper.h"
+#include <QtDebug>
+
+// ======== MEMBER FUNCTIONS ========
+void TestCacheProxy::testQAbstractItemModel(QAbstractItemModel* model, int rows, int columns)
+{
+    QVERIFY(model != 0);
+    QModelIndex idx = model->index(0, 0);
+    if ( rows > 0 && columns > 0){
+        QVERIFY(idx.isValid() == true);
+        QVERIFY(idx.row() == 0);
+        QVERIFY(idx.column() == 0);
+        
+        idx = model->index(rows/2, 0);
+        QVERIFY(idx.row() == rows/2);
+        QVERIFY(idx.column() == 0);
+        
+        idx = model->index(0, columns/2);
+        QVERIFY(idx.row() == 0);
+        QVERIFY(idx.column() == columns/2);
+    
+        idx = model->index(-10, 0);
+        QVERIFY(idx.row() == -10);
+        QVERIFY(idx.column() == 0);
+    
+        idx = model->index(0, -10);
+        QVERIFY(idx.row() == 0);
+        QVERIFY(idx.column() == -10);
+        
+        idx = model->index(rows*2, 0);
+        QVERIFY(idx.row() == -1);
+        QVERIFY(idx.column() == 0);
+    
+        idx = model->index(0, columns*2);
+        QVERIFY(idx.row() == 0);
+        QVERIFY(idx.column() == -1);
+    }else{
+        QVERIFY(idx.row() == -1);
+        QVERIFY(idx.column() == -1);
+        
+        idx = model->index(-10, 0);
+        QVERIFY(idx.row() == -10);
+        QVERIFY(idx.column() == -1);
+
+        idx = model->index(0, -10);
+        QVERIFY(idx.row() == -1);
+        QVERIFY(idx.column() == -10);
+
+        idx = model->index(10, 0);
+        QVERIFY(idx.row() == -1);
+        QVERIFY(idx.column() == -1);
+        
+        idx = model->index(0, 10);
+        QVERIFY(idx.row() == -1);
+        QVERIFY(idx.column() == -1);
+    }
+    
+    idx = model->parent(idx);
+    QVERIFY(idx.isValid() == false);
+    QVERIFY(model->columnCount() == columns);
+    QVERIFY(model->rowCount() == rows);
+    
+//    QVERIFY(model->hasChildren() == false);
+//    QVERIFY(model->headerData(0, Qt::Horizontal).isValid == false);
+    
+}
+
+void TestCacheProxy::initTestCase()
+{
+    bm = 0;
+    bmh = 0;
+    dph = 0;
+    cp = 0;   
+    cph = 0;
+}
+    
+void TestCacheProxy::cleanupTestCase()
+{
+    delete bm;
+    delete bmh;
+    delete dph;   
+    delete cp;
+    delete cph;
+}
+
+void TestCacheProxy::init()
+{
+    delete bm;
+    delete bmh;
+    bm = 0;
+    bmh = 0;
+
+    delete dph;
+    dph = 0;
+    
+    delete cp;
+    cp = 0;
+    
+    delete cph;
+    cph = 0;
+}
+
+void TestCacheProxy::cleanup()
+{    
+    delete bm;
+    delete bmh;
+    bm = 0;
+    bmh = 0;
+    
+    delete dph;
+    dph = 0;
+
+    delete cp;
+    cp = 0;
+    
+    delete cph;
+    cph = 0;
+}
+
+//BufferManager
+void TestCacheProxy::testBM_SetPosition()
+{
+    int totalsize = 100;
+    int bufferSize = 100;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, 110, totalsize);
+    delete bmh;
+    delete bm;
+    
+    totalsize = 100;
+    bufferSize = 200;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, -20, totalsize);
+    delete bmh;
+    delete bm;
+
+    totalsize = 1000;
+    bufferSize = 100;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);
+    
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(5);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(23);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(50);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(111);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(120);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(130);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(271);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(507);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(800);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(880);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(899);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(910);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(950);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(996);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(1000);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(1200);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(950);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(501);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(160);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(150);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(140);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(100);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(37);
+    QVERIFY(bmh->isIntergal(bufferSize));
+   
+    bm->setPosition(1);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(-200);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(250);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(-100);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(891);
+    QVERIFY(bmh->isIntergal(bufferSize));
+}
+
+void TestCacheProxy::testBM_ResetBuffer()
+{
+    int totalsize = 1000;
+    int bufferSize = 100;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);
+
+    bm->resetBuffer(0, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(891);
+    bm->resetBuffer(0, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->resetBuffer(880, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(891);
+    bm->resetBuffer(880, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(999);
+    bm->resetBuffer(0, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(999);
+    bm->resetBuffer(995, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(10);
+    bm->resetBuffer(910, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->resetBuffer(10, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+}
+
+void TestCacheProxy::testBM_ItemCountChanged()
+{
+    int totalsize = 1000;
+    int bufferSize = 100;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);    
+    
+    totalsize--;
+    bmh->itemCountChanged(0, true, totalsize);
+    bm->itemCountChanged(0, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    totalsize--;
+    bmh->itemCountChanged(150, true, totalsize);
+    bm->itemCountChanged(150, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    totalsize--;
+    bm->setPosition(100);
+    bmh->itemCountChanged(150, true, totalsize);
+    bm->itemCountChanged(150, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    totalsize--;
+    bm->setPosition(891);
+    bmh->itemCountChanged(150, true, totalsize);
+    bm->itemCountChanged(150, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize--;
+    bm->setPosition(900);
+    bmh->itemCountChanged(890, true, totalsize);
+    bm->itemCountChanged(890, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize--;
+    bm->setPosition(totalsize);
+    bmh->itemCountChanged(totalsize, true, totalsize);
+    bm->itemCountChanged(totalsize, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize--;
+    bm->setPosition(totalsize+200);
+    bmh->itemCountChanged(totalsize+200, true, totalsize);
+    bm->itemCountChanged(totalsize+200, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    
+    totalsize= totalsize - 10;
+    bm->setPosition(0);
+    bmh->itemCountChanged(0, true, totalsize);
+    bm->itemCountChanged(0, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize= totalsize - 10;
+    bm->setPosition(totalsize);
+    bmh->itemCountChanged(totalsize, true, totalsize);
+    bm->itemCountChanged(totalsize, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize= totalsize - 10;
+    bm->setPosition(totalsize/2);
+    bmh->itemCountChanged(totalsize/2, true, totalsize);
+    bm->itemCountChanged(totalsize/2, true, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize++;
+    bm->setPosition(0);
+    bmh->itemCountChanged(0, false, totalsize);
+    bm->itemCountChanged(0, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize++;    
+    bmh->itemCountChanged(50, false, totalsize);
+    bm->itemCountChanged(50, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize++;    
+    bm->setPosition(100);
+    bmh->itemCountChanged(80, false, totalsize);
+    bm->itemCountChanged(80, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize++;    
+    bm->setPosition(500);
+    bmh->itemCountChanged(480, false, totalsize);
+    bm->itemCountChanged(480, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize++;    
+    bm->setPosition(totalsize-20);
+    bmh->itemCountChanged(totalsize, false, totalsize);
+    bm->itemCountChanged(totalsize, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize=totalsize+10;
+    bm->setPosition(totalsize-20);
+    bmh->itemCountChanged(totalsize, false, totalsize);
+    bm->itemCountChanged(totalsize, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    totalsize=totalsize+10;
+    bm->setPosition(20);
+    bmh->itemCountChanged(totalsize, false, totalsize);
+    bm->itemCountChanged(totalsize, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    totalsize=totalsize+10;
+    bm->setPosition(totalsize/2-20);
+    bmh->itemCountChanged(totalsize, false, totalsize);
+    bm->itemCountChanged(totalsize, false, totalsize);
+    QVERIFY(bmh->isIntergal(bufferSize));   
+}
+
+void TestCacheProxy::testBM_ResizeCache()
+{
+    int totalsize = 1000;
+    int bufferSize = 100;
+    bmh = new BMHelper(totalsize);
+    bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);
+    
+    bm->resizeCache(100, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 50;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 150;
+    bm->resizeCache(bufferSize, 50);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(30);
+    bm->resizeCache(bufferSize, 30);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 50;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 150;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+
+    bm->setPosition(500);
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 50;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 151;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(totalsize-20);
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 53;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 150;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bm->setPosition(totalsize);
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 50;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+    
+    bufferSize = 175;
+    bm->resizeCache(bufferSize, 40);
+    QVERIFY(bmh->isIntergal(bufferSize));
+}
+
+//DataProvider
+void TestCacheProxy::testDP_QAbstractItemModel()
+{
+    dph = new DataProviderHelper();
+    delete dph;
+    dph = new DataProviderHelper(200);
+    testQAbstractItemModel(dph, 200, 1);
+}
+
+void TestCacheProxy::testDP_RequestReleaseAndData()
+{
+    dph = new DataProviderHelper();
+    QModelIndex idx = dph->index(0,0);
+    QVariant res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == true);
+    QString s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+
+    res = dph->data(idx, Qt::UserRole+1); //int value (not less then 0)
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res.toInt() >= 0);
+    
+    res = dph->data(idx, Qt::UserRole+100); //should be empty
+    QVERIFY(res.isValid() == false);
+
+    res = dph->data(idx, Qt::DecorationRole); //should give defaultIcon();
+    QVERIFY(res.isValid() == true);
+    s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+    QVERIFY(res == dph->defaultIcon());
+
+    idx = dph->index(-10, 0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == false);
+
+    idx = dph->index(1000000, 0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == false);
+
+    QList<int> list;
+    list<<-1;
+    list<<0;
+    list<<1;
+    list<<2;
+    list<<1000000;
+    dph->registerObserver(dph);
+    dph->request(list);
+    QList< QPair< int, int > > updates = dph->getObserverDataUpdated();
+    QVERIFY(updates.count() == 3); //3 updates - for 0 1 and 2
+    QVERIFY(updates[0].first == 0); //for 0
+    QVERIFY(updates[0].second == 0); //for 0
+    QVERIFY(updates[1].first == 1); //for 1
+    QVERIFY(updates[1].second == 1); //for 1
+    QVERIFY(updates[2].first == 2); //for 2
+    QVERIFY(updates[2].second == 2); //for 2
+    
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res.isValid() == true);
+    s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+    s = QString("MyNiceIcon %1").arg(0);
+    QVERIFY(res.toString() == s);
+
+    idx = dph->index(1,0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res.isValid() == true);
+    s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+    s = QString("MyNiceIcon 1");
+    QVERIFY(res.toString() == s);
+    
+    idx = dph->index(2,0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res.isValid() == true);
+    s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+    s = QString("MyNiceIcon 2");
+    QVERIFY(res.toString() == s);
+    
+    idx = dph->index(3,0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res.isValid() == true);
+    s = res.toString(); 
+    QVERIFY(s.isNull() == false);
+    s = QString("MyNiceIcon 3");
+    QVERIFY(res.toString() != s);
+    QVERIFY(res == dph->defaultIcon());    
+    
+    dph->release(list, false);
+    updates = dph->getObserverDataUpdated();
+    QVERIFY(updates.count() == 0); //0 updates - updates from emit not observer
+    updates = dph->getSignalDataUpdated();
+    QVERIFY(updates.count() == 1); //1 update for all items
+    QVERIFY(updates[0].first == 0); //for 0
+    QVERIFY(updates[0].second == 2); //for 0
+    
+    idx = dph->index(0, 0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res == dph->defaultIcon());    
+
+    idx = dph->index(1, 0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res == dph->defaultIcon());    
+
+    idx = dph->index(2, 0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res == dph->defaultIcon());    
+    
+    idx = dph->index(3, 0);
+    res = dph->data(idx, Qt::DecorationRole);
+    QVERIFY(res == dph->defaultIcon());    
+    dph->registerObserver(NULL);
+    dph->request(list);
+    updates = dph->getObserverDataUpdated();
+    QVERIFY(updates.count() == 0); //0 updates - no observer
+    dph->getSignalDataUpdated();
+    dph->release(list, false);
+    updates = dph->getObserverDataUpdated();
+    QVERIFY(updates.count() == 0); //0 updates - no observer
+}
+
+void TestCacheProxy::testDP_CacheManagment()
+{
+    dph = new DataProviderHelper(100);
+    //signals status reset
+    dph->getObserverDataUpdated();
+    dph->getSignalDataUpdated();
+    dph->getSignalRowsAboutToBeInserted();    
+    dph->getSignalRowsInserted();
+    dph->getSignalRowsAboutToBeRemoved();    
+    dph->getSignalRowsRemoved();
+    dph->getSignalAboutToBeReset();
+    dph->getSignalReset();
+    
+    int size = dph->rowCount();
+    QModelIndex idx;
+    QVariant res;
+    for ( int i=0; i<size; i++){
+        idx = dph->index(i,0);
+        res = dph->data(idx, Qt::UserRole+1);
+        QVERIFY(res.isValid() == true);
+        QVERIFY(res.toInt() == i);   
+    }
+    idx = dph->index(0,0);
+    dph->testClearCache();    
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == false);
+    
+    QList< QPair< QVariant, int > > list;
+    QString s = "NEWITEM";
+    list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
+    
+    dph->testUpdate(0, &list, false); //update shouldn't change - no item
+    dph->testUpdate(-1, &list, true); //update shouldn't change - no item
+    dph->testUpdate(120000, &list, false); //update shouldn't change - no item
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == false);
+    QVERIFY(dph->getObserverDataUpdated().count() == 0);
+
+    dph->testNewItem(&list, false);
+    QList< QPair< int, int > > resList = dph->getSignalRowsAboutToBeInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0); //for item 0
+    QVERIFY(resList[0].second == 0); //for item 0
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0); //for item 0
+    QVERIFY(resList[0].second == 0); //for item 0
+    
+    QVERIFY(dph->rowCount() == 1);
+    
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res == s);
+    dph->testNewItem(&list, true);
+    QVERIFY(dph->getSignalRowsAboutToBeInserted().count() == 0);//no updates it was suuposed to be silent
+    QVERIFY(dph->getSignalRowsInserted().count() == 0);//no updates it was suuposed to be silent    
+    QVERIFY(dph->rowCount() == 2);
+
+    dph->testNewItem(&list, false);
+    dph->testNewItem(&list, false);
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 2);
+    QVERIFY(resList[0].first == 2); //for item 2
+    QVERIFY(resList[0].second == 2); //for item 2
+    QVERIFY(resList[1].first == 3); //for item 3
+    QVERIFY(resList[1].second == 3); //for item 3
+
+    list.clear();
+    QString s2 = "NEWITEM2";
+    list.append( QPair< QVariant, int >(s2, Qt::DisplayRole) );
+    dph->testUpdate(0, &list, false);
+    resList = dph->getSignalDataUpdated();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res == s2);
+    
+    dph->testRemoveItems(0, 1);//should remove item
+    resList = dph->getSignalRowsAboutToBeRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    resList = dph->getSignalRowsRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    
+    QVERIFY(dph->rowCount() == 3);
+    dph->testRemoveItems(-2, 10);//should remove remaining items (0,1, 2)
+    resList = dph->getSignalRowsAboutToBeRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 2);
+
+    QVERIFY(dph->rowCount() == 0);
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::DisplayRole); //invalid variant, for not existing item
+    QVERIFY(res.isValid() == false);
+    
+    QVERIFY(dph->getSignalAboutToBeReset() == false);
+    QVERIFY(dph->getSignalReset() == false);    
+    dph->resetModel();
+    QVERIFY(dph->getSignalAboutToBeReset() == true);
+    QVERIFY(dph->getSignalReset() == true);
+    QVERIFY(dph->columnCount() == 1);
+    QVERIFY(dph->rowCount() == 1000);
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res.toString().startsWith(QString("NEW ITEM")) == true);    
+    
+    dph->testRemoveItems(0, 100);//should remove items 0 - 99
+    QVERIFY(dph->rowCount() == 900);
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::UserRole+1);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res.toInt() == 100);
+    
+    dph->testUpdate(0, QString(""), Qt::DisplayRole, false);
+    idx = dph->index(0,0);
+    res = dph->data(idx, Qt::DisplayRole);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res.toString() == QString(""));    
+
+    resList = dph->getSignalDataUpdated();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    
+    dph->testNewItem( QPair< QVariant, int >(QString(""), Qt::DisplayRole), false);
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == dph->rowCount()-1);
+    QVERIFY(resList[0].second == dph->rowCount()-1);
+    
+    dph->getSignalRowsInserted();
+    dph->getSignalRowsRemoved();
+    dph->testInsertItem(100, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false);
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 100);
+    QVERIFY(resList[0].second == 100);
+    dph->testRemoveItem(100);
+    resList = dph->getSignalRowsRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 100);
+    QVERIFY(resList[0].second == 100); 
+    
+    dph->getSignalRowsInserted();
+    dph->getSignalRowsRemoved();
+    dph->testInsertItem(-10, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with -10 puts it at begining
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    dph->testRemoveItem(-10);
+    resList = dph->getSignalRowsRemoved();
+    QVERIFY(resList.count() == 0);
+
+    dph->getSignalRowsInserted();
+    dph->getSignalRowsRemoved();
+    dph->testInsertItem(100000, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with beyond range puts it at end
+    resList = dph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == dph->rowCount()-1);
+    QVERIFY(resList[0].second == dph->rowCount()-1);    
+    dph->testRemoveItem(100000);
+    resList = dph->getSignalRowsRemoved();
+    QVERIFY(resList.count() == 0);
+    
+    idx = dph->index(579,0);
+    QMap<int, QVariant> it = dph->itemData(idx);
+    QCOMPARE(it.size(), 4);
+    QCOMPARE(it.contains(Qt::DisplayRole), true);
+    QVariant r2 = it[Qt::DisplayRole];
+    QCOMPARE(r2.isValid(), true);
+    res = dph->data(idx, Qt::DisplayRole);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toString(), r2.toString());
+    
+}
+
+void TestCacheProxy::testDP_QPixmapPool()
+{
+    dph = new DataProviderHelper(100);
+    QPixmap pix;
+    QVariant res = dph->testCreateIcon(0, pix);
+    QVERIFY(res.isValid() == false);
+
+    dph->resizeQPixmapPool(10);
+    
+    res = dph->testCreateIcon(0, pix);
+    QVERIFY(res.isValid() == true);
+    QVERIFY(res != dph->defaultIcon());
+    
+    QVariant res2 = dph->testCreateIcon(0, pix);
+    QVERIFY(res2.isValid() == true);
+    QVERIFY(res != dph->defaultIcon());   
+
+    dph->testCreateIcon(0, pix);
+    dph->testCreateIcon(1, pix);
+    dph->testCreateIcon(2, pix);    
+    dph->testCreateIcon(3, pix);
+    dph->testCreateIcon(4, pix);
+    
+    dph->testReleasePixmap(-10);
+    dph->testReleasePixmap(4);
+    dph->testReleasePixmap(5);
+    dph->testReleasePixmap(200);
+    dph->resizeQPixmapPool(20);
+    dph->resizeQPixmapPool(5);
+    dph->testReleasePixmap(100);
+    dph->resizeQPixmapPool(100);
+    dph->resizeQPixmapPool(2);
+    dph->testReleasePixmap(1);
+    dph->testReleasePixmap(2);
+    dph->testReleasePixmap(3);
+    dph->testReleasePixmap(4);
+    dph->testCreateIcon(1, pix);
+    dph->testCreateIcon(2, pix);
+    dph->testCreateIcon(3, pix);
+    dph->testCreateIcon(4, pix);
+    dph->testCreateIcon(6, pix);
+    dph->resizeQPixmapPool(1);
+    res = dph->testCreateIcon(10, pix);
+    QVERIFY(res.isValid() == false);    
+}
+
+void TestCacheProxy::testCP_QAbstractItemModel()
+{
+    cp = new HgCacheProxyModel();
+    dph = new DataProviderHelper(200);
+    testQAbstractItemModel(cp, 0, 0);
+
+    cp->setDataProvider(dph);
+    QVERIFY(cp->DataProvider() == dph);
+    testQAbstractItemModel(cp, 200, 1);
+    cp->setDataProvider(0);
+    QVERIFY(cp->DataProvider() == 0);
+}
+
+void TestCacheProxy::testCP_SignalsForward()
+{
+    cp = new HgCacheProxyModel();
+    cph = new CacheProxyHelper(cp);
+    dph = new DataProviderHelper(200);    
+    cp->setDataProvider(dph, 50, 20);
+    
+    QList< QPair< int, int > > resList = cph->getSignalDataChanged();
+    QVERIFY(resList.count() == 50);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    QVERIFY(resList[49].first == 49);
+    QVERIFY(resList[49].second == 49);
+    
+    QList< QPair< QVariant, int > > list;
+    QString s = "NEWITEM";
+    list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
+
+    dph->testNewItem(&list, false);
+    resList = cph->getSignalRowsAboutToBeInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == dph->rowCount()-1);
+    QVERIFY(resList[0].second == dph->rowCount()-1);
+    resList = cph->getSignalRowsInserted();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == dph->rowCount()-1);
+    QVERIFY(resList[0].second == dph->rowCount()-1);
+    
+    dph->testRemoveItems(0, 1);//should remove item
+    resList = cph->getSignalRowsAboutToBeRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    resList = cph->getSignalRowsRemoved();
+    QVERIFY(resList.count() == 1);
+    QVERIFY(resList[0].first == 0);
+    QVERIFY(resList[0].second == 0);
+    
+    cph->getSignalModelAboutToBeReset();
+    cph->getSignalModelReset();
+    dph->resetModel();
+    QVERIFY(cph->getSignalModelAboutToBeReset() == true);
+    QVERIFY(cph->getSignalModelReset() == true);
+    QVERIFY(cp->columnCount() == 1);
+    QVERIFY(cp->rowCount() == 1000);
+
+}
+
+void TestCacheProxy::testCP_ResizeCache()
+{
+    cp = new HgCacheProxyModel();
+    cph = new CacheProxyHelper(cp);
+    dph = new DataProviderHelper(200);
+    cp->setDataProvider(dph, 50, 20);
+    dph->getLastRelease();
+    dph->getLastRequest();
+    cp->resizeCache(20, 5);
+    
+    QList<int> l = dph->getLastRelease();
+    QVERIFY(l.count() > 0);
+    l = dph->getLastRequest();
+    QVERIFY(l.count() == 0);
+    
+    dph->getLastRelease();
+    dph->getLastRequest();
+    cp->resizeCache(100, 5);
+    dph->getLastRelease();
+    QVERIFY(l.count() == 0);
+    l = dph->getLastRequest();
+    QVERIFY(l.count() > 0);
+}
+
+void TestCacheProxy::testCP_Data()
+{
+    cp = new HgCacheProxyModel();
+    cph = new CacheProxyHelper(cp);
+    dph = new DataProviderHelper(200);
+    cp->setDataProvider(dph, 50, 20);
+    dph->getLastRelease();
+    dph->getLastRequest();
+    
+    QModelIndex idx = cp->index(0, 0);
+    QVariant res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 0);
+    
+    idx = cp->index(100, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 100);
+    
+    idx = cp->index(101, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 101);
+
+    idx = cp->index(50, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 50);
+    
+    idx = cp->index(40, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 40);
+    
+    idx = cp->index(35, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 35);
+    
+    idx = cp->index(25, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), 25);
+    
+    int v = 234234;
+    res = QVariant(v);
+    idx = cp->index(0, 0);
+    cp->setData(idx, res, Qt::UserRole+1);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), v);
+    
+    QMap<int, QVariant> map = cp->itemData(idx);
+    QCOMPARE(map.size(), 5);
+    map[v]=v;
+    cp->setItemData(idx, map);
+    res = cp->data(idx, v);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), v);
+
+    
+}
+
+void TestCacheProxy::testCP_Sort()
+{
+    cp = new HgCacheProxyModel();
+    cph = new CacheProxyHelper(cp);
+    dph = new DataProviderHelper(200);
+    cp->setDataProvider(dph, 50, 20);
+
+    cp->setSortRole(Qt::UserRole+2);
+    QCOMPARE(cp->sortRole(), Qt::UserRole+2);
+    cp->sort(0, Qt::AscendingOrder);
+    QCOMPARE(cp->sortColumn(), 0);
+    QCOMPARE(cp->sortOrder(), Qt::AscendingOrder);
+    
+    QModelIndex idx = cp->index(10, 0);
+    QVariant res = cp->data(idx, Qt::UserRole+2);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), -(cp->rowCount(idx) -1 -10));
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), cp->rowCount(idx) -1 -10);
+    
+    idx = cp->index(50, 0);
+    res = cp->data(idx, Qt::UserRole+2);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), -(cp->rowCount(idx) -1 -50));
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt(), cp->rowCount(idx) -1 -50);
+    
+    cp->setSortRole(Qt::DisplayRole);
+    cp->setSortCaseSensitivity(Qt::CaseSensitive);
+    QCOMPARE(cp->sortCaseSensitivity(), Qt::CaseSensitive);
+    cp->sort(0, Qt::AscendingOrder);
+    
+    idx = cp->index(10, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+    QCOMPARE(res.toInt()%2, 0);
+    
+    idx = cp->index(110, 0);
+    res = cp->data(idx, Qt::UserRole+1);
+    QCOMPARE(res.isValid(), true);
+//    qWarning("i=%d",res.toInt());
+    QCOMPARE(res.toInt()%2, 1);
+    
+    cp->setSortLocaleAware(true);
+    QCOMPARE(cp->isSortLocaleAware(), true);
+    cp->setSortLocaleAware(false);
+    QCOMPARE(cp->isSortLocaleAware(), false);
+        
+    QString s = QString("AAA");
+    cp->setDynamicSortFilter(true);
+    QCOMPARE(cp->dynamicSortFilter(), true);
+    cp->setSortRole(Qt::DisplayRole);
+    cp->setSortCaseSensitivity(Qt::CaseSensitive);
+    dph->testInsertItem(10, QPair< QVariant, int >(s, Qt::DisplayRole), false);
+    idx = cp->index(0, 0);
+    res = cp->data(idx, Qt::DisplayRole);
+    QCOMPARE(res.isValid(), true);
+//    qWarning()<<res.toString();
+    QCOMPARE(res.toString(), s);
+    
+}
+
+//void TestCacheProxy::testCP_Filter()
+//{
+//    cp = new HgCacheProxyModel();
+//    cph = new CacheProxyHelper(cp);
+//    dph = new DataProviderHelper(200);
+//    cp->setDataProvider(dph, 50, 20);
+//
+//    QModelIndex idx = cp->index(1, 0);
+//    QVariant res = cp->data(idx, Qt::DisplayRole);
+//    QCOMPARE(res.isValid(), true);
+//    QCOMPARE(res.toString().startsWith("item"), true);
+//    
+//    QRegExp regexp = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
+//    
+//    cp->setFilterRegExp(regexp);
+//    QVERIFY(cp->filterRegExp() == regexp);
+//    cp->setFilterCaseSensitivity(Qt::CaseSensitive);
+//    QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseSensitive);   
+//    
+//    idx = cp->index(1, 0);
+//    res = cp->data(idx, Qt::DisplayRole);
+//    QCOMPARE(res.isValid(), true);
+//    QCOMPARE(res.toString().startsWith("item"), false);
+//    
+//    cp->setFilterKeyColumn(1);
+//    QCOMPARE(cp->filterKeyColumn (), 1);
+//    cp->setFilterKeyColumn(0);
+//    
+//    cp->setFilterRole(Qt::UserRole+1);
+//    QCOMPARE(cp->filterRole(), Qt::UserRole+1);
+//    cp->setFilterRole(Qt::DisplayRole);     
+//    
+//    regexp = QRegExp("ITEM*", Qt::CaseInsensitive, QRegExp::Wildcard);
+//    cp->setFilterRegExp(regexp);
+//    QVERIFY(cp->filterRegExp() == regexp);
+//    cp->setFilterCaseSensitivity(Qt::CaseInsensitive);
+//    QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseInsensitive);   
+//
+//    idx = cp->index(1, 0);
+//    res = cp->data(idx, Qt::DisplayRole);
+//    QCOMPARE(res.isValid(), true);
+//    QCOMPARE(res.toString().startsWith("item"), true);
+//
+//}
+
+
+#ifdef _CACHEPROXYDATAMODEL_UNITTEST_LOG_TO_C
+    int main (int argc, char* argv[]) 
+    {
+        QApplication app(argc, argv);
+        TestCacheProxy tc;
+        int c = 3;
+        char* v[] = {argv[0], "-o", "c:/test.txt"};
+        return QTest::qExec(&tc, c, v);
+    }
+#else
+    QTEST_MAIN(TestCacheProxy)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/test_hgcacheproxydatamodel.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 3 %
+*/
+#ifndef TestCacheProxy_H
+#define TestCacheProxy_H
+
+#include <QObject>
+
+class QAbstractItemModel;
+
+class BMHelper;
+class HgBufferManager;
+class DataProviderHelper;
+class HgCacheProxyModel;
+class CacheProxyHelper;
+
+class TestCacheProxy: public QObject
+{
+    Q_OBJECT
+
+public:
+    TestCacheProxy(): QObject() {};
+    
+private:
+    void testQAbstractItemModel(QAbstractItemModel* model, int rows, int columns);
+    
+private slots:
+    void initTestCase();//before first
+    void init();//before each
+    void cleanup();//after each
+    void cleanupTestCase(); //after last
+    
+    //HgBufferManager
+    void testBM_SetPosition();
+    void testBM_ResetBuffer();
+    void testBM_ItemCountChanged();
+    void testBM_ResizeCache();
+    
+    //HgDataProviderModel
+    void testDP_QAbstractItemModel();
+    void testDP_RequestReleaseAndData();
+    void testDP_CacheManagment();
+    void testDP_QPixmapPool();
+    
+    //HgCacheProxyModel
+    void testCP_QAbstractItemModel();
+    void testCP_SignalsForward();
+    void testCP_ResizeCache();
+    void testCP_Data();
+    void testCP_Sort();
+//    void testCP_Filter();
+    
+private:
+    BMHelper* bmh;
+    HgBufferManager* bm;
+    DataProviderHelper* dph;
+    HgCacheProxyModel* cp;
+    CacheProxyHelper* cph;
+    
+};
+#endif // TestCacheProxy_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/unittest_hgcacheproxymodel.pro	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,47 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description:
+
+TEMPLATE = app
+TARGET = unittest_hgcacheproxymodel
+
+#fix that later
+#CONFIG += symbian_test
+
+INCLUDEPATH += . \
+    $$APP_LAYER_SYSTEMINCLUDE \
+    $$MW_LAYER_SYSTEMINCLUDE \
+	../../inc
+
+TARGET.CAPABILITY = ALL -TCB
+
+DEFINES += _CACHEPROXYDATAMODEL_UNITTEST_LOG_TO_C
+
+# Input
+LIBS +=     -lhgcacheproxymodel \
+            -lthumbnailmanagerqt
+
+SOURCES += test_hgcacheproxydatamodel.cpp \
+			bmhelper.cpp \
+			../../src/hgbuffermanager.cpp \
+			dataproviderhelper.cpp \
+			cacheproxyhelper.cpp \
+#			simpledataprovider.cpp\
+
+HEADERS += test_hgcacheproxydatamodel.h \
+			bmhelper.h \
+			../../inc/hgbuffermanager.h \
+			dataproviderhelper.h \
+			cacheproxyhelper.h \
+#			simpledataprovider.h\
+
+CONFIG += qtestlib console
+
+#RESOURCES += unittest_hgcacheproxymodel.qrc
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgcacheproxymodel/tsrc/unit/unittest_hgcacheproxymodel.qrc	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/icons" >
+        <file>cacheproxydatamodel_tsrc.png</file>
+    </qresource>
+</RCC>
--- a/hgwidgets.pro	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets.pro	Mon May 03 13:32:54 2010 +0300
@@ -23,3 +23,4 @@
 
 SUBDIRS += hgwidgets_plat/hgwidgets_plat.pro
 SUBDIRS += ganeswidgets/ganeswidgets.pro
+SUBDIRS += hgcacheproxymodel/hgcacheproxymodel.pro
--- a/hgwidgets_plat/ganeswidgets_api/ganeswidgets_api.pri	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets_plat/ganeswidgets_api/ganeswidgets_api.pri	Mon May 03 13:32:54 2010 +0300
@@ -1,18 +1,13 @@
-#
 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of "Eclipse Public License v1.0"
 # which accompanies this distribution, and is available
 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
 # Initial Contributors:
 # Nokia Corporation - initial contribution.
-#
 # Contributors:
-#
 # Description:
-#
 
 PUBLIC_HEADERS += ganeswidgets_api/inc/hgwidgets.h \
     ganeswidgets_api/inc/hggrid.h \
--- a/hgwidgets_plat/ganeswidgets_api/inc/hggrid.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets_plat/ganeswidgets_api/inc/hggrid.h	Mon May 03 13:32:54 2010 +0300
@@ -27,11 +27,14 @@
     Q_OBJECT
 public:
 
-    HgGrid(Qt::Orientation scrollDirection, QGraphicsItem *parent = 0 );
+    explicit HgGrid(Qt::Orientation scrollDirection, QGraphicsItem *parent = 0 );
     virtual ~HgGrid();
 
+protected:
+    HgGrid(Qt::Orientation scrollDirection, HgGridPrivate &dd, QGraphicsItem *parent);
+
 private:
-    Q_DECLARE_PRIVATE_D(d_ptr, HgGrid)
+    Q_DECLARE_PRIVATE_D(p_ptr, HgGrid)
     Q_DISABLE_COPY(HgGrid)
 };
 
--- a/hgwidgets_plat/ganeswidgets_api/inc/hgmediawall.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets_plat/ganeswidgets_api/inc/hgmediawall.h	Mon May 03 13:32:54 2010 +0300
@@ -29,11 +29,13 @@
     Q_PROPERTY(LabelPosition descriptionPosition READ descriptionPosition WRITE setDescriptionPosition)
     Q_PROPERTY(HbFontSpec titleFontSpec READ titleFontSpec WRITE setTitleFontSpec)
     Q_PROPERTY(HbFontSpec descriptionFontSpec READ descriptionFontSpec WRITE setDescriptionFontSpec)
+    Q_PROPERTY(QPointF frontItemPositionDelta READ frontItemPositionDelta WRITE setFrontItemPositionDelta)
+    Q_PROPERTY(bool reflectionsEnabled READ reflectionsEnabled WRITE enableReflections)
     Q_ENUMS(LabelPosition)
 
 public:
 
-    HgMediawall(QGraphicsItem *parent = 0 );
+    explicit HgMediawall(QGraphicsItem *parent = 0 );
     virtual ~HgMediawall();
 
     enum LabelPosition {
@@ -51,8 +53,17 @@
     void setDescriptionFontSpec(const HbFontSpec &fontSpec);
     HbFontSpec descriptionFontSpec() const;
 
+    void setFrontItemPositionDelta(const QPointF& position);
+    QPointF frontItemPositionDelta() const;
+
+    void enableReflections(bool enabled);
+    bool reflectionsEnabled() const;
+        
+protected:
+    HgMediawall(HgMediawallPrivate &dd, QGraphicsItem *parent);
+
 private:
-    Q_DECLARE_PRIVATE_D(d_ptr, HgMediawall)
+    Q_DECLARE_PRIVATE_D(p_ptr, HgMediawall)
     Q_DISABLE_COPY(HgMediawall)
 };
 
--- a/hgwidgets_plat/ganeswidgets_api/inc/hgwidgets.h	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets_plat/ganeswidgets_api/inc/hgwidgets.h	Mon May 03 13:32:54 2010 +0300
@@ -41,10 +41,14 @@
     Q_PROPERTY(ScrollBarPolicy scrollBarPolicy READ scrollBarPolicy WRITE setScrollBarPolicy)
     Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
     Q_PROPERTY(IndexFeedbackPolicy IndexFeedbackPolicy READ indexFeedbackPolicy WRITE setIndexFeedbackPolicy)
+    Q_PROPERTY(ItemSizePolicy ItemSizePolicy READ itemSizePolicy WRITE setItemSizePolicy)
+    Q_PROPERTY(QSizeF itemSize READ itemSize WRITE setItemSize)
+    Q_PROPERTY(QSizeF itemSpacing READ itemSpacing WRITE setItemSpacing)
     Q_ENUMS(ScrollBarPolicy)
     Q_ENUMS(HgWidgetType)
     Q_ENUMS(SelectionMode)
     Q_ENUMS(IndexFeedbackPolicy)
+    Q_ENUMS(ItemSizePolicy)
 public:
 
     enum HgDataRole
@@ -59,14 +63,20 @@
         IndexFeedbackString
     };    
     
-    virtual ~HgWidget ();
-
     enum ScrollBarPolicy {
         ScrollBarAsNeeded = Qt::ScrollBarAsNeeded,
         ScrollBarAlwaysOff = Qt::ScrollBarAlwaysOff,
         ScrollBarAlwaysOn = Qt::ScrollBarAlwaysOn,
         ScrollBarAutoHide
     };
+    
+    enum ItemSizePolicy {
+        ItemSizeAutomatic,
+        ItemSizeUserDefined
+    };
+
+    explicit HgWidget (QGraphicsItem *parent = 0);
+    virtual ~HgWidget ();
 
     virtual void setModel(QAbstractItemModel *model);
     QAbstractItemModel *model() const;
@@ -108,6 +118,17 @@
     void setIndexFeedbackPolicy( IndexFeedbackPolicy policy);
     IndexFeedbackPolicy indexFeedbackPolicy() const;
     
+    void setDefaultImage(QImage defaultImage);
+
+    void setItemSizePolicy(ItemSizePolicy policy);
+    ItemSizePolicy itemSizePolicy() const;
+    
+    void setItemSize(const QSizeF& size);
+    QSizeF itemSize() const;
+    
+    void setItemSpacing(const QSizeF& spacing);
+    QSizeF itemSpacing() const;
+    
 signals:
     void activated(const QModelIndex &index);
     void longPressed(const QModelIndex &index, const QPointF &coords);
@@ -123,15 +144,15 @@
     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
 protected:
+    HgWidgetPrivate * const p_ptr;
+    HgWidget(HgWidgetPrivate &dd, QGraphicsItem *parent);
 
     bool eventFilter(QObject *obj,QEvent *event);
 
     bool event(QEvent *event);
-
-    HgWidget(HbWidgetPrivate* widgetPrivate, QGraphicsItem *parent = 0);
     
 private:
-    Q_DECLARE_PRIVATE_D(d_ptr, HgWidget)
+    Q_DECLARE_PRIVATE_D(p_ptr, HgWidget)
     Q_DISABLE_COPY(HgWidget)
     Q_PRIVATE_SLOT(d_func(), void _q_scrollPositionChanged(qreal index, bool scrollBarAnimation))
     Q_PRIVATE_SLOT(d_func(), void _q_releaseItems(int releaseStart, int releaseEnd))
@@ -142,6 +163,7 @@
     Q_PRIVATE_SLOT(d_func(), void _q_removeRows(const QModelIndex &parent, int start, int end))
     Q_PRIVATE_SLOT(d_func(), void _q_moveRows(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow))
     Q_PRIVATE_SLOT(d_func(), void _q_groovePressed(qreal, Qt::Orientation))
+    Q_PRIVATE_SLOT(d_func(), void _q_modelReset())
 };
 
 #endif  //HGWIDGET_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgwidgets_plat/hgcacheproxymodel_api/hgcacheproxymodel_api.pri	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,14 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description:
+
+PUBLIC_HEADERS += hgcacheproxymodel_api/inc/hgcacheproxymodel.h \
+    hgcacheproxymodel_api/inc/hgdataprovidermodel.h
+									
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgwidgets_plat/hgcacheproxymodel_api/inc/hgcacheproxymodel.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 2 %
+*/
+
+#ifndef HGCACHEPROXYMODEL_H_
+#define HGCACHEPROXYMODEL_H_
+
+#include <QAbstractItemModel>
+#include <QSortFilterProxyModel>
+
+#include <hgwidgets/hgdataprovidermodel.h>
+
+#ifdef BUILD_CACHEPROXYMODEL
+#define CACHEPROXYMODEL_EXPORT Q_DECL_EXPORT
+#else
+#define CACHEPROXYMODEL_EXPORT Q_DECL_IMPORT
+#endif
+
+class HgBufferManager;
+
+const int KDefaultCacheSize = 120;
+const int KDefaultCacheTreshold = 30;
+
+class HgBufferManagerObserver
+{
+public:
+    enum HgRequestOrder {
+        HgRequestOrderAscending,
+        HgRequestOrderDescending
+    };   
+
+    virtual void release(int start, int end) = 0;
+    virtual void request(int start, int end, HgRequestOrder order = HgRequestOrderAscending) = 0;  
+};
+
+class HgCacheProxyModel : public QAbstractItemModel, public HgBufferManagerObserver, public HgDataProviderModelObserver
+{
+    Q_OBJECT
+public:
+    CACHEPROXYMODEL_EXPORT HgCacheProxyModel(QObject *parent = 0);
+    CACHEPROXYMODEL_EXPORT ~HgCacheProxyModel();   
+    
+    CACHEPROXYMODEL_EXPORT void setDataProvider(HgDataProviderModel *dataProvider, int cacheSize = KDefaultCacheSize, int cacheTreshold = KDefaultCacheTreshold);
+    CACHEPROXYMODEL_EXPORT HgDataProviderModel* DataProvider();
+    CACHEPROXYMODEL_EXPORT void resizeCache(int newSize, int newTreshold);
+    
+//from QAbstractItemModel
+    CACHEPROXYMODEL_EXPORT virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+    CACHEPROXYMODEL_EXPORT virtual QModelIndex parent(const QModelIndex &child) const;
+    CACHEPROXYMODEL_EXPORT virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+    CACHEPROXYMODEL_EXPORT virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+    CACHEPROXYMODEL_EXPORT virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+    CACHEPROXYMODEL_EXPORT virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+    CACHEPROXYMODEL_EXPORT virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+    CACHEPROXYMODEL_EXPORT virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+    CACHEPROXYMODEL_EXPORT virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);
+    CACHEPROXYMODEL_EXPORT virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
+    CACHEPROXYMODEL_EXPORT virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
+    CACHEPROXYMODEL_EXPORT virtual QStringList mimeTypes() const;
+    CACHEPROXYMODEL_EXPORT virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
+    CACHEPROXYMODEL_EXPORT virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
+    CACHEPROXYMODEL_EXPORT virtual Qt::DropActions supportedDropActions() const;
+    CACHEPROXYMODEL_EXPORT virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+    CACHEPROXYMODEL_EXPORT virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+    CACHEPROXYMODEL_EXPORT virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+    CACHEPROXYMODEL_EXPORT virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+    CACHEPROXYMODEL_EXPORT virtual void fetchMore(const QModelIndex &parent);
+    CACHEPROXYMODEL_EXPORT virtual bool canFetchMore(const QModelIndex &parent) const;
+    CACHEPROXYMODEL_EXPORT virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+    CACHEPROXYMODEL_EXPORT virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+    CACHEPROXYMODEL_EXPORT virtual QModelIndex buddy(const QModelIndex &index) const;
+    CACHEPROXYMODEL_EXPORT virtual QModelIndexList match(const QModelIndex &start, int role,
+                                  const QVariant &value, int hits = 1,
+                                  Qt::MatchFlags flags =
+                                  Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+    CACHEPROXYMODEL_EXPORT virtual QSize span(const QModelIndex &index) const;
+
+// for sorting
+    CACHEPROXYMODEL_EXPORT Qt::CaseSensitivity sortCaseSensitivity() const;
+    CACHEPROXYMODEL_EXPORT void setSortCaseSensitivity(Qt::CaseSensitivity cs);
+    CACHEPROXYMODEL_EXPORT bool isSortLocaleAware() const;
+    CACHEPROXYMODEL_EXPORT void setSortLocaleAware(bool on);
+    CACHEPROXYMODEL_EXPORT int sortColumn() const;
+    CACHEPROXYMODEL_EXPORT Qt::SortOrder sortOrder() const;
+    CACHEPROXYMODEL_EXPORT bool dynamicSortFilter() const;
+    CACHEPROXYMODEL_EXPORT void setDynamicSortFilter(bool enable);
+    CACHEPROXYMODEL_EXPORT int sortRole() const;
+    CACHEPROXYMODEL_EXPORT void setSortRole(int role);
+
+//for filtering
+//    CACHEPROXYMODEL_EXPORT QRegExp filterRegExp() const;
+//    CACHEPROXYMODEL_EXPORT void setFilterRegExp(const QRegExp &regExp);
+//    CACHEPROXYMODEL_EXPORT int filterKeyColumn() const;
+//    CACHEPROXYMODEL_EXPORT void setFilterKeyColumn(int column);
+//    CACHEPROXYMODEL_EXPORT Qt::CaseSensitivity filterCaseSensitivity() const;
+//    CACHEPROXYMODEL_EXPORT void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
+//    CACHEPROXYMODEL_EXPORT int filterRole() const;
+//    CACHEPROXYMODEL_EXPORT void setFilterRole(int role);
+    
+public slots:
+    virtual bool submit();
+    virtual void revert();
+    
+public:
+//from HgBufferManagerObserver
+    CACHEPROXYMODEL_EXPORT virtual void release(int start, int end);
+    CACHEPROXYMODEL_EXPORT virtual void request(int start, int end, HgRequestOrder order = HgRequestOrderAscending);  
+    
+private:
+    int count()const;
+    QModelIndex mapToSource(const QModelIndex &index)const;
+    QModelIndex mapToSource(int row, int col) const;
+    int mapToDataProviderIndex(int myIndex) const;
+    int mapFromDataProviderIndex(int myIndex) const;
+    void cleanupForBMResetIfNeeded();
+    void resetBMIfNeeded();
+    void releaseAll();
+    void setBufferPosition(int pos) const;
+    
+private slots:
+    void sourceReset();
+    void sourceAboutToBeReset();
+    void sourceRowsInserted(const QModelIndex &source_parent, int start, int end);
+    void sourceRowsRemoved(const QModelIndex &source_parent, int start, int end);
+    void dataUpdated(QModelIndex from, QModelIndex to);
+    
+//from HgDataProviderModelObserver    
+public:
+    CACHEPROXYMODEL_EXPORT virtual void dataUpdated(int from, int to);
+    
+private:
+    HgBufferManager* mBufferManager;
+    QSortFilterProxyModel* mSortFilterProxyModel;
+    HgDataProviderModel* mDataProviderModel;
+    mutable bool mResetNeeded;
+    mutable bool mSupressBM;
+    mutable int mCurrentPos;
+    bool mSortParameterChanged;
+    bool mFilterParameterChanged;
+    
+};
+
+#endif // HGCACHEPROXYMODEL_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgwidgets_plat/hgcacheproxymodel_api/inc/hgdataprovidermodel.h	Mon May 03 13:32:54 2010 +0300
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*  Version     : %version: 3 %
+*/
+#ifndef HGDATAPROVIDERMODEL_H_
+#define HGDATAPROVIDERMODEL_H_
+
+#include <QObject>
+#include <QList>
+#include <QPair>
+#include <QPixmap.h>
+#include <QMap>
+#include <QMutex>
+#include <QAbstractItemModel>
+
+class HbIcon;
+class QVariant;
+class HgCacheProxyModel;
+
+#ifdef BUILD_CACHEPROXYMODEL
+#define CACHEPROXYMODEL_EXPORT Q_DECL_EXPORT
+#else
+#define CACHEPROXYMODEL_EXPORT Q_DECL_IMPORT
+#endif
+
+class HgDataProviderModelObserver
+{
+public:
+    virtual void dataUpdated(int from, int to) = 0;    
+};
+
+class CACHEPROXYMODEL_EXPORT HgDataProviderModel : public QAbstractItemModel
+{
+    Q_OBJECT
+
+public:
+    HgDataProviderModel(QObject *parent = 0);
+    ~HgDataProviderModel();   
+//to cooperate with buffer manager    
+    void release(QList<int> list, bool silent = true);
+    void request(QList<int> list, bool silent = false);  
+    virtual void doReleaseData(QList<int> list, bool silent) = 0;
+    virtual void doRequestData(QList<int> list, bool silent) = 0;  
+    void registerObserver(HgDataProviderModelObserver* obs);
+
+public:
+//from QAbstractItemModel
+    QModelIndex index(int row, int column,
+                              const QModelIndex &parent = QModelIndex()) const;
+    virtual QModelIndex parent(const QModelIndex &child) const;
+    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+    virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
+    
+//cache management    
+protected:
+    QVariant data(int idx, int role) const;
+    void clearCache();
+    int count() const;
+    bool update(int pos, QVariant obj, int role, bool silent = false);
+    bool update(int pos, QList< QPair< QVariant, int > >* list, bool silent = false);    
+    bool updateIcon(int pos, QVariant obj, bool silent = false);
+    void resetIcon(int idx);
+    void newItem(QList< QPair< QVariant, int > >* list = NULL, bool silent = true);
+    void newItem(QPair< QVariant, int > item, bool silent = true);
+    void insertItem(int pos, QList< QPair< QVariant, int > >* list = NULL, bool silent = true);
+    void insertItem(int pos, QPair< QVariant, int > item, bool silent = true);
+
+private:
+    void doInsertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent);
+
+protected:
+    void removeItem(int pos);
+    void removeItems(int pos, int size);
+    
+    virtual QVariant defaultIcon() const = 0;
+    inline bool containsRole(int idx, int role) const;
+    inline bool isIndexValid(int idx) const;
+
+public:    
+    void resetModel();
+
+protected:    
+    virtual void doResetModel() {};
+    
+// helpers fot emits
+protected:  
+    void emitDataChanged(int start, int end, bool silent);
+    
+//QPixmap pool
+public:
+    void resizeQPixmapPool(int size);
+    
+protected:  
+    void releasePixmap(int idx);
+    QVariant createIcon(int index, QPixmap aPixmap);
+
+private:
+    QPixmap* getPixmap(int idx);
+
+    
+private:
+    QList<QMap<int, QVariant>*>* mCache;   
+    int mCacheSize; //Number of cached Icons. Not same as mCache->count()
+    QList< QPixmap* > mFreePixmaps;
+    QMap< int, QPixmap* > mUsedPixmaps;    
+    int mUnallocatedPixmaps;
+    QMutex mQPixmapsLock;
+    HgDataProviderModelObserver *mObserver;
+};
+
+inline bool HgDataProviderModel::isIndexValid(int idx) const
+{
+    return ((0 <= idx) && 
+            (idx < mCache->size()) && 
+            (mCache->at(idx))); 
+}
+
+inline bool HgDataProviderModel::containsRole(int idx, int role) const
+{
+    return ( isIndexValid(idx) && 
+             mCache->at(idx)->contains(role) ); 
+}
+
+
+
+
+#endif // HGDATAPROVIDERMODEL_H_
--- a/hgwidgets_plat/hgwidgets_plat.pro	Mon Apr 19 14:40:06 2010 +0300
+++ b/hgwidgets_plat/hgwidgets_plat.pro	Mon May 03 13:32:54 2010 +0300
@@ -1,18 +1,13 @@
-#
 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of "Eclipse Public License v1.0"
 # which accompanies this distribution, and is available
 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
 # Initial Contributors:
 # Nokia Corporation - initial contribution.
-#
 # Contributors:
-# 
 # Description:
-#
 
 TEMPLATE = subdirs
 
@@ -21,6 +16,7 @@
 CONFIG += ordered
 
 include(ganeswidgets_api/ganeswidgets_api.pri)
+include(hgcacheproxymodel_api/hgcacheproxymodel_api.pri)
 
 symbian {
     headers.sources = $$PUBLIC_HEADERS