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 // System includes |
|
19 #include <hbdataform.h> |
|
20 #include <hbdataformmodel.h> |
|
21 #include <hbdataformmodelitem.h> |
|
22 #include <hblineedit.h> |
|
23 #include <seccodeeditdataformviewitem.h> |
|
24 #include <seccodesettings.h> |
|
25 |
|
26 // User includes |
|
27 #include "cppincodepluginview.h" |
|
28 #include <../../inc/cpsecplugins.h> |
|
29 |
|
30 /*! |
|
31 \class CpPinCodePluginView |
|
32 \brief Pin Code Setting view class |
|
33 |
|
34 This class is used to create PIN code setting view |
|
35 */ |
|
36 |
|
37 // ======== LOCAL FUNCTIONS ======== |
|
38 |
|
39 /*! |
|
40 Constructor |
|
41 */ |
|
42 CpPinCodePluginView::CpPinCodePluginView(QGraphicsItem *parent /*= 0*/) |
|
43 : CpBaseSettingView(0,parent), mSecCodeSettings(new SecCodeSettings()) |
|
44 { |
|
45 RDEBUG("0", 0); |
|
46 HbDataForm *form = qobject_cast<HbDataForm*>(widget()); |
|
47 if (form) { |
|
48 QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes(); |
|
49 protoTypeList.append(new SecCodeEditDataFormViewItem()); |
|
50 form->setItemPrototypes(protoTypeList); |
|
51 form->setHeading(tr("PIN code")); |
|
52 |
|
53 mFormModel = new HbDataFormModel(this); |
|
54 mPinCodeRequestItem = new HbDataFormModelItem( |
|
55 HbDataFormModelItem::ToggleValueItem, tr("PIN code requests")); |
|
56 |
|
57 bool currentPinCodeRequest = mSecCodeSettings->pinCodeRequest(); |
|
58 if (currentPinCodeRequest) { |
|
59 mPinCodeRequestItem->setContentWidgetData("text", tr("On")); |
|
60 mPinCodeRequestItem->setContentWidgetData("additionalText", tr("On")); |
|
61 } else { |
|
62 mPinCodeRequestItem->setContentWidgetData("text",tr("Off")); |
|
63 mPinCodeRequestItem->setContentWidgetData("additionalText", tr("Off")); |
|
64 } |
|
65 RDEBUG("form->addConnection", 1); |
|
66 connect(mFormModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), |
|
67 this, SLOT(toggleChange(QModelIndex, QModelIndex))); |
|
68 mFormModel->appendDataFormItem(mPinCodeRequestItem); |
|
69 |
|
70 HbDataFormModelItem *pinCodeItem = new HbDataFormModelItem( |
|
71 static_cast<HbDataFormModelItem::DataItemType> |
|
72 (SecCodeEditDataFormViewItem::SecCodeEditItem), tr("PIN code")); |
|
73 pinCodeItem->setContentWidgetData("echoMode", HbLineEdit::Password); |
|
74 pinCodeItem->setContentWidgetData("text", "1111"); |
|
75 pinCodeItem->setContentWidgetData("readOnly", true); |
|
76 form->addConnection(pinCodeItem, SIGNAL(clicked()), this, |
|
77 SLOT(changePinCode())); |
|
78 mFormModel->appendDataFormItem(pinCodeItem); |
|
79 |
|
80 HbDataFormModelItem *pin2CodeItem = new HbDataFormModelItem( |
|
81 static_cast<HbDataFormModelItem::DataItemType> |
|
82 (SecCodeEditDataFormViewItem::SecCodeEditItem), tr("PIN2 code")); |
|
83 pin2CodeItem->setContentWidgetData("echoMode", HbLineEdit::Password); |
|
84 pin2CodeItem->setContentWidgetData("text", "1111"); |
|
85 pin2CodeItem->setContentWidgetData("readOnly", true); |
|
86 form->addConnection(pin2CodeItem, SIGNAL(clicked()), this, |
|
87 SLOT(changePin2Code())); |
|
88 mFormModel->appendDataFormItem(pin2CodeItem); |
|
89 RDEBUG("form->setModel", 1); |
|
90 form->setModel(mFormModel); |
|
91 } |
|
92 } |
|
93 |
|
94 /*! |
|
95 Destructor |
|
96 */ |
|
97 CpPinCodePluginView::~CpPinCodePluginView() |
|
98 { |
|
99 delete mSecCodeSettings; |
|
100 } |
|
101 |
|
102 /*! |
|
103 response for click pin code request |
|
104 */ |
|
105 void CpPinCodePluginView::toggleChange(QModelIndex startIn, |
|
106 QModelIndex /*endIn*/) |
|
107 { |
|
108 RDEBUG("0", 0); |
|
109 HbDataFormModelItem *item = mFormModel->itemFromIndex(startIn); |
|
110 if(item->type() == HbDataFormModelItem::ToggleValueItem) { |
|
111 if (mSecCodeSettings->changePinCodeRequest()) { |
|
112 RDEBUG("got changePinCodeRequest", 1); |
|
113 disconnect(mFormModel, |
|
114 SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, |
|
115 SLOT(toggleChange(QModelIndex, QModelIndex))); |
|
116 RDEBUG("disconnected", 1); |
|
117 QString text = mPinCodeRequestItem->contentWidgetData( |
|
118 "text").toString(); |
|
119 if (0 == text.compare("On")) { |
|
120 mPinCodeRequestItem->setContentWidgetData("text", |
|
121 tr("Off")); |
|
122 mPinCodeRequestItem->setContentWidgetData("additionalText", |
|
123 tr("Off")); |
|
124 } else { |
|
125 mPinCodeRequestItem->setContentWidgetData("text", |
|
126 tr("On")); |
|
127 mPinCodeRequestItem->setContentWidgetData("additionalText", |
|
128 tr("On")); |
|
129 } |
|
130 RDEBUG("reconnect", 1); |
|
131 connect(mFormModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), |
|
132 this, SLOT(toggleChange(QModelIndex, QModelIndex))); |
|
133 } |
|
134 else |
|
135 { |
|
136 RDEBUG("value was not changed", 0); |
|
137 } |
|
138 } |
|
139 RDEBUG("0", 0); |
|
140 } |
|
141 |
|
142 /*! |
|
143 response for click pin code |
|
144 */ |
|
145 void CpPinCodePluginView::changePinCode() |
|
146 { |
|
147 RDEBUG("0", 0); |
|
148 mSecCodeSettings->changePinCode(); |
|
149 } |
|
150 |
|
151 /*! |
|
152 response for click pin2 code |
|
153 */ |
|
154 void CpPinCodePluginView::changePin2Code() |
|
155 { |
|
156 RDEBUG("0", 0); |
|
157 mSecCodeSettings->changePin2Code(); |
|
158 } |
|