File indexing completed on 2024-12-01 13:00:20

0001 /* This file is part of the KDE project
0002    Copyright (C) 2006-2016 Jarosław Staniek <staniek@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KDB_TOOLS_LLONGVALIDATOR_H
0021 #define KDB_TOOLS_LLONGVALIDATOR_H
0022 
0023 #include "kdb_export.h"
0024 
0025 #include <QValidator>
0026 
0027 //! @short A validator for longlong data type.
0028 /*!
0029   This can be used by QLineEdit or subclass to provide validated
0030   text entry.  Can be provided with a base value (default is 10), to allow
0031   the proper entry of hexadecimal, octal, or any other base numeric data.
0032 
0033   Based on KIntValidator code by Glen Parker <glenebob@nwlink.com>
0034 */
0035 class KDB_EXPORT KDbLongLongValidator : public QValidator
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit KDbLongLongValidator(QWidget * parent, int base = 10);
0040     KDbLongLongValidator(qint64 bottom, qint64 top, QWidget * parent, int base = 10);
0041     ~KDbLongLongValidator() override;
0042 
0043     //! Validates the text, and returns the result.  Does not modify the parameters.
0044     State validate(QString &, int &) const override;
0045 
0046     //! Fixes the text if possible, providing a valid string.  The parameter may be modified.
0047     void fixup(QString &) const override;
0048 
0049     //! Sets the minimum and maximum values allowed.
0050     virtual void setRange(qint64 bottom, qint64 top);
0051 
0052     //! Sets the numeric base value.
0053     virtual void setBase(int base);
0054 
0055     //! @return the current minimum value allowed
0056     virtual qint64 bottom() const;
0057 
0058     //! @return the current maximum value allowed
0059     virtual qint64 top() const;
0060 
0061     //! @return the current numeric base
0062     virtual int base() const;
0063 
0064 private:
0065     class Private;
0066     Private * const d;
0067     Q_DISABLE_COPY(KDbLongLongValidator)
0068 };
0069 
0070 #endif