camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeviewfindercontrol.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     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 #include "cxefakeviewfindercontrol.h"
       
    19 #include "cxesettings.h"
       
    20 #include "cxesettingsmappersymbian.h"
       
    21 #include "cxutils.h"
       
    22 #include "cxestate.h"
       
    23 
       
    24 CxeFakeViewfinderControl::CxeFakeViewfinderControl()
       
    25     : CxeStateMachine("CxeFakeViewfinderControl")
       
    26 {
       
    27     CX_DEBUG_ENTER_FUNCTION();
       
    28 
       
    29     initializeStates();
       
    30 
       
    31     CX_DEBUG_EXIT_FUNCTION();
       
    32 }
       
    33 
       
    34 CxeFakeViewfinderControl::~CxeFakeViewfinderControl()
       
    35 {
       
    36     CX_DEBUG_ENTER_FUNCTION();
       
    37 
       
    38     stop();
       
    39 
       
    40     CX_DEBUG_EXIT_FUNCTION();
       
    41 }
       
    42 
       
    43 void CxeFakeViewfinderControl::setWindow(WId /*windowId*/)
       
    44 {
       
    45     CX_DEBUG_IN_FUNCTION();
       
    46     mCallHistory.append(SetWindow);
       
    47 }
       
    48 
       
    49 void CxeFakeViewfinderControl::stop()
       
    50 {
       
    51     CX_DEBUG_ENTER_FUNCTION();
       
    52 
       
    53     setState(Ready);
       
    54     mCallHistory.append(Stop);
       
    55 
       
    56     CX_DEBUG_EXIT_FUNCTION();
       
    57 }
       
    58 
       
    59 CxeError::Id CxeFakeViewfinderControl::start()
       
    60 {
       
    61     CX_DEBUG_ENTER_FUNCTION();
       
    62 
       
    63     mCallHistory.append(Start);
       
    64     setState(Running);
       
    65 
       
    66     CX_DEBUG_EXIT_FUNCTION();
       
    67     return CxeError::None;
       
    68 }
       
    69 
       
    70 CxeViewfinderControl::State CxeFakeViewfinderControl::state() const
       
    71 {
       
    72     return static_cast<State>(stateId());
       
    73 }
       
    74 
       
    75 void CxeFakeViewfinderControl::setState(CxeViewfinderControl::State newState)
       
    76 {
       
    77     CxeStateMachine::setState(newState, CxeError::None);
       
    78 }
       
    79 
       
    80 void CxeFakeViewfinderControl::handleStateChanged(int newStateId, CxeError::Id error)
       
    81 {
       
    82     emit stateChanged(static_cast<State>(newStateId), error);
       
    83 }
       
    84 
       
    85 void CxeFakeViewfinderControl::initializeStates()
       
    86 {
       
    87     // The fake state machine has more relaxed state transition checks
       
    88     // for testing purposes.
       
    89     int anyState = (Uninitialized | Ready | Running);
       
    90 
       
    91     // addState( id, name, allowed next states )
       
    92     addState(new CxeState(Uninitialized , "Uninitialized", anyState));
       
    93     addState(new CxeState(Ready , "Ready", anyState));
       
    94     addState(new CxeState(Running , "Running", anyState));
       
    95 
       
    96     setInitialState(Uninitialized);
       
    97 }
       
    98 
       
    99 QList<CxeFakeViewfinderControl::MethodIndex> CxeFakeViewfinderControl::callHistory() const
       
   100 {
       
   101     return mCallHistory;
       
   102 }
       
   103 
       
   104 void CxeFakeViewfinderControl::resetCallHistory()
       
   105 {
       
   106     mCallHistory.clear();
       
   107 }
       
   108 
       
   109 
       
   110 /*!
       
   111 * Returns Device's Display resolution
       
   112 */
       
   113 QSize CxeFakeViewfinderControl::deviceDisplayResolution() const
       
   114 {
       
   115     return QSize(640, 360);
       
   116 }
       
   117 
       
   118 // end of file