--- a/src/hbwidgets/itemviews/hbabstractviewitem.cpp Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbwidgets/itemviews/hbabstractviewitem.cpp Mon Oct 04 00:38:12 2010 +0300
@@ -28,15 +28,21 @@
#include <hbabstractviewitem.h>
#include <hbabstractitemview.h>
#include <hbnamespace.h>
-#include <hbstyleoptionabstractviewitem_p.h>
#include <hbstyle.h>
#include <hbiconitem.h>
+#include <hbiconitem_p.h>
#include <hbframebackground.h>
#include <hbabstractitemview_p.h>
#include <hbwidgetfeedback.h>
#include <hbtapgesture.h>
#include <hbnamespace_p.h>
#include <hbevent.h>
+#include <hbtextitem.h>
+#include <hbiconitem.h>
+#include <hbstyletextprimitivedata.h>
+#include <hbstyleframeprimitivedata.h>
+#include <hbstyleiconprimitivedata.h>
+#include <hbstyletouchareaprimitivedata.h>
#include <QPersistentModelIndex>
#include <QGraphicsLayout>
@@ -47,14 +53,14 @@
#include <QGraphicsScene>
#include <QPixmap>
-#include <QPainter>
-#include <QDebug>
#include <QChildEvent>
#include <QGesture>
#include <QGestureEvent>
#include <QGraphicsSceneEvent>
+#include <QDebug>
+
const QString KDefaultLayoutOption = "default";
const int HbAbstractViewItemShared::ViewItemDeferredDeleteEvent = QEvent::registerEventType();
const int HbViewItemPressDelay = 100;
@@ -87,10 +93,11 @@
changed. For more information about enabling the pixmap cache see HbAbstractItemView::setItemPixmapCacheEnabled().
\primitives
- \primitive{background} HbIconItem representing the item background. This primitive exists in cases the model's Qt::BackgroundRole returns HbIcon or QBrush for this item.
- \primitive{frame} HbFrameItem representing the background frame of the item. This primitive exists if background primitive does not exist and the model's Qt::BackgroundRole returns HbFrameBackground or there is a default frame set with the setDefaultFrame(). An item can have either the frame or the background primitive, but not the both at the same time.
- \primitive{selection-icon} HbIconItem representing the checkbox in the multi selection mode.
- \primitive{multiselection-toucharea} HbTouchArea used in extending the touch area of the selection-icon.
+ \primitive{background} HbIconItem with item name "background" representing the item background. This primitive exists in cases the model's Qt::BackgroundRole returns HbIcon or QBrush for this item.
+ \primitive{frame} HbFrameItem with item name "frame" representing the background frame of the item. This primitive exists if background primitive does not exist and the model's Qt::BackgroundRole returns HbFrameBackground or there is a default frame set with the setDefaultFrame(). An item can have either the frame or the background primitive, but not the both at the same time.
+ \primitive{selection-icon} HbIconItem with item name "selection-icon" representing the checkbox in the multi selection mode.
+ \primitive{multiselection-toucharea} HbTouchArea with item name "multiselection-toucharea" used in extending the touch area of the selection-icon.
+ \primitive{focus} HbFrameItem with item name "focus" for showing focus.
*/
/*!
@@ -185,6 +192,29 @@
\snippet{ultimatecodesnippet/customlistviewitem.cpp,1}
*/
+void HbAbstractViewItemShared::updateIconItemsAsyncMode()
+{
+ foreach (HbAbstractViewItem *item, mCloneItems) {
+ QList<QGraphicsItem *> childItems = item->childItems();
+ foreach (QGraphicsItem *child, childItems) {
+ item->d_func()->updateIconItemsAsyncMode(child);
+ }
+ }
+}
+
+void HbAbstractViewItemShared::setItemView(HbAbstractItemView *view)
+{
+ if (view != mItemView) {
+ if (mItemView) {
+ disconnect(mItemView, SIGNAL(scrollingStarted()), this, SLOT(scrollingStarted()));
+ }
+ mItemView = view;
+ if (mItemView) {
+ connect(mItemView, SIGNAL(scrollingStarted()), this, SLOT(scrollingStarted()));
+ }
+ }
+}
+
void HbAbstractViewItemShared::pressStateChangeTimerTriggered()
{
HbWidgetFeedback::triggered(mPressedItem, Hb::InstantPressed, 0);
@@ -207,6 +237,13 @@
}
}
+void HbAbstractViewItemShared::scrollingStarted()
+{
+ if (mItemView && mItemView->iconLoadPolicy() == HbAbstractItemView::LoadAsynchronouslyWhenScrolling) {
+ updateIconItemsAsyncMode();
+ }
+}
+
void HbAbstractViewItemPrivate::init()
{
Q_Q(HbAbstractViewItem);
@@ -227,6 +264,11 @@
mSharedData->mCloneItems.append(q);
mFrontPixmapPainter = new HbViewItemPixmapPainter(1000, q);
+ // setChildFlags gets called in the construction phase, but the values are wrong.
+ // Here we set the flags to force FrontPixmap to obey parent opacity, this is needed in animations
+ setChildFlags(mFrontPixmapPainter, false);
+
+ q->connect(q, SIGNAL(childrenChanged()), q, SLOT(_q_childrenChanged()));
}
}
@@ -250,6 +292,47 @@
}
}
+void HbAbstractViewItemPrivate::_q_childrenChanged()
+{
+ Q_Q(HbAbstractViewItem);
+
+ QList<QGraphicsItem *> childList = q->childItems();
+ int currentCount = childList.count();
+ int previousCount = mChildren.count();
+
+ if (currentCount > previousCount) {
+ QGraphicsItem *addedItem = 0;
+ for (int i = 0; i < currentCount; ++i) {
+ QGraphicsItem *item = childList.at(i);
+ if (item != mChildren.value(i)) {
+ addedItem = item;
+ break;
+ }
+ }
+
+ if (usePixmapCache()) {
+ setChildFlags(addedItem, true);
+ }
+
+ updateIconItemsAsyncMode(addedItem);
+ } else {
+ if (mUpdateItems.count()) {
+ int itemCount = mUpdateItems.count();
+ for (int i = 0; i < itemCount; ++i) {
+ QGraphicsItem *item = mUpdateItems.at(i);
+ int index = childList.indexOf(item);
+ if (index == -1) {
+ mUpdateItems.remove(i);
+ mUpdateItems.squeeze();
+ }
+ }
+ }
+ }
+
+ mChildren = childList;
+}
+
+
void HbAbstractViewItemPrivate::repolishCloneItems()
{
int count(mSharedData->mCloneItems.count());
@@ -445,25 +528,30 @@
painter->translate(-child->pos());
continue;
}
- paintChildItemsRecursively(child,painter,option);
+ paintChildItemsRecursively(child,painter,option, child->pos());
}
mInPaintItems = false;
}
-void HbAbstractViewItemPrivate::paintChildItemsRecursively(QGraphicsItem *child, QPainter *painter,QStyleOptionGraphicsItem *option)
+void HbAbstractViewItemPrivate::paintChildItemsRecursively(QGraphicsItem *child,
+ QPainter *painter,
+ QStyleOptionGraphicsItem *option,
+ const QPointF &translatePosition)
{
if (!child->isVisible())
return;
int i = 0;
QList<QGraphicsItem *> children = child->childItems();
int count(children.size());
- painter->translate(child->pos());
+ if (!translatePosition.isNull()) {
+ painter->translate(translatePosition);
+ }
// Draw children behind
for (i = 0; i < count; ++i) {
QGraphicsItem *subChild = children.at(i);
if (!(subChild->flags() & QGraphicsItem::ItemStacksBehindParent))
break;
- paintChildItemsRecursively(subChild, painter,option);
+ paintChildItemsRecursively(subChild, painter,option, subChild->pos());
}
option->exposedRect = child->boundingRect();
@@ -483,9 +571,12 @@
// Draw children in front
for (; i < count; ++i) {
QGraphicsItem *subChild = children.at(i);
- paintChildItemsRecursively(subChild, painter,option);
+ paintChildItemsRecursively(subChild, painter,option, subChild->pos());
}
- painter->translate(-child->pos());
+
+ if (!translatePosition.isNull()) {
+ painter->translate(-translatePosition);
+ }
}
@@ -518,6 +609,71 @@
}
}
+void HbAbstractViewItemPrivate::drawSubPixmap(QPixmap *pixmap,
+ QPainter *painter,
+ const QTransform &itemToPixmapTransform,
+ const QStyleOptionGraphicsItem *option)
+{
+ Q_Q(HbAbstractViewItem);
+
+ QPixmap subPix;
+ QPainter pixmapPainter;
+ QStyleOptionGraphicsItem pixmapOption(*option);
+
+ QList<QGraphicsItem *> childList = q->childItems();
+
+ foreach (QGraphicsItem *subChild, mUpdateItems) {
+ pixmapOption.exposedRect = subChild->boundingRect();
+
+ subPix = QPixmap(pixmapOption.exposedRect.toRect().size());
+ subPix.fill(Qt::transparent);
+
+ pixmapPainter.begin(&subPix);
+ pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);
+ pixmapPainter.setRenderHints(painter->renderHints(), true);
+
+ // Draw items on the pixmap
+ paintChildItemsRecursively(subChild, &pixmapPainter, &pixmapOption, QPointF());
+
+ // Search & paint overlapping child items.
+ QRectF subChildRectRelativeToParent(subChild->pos(), subChild->boundingRect().size());
+
+ int currentIndex = childList.indexOf(subChild) + 1;
+ int childCount = childList.count();
+ while (currentIndex < childCount) {
+ QGraphicsItem *item = childList.at(currentIndex);
+ if (item != mNonCachableItem
+ && item != mFrontPixmapPainter
+ && item != mBackPixmapPainter) {
+ QRectF itemRectRelativeToParent(item->pos(), item->boundingRect().size());
+
+ QRectF intersectionRect(itemRectRelativeToParent.intersected(subChildRectRelativeToParent));
+ if (!intersectionRect.isNull()) {
+ QStyleOptionGraphicsItem itemPixmapOption(*option);
+ itemPixmapOption.exposedRect = intersectionRect.translated(-item->pos());
+
+ paintChildItemsRecursively(item, &pixmapPainter, &itemPixmapOption, subChild->mapFromParent(itemRectRelativeToParent.topLeft()));
+ }
+ }
+ ++currentIndex;
+ }
+
+ pixmapPainter.end();
+
+ if (!subPix.isNull()) {
+ // Blit the subpixmap into the main pixmap.
+ pixmapPainter.begin(pixmap);
+ pixmapPainter.setWorldTransform(itemToPixmapTransform, true);
+ pixmapPainter.translate(subChild->pos());
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ pixmapPainter.setClipRect(pixmapOption.exposedRect);
+ pixmapPainter.drawPixmap(pixmapOption.exposedRect.topLeft(), subPix);
+ pixmapPainter.end();
+ }
+ }
+ mUpdateItems.clear();
+}
+
void HbAbstractViewItemPrivate::updatePixmap(QPixmap *pixmap,
QPainter *painter,
const QTransform &itemToPixmapTransform,
@@ -551,6 +707,48 @@
}
}
+bool HbAbstractViewItemPrivate::iconLoadedCallback(HbIconItem *target, void *param)
+{
+ HbAbstractViewItemPrivate* d_ptr = (HbAbstractViewItemPrivate*)param;
+ return d_ptr->iconLoaded(target);
+}
+
+bool HbAbstractViewItemPrivate::iconLoaded(HbIconItem *target)
+{
+ Q_Q(HbAbstractViewItem);
+
+ bool result = false;
+
+ if (usePixmapCache()) {
+ mUpdateItems.append(target);
+ if (mSharedData->mItemView && !mSharedData->mItemView->isScrolling()) {
+ q->update();
+ }
+
+ result = true;
+ }
+
+ return result;
+}
+
+void HbAbstractViewItemPrivate::updateIconItemsAsyncMode(QGraphicsItem *item)
+{
+ if (mSharedData->mItemView) {
+ HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem *>(item);
+ if (iconItem) {
+ HbAbstractItemView::IconLoadPolicy loadPolicy = mSharedData->mItemView->iconLoadPolicy();
+ if (loadPolicy == HbAbstractItemView::LoadAsynchronouslyAlways
+ || (loadPolicy == HbAbstractItemView::LoadAsynchronouslyWhenScrolling
+ && mSharedData->mItemView->isScrolling())) {
+ HbIconItemPrivate::d_ptr(iconItem)->setAsyncCallbackFilter(&HbAbstractViewItemPrivate::iconLoadedCallback, this);
+ iconItem->setAsync(true);
+ } else {
+ iconItem->setAsync(false);
+ }
+ }
+ }
+}
+
/*!
Constructs an abstract view item with the given parent.
*/
@@ -702,7 +900,7 @@
void HbAbstractViewItem::setItemView( HbAbstractItemView *itemView )
{
HB_SDD( HbAbstractViewItem );
- sd->mItemView = itemView;
+ sd->setItemView(itemView);
}
/*!
@@ -714,37 +912,6 @@
return sd->mItemView;
}
-/*!
- Populates a style option object for this widget based on its current state, and stores the output in \a option.
-*/
-void HbAbstractViewItem::initStyleOption(HbStyleOptionAbstractViewItem *option) const
-{
- HB_SDD( const HbAbstractViewItem );
-
- HbWidget::initStyleOption(option);
-
- option->modelItemType = d->mModelItemType;
- option->index = d->mIndex;
-
- option->viewItemType = type();
- option->checkState = d->mCheckState;
- option->background = d->mBackground;
- if (!option->background.isValid()) {
- if (option->modelItemType == Hb::StandardItem
- && !sd->mDefaultFrame.isNull()) {
- option->background = sd->mDefaultFrame;
- }
- }
-
- if ( sd->mItemView
- && sd->mItemView->selectionMode() == HbAbstractItemView::SingleSelection){
- option->singleSelectionMode = true;
- } else {
- option->singleSelectionMode = false;
- }
-
- option->insidePopup = testAttribute(Hb::InsidePopup);
-}
/*!
Check whether \a position is inside the selection area of the given selectionAreaType in the view item.
@@ -752,11 +919,11 @@
Default selection areas are for
\li HbAbstractViewItem::SingleSelection mode: whole item
\li HbAbstractViewItem::MultiSelection mode: whole item.
- \li HbAbstractViewItem::ContiguousSelection mode: area of HbStylePrivate::P_ItemViewItem_touchmultiselection icon.
+ \li HbAbstractViewItem::ContiguousSelection mode: area of icon of primitive with item name "multiselection-toucharea".
The \a selectionAreaType tells what kind of selection area is requested. The parameter value ContiguousSelection returns
- the area where mouse movement will extend the selection to new items. By default this contiguous selection area is
- the HbStylePrivate::P_ItemViewItem_touchmultiselection.
+ the area where mouse movement will extend the selection to new items. By default this contiguous selection is area of
+ "multiselection-toucharea" primitive.
*/
bool HbAbstractViewItem::selectionAreaContains(const QPointF &position, SelectionAreaType selectionAreaType) const
@@ -804,17 +971,25 @@
}
if (d->mBackgroundItem || d->mFrame || d->mFocusItem) {
- initStyleOption(d->mSharedData->mStyleOption);
if (d->mFocusItem) {
- HbStylePrivate::updatePrimitive(d->mFocusItem, HbStylePrivate::P_ItemViewItem_focus, d->mSharedData->mStyleOption);
+ // HbFrameItem
+ HbStyleFramePrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mFocusItem);
+ style()->updatePrimitive(d->mFocusItem, &primitiveData, this);
}
if (d->mFrame) {
- HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ItemViewItem_frame, d->mSharedData->mStyleOption);
+ // HbFrameItem
+ HbStyleFramePrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mFrame);
+ style()->updatePrimitive(d->mFrame, &primitiveData, this);
}
if (d->mBackgroundItem) {
- HbStylePrivate::updatePrimitive(d->mBackgroundItem, HbStylePrivate::P_ItemViewItem_background, d->mSharedData->mStyleOption);
+ // HbIconItem
+ HbStyleIconPrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mBackgroundItem);
+ style()->updatePrimitive(d->mBackgroundItem, &primitiveData, this);
}
}
break;
@@ -887,13 +1062,6 @@
}
break;
}
- case ItemChildAddedChange: {
- Q_D(HbAbstractViewItem);
- if (d->usePixmapCache()) {
- d->setChildFlags(qvariant_cast<QGraphicsItem *>(value), true);
- }
- break;
- }
default:
break;
}
@@ -902,6 +1070,160 @@
}
/*!
+ Initializes the HbAbstractViewItem primitive data.
+
+ This function calls HbWidgetBase::initPrimitiveData().
+ \a primitiveData is data object, which is populated with data. \a primitive is the primitive.
+*/
+void HbAbstractViewItem::initPrimitiveData( HbStylePrimitiveData *primitiveData,
+ const QGraphicsObject *primitive)
+{
+ Q_ASSERT_X(primitive && primitiveData, "HbAbstractViewItem::initPrimitiveData" , "NULL data not permitted");
+ HB_SDD(HbAbstractViewItem);
+
+ HbWidgetBase::initPrimitiveData(primitiveData, primitive);
+ if (primitiveData->type == HbStylePrimitiveData::SPD_Icon) {
+ HbStyleIconPrimitiveData *iconPrimitiveData = hbstyleprimitivedata_cast<HbStyleIconPrimitiveData*>(primitiveData);
+
+ if (primitive ==d-> mBackgroundItem) {
+ iconPrimitiveData->geometry = boundingRect();
+
+ QVariant background = d->mBackground;
+ if (!background.isValid()) {
+ if ( d->mModelItemType == Hb::StandardItem
+ && !sd->mDefaultFrame.isNull()) {
+ background = sd->mDefaultFrame;
+ }
+ }
+
+ if (background.canConvert<HbIcon>()){
+ iconPrimitiveData->icon = background.value<HbIcon>();
+ iconPrimitiveData->brush = QBrush();
+ } else if (background.canConvert<QBrush>()){
+ iconPrimitiveData->icon = HbIcon();
+ iconPrimitiveData->brush = background.value<QBrush>();
+ } else {
+ iconPrimitiveData->icon = HbIcon();
+ iconPrimitiveData->brush = QBrush();
+ }
+ } else if (primitive == d->mSelectionItem) {
+ int viewItemType = type();
+ bool singleSelectionMode = false;
+ if (sd->mItemView
+ && sd->mItemView->selectionMode() == HbAbstractItemView::SingleSelection){
+ singleSelectionMode = true;
+ }
+
+ if (viewItemType == Hb::ItemType_RadioButtonListViewItem) {
+ if (d->mCheckState == Qt::Checked) {
+ iconPrimitiveData->iconState = QIcon::On;
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_radio_selected");
+ } else {
+ iconPrimitiveData->iconState = QIcon::Off;
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_radio_unselected");
+ }
+ } else {
+ if (d->mCheckState == Qt::Checked) {
+ iconPrimitiveData->iconState = QIcon::On;
+ if (singleSelectionMode) {
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_tick");
+ } else {
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_selected");
+ }
+ } else if (d->mCheckState == Qt::PartiallyChecked) {
+ iconPrimitiveData->iconState = QIcon::On;
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_selected_partial");
+ } else {
+ iconPrimitiveData->iconState = QIcon::Off;
+ if (singleSelectionMode) {
+ iconPrimitiveData->iconName = QLatin1String("");
+ } else {
+ iconPrimitiveData->iconName = QLatin1String("qtg_small_unselected");
+ }
+ }
+ }
+ }
+ } else if (primitiveData->type == HbStylePrimitiveData::SPD_Frame) {
+ HbStyleFramePrimitiveData *framePrimitiveData = hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData);
+
+ if (primitive == d->mFrame ) {
+ framePrimitiveData->geometry = boundingRect();
+
+ QVariant background = d->mBackground;
+ if (!background.isValid()) {
+ if ( d->mModelItemType == Hb::StandardItem
+ && !sd->mDefaultFrame.isNull()) {
+ background = sd->mDefaultFrame;
+ }
+ }
+
+ if (background.canConvert<HbFrameBackground>()) {
+ HbFrameBackground frame = background.value<HbFrameBackground>();
+ framePrimitiveData->frameType = frame.frameType();
+ framePrimitiveData->frameGraphicsName = frame.frameGraphicsName();
+ } else {
+ int viewItemType = type();
+ bool insidePopup = testAttribute(Hb::InsidePopup);
+ if (viewItemType == Hb::ItemType_TreeViewItem) {
+ if (d->mModelItemType == Hb::ParentItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_list_parent_normal") : QLatin1String("qtg_fr_list_parent_normal");
+ } else if (d->mModelItemType == Hb::SeparatorItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = QLatin1String("qtg_fr_list_separator");
+ } else {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal");
+ }
+ } else if (viewItemType == Hb::ItemType_ListViewItem
+ || viewItemType == Hb::ItemType_RadioButtonListViewItem) {
+ if (d->mModelItemType == Hb::SeparatorItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = QLatin1String("qtg_fr_list_separator");
+ } else {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_list_normal") : QLatin1String("qtg_fr_list_normal");
+ }
+ } else if (viewItemType == Hb::ItemType_GridViewItem
+ || viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_grid_normal") : QLatin1String("qtg_fr_grid_normal");
+ } else{
+ framePrimitiveData->frameGraphicsName = QString();
+ }
+ }
+ } else if (primitive == d->mFocusItem) {
+ framePrimitiveData->geometry = boundingRect();
+
+ int viewItemType = type();
+ bool insidePopup = testAttribute(Hb::InsidePopup);
+ if (viewItemType == Hb::ItemType_TreeViewItem
+ || viewItemType == Hb::ItemType_ListViewItem
+ || viewItemType == Hb::ItemType_RadioButtonListViewItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_list_pressed") : QLatin1String("qtg_fr_list_pressed");
+ } else if ( viewItemType == Hb::ItemType_GridViewItem
+ || viewItemType == HbPrivate::ItemType_ColorGridViewItem) {
+ framePrimitiveData->frameType = HbFrameDrawer::NinePieces;
+ framePrimitiveData->frameGraphicsName = insidePopup ?
+ QLatin1String("qtg_fr_popup_grid_pressed") : QLatin1String("qtg_fr_grid_pressed");
+ } else{
+ framePrimitiveData->frameGraphicsName = QString();
+ }
+ }
+
+ } // else if (primitiveData->type == HbStylePrimitiveData::SPD_TouchArea) {
+ // mMultiSelectionTouchArea: no data provided
+}
+
+
+
+/*!
\reimp
To optimize loading css/xml definitions to take place only once, this function should be
@@ -943,27 +1265,39 @@
}
#endif
-
- initStyleOption(d->mSharedData->mStyleOption);
-
if (d->mBackgroundItem) {
- HbStylePrivate::updatePrimitive(d->mBackgroundItem, HbStylePrivate::P_ItemViewItem_background, d->mSharedData->mStyleOption);
+ // HbIconItem
+ HbStyleIconPrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mBackgroundItem);
+ style()->updatePrimitive(d->mBackgroundItem, &primitiveData, this);
}
if (d->mFrame) {
- HbStylePrivate::updatePrimitive(d->mFrame, HbStylePrivate::P_ItemViewItem_frame, d->mSharedData->mStyleOption);
+ // HbFrameItem
+ HbStyleFramePrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mFrame);
+ style()->updatePrimitive(d->mFrame, &primitiveData, this);
}
if (d->mSelectionItem) {
- HbStylePrivate::updatePrimitive(d->mSelectionItem, HbStylePrivate::P_ItemViewItem_selection, d->mSharedData->mStyleOption);
+ // HbIconItem
+ HbStyleIconPrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mSelectionItem);
+ style()->updatePrimitive(d->mSelectionItem, &primitiveData, this);
}
if (d->mMultiSelectionTouchArea) {
- HbStylePrivate::updatePrimitive(d->mMultiSelectionTouchArea, HbStylePrivate::P_ItemViewItem_touchmultiselection, d->mSharedData->mStyleOption);
+ // HbTouchArea
+ HbStyleTouchAreaPrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mMultiSelectionTouchArea);
+ style()->updatePrimitive(d->mMultiSelectionTouchArea, &primitiveData, this);
}
if (d->mFocusItem) {
- HbStylePrivate::updatePrimitive(d->mFocusItem, HbStylePrivate::P_ItemViewItem_focus, d->mSharedData->mStyleOption);
+ // HbFrameItem
+ HbStyleFramePrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mFocusItem);
+ style()->updatePrimitive(d->mFocusItem, &primitiveData, this);
}
updatePixmapCache();
@@ -1018,14 +1352,22 @@
|| currentBackground.canConvert<QBrush>()) {
if (!d->mBackgroundItem) {
d->mItemsChanged = true;
- d->mBackgroundItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_background, this);
+ d->mBackgroundItem = style()->createPrimitive(HbStyle::PT_IconItem, QLatin1String("background"), 0);
+ d->mBackgroundItem->setParentItem(this); // To enable asynchronous icon loading.
+ d->mBackgroundItem->setZValue(-3.0);
+ HbIconItem *iconItem = qobject_cast<HbIconItem*>(d->mBackgroundItem);
+ if (iconItem) {
+ iconItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
+ }
delete d->mFrame;
d->mFrame = 0;
}
} else if (currentBackground.canConvert<HbFrameBackground>()) {
if (!d->mFrame) {
d->mItemsChanged = true;
- d->mFrame = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_frame, this);
+ d->mFrame = style()->createPrimitive(HbStyle::PT_FrameItem, QLatin1String("frame"), this);
+ d->mFrame->setZValue(-4.0);
+
delete d->mBackgroundItem;
d->mBackgroundItem = 0;
}
@@ -1046,7 +1388,8 @@
|| sd->mDefaultFrame.isNull()))) {
if (!d->mFrame) {
d->mItemsChanged = true;
- d->mFrame = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_frame, this);
+ d->mFrame = style()->createPrimitive(HbStyle::PT_FrameItem, QLatin1String("frame"), this);
+ d->mFrame->setZValue(-4.0);
}
} else if (d->mFrame) {
d->mItemsChanged = true;
@@ -1096,7 +1439,12 @@
if (itemSelectable) {
if (!d->mSelectionItem) {
d->mItemsChanged = true;
- d->mSelectionItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_selection, this);
+ d->mSelectionItem = style()->createPrimitive(HbStyle::PT_IconItem, QLatin1String("selection-icon"), 0);
+ d->mSelectionItem ->setParentItem(this); // To enable asynchronous icon loading.
+ HbIconItem *iconItem = qobject_cast<HbIconItem*>(d->mSelectionItem);
+ if (iconItem) {
+ iconItem->setAlignment(Qt::AlignCenter);
+ }
}
} else {
d->mItemsChanged = true;
@@ -1112,7 +1460,7 @@
&& selectionMode == HbAbstractItemView::MultiSelection) {
if (!d->mMultiSelectionTouchArea) {
d->mItemsChanged = true;
- d->mMultiSelectionTouchArea = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_touchmultiselection, this);
+ d->mMultiSelectionTouchArea = style()->createPrimitive(HbStyle::PT_TouchArea, QLatin1String("multiselection-toucharea"), this);
}
} else if (d->mMultiSelectionTouchArea) {
d->mItemsChanged = true;
@@ -1185,14 +1533,17 @@
if (pressed) {
if (!d->mFocusItem) {
- d->mFocusItem = HbStylePrivate::createPrimitive(HbStylePrivate::P_ItemViewItem_focus, this);
+ d->mFocusItem = style()->createPrimitive(HbStyle::PT_FrameItem, QLatin1String("focus") , this);
+ d->mFocusItem->setZValue(-1.0);
+ // setChildFlags gets called in the construction phase, but the values are wrong.
+ // Here we set the flags to force focusItem to be painted even when itemPixmapCache is on
d->setChildFlags(d->mFocusItem, false);
}
- initStyleOption(d->mSharedData->mStyleOption);
-
if (d->mFocusItem) {
- HbStylePrivate::updatePrimitive(d->mFocusItem, HbStylePrivate::P_ItemViewItem_focus, d->mSharedData->mStyleOption);
+ HbStyleFramePrimitiveData primitiveData;
+ initPrimitiveData(&primitiveData, d->mFocusItem);
+ style()->updatePrimitive(d->mFocusItem, &primitiveData, this);
}
if (doAnimate) {
@@ -1228,6 +1579,9 @@
if (d->mNonCachableItem && !d->mBackPixmapPainter) {
d->mBackPixmapPainter = new HbViewItemPixmapPainter(-1000, this);
+ // setChildFlags gets called in the construction phase, but the values are wrong.
+ // Here we set the flags to force BackPixmap to obey parent opacity, this is needed in animations
+ d->setChildFlags(d->mBackPixmapPainter, false);
}
}
@@ -1364,6 +1718,16 @@
d->releasePixmaps();
}
+ if (!d->mResetPixmapCache && d->mUpdateItems.count() && d->mFrontPixmapPainter->pixmap()) {
+ // Construct an item-to-pixmap transform.
+ QPointF point = deviceRect.topLeft();
+ QTransform itemToPixmap = painter->worldTransform();
+ if (!point.isNull()) {
+ itemToPixmap *= QTransform::fromTranslate(-point.x(), -point.y());
+ }
+ d->drawSubPixmap(d->mFrontPixmapPainter->pixmap(), painter, itemToPixmap, option);
+ }
+
if (d->mResetPixmapCache) {
if (!d->mFrontPixmapPainter->pixmap()) {
d->setChildFlagRecursively(true);
@@ -1372,10 +1736,12 @@
}
// Construct an item-to-pixmap transform.
- QPointF p = deviceRect.topLeft();
+ QPointF point = deviceRect.topLeft();
QTransform itemToPixmap = painter->worldTransform();
- if (!p.isNull())
- itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
+ if (!point.isNull()) {
+ itemToPixmap *= QTransform::fromTranslate(-point.x(), -point.y());
+ }
+ d->mUpdateItems.clear();
d->updatePixmap(d->mFrontPixmapPainter->pixmap(), painter, itemToPixmap, option, d->mNonCachableItem, 0);