2021-02-22 11:33:18 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2024-08-01 00:13:01 +00:00
|
|
|
* Copyright (C) 2021 Symless Ltd.
|
2021-02-22 11:33:18 +00:00
|
|
|
*
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
|
|
|
|
*
|
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
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-07-02 19:07:06 +00:00
|
|
|
class LineEditValidator : public QValidator {
|
2021-03-23 07:49:52 +00:00
|
|
|
public:
|
2024-07-16 13:36:44 +00:00
|
|
|
explicit LineEditValidator(
|
2024-08-01 00:13:01 +00:00
|
|
|
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
|