Changeset - 18a2603b6b9b
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-10-07 15:35:43
hy@ozderya.net
improved hex validator to not put space at the end of hex command
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
commandwidget.cpp
Show inline comments
 
@@ -33,7 +33,7 @@ public:
 
HexCommandValidator::HexCommandValidator(QObject* parent) :
 
    QRegExpValidator(parent)
 
{
 
    QRegExp regExp("([0-9A-F]{2}[ ])*");
 
    QRegExp regExp("^(?:(?:[0-9A-F]{2}[ ])+(?:[0-9A-F]{2}))|(?:[0-9A-F]{2})$");
 
    setRegExp(regExp);
 
}
 

	
 
@@ -47,10 +47,10 @@ QValidator::State HexCommandValidator::v
 
    pos = orgPos;
 

	
 
    // try fixing up spaces
 
    if (r == QValidator::Invalid)
 
    if (r != QValidator::Acceptable)
 
    {
 
        input = input.replace(" ", "");
 
        input.replace(QRegExp("([0-9A-F]{2})"), "\\1 ");
 
        input.replace(QRegExp("([0-9A-F]{2}(?!$))"), "\\1 ");
 
        if (pos == input.size()-1) pos = input.size();
 
        r = QRegExpValidator::validate(input, pos);
 
    }
0 comments (0 inline, 0 general)