QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsdoublevalidator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdoublevalidator.h - description
3  -------------------
4  begin : June 2020
5  copyright : (C) 2020 by Sebastien Peillet
6  email : [email protected]
7 
8  adapted version of Qgslonglongvalidator + QgsFieldValidator
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #ifndef QGSDOUBLEVALIDATOR_H
21 #define QGSDOUBLEVALIDATOR_H
22 
23 #include <limits>
24 #include <QRegExpValidator>
25 #include <QLocale>
26 #include "qgis_gui.h"
27 #include "qgis_sip.h"
28 
38 class GUI_EXPORT QgsDoubleValidator : public QRegularExpressionValidator
39 {
40  Q_OBJECT
41 
42  public:
43 
47  explicit QgsDoubleValidator( QObject *parent );
48 
55  QgsDoubleValidator( const QRegularExpression &expression, double bottom, double top, QObject *parent );
56 
63  QgsDoubleValidator( double bottom, double top, QObject *parent );
64 
72  QgsDoubleValidator( double bottom, double top, int decimal, QObject *parent );
73 
74 
75  QValidator::State validate( QString &input, int & ) const override SIP_SKIP;
76 
81  QValidator::State validate( QString &input ) const;
82 
88  static double toDouble( const QString &input, bool *ok ) SIP_SKIP;
89 
95  static double toDouble( const QString &input );
96 
102  void setBottom( double bottom ) { mMinimum = bottom; }
103 
109  void setTop( double top ) { mMaximum = top; }
110 
116  virtual void setRange( double bottom, double top )
117  {
118  mMinimum = bottom;
119  mMaximum = top;
120  }
121 
126  double bottom() const { return mMinimum; }
127 
132  double top() const { return mMaximum; }
133 
134  private:
135  // Disables copy constructing
136  Q_DISABLE_COPY( QgsDoubleValidator )
137 
138 
141  double mMinimum;
142 
146  double mMaximum;
147 };
148 
149 #endif // QGSDOUBLEVALIDATOR_H
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsDoubleValidator::setTop
void setTop(double top)
Set top range limit.
Definition: qgsdoublevalidator.h:109
QgsDoubleValidator
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
Definition: qgsdoublevalidator.h:39
qgis_sip.h
QgsDoubleValidator::top
double top() const
Returns top range limit.
Definition: qgsdoublevalidator.h:132
QgsDoubleValidator::bottom
double bottom() const
Returns top range limit.
Definition: qgsdoublevalidator.h:126
QgsDoubleValidator::setRange
virtual void setRange(double bottom, double top)
Set bottom and top range limits.
Definition: qgsdoublevalidator.h:116
QgsDoubleValidator::setBottom
void setBottom(double bottom)
Set top range limit.
Definition: qgsdoublevalidator.h:102