File indexing completed on 2024-04-28 16:52:16

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2022 Daniel Vrátil <dvratil@kde.org>
0003 
0004 #include "kcm_firewall_core_export.h"
0005 
0006 #include <QValidator>
0007 
0008 class KCM_FIREWALL_CORE_EXPORT IPValidator : public QValidator
0009 {
0010     Q_OBJECT
0011 
0012     Q_PROPERTY(IPVersion ipVersion READ ipVersion WRITE setIPVersion NOTIFY ipVersionChanged)
0013 public:
0014     enum class IPVersion { IPv4, IPv6 };
0015     Q_ENUM(IPVersion)
0016 
0017     explicit IPValidator(QObject *parent = nullptr);
0018 
0019     IPVersion ipVersion() const;
0020     void setIPVersion(IPVersion version);
0021 
0022     QValidator::State validate(QString &input, int &pos) const override;
0023 
0024 Q_SIGNALS:
0025     void ipVersionChanged(IPVersion version);
0026 
0027 private:
0028     IPVersion mIPVersion = IPVersion::IPv4;
0029 };