camerauis/cameraxui/cxui/src/cxuiscenelabel.cpp
changeset 46 c826656d6714
parent 42 feebad15db8c
child 52 7e18d488ac5f
equal deleted inserted replaced
42:feebad15db8c 46:c826656d6714
     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 "cxuiscenelabel.h"
       
    19 #include "cxeengine.h"
       
    20 #include "cxesettings.h"
       
    21 #include "cxutils.h"
       
    22 
       
    23 CxuiSceneLabel::CxuiSceneLabel(QGraphicsItem *parent, CxeEngine *engine)
       
    24 : HbLabel(parent), mSettingId(), mItemValues(), mItems(), mEngine(engine)
       
    25 {
       
    26     CX_ASSERT_ALWAYS(engine);
       
    27 }
       
    28 
       
    29 QStringList CxuiSceneLabel::itemValues() const
       
    30 {
       
    31     return mItemValues;
       
    32 }
       
    33 
       
    34 void CxuiSceneLabel::setItemValues(const QStringList &values)
       
    35 {
       
    36     CX_DEBUG_ENTER_FUNCTION();
       
    37     mItemValues = values;
       
    38     CX_DEBUG_EXIT_FUNCTION();
       
    39 }
       
    40 
       
    41 QStringList CxuiSceneLabel::items() const
       
    42 {
       
    43     return mItems;
       
    44 }
       
    45 
       
    46 void CxuiSceneLabel::setItems(const QStringList &values)
       
    47 {
       
    48     CX_DEBUG_ENTER_FUNCTION();
       
    49     mItems = values;
       
    50     CX_DEBUG_EXIT_FUNCTION();
       
    51 }
       
    52 
       
    53 QString CxuiSceneLabel::settingId() const
       
    54 {
       
    55     return mSettingId;
       
    56 }
       
    57 
       
    58 void CxuiSceneLabel::setSettingId(const QString &id)
       
    59 {
       
    60     CX_DEBUG_ENTER_FUNCTION();
       
    61     mSettingId = id;
       
    62     setSceneIcon();
       
    63     CX_DEBUG_EXIT_FUNCTION();
       
    64 }
       
    65 
       
    66 void CxuiSceneLabel::setSceneIcon()
       
    67 {
       
    68     CX_DEBUG_ENTER_FUNCTION();
       
    69 
       
    70     QString scenevalue;
       
    71     if (!mSettingId.isEmpty() && !mItems.isEmpty() && !mItemValues.isEmpty()) {
       
    72         int err = mEngine->settings().get(mSettingId, scenevalue);
       
    73         int index = mItemValues.indexOf(scenevalue);
       
    74         CX_DEBUG((("err: %d index: %d"),err,index));
       
    75         setIcon(HbIcon(mItems.at(index)));
       
    76     }
       
    77 
       
    78     CX_DEBUG_EXIT_FUNCTION();
       
    79 }
       
    80 
       
    81 void CxuiSceneLabel::changeIcon(int index)
       
    82 {
       
    83     CX_DEBUG_ENTER_FUNCTION();
       
    84     if (!mItems.isEmpty()) {
       
    85         setIcon(HbIcon(mItems.at(index)));
       
    86     }
       
    87     CX_DEBUG_EXIT_FUNCTION();
       
    88 }
       
    89