-
-
Notifications
You must be signed in to change notification settings - Fork 342
Expand file tree
/
Copy pathQULongValidator.cpp
More file actions
78 lines (66 loc) · 1.44 KB
/
Copy pathQULongValidator.cpp
File metadata and controls
78 lines (66 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (C) 2006 - 2025 Evan Teran <evan.teran@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "QULongValidator.h"
/**
* @brief
*/
QULongValidator::QULongValidator(QObject *parent)
: QValidator(parent) {
}
/**
* @brief
*/
QULongValidator::QULongValidator(QULongValidator::value_type minimum, QULongValidator::value_type maximum, QObject *parent)
: QValidator(parent), minimum_(minimum), maximum_(maximum) {
}
/**
* @brief
*/
QULongValidator::value_type QULongValidator::bottom() const {
return minimum_;
}
/**
* @brief Sets the minimum value for the validator.
*
* @param bottom The new minimum value.
*/
void QULongValidator::setBottom(QULongValidator::value_type bottom) {
minimum_ = bottom;
}
/**
* @brief
*/
void QULongValidator::setRange(QULongValidator::value_type bottom, QULongValidator::value_type top) {
setBottom(bottom);
setTop(top);
}
/**
* @brief
*/
void QULongValidator::setTop(QULongValidator::value_type top) {
maximum_ = top;
}
/**
* @brief
*/
QULongValidator::value_type QULongValidator::top() const {
return maximum_;
}
/**
* @brief
*/
QValidator::State QULongValidator::validate(QString &input, int &pos) const {
Q_UNUSED(pos)
if (input.isEmpty()) {
return QValidator::Acceptable;
}
bool ok;
const value_type temp = input.toULongLong(&ok);
if (!ok) {
return QValidator::Invalid;
}
return (temp >= bottom() && temp <= top()) ? QValidator::Acceptable : QValidator::Invalid;
}