swift
uppercasevalidator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_UPPERCASEVALIDATOR_H
7 #define SWIFT_GUI_UPPERCASEVALIDATOR_H
8 
9 #include <QStringList>
10 #include <QValidator>
11 
12 #include "gui/swiftguiexport.h"
13 
14 namespace swift::gui
15 {
17  class SWIFT_GUI_EXPORT CUpperCaseValidator : public QValidator
18  {
19  Q_OBJECT
20 
21  public:
23  explicit CUpperCaseValidator(QObject *parent = nullptr);
24 
26  CUpperCaseValidator(int minLength, int maxLength, QObject *parent = nullptr);
27 
29  CUpperCaseValidator(bool optionalValue, int minLength, int maxLength, QObject *parent = nullptr);
30 
32  void setRestrictions(const QStringList &restrictions) { m_restrictions = restrictions; }
33 
35  void setAllowedCharacters(const QString &chars) { m_allowedCharacters = chars.toUpper(); }
36 
38  void setAllowedCharacters09AZ();
39 
41  virtual State validate(QString &input, int &pos) const override;
42 
44  virtual void fixup(QString &input) const override;
45 
46  private:
47  bool m_optionalValue = false;
48  int m_minLength = 0;
49  int m_maxLength = 32678;
50  QString m_allowedCharacters;
51  QStringList m_restrictions;
52  };
53 } // namespace swift::gui
54 #endif // SWIFT_GUI_UPPERCASEVALIDATOR_H
void setRestrictions(const QStringList &restrictions)
Set restrictions.
void setAllowedCharacters(const QString &chars)
Allowed characters.
GUI related classes.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.