phonebookui/pbkcommonui/src/cntcontactcardheadingitem.cpp
changeset 50 77bc263e1626
parent 47 7cbcb2896f0e
child 61 d30183af6ca6
equal deleted inserted replaced
49:74b30151afd6 50:77bc263e1626
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cntcontactcardheadingitem.h"
    18 #include "cntcontactcardheadingitem.h"
       
    19 #include "cntdebug.h"
    19 
    20 
    20 #include <qtcontacts.h>
    21 #include <qtcontacts.h>
    21 #include <QGraphicsSceneMouseEvent>
    22 #include <QGraphicsSceneMouseEvent>
    22 
    23 
    23 #include <hbiconitem.h>
    24 #include <hbiconitem.h>
    28 #include <hbstyleloader.h>
    29 #include <hbstyleloader.h>
    29 #include <hbtoucharea.h>
    30 #include <hbtoucharea.h>
    30 #include <hbaction.h>
    31 #include <hbaction.h>
    31 #include <hbmainwindow.h>
    32 #include <hbmainwindow.h>
    32 #include <hbtapgesture.h>
    33 #include <hbtapgesture.h>
       
    34 #include <hbeffect.h>
       
    35 #include <hbinstantfeedback.h>
    33 #include <cntuids.h>
    36 #include <cntuids.h>
    34 #include <xqsettingsmanager.h>
    37 #include <xqsettingsmanager.h>
    35 #include <xqsettingskey.h>
    38 #include <xqsettingskey.h>
    36 
    39 
    37 CntContactCardHeadingItem::CntContactCardHeadingItem(QGraphicsItem *parent) :
    40 CntContactCardHeadingItem::CntContactCardHeadingItem(QGraphicsItem *parent) :
    46     mFrameItem(NULL),
    49     mFrameItem(NULL),
    47     mPictureArea(NULL),
    50     mPictureArea(NULL),
    48     mIsFavorite(false),
    51     mIsFavorite(false),
    49     mIsOnline(false)
    52     mIsOnline(false)
    50 {
    53 {
       
    54     HbEffect::add("icon", "groupbox_icon_click", "iconclick");
    51 }
    55 }
    52 
    56 
    53 CntContactCardHeadingItem::~CntContactCardHeadingItem()
    57 CntContactCardHeadingItem::~CntContactCardHeadingItem()
    54 {
    58 {
    55 
    59 
   196     }
   200     }
   197 
   201 
   198     if (!mFrameItem)
   202     if (!mFrameItem)
   199     {
   203     {
   200         mFrameItem = new HbFrameItem(this);
   204         mFrameItem = new HbFrameItem(this);
   201         mFrameItem->frameDrawer().setFrameGraphicsName("qtg_fr_groupbox");
   205         mFrameItem->frameDrawer().setFrameGraphicsName("qtg_fr_groupbox_normal");
   202         mFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   206         mFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   203         mFrameItem->setZValue(-2);
   207         mFrameItem->setZValue(-2);
   204         style()->setItemName(mFrameItem, "background");
   208         style()->setItemName(mFrameItem, "background");
   205     }
   209     }
   206     
   210     
   211     }
   215     }
   212 
   216 
   213     if ( mainWindow()->orientation() != Qt::Horizontal)
   217     if ( mainWindow()->orientation() != Qt::Horizontal)
   214     {
   218     {
   215         initGesture();
   219         initGesture();
       
   220     }
       
   221     else
       
   222     {
       
   223         ungrabGesture(Qt::TapGesture);
   216     }
   224     }
   217 }
   225 }
   218 
   226 
   219 void CntContactCardHeadingItem::setIcon(const HbIcon newIcon)
   227 void CntContactCardHeadingItem::setIcon(const HbIcon newIcon)
   220 {
   228 {
   352                              KCRCntSettings.iUid,
   360                              KCRCntSettings.iUid,
   353                              KCntNameOrdering);
   361                              KCntNameOrdering);
   354     int setting = settingsMng.readItemValue(nameOrderKey, XQSettingsManager::TypeInt).toInt();
   362     int setting = settingsMng.readItemValue(nameOrderKey, XQSettingsManager::TypeInt).toInt();
   355     
   363     
   356     QStringList nameList;
   364     QStringList nameList;
   357     QString last;
   365     QString last_first;
   358     
   366     
   359     switch( setting ) {
   367     switch( setting ) {
   360         case CntOrderLastFirst:
   368         case CntOrderLastFirst:
   361             nameList << name.prefix() << name.lastName() << name.firstName() << name.middleName() << name.suffix();
   369             nameList << name.prefix() << name.lastName() << name.firstName() << name.middleName() << name.suffix();
   362             break;
   370             break;
   363         case CntOrderLastCommaFirst:
   371         case CntOrderLastCommaFirst:
   364             if (!name.lastName().isEmpty())
   372             if (!name.firstName().isEmpty() && !name.lastName().isEmpty())
   365                 last = name.lastName() + ",";
   373                 last_first = name.lastName() + ", " + name.firstName();
   366             nameList << name.prefix() << last << name.firstName() << name.middleName() << name.suffix();
   374             else
       
   375                 last_first = !name.firstName().isEmpty() ? name.firstName() : name.lastName();
       
   376             nameList << name.prefix() << last_first << name.middleName() << name.suffix();
   367             break;
   377             break;
   368         default:    // Default to first name last name
   378         default:    // Default to first name last name
   369             nameList << name.prefix() << name.firstName() << name.middleName() << name.lastName() << name.suffix();
   379             nameList << name.prefix() << name.firstName() << name.middleName() << name.lastName() << name.suffix();
   370             break;
   380             break;
   371     }
   381     }
   430                 }
   440                 }
   431                 break;
   441                 break;
   432             case Qt::GestureUpdated:
   442             case Qt::GestureUpdated:
   433                 if (tap->tapStyleHint() == HbTapGesture::TapAndHold && mIcon->rect().contains(mapFromScene(tap->position()))) 
   443                 if (tap->tapStyleHint() == HbTapGesture::TapAndHold && mIcon->rect().contains(mapFromScene(tap->position()))) 
   434                 {
   444                 {
       
   445                     HbEffect::cancel(mIcon, QString("iconclick"));
   435                     processLongPress(tap->position());
   446                     processLongPress(tap->position());
   436                 }
   447                 }
   437                 break;
   448                 break;
       
   449             case Qt::GestureStarted:
       
   450                 if (tap->tapStyleHint() == HbTapGesture::Tap && mIcon->rect().contains(mapFromScene(tap->position())))
       
   451                 {
       
   452                     HbInstantFeedback::play(HbFeedback::Basic);
       
   453                     HbEffect::start(mIcon, QString("icon"), QString("iconclick"));
       
   454                 }
       
   455                 
   438             default:
   456             default:
   439                 break;
   457                 break;
   440         }
   458         }
   441         event->accept();
   459         event->accept();
   442     } 
   460     }