--- a/src/hbwidgets/itemviews/hbtumbleviewitem.cpp Wed Jun 23 18:33:25 2010 +0300
+++ b/src/hbwidgets/itemviews/hbtumbleviewitem.cpp Tue Jul 06 14:36:53 2010 +0300
@@ -23,11 +23,14 @@
**
****************************************************************************/
#include "hbtumbleviewitem.h"
+#include "hbtapgesture_p.h"
#include "hblistviewitem_p.h"
+#include "hbnamespace_p.h"
#include <hbstyleoptionlistviewitem_p.h>
#include <QGestureEvent>
+#include <QCoreApplication>
HbTumbleViewItem::HbTumbleViewItem(QGraphicsItem *parent) :
HbListViewItem(parent)
@@ -53,20 +56,21 @@
/*!
\reimp
*/
-HbAbstractViewItem *HbTumbleViewItem::createItem()
+HbAbstractViewItem *HbTumbleViewItem::createItem()
{
HbTumbleViewItem* item = new HbTumbleViewItem(*this);
item->setFocusPolicy(Qt::NoFocus);
-
+ connect(item,SIGNAL(released(QPointF)),item->itemView(),SLOT(_q_itemSelected(QPointF)));
return item;
}
-
/*!
\reimp
*/
void HbTumbleViewItem::updateChildItems()
{
Q_D(HbListViewItem);
+ if (d->mIndex.data(Qt::DisplayRole).isNull())
+ return;
HbListViewItem::updateChildItems();
if(d->mSelectionItem){
d->mSelectionItem->hide();
@@ -75,20 +79,62 @@
void HbTumbleViewItem::gestureEvent(QGestureEvent *event)
{
- if (event->gesture(Qt::TapGesture)) {
+ HbTapGesture *gesture = static_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
+ if (gesture) {
Q_D(HbAbstractViewItem);
if(itemView()->isScrolling()){
event->ignore();
event->ignore(Qt::TapGesture);
return;
}
+ if(gesture->state() == Qt::GestureCanceled){
+ d->setPressed(false, false);
+ event->accept();
+ scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
+ return;
+ }
d->tapTriggered(event);
-
} else {
HbWidget::gestureEvent(event);
+
}
}
+QSizeF HbTumbleViewItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+ HB_SDD(const HbAbstractViewItem);
+ static qreal height=0;
+
+ QSizeF sh=HbListViewItem::sizeHint(which,constraint);
+ if(which == Qt::PreferredSize && sh.height()<=0) {
+ //TODO:remove this check once refresh issue in DTP is solved on removeRows/insertRows
+ if(height<=0) {
+ //Let's create a temporary item and take the height for the size hint
+ HbAbstractViewItem *tempitem = sd->mPrototype->createItem();
+ if(sd->mItemView) {
+ QAbstractItemModel *model = sd->mItemView->model();
+ if(model) {
+ int rowCount=model->rowCount();
+ QModelIndex ind=model->index(rowCount,0);
+ if(ind.isValid()) {
+ tempitem->setModelIndex(ind);
+ }
+ }
+ }
+
+
+ //call polish
+ QEvent polishEvent(QEvent::Polish);
+ QCoreApplication::sendEvent(const_cast<HbAbstractViewItem *>(tempitem), &polishEvent);
+ height=tempitem->effectiveSizeHint(which,constraint).height();
+ delete tempitem;
+ }
+ return QSizeF(sh.width(),height);
+ }
+ return sh;
+}
+
+
#include "moc_hbtumbleviewitem.cpp"