Changeset View
Changeset View
Standalone View
Standalone View
libs/editor/simpleipv6addressvalidator.h
Show All 20 Lines | |||||
21 | #ifndef SIMPLEIPV6ADDRESSVALIDATOR_H | 21 | #ifndef SIMPLEIPV6ADDRESSVALIDATOR_H | ||
22 | #define SIMPLEIPV6ADDRESSVALIDATOR_H | 22 | #define SIMPLEIPV6ADDRESSVALIDATOR_H | ||
23 | 23 | | |||
24 | #include <QValidator> | 24 | #include <QValidator> | ||
25 | 25 | | |||
26 | class Q_DECL_EXPORT SimpleIpV6AddressValidator : public QValidator | 26 | class Q_DECL_EXPORT SimpleIpV6AddressValidator : public QValidator | ||
27 | { | 27 | { | ||
28 | public: | 28 | public: | ||
29 | explicit SimpleIpV6AddressValidator(QObject *parent); | 29 | enum AddressStyle {Base, WithCidr, WithPort}; | ||
30 | | ||||
31 | explicit SimpleIpV6AddressValidator(QObject *parent, AddressStyle style = AddressStyle::Base); | ||||
30 | ~SimpleIpV6AddressValidator() override; | 32 | ~SimpleIpV6AddressValidator() override; | ||
31 | 33 | | |||
32 | State validate(QString &, int &) const override; | 34 | State validate(QString &, int &) const override; | ||
33 | 35 | | |||
34 | /** Check input value with a regular expression describing simple input mask. | 36 | /** Check input value with a regular expression describing simple input mask. | ||
35 | */ | 37 | */ | ||
36 | QValidator::State checkWithInputMask(QString &, int &) const; | 38 | QValidator::State checkWithInputMask(QString &, int &) const; | ||
37 | /** Function split intput string into tetrads and check them for valid values. | 39 | /** 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. | 40 | * In the tetrads are placed into QList. Input string may be changed. | ||
39 | */ | 41 | */ | ||
40 | QValidator::State checkTetradsRanges(QString &) const; | 42 | QValidator::State checkTetradsRanges(QString &) const; | ||
43 | private: | ||||
44 | AddressStyle m_addressStyle; | ||||
45 | QRegularExpressionValidator m_validator; | ||||
41 | }; | 46 | }; | ||
42 | 47 | | |||
43 | #endif // SIMPLEIPV6ADDRESSVALIDATOR_H | 48 | #endif // SIMPLEIPV6ADDRESSVALIDATOR_H |