-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
5 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "quintvalidator.h" | ||
|
||
/// | ||
/// \brief QUIntValidator::QUIntValidator | ||
/// \param parent | ||
/// | ||
QUIntValidator::QUIntValidator(QObject *parent) | ||
: QValidator{parent} | ||
,_bottom(0) | ||
,_top(UINT_MAX) | ||
{ | ||
} | ||
|
||
/// | ||
/// \brief QUIntValidator::QUIntValidator | ||
/// \param bottom | ||
/// \param top | ||
/// \param parent | ||
/// | ||
QUIntValidator::QUIntValidator(uint bottom, uint top, QObject *parent) | ||
: QValidator(parent) | ||
,_bottom(bottom) | ||
,_top(top) | ||
{ | ||
|
||
} | ||
|
||
/// | ||
/// \brief QUIntValidator::validate | ||
/// \return | ||
/// | ||
QValidator::State QUIntValidator::validate(QString& input, int &) const | ||
{ | ||
bool ok = false; | ||
const auto value = input.toUInt(&ok, 10); | ||
|
||
if (ok && value >=_bottom && value <=_top ) | ||
{ | ||
return QValidator::Acceptable; | ||
} | ||
|
||
return QValidator::Invalid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef QUINTVALIDATOR_H | ||
#define QUINTVALIDATOR_H | ||
|
||
#include <QValidator> | ||
#include <QObject> | ||
|
||
class QUIntValidator : public QValidator | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QUIntValidator(QObject *parent = nullptr); | ||
QUIntValidator(uint bottom, uint top, QObject *parent = nullptr); | ||
|
||
State validate(QString &, int &) const override; | ||
|
||
private: | ||
uint _bottom; | ||
uint _top; | ||
}; | ||
|
||
#endif // QUINTVALIDATOR_H |