252 This API allows the user to set any validator to the user input field. |
252 This API allows the user to set any validator to the user input field. |
253 |
253 |
254 \param validator Validator uses undo stack to back out invalid changes. Therefore undo |
254 \param validator Validator uses undo stack to back out invalid changes. Therefore undo |
255 is enabled when validator is set. |
255 is enabled when validator is set. |
256 |
256 |
257 \param row This parameter indicates which row of the user field.0 means the |
257 \param row This parameter indicates which row of the user field.0 means the |
258 the first user field and 1 means second user field |
258 the first user field and 1 means second user field |
259 |
259 |
260 \sa HbAbstractEdit::validator |
260 \sa HbAbstractEdit::validator |
261 */ |
261 */ |
262 void HbInputDialog::setValidator(HbValidator *validator,int row) |
262 void HbInputDialog::setValidator(HbValidator *validator,int row) |
327 d->mEchoMode = echoMode; |
327 d->mEchoMode = echoMode; |
328 } |
328 } |
329 }; |
329 }; |
330 |
330 |
331 /*! |
331 /*! |
332 \deprecated HbInputDialog::primitive(HbStyle::Primitive) |
|
333 is deprecated. |
|
334 |
|
335 Provides access to primitives of HbInputDialog. |
|
336 \param primitive is the type of the requested primitive. The available |
|
337 primitives are P_InputDialog_text, and P_InputDialog_additionaltext. |
|
338 |
|
339 */ |
|
340 QGraphicsItem* HbInputDialog::primitive(HbStyle::Primitive primitive) const |
|
341 { |
|
342 Q_D(const HbInputDialog); |
|
343 switch (primitive) { |
|
344 case HbStyle::P_InputDialog_text: |
|
345 return d->mContentWidget->mLabel1; |
|
346 case HbStyle::P_InputDialog_additionaltext: |
|
347 return d->mContentWidget->mLabel2; |
|
348 default: |
|
349 return 0; |
|
350 } |
|
351 } |
|
352 |
|
353 /*! |
|
354 \reimp |
332 \reimp |
355 */ |
333 */ |
356 void HbInputDialog::initStyleOption(HbStyleOptionInputDialog *option) const |
334 void HbInputDialog::initStyleOption(HbStyleOptionInputDialog *option) const |
357 { |
335 { |
358 Q_D(const HbInputDialog); |
336 Q_D(const HbInputDialog); |
359 HbDialog::initStyleOption(option); |
337 HbDialog::initStyleOption(option); |
360 option->text = d->mPromptText; |
338 option->text = d->mPromptText; |
361 option->additionalText = d->mPromptAdditionalText; |
339 option->additionalText = d->mPromptAdditionalText; |
362 } |
340 } |
363 |
341 |
|
342 void HbInputDialog::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive) |
|
343 { |
|
344 HbWidgetBase::initPrimitiveData(primitiveData, primitive); |
|
345 QString itemName = HbStyle::itemName(primitive); |
|
346 if (itemName == QLatin1String("label-1")) { |
|
347 HbStyleTextPrimitiveData *data = hbstyleprimitivedata_cast<HbStyleTextPrimitiveData*>(primitiveData); |
|
348 data->text = promptText(); |
|
349 data->textWrapping = Hb::TextWordWrap; |
|
350 } |
|
351 |
|
352 if (itemName == QLatin1String("label-2")) { |
|
353 HbStyleTextPrimitiveData *data = hbstyleprimitivedata_cast<HbStyleTextPrimitiveData*>(primitiveData); |
|
354 data->text = promptText(1); |
|
355 data->textWrapping = Hb::TextWordWrap; |
|
356 } |
|
357 } |
|
358 |
364 /*! |
359 /*! |
365 \reimp |
360 \reimp |
366 */ |
361 */ |
367 void HbInputDialog::updatePrimitives() |
362 void HbInputDialog::updatePrimitives() |
368 { |
363 { |
369 Q_D(HbInputDialog); |
364 Q_D(HbInputDialog); |
370 HbDialog::updatePrimitives(); |
365 HbDialog::updatePrimitives(); |
371 HbStyleOptionInputDialog option; |
|
372 initStyleOption(&option); |
|
373 if (d->mContentWidget->mLabel1) { |
366 if (d->mContentWidget->mLabel1) { |
374 style()->updatePrimitive(d->mContentWidget->mLabel1, HbStyle::P_InputDialog_text, &option); |
367 HbStyleTextPrimitiveData data; |
375 } |
368 initPrimitiveData(&data, d->mContentWidget->mLabel1); |
376 |
369 style()->updatePrimitive(d->mContentWidget->mLabel1, &data, this); |
377 if (d->mContentWidget->mLabel2 && d->mContentWidget->mAdditionalRowVisible) { |
370 } |
378 style()->updatePrimitive(d->mContentWidget->mLabel2, HbStyle::P_InputDialog_additionaltext, &option); |
371 |
379 } |
372 if (d->mContentWidget->mLabel2) { |
380 } |
373 HbStyleTextPrimitiveData data; |
381 |
374 initPrimitiveData(&data, d->mContentWidget->mLabel2); |
|
375 style()->updatePrimitive(d->mContentWidget->mLabel2, &data, this); |
|
376 } |
|
377 } |
|
378 |
|
379 |
|
380 /*! |
|
381 Recreaction of all the primitives. |
|
382 */ |
|
383 void HbInputDialog::recreatePrimitives() |
|
384 { |
|
385 Q_D(HbInputDialog); |
|
386 if (d->mContentWidget->mLabel1) { |
|
387 delete d->mContentWidget->mLabel1; |
|
388 d->mContentWidget->mLabel1 = 0; |
|
389 d->mContentWidget->mLabel1 = style()->createPrimitive(HbStyle::PT_IconItem, "label-1",d->mContentWidget); |
|
390 } |
|
391 if (d->mContentWidget->mLabel2) { |
|
392 delete d->mContentWidget->mLabel2; |
|
393 d->mContentWidget->mLabel2 = 0; |
|
394 d->mContentWidget->mLabel2 = style()->createPrimitive(HbStyle::PT_IconItem, "label-2",d->mContentWidget); |
|
395 } |
|
396 } |
382 void HbInputDialog::done(int code) |
397 void HbInputDialog::done(int code) |
383 { |
398 { |
384 Q_D(HbInputDialog); |
399 Q_D(HbInputDialog); |
385 if(code==Accepted) { |
400 if(code==Accepted) { |
386 QString text; |
401 QString text; |
672 dlg->setPromptText(promptText); |
687 dlg->setPromptText(promptText); |
673 dlg->setValue(defaultIp); |
688 dlg->setValue(defaultIp); |
674 dlg->setInputMode(IpInput); |
689 dlg->setInputMode(IpInput); |
675 dlg->open(receiver,member); |
690 dlg->open(receiver,member); |
676 } |
691 } |
|
692 |
|
693 QGraphicsItem *HbInputDialog::primitive(const QString &itemName) const |
|
694 { |
|
695 Q_D(const HbInputDialog); |
|
696 |
|
697 if(!itemName.compare(QString("label-1"))){ |
|
698 return d->mContentWidget->mLabel1; |
|
699 } |
|
700 if(!itemName.compare(QString("label-2"))){ |
|
701 return d->mContentWidget->mLabel2; |
|
702 } |
|
703 |
|
704 return HbDialog::primitive(itemName); |
|
705 } |
|
706 |
677 #include "moc_hbinputdialog.cpp" |
707 #include "moc_hbinputdialog.cpp" |
678 |
708 |