--- a/src/hbwidgets/popups/hbinputdialog.cpp Mon May 03 12:48:33 2010 +0300
+++ b/src/hbwidgets/popups/hbinputdialog.cpp Fri May 14 16:09:54 2010 +0300
@@ -23,14 +23,13 @@
**
****************************************************************************/
-
#include <hbinputdialog.h>
#include "hbinputdialog_p.h"
#include "hbglobal_p.h"
#include <hblineedit.h>
#include <hbaction.h>
#include "hbinputdialogcontent_p.h"
-#include <hbstyleoptioninputdialog.h>
+#include <hbstyleoptioninputdialog_p.h>
#include <hbvalidator.h>
#include <QGraphicsScene>
@@ -45,9 +44,12 @@
@hbwidgets
\class HbInputDialog
- \brief A class used to get information from the user.
+ \brief HbInputDialog creates a modal dialog for the user to get some information in the form of text or numbers.
- the input value can be a text, int, double or ip address.
+ Based on the \InputMode user can enter text, int, double or an IP address. InputDialog can have one or two line edit input fields.
+
+ HbInputDialog by default will have a label to display a descriptive text for the line edit input field and,
+ OK and Cancel buttons.
example code example:
\code
@@ -57,11 +59,26 @@
Four static convenience API's are provided: getText(), getInteger(), getDouble(), and getIp()
static API's can be used to quickly get an input from user.
+
+ \enum HbInputDialog::InputMode
+
+ \value \b TextInput When this value is set as Input mode, input dialog accepts text input in its
+ correspoinding line edit field.
+
+ \value \b IntInput When this value is set as Input mode, input dialog accepts Integer input in its
+ correspoinding line edit field.
+
+ \value \b RealInput When this value is set as Input mode, input dialog accepts double or float input in its
+ correspoinding line edit field.
+
+ \value \b IpInput When this value is set as Input mode, input dialog accepts Ip address as input in its
+ correspoinding line edit field.
+
*/
/*!
- Constructor of HbInputDialog
+ Constructor of HbInputDialog with a \a parent.
\param parent. Parent widget
*/
HbInputDialog::HbInputDialog(QGraphicsItem* parent) :
@@ -89,29 +106,29 @@
{
}
+/*!
+ Sets the input mode of the primary(Top/default)line edit in the query widget.
-/*!
- @beta
- Sets the input mode of the primary(Top/default)line edit in the query widget.
+ The default InputMode is TextInput
\param mode. InputMode can be TextMode, IntMode, RealMode and Ip address mode.
- each mode will affect how the line edit filters its input.
+ each mode will affect how the line edit filters its input.
\param row. value 0 or 1
\sa inputMode()
-*/
+*/
void HbInputDialog::setInputMode(InputMode mode ,int row)
{
Q_D(HbInputDialog);
d->setInputMode(mode,row);
}
+/*!
+ Returns input mode for top/default line edit.
-/*!
- @beta
- Returns input mode for top/default line edit.
The default InputMode is TextInput
+
\param row. value 0 or 1
\sa setInputMode()
@@ -130,12 +147,10 @@
}
}
-
/*!
- @beta
Sets the prompt \a text for top/default line edit.
- \param text. user defined text
+ \param text. Text for the label which describes the purpose of the corresponding input line edit field.
\param row. value 0 or 1
\sa promtText()
@@ -146,9 +161,7 @@
d->setPromptText(text, row);
}
-
/*!
- @beta
Returns prompt text for top/default line edit.
the default is null string.
\param row. value 0 or 1
@@ -162,10 +175,9 @@
}
/*!
- @beta
Sets the top/default line edit value in \a text format.
- \param value. user defined value
+ \param value. user defined value for the default line edit.
\param row. value 0 or 1
\sa value()
@@ -177,7 +189,6 @@
}
/*!
- @beta
Returns top/default line edit value as QVariant object.
\param row. value 0 or 1
@@ -191,7 +202,6 @@
}
/*!
- @beta
Sets the visibility of bottom line edit and prompt text.
\param visible true or false.
@@ -205,7 +215,6 @@
}
/*!
- @beta
Returns the visibility of secondary row(bottom line edit and prompt text).
the default is false
\sa setAdditionalRowVisible()
@@ -216,9 +225,7 @@
return d->isAdditionalRowVisible();
}
-
/*!
- @beta
Validator is used to validate the content and cursor movements.
\param validator. Validator uses undo stack to back out invalid changes. Therefore undo
@@ -236,10 +243,8 @@
}
}
-
/*!
- @beta
- returns the validator of the inputDialog's line edit.
+ Returns the validator of the inputDialog's line edit.
\param row. A value 0 or 1
@@ -256,9 +261,7 @@
return NULL;
}
-
/*!
- @beta
returns the lineEdit pointer. will return NULL if row is greater than 2.
\param row. A value 0 or 1
@@ -275,7 +278,6 @@
}
/*!
- @beta
sets the echo mode for the given row.
\param echoMode
@@ -296,9 +298,7 @@
}
};
-
/*!
-
\deprecated HbInputDialog::primitive(HbStyle::Primitive)
is deprecated.
@@ -321,7 +321,6 @@
}
/*!
- @beta
\reimp
Initializes \a option with the values from this HbInputDialog.
*/
@@ -333,9 +332,8 @@
option->additionalText = d->mPromptAdditionalText;
}
-
/*!
- @beta
+ \reimp
updatePrimitives.
*/
void HbInputDialog::updatePrimitives()
@@ -353,10 +351,8 @@
}
}
-
/*!
- @beta
- returns the echoMode of line edit. returns -1 if row is more than 2.
+ Returns the echoMode of line edit. returns -1 if row is more than 2.
\param row. A value 0 or 1
@@ -373,11 +369,9 @@
return HbLineEdit::EchoMode(-1);//
}
-
/*!
- @beta
- Static convenience function to get a string from the user. \a
- label is the text which is shown to the user (it should
+ Static convenience function for creating an input dialog to get a string from the user.
+ \a label is the text which is shown to the user (it should
say what should be entered). \a text is the default text which is
placed in the line edit. If \a ok is non-null \e *\a ok will be
set to true if the user pressed \gui OK and to false if the user pressed
@@ -401,60 +395,13 @@
}
dlg->setPromptText(label);
dlg->setInputMode(TextInput);
- dlg->setValue(text);
+ dlg->setValue(text);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->open(receiver,member);
}
-/*!
- \deprecated HbInputDialog::getText(const QString&,const QString&,bool*,QGraphicsScene*,QGraphicsItem*)
- is deprecated. Please use the other available getText API.
-
- Static convenience function to get a string from the user. \a
- label is the text which is shown to the user (it should
- say what should be entered). \a text is the default text which is
- placed in the line edit. If \a ok is non-null \e *\a ok will be
- set to true if the user pressed \gui OK and to false if the user pressed
- \gui Cancel. The dialog's parent is \a parent. The dialog will be
- modal.
-
- This function returns the text which has been entered in the line
- edit. It will not return an empty string.
-
- \sa getInteger(), getDouble(), getIp()
-*/
-QString HbInputDialog::getText(const QString &label,const QString &text,
- bool *ok, QGraphicsScene *scene, QGraphicsItem *parent)
-{
- HB_DEPRECATED("HbInputDialog::getText is deprecated. Please use HbInputDialog::getText((const QString&, QObject*, const char*, const QString&, QGraphicsScene*, QGraphicsItem*) instead.");
- Q_UNUSED(parent);//this is a bug in popup framework, cannot set parent will affect fading
-
- HbInputDialog *dlg = new HbInputDialog();
- if (scene) {
- scene->addItem(dlg);
- }
- QString result;
- dlg->setPromptText(label);
- dlg->setInputMode(TextInput);
- dlg->setValue(text);
- HbAction* action = dlg->exec();
- if(action == dlg->secondaryAction()) { //Cancel was pressed
- if(ok) {
- *ok = false;
- }
- } else { //OK was pressed
- if(ok) {
- *ok = true;
- }
- result = dlg->value().toString();
- }
- delete dlg;
- return result;
-}
-
/*!
- @beta
Static convenience function to get an integer input from the
user.\a label is the text which is shown to the user
(it should say what should be entered). \a value is the default
@@ -485,56 +432,6 @@
dlg->open(receiver,member);
}
/*!
- \deprecated HbInputDialog::getInteger(const QString&,int,bool*,QGraphicsScene*,QGraphicsItem*)
- is deprecated. Please use the other available HbInputDialog::getInteger API.
-
- Static convenience function to get an integer input from the
- user.\a label is the text which is shown to the user
- (it should say what should be entered). \a value is the default
- integer which the spinbox will be set to.
- If \a ok is non-null *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal.
-
- This function returns the integer which has been entered by the user.
-
- \sa getText(), getDouble(), getIp()
-*/
-int HbInputDialog::getInteger(const QString &label, int value,
- bool *ok,QGraphicsScene *scene,QGraphicsItem *parent)
-{
- HB_DEPRECATED("HbInputDialog::getInteger is deprecated. Please use HbInputDialog::getInteger(const QString&, QObject*, const char*,int,QGraphicsScene*,QGraphicsItem *) instead.");
-
- Q_UNUSED(parent)
-
- HbInputDialog *dlg = new HbInputDialog();
- QString result;
- dlg->setPromptText(label);
- dlg->setInputMode(IntInput);
- dlg->setValue(QString::number(value));
- if(scene) {
- scene->addItem(dlg);
- }
- HbAction* action = dlg->exec();
- if(action == dlg->secondaryAction()) { //Cancel was pressed
- if(ok) {
- *ok = false;
- }
- } else { //OK was pressed
- if(ok) {
- *ok = true;
- }
- result = dlg->value().toString();
- }
- delete dlg;
-#ifdef HBINPUTDIALOG_DEBUG
- qDebug()<<"Value:"<<result;
-#endif
- return result.toInt();
-}
-
-
-/*!
Static convenience function to get a floating point number from
the user.\a label is the text which is shown to the user
(it should say what should be entered). \a value is the default
@@ -557,7 +454,7 @@
{
HbInputDialog *dlg = new HbInputDialog(parent);
if(scene && !parent) {
- scene->addItem(dlg);
+ scene->addItem(dlg);
}
dlg->setPromptText(label);
dlg->setInputMode(RealInput);
@@ -567,59 +464,7 @@
/*!
- \deprecated HbInputDialog::getDouble(const QString &,double,bool*,QGraphicsScene*,QGraphicsItem*)
- is deprecated. Please use the other available HbInputDialog::getDouble(...) API.
-
- Static convenience function to get a floating point number from
- the user.\a label is the text which is shown to the user
- (it should say what should be entered). \a value is the default
- floating point number that the line edit will be set to.
-
- If \a ok is non-null, *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal.
-
- This function returns the floating point number which has been
- entered by the user.
-
- \sa getText(), getInteger(), getIp()
-*/
-double HbInputDialog::getDouble(const QString &label, double value,
- bool *ok, QGraphicsScene *scene, QGraphicsItem *parent)
-{
- HB_DEPRECATED("HbInputDialog::getDouble is deprecated.Please use HbInputDialog::getDouble(const QString&, QObject*,const char*,double, QGraphicsItem*) instead.");
-
- Q_UNUSED(parent)
-
- HbInputDialog *dlg = new HbInputDialog();
- QString result;
- dlg->setPromptText(label);
- dlg->setInputMode(RealInput);
- dlg->setValue(QString::number(value));
- if(scene) {
- scene->addItem(dlg);
- }
- HbAction* action = dlg->exec();
- if(action == dlg->secondaryAction()){ //Cancel was pressed
- if(ok) {
- *ok = false;
- }
- } else { //OK was pressed
- if(ok) {
- *ok = true;
- }
- result = dlg->value().toString();
- }
- delete dlg;
-#ifdef HBINPUTDIALOG_DEBUG
- qDebug()<<"Value:"<<result;
-#endif
- return result.toDouble();
-}
-
-/*!
- @beta
- Static convenience function to get a ip address from
+ Static convenience function to get an ip address from
the user.\a label is the text which is shown to the user
(it should say what should be entered). \a address is the default
QHostAddress that the line edit will be set to.
@@ -641,64 +486,12 @@
{
HbInputDialog *dlg = new HbInputDialog(parent);
if(scene && !parent) {
- scene->addItem(dlg);
+ scene->addItem(dlg);
}
dlg->setPromptText(label);
- dlg->setInputMode(IpInput);
- dlg->setValue(ipaddress);
+ dlg->setValue(ipaddress);
+ dlg->setInputMode(IpInput);
dlg->open(receiver,member);
}
-
-/*!
- \deprecated HbInputDialog::getIp(const QString &,const QString&, bool *,QGraphicsScene*,QGraphicsItem*)
- is deprecated. Please use the other available HbInputDialog::getIp API.
-
- Static convenience function to get a ip address from
- the user.\a label is the text which is shown to the user
- (it should say what should be entered). \a address is the default
- QHostAddress that the line edit will be set to.
-
- If \a ok is non-null, *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal.
-
- This function returns the ip address number which has been
- entered by the user.
-
- \sa getText(), getInteger(), getDouble()
-*/
-QString HbInputDialog::getIp(const QString &label, const QString &ipaddress, bool *ok, QGraphicsScene *scene,
- QGraphicsItem *parent)
-{
- HB_DEPRECATED("HbInputDialog::getIp is deprecated. Please use HbInputDialog::getIp(const QString &,QObject *,const char *,const QString &, QGraphicsScene *, QGraphicsItem *)");
-
- Q_UNUSED(parent)
-
- HbInputDialog *dlg = new HbInputDialog();
- QString result;
- dlg->setPromptText(label);
- dlg->setInputMode(IpInput);
- dlg->setValue(ipaddress);
- if(scene) {
- scene->addItem(dlg);
- }
- HbAction* action = dlg->exec();
- if(action == dlg->secondaryAction()){ //Cancel was pressed
- if(ok) {
- *ok = false;
- }
- } else { //OK was pressed
- if(ok) {
- *ok = true;
- }
- result = dlg->value().toString();
- }
- delete dlg;
-#ifdef HBINPUTDIALOG_DEBUG
- qDebug()<<"Value:"<<result;
-#endif
- return result;
-}
#include "moc_hbinputdialog.cpp"
-