| 1 |
/* Copyright (c) 2023, DyssolTEC. |
| 2 |
* All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ |
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <QRegExpValidator> |
| 7 |
|
| 8 |
template<typename T> |
| 9 |
class CQtValidator : public QRegExpValidator |
| 10 |
{ |
| 11 |
void fixup(QString& _input) const override |
| 12 |
{ |
| 13 |
_input = "0"; |
| 14 |
} |
| 15 |
}; |
| 16 |
|
| 17 |
template<> |
| 18 |
class CQtValidator<double> : public QRegExpValidator |
| 19 |
{ |
| 20 |
public: |
| 21 |
explicit CQtValidator(QObject* _parent = nullptr) |
| 22 |
: QRegExpValidator(QRegExp{ "^([+-]?(?:[0-9]+\\.?|[0-9]*\\.[0-9]+))(?:[Ee][+-]?[0-9]+)?$" }, _parent) |
| 23 |
{ |
| 24 |
} |
| 25 |
}; |
| 26 |
|
| 27 |
template<> |
| 28 |
class CQtValidator<int64_t> : public QRegExpValidator |
| 29 |
{ |
| 30 |
public: |
| 31 |
explicit CQtValidator(QObject* _parent = nullptr) |
| 32 |
: QRegExpValidator(QRegExp{ "^([+-]?([\\d]+))([Ee][+]?[0-9]+)?$" }, _parent) |
| 33 |
{ |
| 34 |
} |
| 35 |
}; |
| 36 |
|
| 37 |
template<> |
| 38 |
class CQtValidator<uint64_t> : public QRegExpValidator |
| 39 |
{ |
| 40 |
public: |
| 41 |
explicit CQtValidator(QObject* _parent = nullptr) |
| 42 |
: QRegExpValidator(QRegExp{ "^([+]?([\\d]+))([Ee][+]?[0-9]+)?$" }, _parent) |
| 43 |
{ |
| 44 |
} |
| 45 |
}; |