17 */ |
17 */ |
18 |
18 |
19 #include "fmsingletextquery.h" |
19 #include "fmsingletextquery.h" |
20 |
20 |
21 #include <QGraphicsLinearLayout> |
21 #include <QGraphicsLinearLayout> |
|
22 #include <QRegExp> |
22 |
23 |
23 #include <hbwidget.h> |
24 #include <hbwidget.h> |
24 #include <hblineedit.h> |
25 #include <hblineedit.h> |
25 #include <hbaction.h> |
26 #include <hbaction.h> |
26 |
27 |
27 FmSingleTextQuery::FmSingleTextQuery( Options options, |
28 FmSingleTextQuery::FmSingleTextQuery( HbLineEdit::EchoMode echoMode, QGraphicsItem *parent ) : |
28 HbLineEdit::EchoMode echoMode, QGraphicsItem *parent ) : |
29 FmDialog( parent ), mEchoMode( echoMode ) |
29 HbDialog( parent ), mOptions( options ), mEchoMode( echoMode ) |
|
30 { |
30 { |
31 init(); |
31 init(); |
32 } |
32 } |
33 |
33 |
34 FmSingleTextQuery::~FmSingleTextQuery() |
34 FmSingleTextQuery::~FmSingleTextQuery() |
35 { |
35 { |
36 } |
36 } |
37 |
37 |
38 void FmSingleTextQuery::init() |
38 void FmSingleTextQuery::init() |
39 { |
39 { |
|
40 setObjectName( "SingleTextQuery " ); |
40 setDismissPolicy( HbPopup::NoDismiss ); |
41 setDismissPolicy( HbPopup::NoDismiss ); |
41 mContentWidget = new HbWidget(); |
42 mContentWidget = new HbWidget(); |
42 setContentWidget( mContentWidget ); |
43 mContentWidget->setObjectName( "SingleTextContentWidget" ); |
|
44 setContentWidget( mContentWidget ); |
|
45 |
43 |
46 |
44 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
47 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
45 vLayout->setOrientation( Qt::Vertical ); |
48 vLayout->setOrientation( Qt::Vertical ); |
46 |
49 |
47 mTextEdit = new HbLineEdit(); |
50 mTextEdit = new HbLineEdit(); |
48 mTextEdit->setEchoMode( mEchoMode ); |
51 mTextEdit->setEchoMode( mEchoMode ); |
49 mTextEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
52 mTextEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
|
53 mTextEdit->setObjectName( "textLineEdit" ); |
50 vLayout->addItem( mTextEdit ); |
54 vLayout->addItem( mTextEdit ); |
51 |
55 |
52 mContentWidget->setLayout( vLayout ); |
56 mContentWidget->setLayout( vLayout ); |
53 |
57 |
54 setTimeout( NoTimeout ); |
58 setTimeout( NoTimeout ); |
72 void FmSingleTextQuery::setLineEditMaxLength( int length ) |
76 void FmSingleTextQuery::setLineEditMaxLength( int length ) |
73 { |
77 { |
74 mTextEdit->setMaxLength( length ); |
78 mTextEdit->setMaxLength( length ); |
75 } |
79 } |
76 |
80 |
|
81 void FmSingleTextQuery::setRegExpStringList( QStringList regExpStringList ) |
|
82 { |
|
83 mRegExpStringList = regExpStringList; |
|
84 } |
|
85 |
77 void FmSingleTextQuery::checkActions() |
86 void FmSingleTextQuery::checkActions() |
78 { |
87 { |
79 if( mOptions & DimPrimereActionWhenEmpty ) { |
88 // check if all regExp match, disable primary action if not match |
80 if( !mTextEdit->text().isEmpty() ){ |
89 bool validateResult = true; |
81 this->primaryAction()->setEnabled( true ); |
90 foreach( const QString ®ExpString, mRegExpStringList ) { |
82 } else { |
91 if( !regExpString.isEmpty() ) { |
83 this->primaryAction()->setEnabled( false ); |
92 QRegExp regExp( regExpString ); |
|
93 if( !regExp.exactMatch( mTextEdit->text() ) ) { |
|
94 validateResult = false; |
|
95 } |
84 } |
96 } |
85 } |
97 } |
|
98 if( validateResult ) { |
|
99 this->primaryAction()->setEnabled( true ); |
|
100 } else { |
|
101 this->primaryAction()->setEnabled( false ); |
|
102 } |
86 } |
103 } |