--- a/phonebookui/pbkcommonui/src/cntcontactcardheadingitem.cpp Fri Jun 11 13:29:23 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntcontactcardheadingitem.cpp Wed Jun 23 18:02:44 2010 +0300
@@ -30,6 +30,9 @@
#include <hbaction.h>
#include <hbmainwindow.h>
#include <hbtapgesture.h>
+#include <cntuids.h>
+#include <xqsettingsmanager.h>
+#include <xqsettingskey.h>
CntContactCardHeadingItem::CntContactCardHeadingItem(QGraphicsItem *parent) :
HbWidget(parent),
@@ -41,7 +44,9 @@
mSecondaryText(NULL),
mMarqueeItem(NULL),
mFrameItem(NULL),
- mPictureArea(NULL)
+ mPictureArea(NULL),
+ mIsFavorite(false),
+ mIsOnline(false)
{
}
@@ -71,22 +76,22 @@
}
if (!secondaryIcon.isNull())
+ {
+ if (!mSecondaryIcon)
{
- if (!mSecondaryIcon)
- {
- mSecondaryIcon = new HbIconItem(this);
- mSecondaryIcon->setIcon(secondaryIcon);
- style()->setItemName(mSecondaryIcon, "secondary_icon");
- }
+ mSecondaryIcon = new HbIconItem(this);
+ mSecondaryIcon->setIcon(secondaryIcon);
+ style()->setItemName(mSecondaryIcon, "secondary_icon");
}
- else
+ }
+ else
+ {
+ if (mSecondaryIcon)
{
- if (mSecondaryIcon)
- {
- delete mSecondaryIcon;
- }
- mSecondaryIcon = 0;
+ delete mSecondaryIcon;
}
+ mSecondaryIcon = 0;
+ }
if (!firstLineText.isNull())
{
@@ -95,6 +100,7 @@
mFirstLineText = new HbTextItem(this);
mFirstLineText->setText(firstLineText);
mFirstLineText->setMaximumLines(1);
+ mFirstLineText->setElideMode(Qt::ElideRight);
style()->setItemName(mFirstLineText, "first_line_text");
}
}
@@ -115,6 +121,7 @@
mPrimaryText->setText(primaryText);
mPrimaryText->setMaximumLines(2);
mPrimaryText->setTextWrapping(Hb::TextWordWrap);
+ mPrimaryText->setElideMode(Qt::ElideRight);
style()->setItemName(mPrimaryText, "primary_text");
}
}
@@ -222,22 +229,17 @@
}
}
-void CntContactCardHeadingItem::setSecondaryIcon(bool favoriteContact)
+void CntContactCardHeadingItem::setFavoriteStatus(bool favoriteContact)
{
- secondaryIcon.clear();
-
- if (favoriteContact)
+ if (favoriteContact != mIsFavorite)
{
- secondaryIcon = HbIcon("qtg_small_favorite");
- createPrimitives();
- mSecondaryIcon->setIcon(secondaryIcon);
+ mIsFavorite = favoriteContact;
+
+ if (!mIsOnline)
+ {
+ setSecondaryIcon();
+ }
}
- else
- {
- createPrimitives();
- }
- repolish();
-
}
void CntContactCardHeadingItem::recreatePrimitives()
@@ -299,6 +301,7 @@
secondaryText.clear();
icon.clear();
tinyMarqueeText.clear();
+ secondaryIcon.clear();
// icon label
icon = HbIcon("qtg_large_add_contact_picture");
@@ -308,10 +311,7 @@
// name label
if (isNickName(contact) || isCompanyName(contact))
{
- // prefix, first, middle, last and suffix
- QStringList nameList;
- nameList << name.prefix() << name.firstName() << name.middleName() << name.lastName() << name.suffix();
- firstLineText = nameList.join(" ").trimmed();
+ firstLineText = createNameText(name);
if (firstLineText.isEmpty())
{
firstLineText = hbTrId("txt_phob_list_unnamed");
@@ -319,10 +319,7 @@
}
else
{
- // prefix, first, middle, last and suffix
- QStringList nameList;
- nameList << name.prefix() << name.firstName() << name.middleName() << name.lastName() << name.suffix();
- primaryText = nameList.join(" ").trimmed();
+ primaryText = createNameText(name);
if (primaryText.isEmpty())
{
primaryText = hbTrId("txt_phob_list_unnamed");
@@ -347,6 +344,35 @@
recreatePrimitives();
}
+QString CntContactCardHeadingItem::createNameText(const QContactName name)
+{
+ XQSettingsManager settingsMng;
+ XQSettingsKey nameOrderKey(XQSettingsKey::TargetCentralRepository,
+ KCRUiContacts.iUid,
+ KCntNameOrdering);
+ int setting = settingsMng.readItemValue(nameOrderKey, XQSettingsManager::TypeInt).toInt();
+
+ QStringList nameList;
+ QString last;
+
+ switch( setting ) {
+ case CntOrderLastFirst:
+ nameList << name.prefix() << name.lastName() << name.firstName() << name.middleName() << name.suffix();
+ break;
+ case CntOrderLastCommaFirst:
+ if (!name.lastName().isEmpty())
+ last = name.lastName() + ",";
+ nameList << name.prefix() << last << name.firstName() << name.middleName() << name.suffix();
+ break;
+ default: // Default to first name last name
+ nameList << name.prefix() << name.firstName() << name.middleName() << name.lastName() << name.suffix();
+ break;
+ }
+
+ nameList.removeAll("");
+ return nameList.join(" ").trimmed();
+}
+
void CntContactCardHeadingItem::setGroupDetails(const QContact* contact)
{
firstLineText.clear();
@@ -379,6 +405,16 @@
emit passShortPressed(point);
}
+void CntContactCardHeadingItem::setOnlineStatus(bool online)
+{
+ if (online != mIsOnline)
+ {
+ mIsOnline = online;
+
+ setSecondaryIcon();
+ }
+}
+
void CntContactCardHeadingItem::gestureEvent(QGestureEvent* event)
{
@@ -409,11 +445,6 @@
}
}
-void CntContactCardHeadingItem::initGesture()
-{
- grabGesture(Qt::TapGesture);
-}
-
QVariant CntContactCardHeadingItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSceneHasChanged)
@@ -438,6 +469,32 @@
repolish();
}
+void CntContactCardHeadingItem::initGesture()
+{
+ grabGesture(Qt::TapGesture);
+}
+
+void CntContactCardHeadingItem::setSecondaryIcon()
+{
+ if (mIsOnline)
+ {
+ secondaryIcon = HbIcon("qtg_small_online");
+ createPrimitives();
+ mSecondaryIcon->setIcon(secondaryIcon);
+ }
+ else if (!mIsOnline && mIsFavorite)
+ {
+ secondaryIcon = HbIcon("qtg_small_favorite");
+ createPrimitives();
+ mSecondaryIcon->setIcon(secondaryIcon);
+ }
+ else
+ {
+ secondaryIcon.clear();
+ createPrimitives();
+ }
+
+ repolish();
+}
// EOF
-