controlpanelplugins/themeplugin/src/cpthemepluginentryitemdata.cpp
branchRCL_3
changeset 13 90fe62538f66
equal deleted inserted replaced
12:3fec62e6e7fc 13:90fe62538f66
       
     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 <hbdataform.h>
       
    19 #include <hbiconitem.h>
       
    20 
       
    21 #include <cpbasesettingview.h>
       
    22 #include "cpthemecontrol.h"
       
    23 #include "cpthemepluginentryitemdata.h"
       
    24 #include <cpitemdatahelper.h>
       
    25 
       
    26 /*!
       
    27     \class CpThemePluginEntryItemData
       
    28     \brief CpThemePluginEntryItemData is the entry item view for Theme Changer plugin.  It displays a title "Theme",
       
    29     the name of current theme and the preview icon of the current theme.
       
    30 
       
    31 */
       
    32 
       
    33 /*!
       
    34     constructor.
       
    35 */
       
    36 CpThemePluginEntryItemData::CpThemePluginEntryItemData(CpItemDataHelper &itemDataHelper,
       
    37                                             const QString &text,
       
    38                                             const QString &description,
       
    39                                             const HbIcon &icon,
       
    40                                             const HbDataFormModelItem *parent) :
       
    41                                         CpSettingFormEntryItemData(itemDataHelper,
       
    42                                                                    text,
       
    43                                                                    description,
       
    44                                                                    icon,
       
    45                                                                    parent)
       
    46 {
       
    47     //Create a CpThemeControl. the themeControl takes care of displaying the themes
       
    48     //and letting user select a theme and apply a theme change.
       
    49     mThemeControl = new CpThemeControl();
       
    50     
       
    51     setEntryItemIcon(mThemeControl->currentThemeIcon());
       
    52     setDescription(mThemeControl->currentThemeName());
       
    53 
       
    54     //connect to signal to update the current theme name and icon whenever the theme changes.
       
    55     QObject::connect(mThemeControl, SIGNAL(themeUpdated(const QString&, const HbIcon&)), this, 
       
    56                             SLOT(themeUpdated(const QString&, const HbIcon&)));
       
    57 }
       
    58 
       
    59 /*!
       
    60     destructor.
       
    61 */
       
    62 CpThemePluginEntryItemData::~CpThemePluginEntryItemData()
       
    63 {
       
    64     delete mThemeControl;
       
    65     mThemeControl = 0;
       
    66 }
       
    67 
       
    68 /*!
       
    69     Slot used for updating entry item's description and icon with current theme name and its 
       
    70     preview icon.
       
    71  */
       
    72 void CpThemePluginEntryItemData::themeUpdated(const QString& themeName, const HbIcon& icon)
       
    73 {
       
    74     setEntryItemIcon(icon);
       
    75     setDescription(themeName);
       
    76 }
       
    77 
       
    78 /*!
       
    79     Return the theme changer UI view.  Returns 0 if it can't create
       
    80     the view.
       
    81 */
       
    82 CpBaseSettingView *CpThemePluginEntryItemData::createSettingView() const
       
    83 {
       
    84     if(mThemeControl) {
       
    85         CpBaseSettingView *view = mThemeControl->themeListView();
       
    86         return view;
       
    87     }
       
    88     
       
    89     return 0;
       
    90 }