Changeset View
Changeset View
Standalone View
Standalone View
libs/editor/simpleiplistvalidator.h
- This file was copied from libs/editor/simpleipv4addressvalidator.h.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 2009 Paul Marchouk <pmarchouk@gmail.com> | 2 | Copyright 2018 Bruce Anderson <banderson19com@san.rr.com> | ||
3 | 3 | | |||
4 | This program is free software; you can redistribute it and/or | 4 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | 5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2 of | 6 | published by the Free Software Foundation; either version 2 of | ||
7 | the License or (at your option) version 3 or any later version | 7 | the License or (at your option) version 3 or any later version | ||
8 | accepted by the membership of KDE e.V. (or its successor approved | 8 | accepted by the membership of KDE e.V. (or its successor approved | ||
9 | by the membership of KDE e.V.), which shall act as a proxy | 9 | by the membership of KDE e.V.), which shall act as a proxy | ||
10 | defined in Section 14 of version 3 of the license. | 10 | defined in Section 14 of version 3 of the license. | ||
11 | 11 | | |||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef SIMPLEIPV4ADDRESSVALIDATOR_H | 21 | #ifndef SIMPLEIPLISTVALIDATOR_H | ||
22 | #define SIMPLEIPV4ADDRESSVALIDATOR_H | 22 | #define SIMPLEIPLISTVALIDATOR_H | ||
23 | 23 | | |||
24 | #include <QValidator> | 24 | #include <QValidator> | ||
25 | #include "simpleipv4addressvalidator.h" | ||||
26 | #include "simpleipv6addressvalidator.h" | ||||
25 | 27 | | |||
26 | class Q_DECL_EXPORT SimpleIpV4AddressValidator : public QValidator | 28 | class Q_DECL_EXPORT SimpleIpListValidator : public QValidator | ||
27 | { | 29 | { | ||
28 | public: | 30 | public: | ||
29 | explicit SimpleIpV4AddressValidator(QObject *parent); | 31 | enum AddressType {Ipv4, Ipv6, Both}; | ||
30 | ~SimpleIpV4AddressValidator() override; | 32 | enum AddressStyle {Base, WithCidr, WithPort}; | ||
33 | | ||||
34 | explicit SimpleIpListValidator(QObject *parent, | ||||
35 | AddressStyle style = AddressStyle::Base, | ||||
36 | AddressType allow = AddressType::Both); | ||||
37 | ~SimpleIpListValidator() override; | ||||
31 | 38 | | |||
32 | State validate(QString &, int &) const override; | 39 | State validate(QString &, int &) const override; | ||
33 | 40 | | |||
34 | /** Check input value with a regular expression describing simple input mask. | 41 | private: | ||
35 | */ | 42 | SimpleIpV6AddressValidator *m_ipv6Validator; | ||
36 | QValidator::State checkWithInputMask(QString &, int &) const; | 43 | SimpleIpV4AddressValidator *m_ipv4Validator; | ||
37 | /** Function split intput string into tetrads and check them for valid values. | | |||
38 | * In the tetrads are placed into QList. Input string may be changed. | | |||
39 | */ | | |||
40 | QValidator::State checkTetradsRanges(QString &, QList<int>&) const; | | |||
41 | }; | 44 | }; | ||
42 | 45 | | |||
43 | #endif // SIMPLEIPV4ADDRESSVALIDATOR_H | 46 | #endif // SIMPLEIPV4ADDRESSVALIDATOR_H |