This class implements the BPS mask validator for input text. More...
#include <bpsmaskprocessor.h>
Public Member Functions | |
BpsMaskProcessor () | |
Default constructor. | |
BpsMaskProcessor (const QString &aMask) | |
QString | fixup (const QString &aInput) const |
Fix up the input if possible. More... | |
QString | mask () const |
int | maxLength () const |
Returns the maximum input length (including fillers) | |
int | minLength () const |
Returns the minimum input length (including fillers) | |
void | setMask (const QString &aMask) |
Set the new mask. More... | |
bool | validate (QString &aInput, int &aPos) const |
Validate input and remove invalid inputs. More... | |
This class implements the BPS mask validator for input text.
A mask is a QString containing the characters defined in the following table.
Mask char | Allowed input chars | Notes |
---|---|---|
A,a | A-Z a-z | ASCII alphabetic characters |
B,b | 0 1 | Binary digits |
C,c | A-Z a-z 0-9 | ASCII alphabetic characters and digits |
D,d | 0-9 | Decimal digits |
F,f | A-Z a-z 0-9 - _ $ . | Filenames (words and dots) |
G,g | A-Z a-z 0-9 - _ $ . space | Filenames with spaces |
H,h | 0-9 a-f A-F | Hexadecimal digits |
I,i | 0-9 - , | Comma separated list of integers |
J,j | 0-9 - . , | Comma separated list of floats |
N,n | 0-9 | Formatted numbers: Upper case N's are interpreted as minimum number of digits to enter during input, followed by lower case n's to complete to the maximum number of digits. So NnnNNnn will be interpreted as two numbers, where the first is 3 digits long and 1 must be entered at least, and the second is 4 digits while 2 of them must be entered at least. |
P,p | A-Z a-z 0-9 - _ $ . / | Pathnames (filenames and slashes) |
Q,q | A-Z a-z 0-9 - _ $ . / space | Pathnames with spaces |
S,s | + - | Plus or minus sign |
W,w | A-Z a-z 0-9 - _ $ | Words |
X,x | All printable characters | No whitespace |
Y,y | All printable characters | Including whitespace |
> | Convert following input to upper case. | |
< | Convert following input to lower case. | |
! | Switch off case conversion. | |
\ | Do not interpret the next char as mask, use it as filler. | |
Other char | Filler | Insert exactly as written in mask. The user can omit input, it will be inserted automatically. |
Examples:
Mask | User input | Result after fixup |
---|---|---|
nnnn.nnn.nnn.nn | 1 | 1000.000.000.00 |
1.1.12.5 | 0001.001.012.05 | |
.23..6 | 0000.023.000.06 | |
0000.000.000.00 | ||
123456 | 1234.056.000.00 | |
NNnnNNNnnn | 1 | 0001000000 |
12345 | 1234000005 | |
123456 | 1234000056 | |
12345678 | 1234005678 | |
Ddd-Bnn | 1a | 1-A00 |
10k5 | 10-K05 |
BpsMaskProcessor::BpsMaskProcessor | ( | const QString & | aMask | ) |
aMask | The mask. |
Fix up the input if possible.
This will remove all invalid characters and format all n/N sequences.
aInput | The unprocessed string |
QString BpsMaskProcessor::mask | ( | ) | const |
void BpsMaskProcessor::setMask | ( | const QString & | aMask | ) |
Set the new mask.
aMask | The new mask to set |
bool BpsMaskProcessor::validate | ( | QString & | aInput, |
int & | aPos | ||
) | const |
Validate input and remove invalid inputs.
aInput | The input to validate. |
aPos | The cursor position. |