emailuis/nmhswidget/src/nmhswidgetemailrow.cpp
changeset 65 478bc57ad291
parent 54 997a02608b3a
child 66 084b5b1f02a7
equal deleted inserted replaced
59:16ed8d08d0b1 65:478bc57ad291
    21 #include <hbextendedlocale.h>
    21 #include <hbextendedlocale.h>
    22 #include <hbframedrawer.h>
    22 #include <hbframedrawer.h>
    23 #include <hbframeitem.h>
    23 #include <hbframeitem.h>
    24 #include <hbcolorscheme.h>
    24 #include <hbcolorscheme.h>
    25 #include <hbevent.h>
    25 #include <hbevent.h>
       
    26 #include <hbtapgesture.h>
       
    27 #include <hbinstantfeedback.h>
    26 #include "nmicons.h"
    28 #include "nmicons.h"
    27 #include "nmcommon.h"
    29 #include "nmcommon.h"
    28 #include "nmhswidgetemailrow.h"
    30 #include "nmhswidgetemailrow.h"
    29 #include "nmhswidgetconsts.h"
    31 #include "nmhswidgetconsts.h"
    30 #include "emailtrace.h"
    32 #include "emailtrace.h"
    38     mSeparatorIcon(0), 
    40     mSeparatorIcon(0), 
    39     mMessageId(0),
    41     mMessageId(0),
    40     mBackgroundLayoutItem(0)
    42     mBackgroundLayoutItem(0)
    41 {
    43 {
    42     NM_FUNCTION;
    44     NM_FUNCTION;
       
    45     grabGesture(Qt::TapGesture);
    43 }
    46 }
    44 
    47 
    45 /*!
    48 /*!
    46  Destructor
    49  Destructor
    47  */
    50  */
   119         mSenderLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowSenderLabel));
   122         mSenderLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowSenderLabel));
   120         mSubjectLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowSubjectLabel));
   123         mSubjectLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowSubjectLabel));
   121         mTimeLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowTimeLabel));
   124         mTimeLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowTimeLabel));
   122     
   125     
   123         //icons
   126         //icons
   124         mNewMailIcon = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowNewMailIcon));
   127         mNewMailIcon = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetMailRowNewMailIcon));
   125         // KNmHsWidgetMailRowLeftIcon is not yet used, because followup information is not shown in client side
   128         // KNmHsWidgetMailRowLeftIcon is not yet used, because followup information is not shown in client side
   126         // and thus it is not wanted to be shown in widget side
   129         // and thus it is not wanted to be shown in widget side
   127         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowRightIcon)));
   130         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowRightIcon)));
   128         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowMiddleIcon)));
   131         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowMiddleIcon)));
   129         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowLeftIcon)));
   132         mStatusIcons.append(static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetMailRowLeftIcon)));
   238     NM_FUNCTION;
   241     NM_FUNCTION;
   239     //Set Date with locale support
   242     //Set Date with locale support
   240     //Time shown if message is sent today, otherwise show date
   243     //Time shown if message is sent today, otherwise show date
   241     HbExtendedLocale locale = HbExtendedLocale::system();
   244     HbExtendedLocale locale = HbExtendedLocale::system();
   242     QDateTime now = QDateTime::currentDateTime();
   245     QDateTime now = QDateTime::currentDateTime();
   243     if ( mMessageSentTime.date() == now.date() )
   246     //change time to locale time. mMessageSentTime is always in GMT
       
   247     QDateTime localTime = mMessageSentTime.addSecs(locale.universalTimeOffset());
       
   248     if ( localTime.date() == now.date() )
   244         {
   249         {
   245         //time format specification
   250         //time format specification
   246         QString timeSpec = r_qtn_time_usual;
   251         QString timeSpec = r_qtn_time_usual;
   247         mTimeLabel->setPlainText( locale.format(mMessageSentTime.time(), timeSpec) );
   252         mTimeLabel->setPlainText( locale.format(localTime.time(), timeSpec) );
   248         }
   253         }
   249     else
   254     else
   250         {
   255         {
   251         QString dateSpec = r_qtn_date_without_year;
   256         QString dateSpec = r_qtn_date_without_year;
   252         mTimeLabel->setPlainText( locale.format(mMessageSentTime.date(), dateSpec) );
   257         mTimeLabel->setPlainText( locale.format(localTime.date(), dateSpec) );
   253         }
   258         }
   254     }
   259     }
   255 
   260 
   256 /*!
   261 /*!
   257  hide icons from widget
   262  hide icons from widget
   378     else{
   383     else{
   379         mBackgroundLayoutItem->hide();
   384         mBackgroundLayoutItem->hide();
   380     }
   385     }
   381     }
   386     }
   382 
   387 
   383 /*!
   388 /*
   384  mousePressEvent(QGraphicsSceneMouseEvent *event)
   389  * NmHsWidgetEmailRow::gestureEvent(QGestureEvent *event)
   385  */
   390  */
   386 void NmHsWidgetEmailRow::mousePressEvent(QGraphicsSceneMouseEvent *event)
   391 void NmHsWidgetEmailRow::gestureEvent(QGestureEvent *event)
   387 {
   392 {
   388     NM_FUNCTION;
   393     NM_FUNCTION;
   389     Q_UNUSED(event); 
   394     if(!event){
   390     setHighlighedFontsColor(true);
   395         return;
   391     showHighlight(true);
   396     }
   392 }
   397     HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
   393 
   398     if(!gesture){
   394 /*!
   399         return;
   395     mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   400     }
   396 */
   401     switch (gesture->state()) {
   397 void NmHsWidgetEmailRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   402         case Qt::GestureStarted:
   398 {
   403             setHighlighedFontsColor(true);
   399     NM_FUNCTION;
   404             showHighlight(true);
   400     Q_UNUSED(event);
   405         break;
   401     setHighlighedFontsColor(false);
   406         case Qt::GestureCanceled:
   402     showHighlight(false);
   407             setHighlighedFontsColor(false);
   403     emit mailViewerLaunchTriggered(mMessageId);
   408             showHighlight(false);
       
   409         break;
       
   410         case Qt::GestureFinished:
       
   411             setHighlighedFontsColor(false);
       
   412             showHighlight(false);
       
   413             if (gesture->tapStyleHint() == HbTapGesture::Tap) {
       
   414                 HbInstantFeedback::play(HbFeedback::BasicItem);
       
   415                 emit mailViewerLaunchTriggered(mMessageId);
       
   416             }
       
   417         break;
       
   418     default: 
       
   419         break;
       
   420     }
   404 }
   421 }
   405 
   422 
   406 /*
   423 /*
   407  * NmHsWidgetEmailRow::event()
   424  * NmHsWidgetEmailRow::event()
   408  */
   425  */