File indexing completed on 2024-12-01 08:10:07
0001 /* 0002 SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>, based on work by Paul Marchouk <pmarchouk@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef SIMPLEIPV6ADDRESSVALIDATOR_H 0008 #define SIMPLEIPV6ADDRESSVALIDATOR_H 0009 0010 #include "plasmanm_editor_export.h" 0011 0012 #include <QValidator> 0013 0014 class PLASMANM_EDITOR_EXPORT SimpleIpV6AddressValidator : public QValidator 0015 { 0016 Q_OBJECT 0017 public: 0018 enum AddressStyle { Base, WithCidr, WithPort }; 0019 0020 explicit SimpleIpV6AddressValidator(AddressStyle style = AddressStyle::Base, QObject *parent = nullptr); 0021 ~SimpleIpV6AddressValidator() override; 0022 0023 State validate(QString &, int &) const override; 0024 0025 /** Check input value with a regular expression describing simple input mask. 0026 */ 0027 QValidator::State checkWithInputMask(QString &, int &) const; 0028 /** Function split input string into tetrads and check them for valid values. 0029 * In the tetrads are placed into QList. Input string may be changed. 0030 */ 0031 QValidator::State checkTetradsRanges(QString &) const; 0032 0033 private: 0034 const AddressStyle m_addressStyle; 0035 QRegularExpressionValidator m_validator; 0036 }; 0037 0038 #endif // SIMPLEIPV6ADDRESSVALIDATOR_H