emailuis/nmindicatorplugin/src/nmsendingindicator.cpp
branchGCC_SURGE
changeset 55 cdd802add233
parent 54 997a02608b3a
child 57 ae34e1715e21
equal deleted inserted replaced
28:011f79704660 55:cdd802add233
       
     1 /*
       
     2  * Copyright (c) 2010 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 #include "nmsendingindicator.h"
       
    18 #include <QTimer>
       
    19 #include <nmcommon.h>
       
    20 
       
    21 const int NmSendingStateDelay = 2000; // delay for 'send in progress' indicator
       
    22 
       
    23 /*!
       
    24     \class NmSendingIndicator
       
    25     \brief Handles sending progress indicator
       
    26 */
       
    27 
       
    28 /*!
       
    29      Class constructor.
       
    30 */
       
    31 NmSendingIndicator::NmSendingIndicator(const QString &indicatorType)
       
    32 :HbIndicatorInterface(indicatorType,
       
    33         HbIndicatorInterface::ProgressCategory,
       
    34         HbIndicatorInterface::NoInteraction)
       
    35 {
       
    36 }
       
    37 
       
    38 /*!
       
    39     Class destructor.
       
    40 */
       
    41 NmSendingIndicator::~NmSendingIndicator()
       
    42 {
       
    43 }
       
    44 
       
    45 /*!
       
    46     \fn QVariant HbIndicatorInterface::indicatorData(int role) const = 0
       
    47 
       
    48     No texts or icons show by this indicator
       
    49 */
       
    50 QVariant NmSendingIndicator::indicatorData(int role) const
       
    51 {
       
    52     if (role==DecorationNameRole) {
       
    53 		// Must return non-empty to make the indicator visible
       
    54 		return " ";
       
    55 	}
       
    56 
       
    57     return QVariant();
       
    58 }
       
    59 
       
    60 /*!
       
    61     Timer callback for hiding 'send in progress' indicator
       
    62 */
       
    63 void NmSendingIndicator::hideSendIndicator()
       
    64 {
       
    65     NM_FUNCTION;
       
    66     emit deactivate();
       
    67 }
       
    68 
       
    69 /*!
       
    70     Handles the requests sent from the client
       
    71     \a type is a type of the request.
       
    72     \a parameter is extra parameter from the client. Can be invalid, if not given.
       
    73 
       
    74     Should return true, when the request is handled.
       
    75     Default implementation returns false.
       
    76 
       
    77     \sa RequestType, HbIndicator
       
    78 */
       
    79 bool NmSendingIndicator::handleClientRequest( RequestType type,
       
    80         const QVariant &parameter)
       
    81 {
       
    82     NM_FUNCTION;
       
    83     Q_UNUSED(parameter);
       
    84 
       
    85     switch (type) {
       
    86         case RequestActivate:
       
    87             {
       
    88             // Hide the progress state after some delay
       
    89             QTimer::singleShot(NmSendingStateDelay, this, SLOT(hideSendIndicator()));
       
    90             }
       
    91             break;
       
    92         default:
       
    93             break;
       
    94     }
       
    95     return false;
       
    96 }