|
CenGen - Генератор ценников
1.1
|
00001 #ifndef BVALIDATOR_H 00002 #define BVALIDATOR_H 00003 00004 #include <QValidator> 00005 00006 class BarcodeValidator : public QValidator { 00007 public: 00008 BarcodeValidator(QObject* parent) 00009 : QValidator(parent) 00010 { 00011 00012 } 00013 00014 virtual State validate(QString& str, int& pos) const 00015 { 00016 QString tmp; 00017 QRegExp rxp = QRegExp ("[0-9]"); 00018 for (int i = 0; i<str.length(); i++) { 00019 tmp = str.at(i); 00020 if (!tmp.contains(rxp) && tmp != "*") { 00021 return Invalid; 00022 } 00023 } 00024 if (pos == 1 && str[0] == '0') { 00025 return Invalid; 00026 } 00027 if (str.length()>13) { 00028 return Invalid; 00029 } 00030 return Acceptable; 00031 00032 } 00033 }; 00034 00035 00036 #endif // BVALIDATOR_H