|
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: Creates the custom items required for HbDataFormModelItem. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <cprfssettingsdataformcustomitem.h> |
|
19 #include <hbdataformmodelitem.h> |
|
20 #include <hbpushbutton.h> |
|
21 #include <hbtranslator.h> |
|
22 |
|
23 CpRfsSettingsDataFormCustomItem::CpRfsSettingsDataFormCustomItem(QGraphicsItem *parent) : |
|
24 HbDataFormViewItem(parent) |
|
25 { |
|
26 } |
|
27 |
|
28 CpRfsSettingsDataFormCustomItem::~CpRfsSettingsDataFormCustomItem() |
|
29 { |
|
30 } |
|
31 |
|
32 //overridden method which is required in case of customwidget |
|
33 bool CpRfsSettingsDataFormCustomItem::canSetModelIndex(const QModelIndex &index) const |
|
34 { |
|
35 HbDataFormModelItem::DataItemType itemType = |
|
36 static_cast<HbDataFormModelItem::DataItemType>( |
|
37 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
38 //each custom item can be represented by customitembase+number and 10 is just in future if u have to add extra custom items |
|
39 if(itemType >= HbDataFormModelItem::CustomItemBase && |
|
40 itemType <= HbDataFormModelItem::CustomItemBase + 10 ) { |
|
41 return true; |
|
42 } |
|
43 return false; |
|
44 |
|
45 } |
|
46 //overridden method which is required in case of customwidget |
|
47 HbAbstractViewItem* CpRfsSettingsDataFormCustomItem::createItem() |
|
48 { |
|
49 return new CpRfsSettingsDataFormCustomItem(*this); |
|
50 } |
|
51 //overridden method which is required in case of customwidget |
|
52 HbWidget* CpRfsSettingsDataFormCustomItem::createCustomWidget() |
|
53 { |
|
54 HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>( |
|
55 modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
56 HbTranslator trans("control_panel"); |
|
57 switch(itemType) |
|
58 { |
|
59 case HbDataFormModelItem::CustomItemBase + 1: |
|
60 { |
|
61 //Create 1st button |
|
62 mButton = new HbPushButton(); |
|
63 mButton->setText(hbTrId("txt_cp_setlabel_settings_reset_val_reset_settings")); |
|
64 return mButton; |
|
65 } |
|
66 case HbDataFormModelItem::CustomItemBase + 2: |
|
67 { |
|
68 //Create 2nd button |
|
69 mButton = new HbPushButton(); |
|
70 mButton->setText(hbTrId("txt_cp_setlabel_device_reset_val_reset_device")); |
|
71 return mButton; |
|
72 } |
|
73 //Some other cases can also be added if there are more than 2 custom data item |
|
74 default: |
|
75 return 0; |
|
76 } |
|
77 } |