17 |
17 |
18 #include "cntcontactcardheadingitem.h" |
18 #include "cntcontactcardheadingitem.h" |
19 |
19 |
20 #include <qtcontacts.h> |
20 #include <qtcontacts.h> |
21 #include <QGraphicsSceneMouseEvent> |
21 #include <QGraphicsSceneMouseEvent> |
|
22 #include <QTapAndHoldGesture> |
22 |
23 |
23 #include <hbiconitem.h> |
24 #include <hbiconitem.h> |
24 #include <hbtextitem.h> |
25 #include <hbtextitem.h> |
25 #include <hbmarqueeitem.h> |
26 #include <hbmarqueeitem.h> |
26 #include <hbframedrawer.h> |
27 #include <hbframedrawer.h> |
190 } |
188 } |
191 |
189 |
192 if (!mFrameItem) |
190 if (!mFrameItem) |
193 { |
191 { |
194 mFrameItem = new HbFrameItem(this); |
192 mFrameItem = new HbFrameItem(this); |
195 mFrameItem->frameDrawer().setFrameGraphicsName("qtg_fr_list_parent_normal"); |
193 mFrameItem->frameDrawer().setFrameGraphicsName("qtg_fr_groupbox"); |
196 mFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
194 mFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
197 mFrameItem->setZValue(-2); |
195 mFrameItem->setZValue(-2); |
198 style()->setItemName(mFrameItem, "background"); |
196 style()->setItemName(mFrameItem, "background"); |
199 } |
197 } |
200 |
198 |
289 return (!(contact->detail<QContactOrganization>().title().isNull()) |
287 return (!(contact->detail<QContactOrganization>().title().isNull()) |
290 || !(contact->detail<QContactOrganization>().name().isNull()) |
288 || !(contact->detail<QContactOrganization>().name().isNull()) |
291 || !(contact->detail<QContactOrganization>().department().isEmpty())); |
289 || !(contact->detail<QContactOrganization>().department().isEmpty())); |
292 } |
290 } |
293 |
291 |
294 void CntContactCardHeadingItem::setDetails(const QContact* contact, bool isMyCard) |
292 void CntContactCardHeadingItem::setDetails(const QContact* contact) |
295 { |
293 { |
296 primaryText.clear(); |
294 primaryText.clear(); |
297 firstLineText.clear(); |
295 firstLineText.clear(); |
298 secondaryText.clear(); |
296 secondaryText.clear(); |
299 icon.clear(); |
297 icon.clear(); |
300 tinyMarqueeText.clear(); |
298 tinyMarqueeText.clear(); |
301 |
299 |
302 // icon label |
300 // icon label |
303 if (isMyCard) |
301 icon = HbIcon("qtg_large_add_contact_picture"); |
304 { |
|
305 icon = HbIcon("qtg_large_mycard"); |
|
306 } |
|
307 else |
|
308 { |
|
309 icon = HbIcon("qtg_large_avatar"); |
|
310 } |
|
311 |
302 |
312 QContactName name = contact->detail<QContactName>(); |
303 QContactName name = contact->detail<QContactName>(); |
313 |
304 |
314 // name label |
305 // name label |
315 if (isNickName(contact) || isCompanyName(contact)) |
306 if (isNickName(contact) || isCompanyName(contact)) |
390 void CntContactCardHeadingItem::processLongPress(const QPointF &point) |
381 void CntContactCardHeadingItem::processLongPress(const QPointF &point) |
391 { |
382 { |
392 emit passLongPressed(point); |
383 emit passLongPressed(point); |
393 } |
384 } |
394 |
385 |
395 void CntContactCardHeadingItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
386 void CntContactCardHeadingItem::gestureEvent(QGestureEvent* event) |
396 { |
387 { |
397 event->accept(); |
388 QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture); |
398 } |
389 if (tapAndHold && tapAndHold->state() == Qt::GestureFinished) { |
399 |
390 processLongPress(static_cast<QTapAndHoldGesture *>(tapAndHold)->position()); |
400 void CntContactCardHeadingItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
391 } |
401 { |
392 } |
402 event->accept(); |
393 |
403 } |
|
404 |
|
405 void CntContactCardHeadingItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
406 { |
|
407 if (rect().contains(event->pos())) { |
|
408 emit clicked(); |
|
409 } |
|
410 event->accept(); |
|
411 } |
|
412 |
|
413 void CntContactCardHeadingItem::initGesture() |
394 void CntContactCardHeadingItem::initGesture() |
414 { |
395 { |
415 mGestureFilter = new HbGestureSceneFilter(Qt::LeftButton, this); |
396 grabGesture(Qt::TapAndHoldGesture); |
416 |
|
417 // Orbit documentation states that added gestures will be deleted |
|
418 // when the filter is deleted (filter takes ownership). So no |
|
419 // need to worry about deleting the gesture. |
|
420 mGestureLongpressed = new HbGesture(HbGesture::longpress, 5); |
|
421 mGestureFilter->addGesture(mGestureLongpressed); |
|
422 mGestureFilter->setLongpressAnimation(true); |
|
423 |
|
424 mIcon->installSceneEventFilter(mGestureFilter); |
|
425 connect(mGestureLongpressed, SIGNAL(longPress(QPointF)), this, SLOT(processLongPress(QPointF))); |
|
426 } |
397 } |
427 |
398 |
428 QVariant CntContactCardHeadingItem::itemChange(GraphicsItemChange change, const QVariant &value) |
399 QVariant CntContactCardHeadingItem::itemChange(GraphicsItemChange change, const QVariant &value) |
429 { |
400 { |
430 if (change == QGraphicsItem::ItemSceneHasChanged) |
401 if (change == QGraphicsItem::ItemSceneHasChanged) |