equal
deleted
inserted
replaced
18 #include <glxcommondialogs.h> |
18 #include <glxcommondialogs.h> |
19 |
19 |
20 #include <hbaction.h> |
20 #include <hbaction.h> |
21 #include <QEventLoop> |
21 #include <QEventLoop> |
22 const int MAXSTRINGLENGHT = 256; |
22 const int MAXSTRINGLENGHT = 256; |
|
23 |
|
24 // this is regexp for valid file/folder name: no \/:*?"<>| and is not totally empty characters. |
|
25 // file name can not end with "." , but it is not include in this RegExp. It should be checked in Regex_ValidNotEndWithDot |
|
26 // this expression is composed by two expressions: |
|
27 // ^.*[^\\s].*$ used to match un-empty string and is not totally empty characters. |
|
28 // [^\\\\/:*?\"<>|] used to math valid file/folder name |
|
29 // merge the two regex together: |
|
30 // valid file/folder name and is not totally empty. |
|
31 #define Regex_ValidFileFolderName QString( "^[^\\\\/:*?\"<>|]*[^\\\\/:*?\"<>|\\s][^\\\\/:*?\"<>|]*$" ) |
|
32 |
|
33 // is not end with dot( trim blank characters in the end first ) |
|
34 #define Regex_ValidNotEndWithDot QString( "^.*[^\\.\\s][\\s]*$" ) |
23 |
35 |
24 GlxTextInputDialog::GlxTextInputDialog(bool disableOkForEmptyText) |
36 GlxTextInputDialog::GlxTextInputDialog(bool disableOkForEmptyText) |
25 : mDialog ( NULL ), |
37 : mDialog ( NULL ), |
26 mEventLoop ( 0 ), |
38 mEventLoop ( 0 ), |
27 mResult ( false ), |
39 mResult ( false ), |
68 return retText; |
80 return retText; |
69 } |
81 } |
70 |
82 |
71 void GlxTextInputDialog::textChanged(const QString &text) |
83 void GlxTextInputDialog::textChanged(const QString &text) |
72 { |
84 { |
73 if (text.trimmed().isEmpty()) { |
85 // check if all regExp match, disable primary action if not match |
|
86 QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot ); |
|
87 |
|
88 bool validateResult = true; |
|
89 foreach( const QString ®ExpString, regExpList ) { |
|
90 if( !regExpString.isEmpty() ) { |
|
91 QRegExp regExp( regExpString ); |
|
92 if( !regExp.exactMatch( text ) ) { |
|
93 validateResult = false; |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 if(!validateResult){ |
74 mDialog->actions().first()->setEnabled(false); |
99 mDialog->actions().first()->setEnabled(false); |
75 } |
100 } |
76 else { |
101 else { |
77 mDialog->actions().first()->setEnabled(true); |
102 mDialog->actions().first()->setEnabled(true); |
78 } |
103 } |