|
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 "nmsettingsformcustomitems.h" |
|
19 |
|
20 #include <hbpushbutton.h> |
|
21 |
|
22 |
|
23 /*! |
|
24 \class NmSettingsFormCustomItems |
|
25 \brief Contains definitions for custom setting data form items. |
|
26 */ |
|
27 |
|
28 |
|
29 /*! |
|
30 Class constructor. |
|
31 */ |
|
32 NmSettingsFormCustomItems::NmSettingsFormCustomItems(QGraphicsItem *parent) |
|
33 : HbDataFormViewItem(parent) |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 /*! |
|
39 Class destructor. |
|
40 */ |
|
41 NmSettingsFormCustomItems::~NmSettingsFormCustomItems() |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 /*! |
|
47 From HbDataFormViewItem. |
|
48 */ |
|
49 HbAbstractViewItem *NmSettingsFormCustomItems::createItem() |
|
50 { |
|
51 return new NmSettingsFormCustomItems(*this); |
|
52 } |
|
53 |
|
54 bool NmSettingsFormCustomItems::canSetModelIndex(const QModelIndex &index) const |
|
55 { |
|
56 int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
57 return type==NmButtonItem; |
|
58 } |
|
59 |
|
60 |
|
61 /*! |
|
62 From HbDataFormViewItem. |
|
63 */ |
|
64 HbWidget *NmSettingsFormCustomItems::createCustomWidget() |
|
65 { |
|
66 HbDataFormModelItem::DataItemType itemType = |
|
67 static_cast<HbDataFormModelItem::DataItemType>( |
|
68 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
69 |
|
70 HbWidget *widget = 0; |
|
71 |
|
72 switch (itemType) { |
|
73 case NmButtonItem: { |
|
74 // Push button. |
|
75 QString text = modelIndex().data(HbDataFormModelItem::KeyRole).toString(); |
|
76 widget = new HbPushButton(text); |
|
77 } |
|
78 default: { |
|
79 break; |
|
80 } |
|
81 } |
|
82 |
|
83 return widget; |
|
84 } |
|
85 |
|
86 |
|
87 // End of file. |