2021-02-22 11:33:18 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2021-02-22 11:33:18 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-07-22 16:48:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "IStringValidator.h"
|
2021-02-22 11:33:18 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
2024-07-22 16:48:02 +00:00
|
|
|
#include <QValidator>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
#include "ValidationError.h"
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
namespace validators {
|
2021-03-23 07:49:52 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
class LineEditValidator : public QValidator
|
|
|
|
|
{
|
2021-03-23 07:49:52 +00:00
|
|
|
public:
|
2024-10-17 18:04:35 +00:00
|
|
|
explicit LineEditValidator(QLineEdit *lineEdit = nullptr, ValidationError *error = nullptr);
|
2024-07-02 19:07:06 +00:00
|
|
|
QValidator::State validate(QString &input, int &pos) const override;
|
|
|
|
|
void addValidator(std::unique_ptr<IStringValidator> validator);
|
2021-03-23 07:49:52 +00:00
|
|
|
|
|
|
|
|
private:
|
2024-08-01 00:13:01 +00:00
|
|
|
ValidationError *m_pError = nullptr;
|
|
|
|
|
QLineEdit *m_pLineEdit = nullptr;
|
2024-07-02 19:07:06 +00:00
|
|
|
std::vector<std::unique_ptr<IStringValidator>> m_Validators;
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
void setError(const QString &message) const;
|
2021-02-22 11:33:18 +00:00
|
|
|
};
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
} // namespace validators
|