116 */ |
120 */ |
117 void BtDeviceDialogInputWidget::processParam(const QVariantMap ¶meters) |
121 void BtDeviceDialogInputWidget::processParam(const QVariantMap ¶meters) |
118 { |
122 { |
119 TRACE_ENTRY |
123 TRACE_ENTRY |
120 |
124 |
121 QString keyStr, prompt; |
125 QString keyStr, prompt,title,regExp; |
|
126 QVariant name; |
122 keyStr.setNum( TBluetoothDialogParams::EResource ); |
127 keyStr.setNum( TBluetoothDialogParams::EResource ); |
123 // Validate if the resource item exists. |
128 // Validate if the resource item exists. |
124 QVariantMap::const_iterator i = parameters.constFind( keyStr ); |
129 QVariantMap::const_iterator i = parameters.constFind( keyStr ); |
125 // item of ResourceId is not found, can't continue. |
130 // item of ResourceId is not found, can't continue. |
126 if ( i == parameters.constEnd() ) { |
131 if ( i == parameters.constEnd() ) { |
128 return; |
133 return; |
129 } |
134 } |
130 |
135 |
131 QVariant param = parameters.value( keyStr ); |
136 QVariant param = parameters.value( keyStr ); |
132 if ( param.toInt() == EPinInput ) { |
137 if ( param.toInt() == EPinInput ) { |
133 prompt = QString( tr( "Passcode for device %1:" ) ); |
138 // Numeric value only |
|
139 mInputDialog->setInputMode(HbInputDialog::RealInput); |
|
140 title = QString(hbTrId("txt_bt_title_pairing_with_1")); |
|
141 // todo: Fixe the multiline problem |
|
142 prompt = QString( hbTrId( "txt_bt_dialog_please_enter_the_passcode_for_1" ) ); |
134 } |
143 } |
135 else { |
144 else { |
136 mLastError = ParameterError; |
145 mLastError = ParameterError; |
137 return; |
146 return; |
138 } |
147 } |
139 |
148 |
140 // check if minLength of passcode required |
149 // check if minLength of passcode required |
141 keyStr.setNum( TBluetoothDeviceDialog::EAdditionalDesc ); |
150 keyStr.setNum( TBluetoothDeviceDialog::EAdditionalDesc ); |
142 i = parameters.constFind( keyStr ); |
151 i = parameters.constFind( keyStr ); |
143 // Mini Length required, update prompt |
152 // Mini Length required, update prompt |
144 // ToDo: use Validator to check input length. |
153 // ToDo: The validator doesn't seem to work properly |
145 if ( i != parameters.constEnd() ) { |
154 if ( i != parameters.constEnd() ) { |
146 prompt = QString( tr( "Enter %1 digit passcode for device %2:" ) ); |
155 // Todo : The string ID for the localization is not available yet |
|
156 // for string : "Enter %1 digit passcode for device %2:" |
|
157 // I'm using the "Enter the passcode for device %1" instead |
|
158 prompt = QString( hbTrId( "txt_bt_dialog_please_enter_the_passcode_for_1" ) ); |
147 param = parameters.value( keyStr ); |
159 param = parameters.value( keyStr ); |
148 } |
160 regExp = tr("^\\d{%1,}$"); |
149 |
161 regExp.arg(param.toString()); |
|
162 HbValidator* validator = new HbValidator(mInputDialog->lineEdit()); |
|
163 validator->addField( |
|
164 new QRegExpValidator( |
|
165 QRegExp(regExp, Qt::CaseInsensitive), validator ),""); |
|
166 mInputDialog->setValidator(validator); |
|
167 }else{ |
|
168 // Minimum requirement is to have at least 1 digit |
|
169 regExp = tr("^\\d{1,}$"); |
|
170 HbValidator* validator = new HbValidator(mInputDialog->lineEdit()); |
|
171 validator->addField( |
|
172 new QRegExpValidator( |
|
173 QRegExp(regExp, Qt::CaseInsensitive), validator ),""); |
|
174 mInputDialog->setValidator(validator); |
|
175 } |
150 // replace % with the miniLength and device name |
176 // replace % with the miniLength and device name |
151 int repls = prompt.count( QString( "%" ) ); |
177 int repls = prompt.count( QString( "%" ) ); |
152 if ( repls > 1 ) { |
178 if ( repls > 1 ) { |
153 prompt = prompt.arg( param.toString() ); |
179 prompt = prompt.arg( param.toString() ); |
154 } |
180 } |
155 if ( repls > 0 ) { |
181 if ( repls > 0 ) { |
156 QVariant name = parameters.value( QString::number( TBluetoothDeviceDialog::EDeviceName ) ); |
182 name = parameters.value( QString::number( TBluetoothDeviceDialog::EDeviceName ) ); |
157 prompt = prompt.arg( name.toString() ); |
183 prompt = prompt.arg( name.toString() ); |
158 } |
184 } |
159 // set property value to this dialog widget |
185 repls = title.count(QString("%")); |
160 mInputDialog->setPromptText( prompt ); |
186 if(repls > 0){ |
|
187 title = title.arg( name.toString() ); |
|
188 } |
|
189 mInputDialog->setHeadingWidget(new HbLabel(title)); |
|
190 mInputDialog->lineEdit(0)->setMaxLength(PASSCODE_MAX_LEN); |
|
191 mInputDialog->lineEdit(0)->setText(tr("")); // clear the input field |
|
192 mInputDialog->setPromptText(prompt); |
161 TRACE_EXIT |
193 TRACE_EXIT |
162 } |
194 } |
163 |
195 |
164 /*! |
196 /*! |
165 Reset properties to default values |
197 Reset properties to default values |