diff -r 36f374c67aa8 -r 12db4185673b messagingapp/msgui/msgapp/src/msglistviewitem.cpp --- a/messagingapp/msgui/msgapp/src/msglistviewitem.cpp Tue Jul 06 14:12:40 2010 +0300 +++ b/messagingapp/msgui/msgapp/src/msglistviewitem.cpp Wed Aug 18 09:45:25 2010 +0300 @@ -26,7 +26,10 @@ #include #include #include +#include #include +#include +#include #include "msgcommondefines.h" #include "conversationsengine.h" @@ -38,17 +41,22 @@ #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone") #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_list_message_sending_failed") #define LOC_MSG_OUTGOING hbTrId("txt_messaging_list_outgoing_message") -#define LOC_MSG_RESEND_AT hbTrId("Resend at ") +#define LOC_MSG_RESEND_AT hbTrId("txt_messaging_list_listview_resend_at_time") #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card") #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event") #define LOC_UNSUPPORTED_MSG_TYPE hbTrId("txt_messaging_list_unsupported_message_type") #define LOC_RECEIVED_FILES hbTrId("txt_messaging_list_received_files") +#define LOC_MULTIMEDIA_MSG hbTrId("txt_messaging_list_multimedia_message") const QString NEW_ITEM_FRAME("qtg_fr_list_new_item"); const QString BT_ICON("qtg_large_bluetooth"); const QString MSG_OUTGOING_ICON("qtg_mono_outbox"); const QString MSG_FAILED_ICON("qtg_mono_failed"); +// @see hbi18ndef.h +static const char DATE_FORMAT[] = r_qtn_date_short_with_zero; +static const char TIME_FORMAT[] = r_qtn_time_usual_with_zero; + //--------------------------------------------------------------- // MsgListViewItem::MsgListViewItem // Constructor @@ -61,7 +69,7 @@ mTimestampItem(NULL), mPreviewLabelItem(NULL), mUnreadCountItem(NULL), - mPresenceIndicatorItem(NULL) + mMsgCommonIndicatorItem(NULL) { } @@ -99,35 +107,6 @@ } mAddressLabelItem->setText(contactName); - // Unread message count - int unreadCount = modelIndex().data(UnreadCount).toInt(); - - if (unreadCount > 0) - { - QString unRead(tr("(%n)", "", unreadCount)); - mUnreadCountItem->setText(unRead); - if(!mUnReadMsg) - { - mUnReadMsg = true; - mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName(NEW_ITEM_FRAME); - repolish(); - // Needed for colour group changes to be visible - QCoreApplication::postEvent(this, new HbEvent(HbEvent::ThemeChanged)); - } - } - else - { - mUnreadCountItem->setText(QString()); - if(mUnReadMsg) - { - mUnReadMsg = false; - mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName(QString()); - repolish(); - // Needed for colour group changes to be visible - QCoreApplication::postEvent(this, new HbEvent(HbEvent::ThemeChanged)); - } - } - HbListViewItem::updateChildItems(); } @@ -151,8 +130,8 @@ HbStyle::setItemName(mPreviewLabelItem, "previewLabel"); } if (!mUnreadCountItem) { - mUnreadCountItem = new HbTextItem(this); - HbStyle::setItemName(mUnreadCountItem, "unreadCount"); + mUnreadCountItem = new HbTextItem(this); + HbStyle::setItemName(mUnreadCountItem, "unreadCount"); } if (!mNewMsgIndicatorItem) { mNewMsgIndicatorItem = new HbFrameItem(this); @@ -160,11 +139,19 @@ mNewMsgIndicatorItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical); } - if (!mPresenceIndicatorItem) { - mPresenceIndicatorItem = new HbIconItem(this); - HbStyle::setItemName(mPresenceIndicatorItem, "presenceIndicator"); + if (!mMsgCommonIndicatorItem) { + mMsgCommonIndicatorItem = new HbIconItem(this); + HbStyle::setItemName(mMsgCommonIndicatorItem, "msgCommonIndicator"); } + mUnreadCountItem->hide(); + mMsgCommonIndicatorItem->hide(); + + HbMainWindow *mainWindow = hbInstance->allMainWindows()[0]; + + connect(mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, + SLOT(orientationchanged(Qt::Orientation)), Qt::UniqueConnection); } + //--------------------------------------------------------------- // MsgListViewItem::defaultPreviewText // @see header @@ -193,8 +180,6 @@ else { previewText = LOC_UNSUPPORTED_MSG_TYPE; } - - mPresenceIndicatorItem->setVisible(false); } else if (msgType == ConvergedMessage::BT) { @@ -206,14 +191,15 @@ else { previewText = bodyText; } - - mPresenceIndicatorItem->setIconName(BT_ICON); - mPresenceIndicatorItem->setVisible(true); + + setCommonIndicator(BT_ICON); } else { // All message types except BIO & BT. previewText = modelIndex().data(BodyText).toString(); - mPresenceIndicatorItem->setVisible(false); + if (previewText.isEmpty() && ConvergedMessage::Mms == msgType) { + previewText = LOC_MULTIMEDIA_MSG; + } } return previewText; } @@ -228,12 +214,14 @@ // Get timestamp QDateTime dateTime; dateTime.setTime_t(modelIndex().data(TimeStamp).toUInt()); - QString dateString; + + HbExtendedLocale locale = HbExtendedLocale::system(); + QString dateTimeString; if (dateTime.date() == QDateTime::currentDateTime().date()) { - dateString = MsgUtils::dateTimeToString(dateTime, TIME_FORMAT); + dateTimeString = locale.format(dateTime.time(), TIME_FORMAT); } else { - dateString = MsgUtils::dateTimeToString(dateTime, DATE_FORMAT); + dateTimeString = locale.format(dateTime.date(), DATE_FORMAT); } // Set preview text & time based on direction @@ -243,17 +231,22 @@ int msgDirection = modelIndex().data(Direction).toInt(); QString previewText; if (ConvergedMessage::Incoming == msgDirection) { - previewText = defaultPreviewText(msgType, msgSubType); + if( ConvergedMessage::BT != msgType) + { + setUnreadCountStatus(); + } + previewText = defaultPreviewText(msgType, msgSubType); } else if (msgDirection == ConvergedMessage::Outgoing) { - + + setUnreadCountStatus(); + switch (sendState) { case ConvergedMessage::Resend: { - previewText = LOC_MSG_RESEND_AT + dateString; - dateString = QString(); - mPresenceIndicatorItem->setIconName(MSG_OUTGOING_ICON); - mPresenceIndicatorItem->setVisible(true); + previewText = LOC_MSG_RESEND_AT + dateTimeString; + dateTimeString = QString(); + setCommonIndicator(MSG_OUTGOING_ICON); break; } case ConvergedMessage::Sending: @@ -261,21 +254,24 @@ case ConvergedMessage::Scheduled: case ConvergedMessage::Waiting: { - previewText = QString(LOC_MSG_OUTGOING); - mPresenceIndicatorItem->setIconName(MSG_OUTGOING_ICON); - mPresenceIndicatorItem->setVisible(true); + previewText = QString(LOC_MSG_OUTGOING); + setCommonIndicator(MSG_OUTGOING_ICON); break; } case ConvergedMessage::Failed: { previewText = QString(LOC_MSG_SEND_FAILED); - mPresenceIndicatorItem->setIconName(MSG_FAILED_ICON); - mPresenceIndicatorItem->setVisible(true); + setCommonIndicator(MSG_FAILED_ICON); break; } default: { - // Successful case + // Successful case + if( ConvergedMessage::BT != msgType) + { + setUnreadCountStatus(); + } + previewText = defaultPreviewText(msgType, msgSubType); break; } @@ -284,7 +280,7 @@ previewText.replace(QChar::ParagraphSeparator, QChar::LineSeparator); previewText.replace('\r', QChar::LineSeparator); mPreviewLabelItem->setText(previewText); - mTimestampItem->setText(dateString); + mTimestampItem->setText(dateTimeString); } //--------------------------------------------------------------- @@ -317,4 +313,68 @@ return mUnReadMsg; } +//--------------------------------------------------------------- +// MsgListViewItem::setUnreadCountStatus +// @see header file +//--------------------------------------------------------------- +void MsgListViewItem::setUnreadCountStatus() + { + // Unread message count + int unreadCount = modelIndex().data(UnreadCount).toInt(); + + if (unreadCount > 0) + { + QString unRead(tr("(%n)", "", unreadCount)); + + mMsgCommonIndicatorItem->hide(); + mUnreadCountItem->setText(unRead); + mUnreadCountItem->show(); + + if (!mUnReadMsg) + { + mUnReadMsg = true; + mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName( + NEW_ITEM_FRAME); + repolish(); + // Needed for colour group changes to be visible + QCoreApplication::postEvent(this, new HbEvent( + HbEvent::ThemeChanged)); + } + } + else + { + if (mUnReadMsg) + { + mUnReadMsg = false; + mNewMsgIndicatorItem->frameDrawer().setFrameGraphicsName( + QString()); + repolish(); + // Needed for colour group changes to be visible + QCoreApplication::postEvent(this, new HbEvent( + HbEvent::ThemeChanged)); + } + } + } + +//--------------------------------------------------------------- +// MsgListViewItem::setCommonIndicator +// @see header file +//--------------------------------------------------------------- +void MsgListViewItem::setCommonIndicator(const QString& string) + { + mUnreadCountItem->hide(); + mMsgCommonIndicatorItem->setIconName(string); + mMsgCommonIndicatorItem->show(); + } + +//--------------------------------------------------------------- +// MsgListViewItem::orientationchanged +// @see header file +//--------------------------------------------------------------- +void MsgListViewItem::orientationchanged(Qt::Orientation orientation) +{ + Q_UNUSED(orientation) + repolish(); +} + //EOF