|
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 |
|
29 /*! |
|
30 \class CpPinCodePluginView |
|
31 \brief Pin Code Setting view class |
|
32 |
|
33 This class is used to create PIN code setting view |
|
34 */ |
|
35 |
|
36 // ======== LOCAL FUNCTIONS ======== |
|
37 |
|
38 /*! |
|
39 Constructor |
|
40 */ |
|
41 CpPinCodePluginView::CpPinCodePluginView(QGraphicsItem *parent /*= 0*/) |
|
42 : CpBaseSettingView(0,parent), mSecCodeSettings(new SecCodeSettings()) |
|
43 { |
|
44 HbDataForm *form = settingForm(); |
|
45 if (form) { |
|
46 QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes(); |
|
47 protoTypeList.append(new SecCodeEditDataFormViewItem()); |
|
48 form->setItemPrototypes(protoTypeList); |
|
49 form->setHeading(tr("PIN code")); |
|
50 |
|
51 HbDataFormModel *formModel = new HbDataFormModel(); |
|
52 mPinCodeRequestItem = new HbDataFormModelItem( |
|
53 HbDataFormModelItem::ToggleValueItem, tr("PIN code requests")); |
|
54 |
|
55 bool currentPinCodeRequest = mSecCodeSettings->pinCodeRequest(); |
|
56 if (currentPinCodeRequest) { |
|
57 mPinCodeRequestItem->setContentWidgetData("text", tr("On")); |
|
58 mPinCodeRequestItem->setContentWidgetData("additionalText", tr("On")); |
|
59 } else { |
|
60 mPinCodeRequestItem->setContentWidgetData("text",tr("Off")); |
|
61 mPinCodeRequestItem->setContentWidgetData("additionalText", tr("Off")); |
|
62 } |
|
63 |
|
64 form->addConnection(mPinCodeRequestItem, SIGNAL(clicked()), this, |
|
65 SLOT(changePinCodeRequest())); |
|
66 formModel->appendDataFormItem(mPinCodeRequestItem); |
|
67 |
|
68 HbDataFormModelItem *pinCodeItem = new HbDataFormModelItem( |
|
69 static_cast<HbDataFormModelItem::DataItemType> |
|
70 (SecCodeEditDataFormViewItem::SecCodeEditItem), tr("PIN code")); |
|
71 pinCodeItem->setContentWidgetData("echoMode", HbLineEdit::Password); |
|
72 pinCodeItem->setContentWidgetData("text", "1111"); |
|
73 pinCodeItem->setContentWidgetData("readOnly", true); |
|
74 form->addConnection(pinCodeItem, SIGNAL(clicked()), this, |
|
75 SLOT(changePinCode())); |
|
76 formModel->appendDataFormItem(pinCodeItem); |
|
77 |
|
78 HbDataFormModelItem *pin2CodeItem = new HbDataFormModelItem( |
|
79 static_cast<HbDataFormModelItem::DataItemType> |
|
80 (SecCodeEditDataFormViewItem::SecCodeEditItem), tr("PIN2 code")); |
|
81 pin2CodeItem->setContentWidgetData("echoMode", HbLineEdit::Password); |
|
82 pin2CodeItem->setContentWidgetData("text", "1111"); |
|
83 pin2CodeItem->setContentWidgetData("readOnly", true); |
|
84 form->addConnection(pin2CodeItem, SIGNAL(clicked()), this, |
|
85 SLOT(changePin2Code())); |
|
86 formModel->appendDataFormItem(pin2CodeItem); |
|
87 |
|
88 form->setModel(formModel); |
|
89 } |
|
90 } |
|
91 |
|
92 /*! |
|
93 Destructor |
|
94 */ |
|
95 CpPinCodePluginView::~CpPinCodePluginView() |
|
96 { |
|
97 delete mSecCodeSettings; |
|
98 } |
|
99 |
|
100 /*! |
|
101 response for click pin code |
|
102 */ |
|
103 void CpPinCodePluginView::changePinCode() |
|
104 { |
|
105 mSecCodeSettings->changePinCode(); |
|
106 } |
|
107 |
|
108 /*! |
|
109 response for click pin2 code |
|
110 */ |
|
111 void CpPinCodePluginView::changePin2Code() |
|
112 { |
|
113 mSecCodeSettings->changePin2Code(); |
|
114 } |
|
115 |
|
116 /*! |
|
117 response for click pin code request |
|
118 */ |
|
119 void CpPinCodePluginView::changePinCodeRequest() |
|
120 { |
|
121 if (mSecCodeSettings->changePinCodeRequest()) { |
|
122 QString text = mPinCodeRequestItem->contentWidgetData("text").toString(); |
|
123 if (0 == text.compare("On")) { |
|
124 mPinCodeRequestItem->setContentWidgetData("text", |
|
125 tr("Off")); |
|
126 mPinCodeRequestItem->setContentWidgetData("additionalText", |
|
127 tr("Off")); |
|
128 } else { |
|
129 mPinCodeRequestItem->setContentWidgetData("text", |
|
130 tr("On")); |
|
131 mPinCodeRequestItem->setContentWidgetData("additionalText", |
|
132 tr("On")); |
|
133 } |
|
134 } |
|
135 } |