controlpanel/src/cpframework/src/cpsettingformentryitemdata.cpp
changeset 68 13e71d907dc3
parent 40 6465d5bb863a
equal deleted inserted replaced
40:6465d5bb863a 68:13e71d907dc3
     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 #include "cpsettingformentryitemdata.h"
       
    18 #include "cpsettingformentryitemdata_p.h"
       
    19 #include "cpviewlauncher.h"
       
    20 #include <cpbasesettingview.h>
       
    21 
       
    22 
       
    23 /*!
       
    24     \class CpSettingFormEntryItemData
       
    25     \brief The CpSettingFormEntryItemData can be used to control panel plugin which appears as a setting item. And after clicking
       
    26     it, a new setting view will open.
       
    27  */
       
    28 
       
    29 /*
       
    30     \fn CpSettingFormEntryItemData::createSettingView
       
    31     
       
    32     Create a new setting view.
       
    33     
       
    34     createSettingView will be called automatically when user click a setting item represented by a CpSettingFormEntryItemData.
       
    35     
       
    36     In most cases, you do not need to write a derived class from CpSettingFormEntryItemData, instead, you can simply use template class CpSettingFormEntryItemDataImpl.
       
    37 */
       
    38 
       
    39 
       
    40 /*!
       
    41     Construct a new CpSettingFormEntryItemData with the given parent.
       
    42 */
       
    43 CpSettingFormEntryItemData::CpSettingFormEntryItemData(const HbDataFormModelItem *parent /* = 0*/)
       
    44 : CpSettingFormItemData(parent),  d_ptr(new CpSettingFormEntryItemDataPrivate())
       
    45 {
       
    46     d_ptr->init(this);
       
    47 }
       
    48 
       
    49 
       
    50 /*!
       
    51     Construct a new CpSettingFormEntryItemData with the given text,description and parent.
       
    52 */
       
    53 
       
    54 CpSettingFormEntryItemData::CpSettingFormEntryItemData(CpItemDataHelper &itemDataHelper,
       
    55 		const QString &text /* = QString()*/,
       
    56         const QString &description /* = QString()*/,
       
    57 		const HbIcon &icon,
       
    58         const HbDataFormModelItem *parent /*= 0*/) : 
       
    59         CpSettingFormItemData(HbDataFormModelItem::CustomItemBase,QString(),parent),
       
    60         d_ptr(new CpSettingFormEntryItemDataPrivate(&itemDataHelper))
       
    61 {
       
    62     setType ( static_cast<HbDataFormModelItem::DataItemType> (CpSettingFormEntryItemData::ListEntryItem) );
       
    63 	
       
    64     d_ptr->init(this);
       
    65     
       
    66 	setText(text);
       
    67 	setDescription(description);
       
    68 	setIcon(icon.iconName());
       
    69 }
       
    70 
       
    71 /*!
       
    72     Construct a new CpSettingFormEntryItemData with the given text,description and parent.
       
    73 */
       
    74 
       
    75 CpSettingFormEntryItemData::CpSettingFormEntryItemData(HbDataForm *dataForm,
       
    76         const QString &text /*= QString()*/,
       
    77         const QString &description /*= QString()*/,
       
    78         const HbIcon &icon /*= HbIcon()*/,
       
    79         const HbDataFormModelItem *parent/* = 0*/) :
       
    80         CpSettingFormItemData(HbDataFormModelItem::CustomItemBase,QString(),parent),
       
    81         d_ptr(new CpSettingFormEntryItemDataPrivate(dataForm))
       
    82 {
       
    83 	setType ( static_cast<HbDataFormModelItem::DataItemType> (CpSettingFormEntryItemData::ListEntryItem) );
       
    84 	
       
    85 	d_ptr->init(this);
       
    86 	
       
    87     setText(text);
       
    88     setDescription(description);
       
    89     setIcon(icon.iconName());
       
    90 }
       
    91 
       
    92 
       
    93 CpSettingFormEntryItemData::CpSettingFormEntryItemData(
       
    94          EntryItemType type,
       
    95          CpItemDataHelper &itemDataHelper,
       
    96          const QString &text /*= QString()*/,
       
    97          const QString &description /*= QString()*/,
       
    98          const QString &iconName /*= QString()*/,
       
    99          const HbDataFormModelItem *parent /*= 0*/) :
       
   100          CpSettingFormItemData(HbDataFormModelItem::CustomItemBase,QString(),parent),
       
   101          d_ptr(new CpSettingFormEntryItemDataPrivate(&itemDataHelper))
       
   102 {
       
   103     setType ( static_cast<HbDataFormModelItem::DataItemType> (type) );
       
   104     
       
   105     d_ptr->init(this);
       
   106     
       
   107     setText(text);
       
   108     setDescription(description);
       
   109     setIcon(iconName);
       
   110 }
       
   111 
       
   112 CpSettingFormEntryItemData::CpSettingFormEntryItemData(
       
   113          EntryItemType type,
       
   114          HbDataForm *dataForm,
       
   115          const QString &text /*= QString()*/,
       
   116          const QString &description /*= QString()*/,
       
   117          const QString &iconName /*= QString()*/,
       
   118          const HbDataFormModelItem *parent /*= 0*/) : 
       
   119          CpSettingFormItemData(HbDataFormModelItem::CustomItemBase,QString(),parent),
       
   120          d_ptr(new CpSettingFormEntryItemDataPrivate(dataForm))
       
   121 {
       
   122     setType ( static_cast<HbDataFormModelItem::DataItemType> (type) );
       
   123     
       
   124     d_ptr->init(this);
       
   125     
       
   126     setText(text);
       
   127     setDescription(description);
       
   128     setIcon(iconName);
       
   129 }
       
   130 
       
   131 
       
   132 /*!
       
   133      Destructor.
       
   134 */
       
   135 CpSettingFormEntryItemData::~CpSettingFormEntryItemData()
       
   136 {
       
   137     delete d_ptr;
       
   138 }
       
   139 
       
   140 
       
   141 /*!
       
   142      Get the text string of the entry item.
       
   143 */
       
   144 QString CpSettingFormEntryItemData::text() const
       
   145 {
       
   146     return d_ptr->text();
       
   147 }
       
   148 
       
   149 /*!
       
   150      Set the text string of the entry item.
       
   151 */
       
   152 void CpSettingFormEntryItemData::setText(const QString &text)
       
   153 {
       
   154     d_ptr->setText(text);
       
   155 }
       
   156 
       
   157 /*!
       
   158      Get the description string of the entry item.
       
   159 */
       
   160 QString CpSettingFormEntryItemData::description() const
       
   161 {
       
   162     return d_ptr->description();
       
   163 }
       
   164 
       
   165 /*!
       
   166      Set the description string of the entry item.
       
   167 */
       
   168 void CpSettingFormEntryItemData::setDescription(const QString &description)
       
   169 {
       
   170     d_ptr->setDescription(description);
       
   171 }
       
   172 
       
   173 
       
   174 QString CpSettingFormEntryItemData::iconName() const
       
   175 {
       
   176     return d_ptr->iconName();
       
   177 }
       
   178 
       
   179 void CpSettingFormEntryItemData::setIconName(const QString &icon)
       
   180 {
       
   181     d_ptr->setIconName(icon);
       
   182 }
       
   183 
       
   184 /*!
       
   185 	Return the icon of the entry item
       
   186 */
       
   187 HbIcon CpSettingFormEntryItemData::entryItemIcon()const
       
   188 {
       
   189     return d_ptr->entryItemIcon();
       
   190 }
       
   191 
       
   192 /*!
       
   193 	Set the icon for the entry item
       
   194 */
       
   195 void CpSettingFormEntryItemData::setEntryItemIcon(const HbIcon& icon)
       
   196 {
       
   197     d_ptr->setEntryItemIcon(icon);
       
   198 }
       
   199 
       
   200 void CpSettingFormEntryItemData::onLaunchView() 
       
   201 {
       
   202     //avoid being launched more than one times
       
   203     if (d_ptr->mSettingViewPtr.isNull()) {
       
   204         d_ptr->mSettingViewPtr = createSettingView();
       
   205         if (!d_ptr->mSettingViewPtr.isNull()) {
       
   206             CpViewLauncher::launchView(d_ptr->mSettingViewPtr.data());
       
   207         }
       
   208     }
       
   209 }
       
   210 
       
   211 //End of File