File indexing completed on 2024-05-12 12:41:37

0001 /*
0002  *   SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QValidator>
0010 
0011 class TimeInputValidatorPrivate;
0012 
0013 class TimeInputValidator : public QValidator
0014 {
0015     Q_OBJECT
0016 
0017     /**
0018      * This property holds the desired time format.
0019      */
0020     Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
0021 
0022 public:
0023     explicit TimeInputValidator(QObject *parent = nullptr);
0024     ~TimeInputValidator() override;
0025 
0026     // Overrides from QValidator.
0027     void fixup(QString &input) const override;
0028     QValidator::State validate(QString &input, int &pos) const override;
0029 
0030     /**
0031      * Returns the desired time format.
0032      */
0033     QString format() const;
0034 
0035     /**
0036      * Sets the desired time format.
0037      */
0038     void setFormat(const QString &format);
0039 
0040 Q_SIGNALS:
0041     void formatChanged();
0042 
0043 private:
0044     QScopedPointer<TimeInputValidatorPrivate> d;
0045 
0046     Q_DISABLE_COPY(TimeInputValidator)
0047 };