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> |
|
23 |
22 |
24 #include <hbiconitem.h> |
23 #include <hbiconitem.h> |
25 #include <hbtextitem.h> |
24 #include <hbtextitem.h> |
26 #include <hbmarqueeitem.h> |
25 #include <hbmarqueeitem.h> |
27 #include <hbframedrawer.h> |
26 #include <hbframedrawer.h> |
28 #include <hbframeitem.h> |
27 #include <hbframeitem.h> |
29 #include <hbstyleloader.h> |
28 #include <hbstyleloader.h> |
30 #include <hbtoucharea.h> |
29 #include <hbtoucharea.h> |
31 #include <hbaction.h> |
30 #include <hbaction.h> |
32 #include <hbmainwindow.h> |
31 #include <hbmainwindow.h> |
|
32 #include <hbtapgesture.h> |
33 |
33 |
34 CntContactCardHeadingItem::CntContactCardHeadingItem(QGraphicsItem *parent) : |
34 CntContactCardHeadingItem::CntContactCardHeadingItem(QGraphicsItem *parent) : |
35 HbWidget(parent), |
35 HbWidget(parent), |
36 mIcon(NULL), |
36 mIcon(NULL), |
37 mSecondaryIcon(NULL), |
37 mSecondaryIcon(NULL), |
322 primaryText = nameList.join(" ").trimmed(); |
322 primaryText = nameList.join(" ").trimmed(); |
323 if (primaryText.isEmpty()) |
323 if (primaryText.isEmpty()) |
324 { |
324 { |
325 primaryText = hbTrId("txt_phob_list_unnamed"); |
325 primaryText = hbTrId("txt_phob_list_unnamed"); |
326 } |
326 } |
327 |
|
328 /* |
|
329 // prefix, first and middle |
|
330 QStringList firstNameList; |
|
331 firstNameList << name.prefix() << name.first() << name.middle(); |
|
332 firstLineText = firstNameList.join(" ").trimmed(); |
|
333 |
|
334 // last and suffix |
|
335 QStringList lastNameList; |
|
336 lastNameList << name.last() << name.suffix(); |
|
337 mSecondLineText = lastNameList.join(" ").trimmed(); |
|
338 */ |
|
339 } |
327 } |
340 |
328 |
341 // nick label |
329 // nick label |
342 if (isNickName(contact)) |
330 if (isNickName(contact)) |
343 { |
331 { |
381 void CntContactCardHeadingItem::processLongPress(const QPointF &point) |
369 void CntContactCardHeadingItem::processLongPress(const QPointF &point) |
382 { |
370 { |
383 emit passLongPressed(point); |
371 emit passLongPressed(point); |
384 } |
372 } |
385 |
373 |
|
374 void CntContactCardHeadingItem::processShortPress(const QPointF &point) |
|
375 { |
|
376 emit passShortPressed(point); |
|
377 } |
|
378 |
386 void CntContactCardHeadingItem::gestureEvent(QGestureEvent* event) |
379 void CntContactCardHeadingItem::gestureEvent(QGestureEvent* event) |
387 { |
380 { |
388 QGesture *tapAndHold = event->gesture(Qt::TapAndHoldGesture); |
381 |
389 if (tapAndHold && tapAndHold->state() == Qt::GestureFinished) { |
382 if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) |
390 processLongPress(static_cast<QTapAndHoldGesture *>(tapAndHold)->position()); |
383 { |
|
384 switch (tap->state()) |
|
385 { |
|
386 case Qt::GestureFinished: |
|
387 if (tap->tapStyleHint() == HbTapGesture::Tap && mIcon->rect().contains(mapFromScene(tap->position()))) |
|
388 { |
|
389 processShortPress(tap->position()); |
|
390 } |
|
391 break; |
|
392 case Qt::GestureUpdated: |
|
393 if (tap->tapStyleHint() == HbTapGesture::TapAndHold && mIcon->rect().contains(mapFromScene(tap->position()))) |
|
394 { |
|
395 processLongPress(tap->position()); |
|
396 } |
|
397 break; |
|
398 default: |
|
399 break; |
|
400 } |
|
401 event->accept(); |
|
402 } |
|
403 else |
|
404 { |
|
405 event->ignore(); |
391 } |
406 } |
392 } |
407 } |
393 |
408 |
394 void CntContactCardHeadingItem::initGesture() |
409 void CntContactCardHeadingItem::initGesture() |
395 { |
410 { |
396 grabGesture(Qt::TapAndHoldGesture); |
411 grabGesture(Qt::TapGesture); |
397 } |
412 } |
398 |
413 |
399 QVariant CntContactCardHeadingItem::itemChange(GraphicsItemChange change, const QVariant &value) |
414 QVariant CntContactCardHeadingItem::itemChange(GraphicsItemChange change, const QVariant &value) |
400 { |
415 { |
401 if (change == QGraphicsItem::ItemSceneHasChanged) |
416 if (change == QGraphicsItem::ItemSceneHasChanged) |
402 { |
417 { |
403 HbMainWindow *window = mainWindow(); |
418 HbMainWindow *window = mainWindow(); |
404 if (window) |
419 if (window) |
405 { |
420 { |