File indexing completed on 2024-12-01 04:19:02

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003-2005 Jarosław Staniek <staniek@kde.org>
0003    Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This program is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this program; see the file COPYING.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KDB_TOOLS_IDENTIFIER_H
0022 #define KDB_TOOLS_IDENTIFIER_H
0023 
0024 #include "KDbValidator.h"
0025 
0026 //! Validates input for identifier.
0027 class KDB_EXPORT KDbIdentifierValidator : public KDbValidator
0028 {
0029     Q_OBJECT
0030 public:
0031     explicit KDbIdentifierValidator(QObject * parent = nullptr);
0032 
0033     ~KDbIdentifierValidator() override;
0034 
0035     State validate(QString &input, int &pos) const override;
0036 
0037     //! @return true if upper-case letters in the input are replaced to lower-case.
0038     //! @c false by default.
0039     bool isLowerCaseForced() const;
0040 
0041     //! If @a set is true, upper-case letters in the input are replaced to lower-case.
0042     void setLowerCaseForced(bool set);
0043 
0044 protected:
0045     KDbValidator::Result internalCheck(const QString &valueName, const QVariant &value,
0046                                        QString *message, QString *details) override;
0047 
0048 private:
0049     class Private;
0050     Private* const d;
0051     Q_DISABLE_COPY(KDbIdentifierValidator)
0052 };
0053 
0054 #endif