|
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 view for "Reset" and "Delete Data and Resore" and activates the RFS operation based on the user selection. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cprfssettingsform.h" |
|
19 #include "cprfssettingsdataformcustomitem.h" |
|
20 |
|
21 |
|
22 #include <hbdataformmodelitem.h> |
|
23 #include <hbdataformmodel.h> |
|
24 #include <hbpushbutton.h> |
|
25 #include <rfsHandler.h> |
|
26 |
|
27 CpRfsSettingsForm::CpRfsSettingsForm(QGraphicsItem *parent) : |
|
28 HbDataForm(parent) |
|
29 { |
|
30 this->setHeading(tr("Restore Factory Settings")); |
|
31 |
|
32 //initialize the form model |
|
33 initRfsSettingModel(); |
|
34 |
|
35 connect(this, SIGNAL(activated(QModelIndex)),this, SLOT(onItemActivated(QModelIndex))); |
|
36 } |
|
37 |
|
38 CpRfsSettingsForm::~CpRfsSettingsForm() |
|
39 { |
|
40 } |
|
41 |
|
42 void CpRfsSettingsForm::initRfsSettingModel() |
|
43 { |
|
44 HbDataFormModel *model = new HbDataFormModel(0); |
|
45 |
|
46 // Create the custom items because HbPushButton cannot be added to the HbDataFormModelItem |
|
47 HbDataFormModelItem::DataItemType customItem = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 1); |
|
48 |
|
49 mNormalRfs = model->appendDataFormItem(customItem, QString(), model->invisibleRootItem()); |
|
50 mNormalRfs->setData(HbDataFormModelItem::KeyRole, tr("Restore")); |
|
51 |
|
52 HbDataFormModelItem::DataItemType customItem1 = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 1); |
|
53 |
|
54 mDeepRfs = model->appendDataFormItem(customItem1, QString(), model->invisibleRootItem()); |
|
55 mDeepRfs->setData(HbDataFormModelItem::KeyRole,tr("Delete Data and Restore")); |
|
56 |
|
57 this->setModel(model); |
|
58 } |
|
59 |
|
60 // On Item activated |
|
61 void CpRfsSettingsForm::onItemActivated(const QModelIndex &index) |
|
62 { |
|
63 HbDataFormModelItem *itemData = static_cast<HbDataFormModelItem *> (index.internalPointer()); |
|
64 // to deal with orbit change temparialy |
|
65 if (itemData->type() > HbDataFormModelItem::GroupPageItem) |
|
66 { |
|
67 //get the widget of setting item |
|
68 HbWidget* widget = this->dataFormViewItem(index)->dataItemContentWidget(); |
|
69 |
|
70 if (itemData == mNormalRfs) |
|
71 { |
|
72 activateNormalRfs(widget); |
|
73 } |
|
74 if (itemData == mDeepRfs) |
|
75 { |
|
76 activateDeepRfs(widget); |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 void CpRfsSettingsForm::activateNormalRfs(HbWidget* widget) |
|
82 { |
|
83 HbPushButton *advanced = qobject_cast<HbPushButton *> (widget); |
|
84 |
|
85 if(advanced) |
|
86 { |
|
87 //TODO Issue in DataForm Calling the itemActivated twice |
|
88 disconnect( advanced, SIGNAL(clicked()), this, SLOT(onPressedNormalRfs()) ); |
|
89 |
|
90 connect( advanced, SIGNAL(clicked()), this, SLOT(onPressedNormalRfs()) ); |
|
91 } |
|
92 } |
|
93 |
|
94 void CpRfsSettingsForm::activateDeepRfs(HbWidget* widget) |
|
95 { |
|
96 HbPushButton *advanced = qobject_cast<HbPushButton *> (widget); |
|
97 |
|
98 if(advanced) |
|
99 { |
|
100 //TODO Issue in DataForm Calling the itemActivated twice |
|
101 disconnect( advanced, SIGNAL(clicked()), this, SLOT(onPressedDeepRfs()) ); |
|
102 |
|
103 connect( advanced, SIGNAL(clicked()), this, SLOT(onPressedDeepRfs()) ); |
|
104 } |
|
105 } |
|
106 |
|
107 void CpRfsSettingsForm::onPressedNormalRfs() |
|
108 { |
|
109 CRfsHandler* rfsHandler = new ( ELeave ) CRfsHandler; |
|
110 CleanupStack :: PushL(rfsHandler); |
|
111 |
|
112 //activate the Normal RFS |
|
113 rfsHandler->ActivateRfsL( ERfsNormal ); |
|
114 |
|
115 CleanupStack :: PopAndDestroy(rfsHandler); |
|
116 |
|
117 } |
|
118 |
|
119 void CpRfsSettingsForm::onPressedDeepRfs() |
|
120 { |
|
121 CRfsHandler* rfsHandler = new ( ELeave ) CRfsHandler; |
|
122 CleanupStack :: PushL(rfsHandler); |
|
123 |
|
124 //activate the Deep RFS |
|
125 rfsHandler->ActivateRfsL( ERfsDeep ); |
|
126 |
|
127 CleanupStack :: PopAndDestroy(rfsHandler); |
|
128 } |