ipsservices/nmipssettings/src/nmipssettingscustomitem.cpp
changeset 18 578830873419
child 20 ecc8def7944a
equal deleted inserted replaced
4:e7aa27f58ae1 18:578830873419
       
     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 
       
    18 #include <QVariant>
       
    19 
       
    20 #include "nmipssettingscustomitem.h"
       
    21 #include "nmipssettingslabeledcombobox.h"
       
    22 
       
    23 /*!
       
    24     \class NmIpsSettingsCustomItem
       
    25     \brief The class implements a custom HbDataFormViewItem.
       
    26 
       
    27 */
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 /*!
       
    32     Constructor of NmIpsSettingsCustomItem.
       
    33 */
       
    34 NmIpsSettingsCustomItem::NmIpsSettingsCustomItem(QGraphicsItem *parent)
       
    35 : HbDataFormViewItem(parent)
       
    36 {
       
    37 }
       
    38 
       
    39 /*!
       
    40     Destructor of NmIpsSettingsCustomItem.
       
    41 */
       
    42 NmIpsSettingsCustomItem::~NmIpsSettingsCustomItem()
       
    43 {
       
    44 }
       
    45 
       
    46 /*!
       
    47     Creates the custom data form view item.
       
    48 */
       
    49 HbAbstractViewItem* NmIpsSettingsCustomItem::createItem()
       
    50 {
       
    51     return new NmIpsSettingsCustomItem(*this);
       
    52 }
       
    53 
       
    54 /*!
       
    55     \param index Model index of the item.
       
    56     \return true if item type for the index is supported, otherwise false.
       
    57 */
       
    58 bool NmIpsSettingsCustomItem::canSetModelIndex(const QModelIndex &index) const
       
    59 {
       
    60     int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
       
    61     return type==LabeledComboBox;
       
    62 }
       
    63 
       
    64 /*!
       
    65     Creates the custom widget.
       
    66 */
       
    67 HbWidget *NmIpsSettingsCustomItem::createCustomWidget()
       
    68 {
       
    69     QVariant data(modelIndex().data(HbDataFormModelItem::ItemTypeRole));
       
    70     int type(data.toInt());
       
    71 
       
    72     HbWidget *widget = 0;
       
    73 
       
    74     if (type == LabeledComboBox) {
       
    75         widget = new NmIpsSettingsLabeledComboBox();
       
    76     }
       
    77 
       
    78     return widget;
       
    79 }