messagingapp/msgui/unifiededitor/src/msgtypenotifier.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDES
       
    19 #include "debugtraces.h"
       
    20 //#include <HbDeviceNotificationDialog>
       
    21 #include <HbNotificationDialog>
       
    22 
       
    23 // USER INCLUDES
       
    24 #include "msgtypenotifier.h"
       
    25 
       
    26 // Constants
       
    27 
       
    28 //Localized strings
       
    29 #define LOC_POP_MESSAGE_CHANGE_MUL hbTrId("txt_messaging_dpopinfo_message_type_changed_to_mul")
       
    30 #define LOC_POP_MESSAGE_CHANGE_TEXT hbTrId("txt_messaging_dpopinfo_message_type_changed_to_tex")
       
    31 
       
    32 //---------------------------------------------------------------
       
    33 // MsgTypeNotifier::MsgTypeNotifier
       
    34 // @see header file
       
    35 //---------------------------------------------------------------
       
    36 MsgTypeNotifier::MsgTypeNotifier(QObject* parent) :
       
    37 QObject(parent),
       
    38 mmContentCount(0),
       
    39 mSkipNote(false)
       
    40 {
       
    41     // do nothing
       
    42 }
       
    43 
       
    44 //---------------------------------------------------------------
       
    45 // MsgTypeNotifier::~MsgTypeNotifier
       
    46 // @see header file
       
    47 //---------------------------------------------------------------
       
    48 MsgTypeNotifier::~MsgTypeNotifier()
       
    49 {
       
    50     // do nothing
       
    51 }
       
    52 
       
    53 //---------------------------------------------------------------
       
    54 // MsgTypeNotifier::messageType
       
    55 // @see header file
       
    56 //---------------------------------------------------------------
       
    57 ConvergedMessage::MessageType MsgTypeNotifier::messageType() const
       
    58 {
       
    59     ConvergedMessage::MessageType msgtype = ConvergedMessage::None;
       
    60     if(mmContentCount)
       
    61     {
       
    62         msgtype = ConvergedMessage::Mms;
       
    63 	}
       
    64 	else
       
    65 	{
       
    66         msgtype = ConvergedMessage::Sms;
       
    67 	}
       
    68 
       
    69     return msgtype;
       
    70 }
       
    71 
       
    72 //---------------------------------------------------------------
       
    73 // MsgTypeNotifier::onMMContentAdded
       
    74 // @see header file
       
    75 //---------------------------------------------------------------
       
    76 void MsgTypeNotifier::onMMContentAdded(bool isAdded)
       
    77 {    if(isAdded)
       
    78         {
       
    79         mmContentCount++;
       
    80         if(mmContentCount == 1)
       
    81             {
       
    82             showPopup(LOC_POP_MESSAGE_CHANGE_MUL);
       
    83             }
       
    84         }
       
    85     else
       
    86         {
       
    87         mmContentCount--;
       
    88         if(mmContentCount == 0)
       
    89             {
       
    90             showPopup(LOC_POP_MESSAGE_CHANGE_TEXT);
       
    91             }
       
    92         
       
    93         Q_ASSERT(mmContentCount >= 0);
       
    94         }
       
    95 }
       
    96 
       
    97 void MsgTypeNotifier::showPopup(const QString& text)
       
    98 {
       
    99     if(!mSkipNote)
       
   100     {
       
   101         HbNotificationDialog* dlg = new HbNotificationDialog();
       
   102         dlg->setFocusPolicy(Qt::NoFocus);
       
   103         dlg->setAttribute(Qt::WA_DeleteOnClose, true);
       
   104         dlg->setText(text);
       
   105         dlg->show();
       
   106     }
       
   107     // reset skip note flag
       
   108     mSkipNote = false;
       
   109 }
       
   110 
       
   111 void MsgTypeNotifier::setSkipNote()
       
   112 {
       
   113     mSkipNote = true;
       
   114 }
       
   115 
       
   116 //EOF