1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.validator; 15 extern(C++): 16 17 import qt.config; 18 import qt.helpers; 19 version(QT_NO_REGEXP){}else 20 version(QT_NO_VALIDATOR){}else 21 import qt.core.regexp; 22 version(QT_NO_VALIDATOR){}else 23 { 24 import qt.core.locale; 25 import qt.core.object; 26 import qt.core.regularexpression; 27 import qt.core.string; 28 } 29 30 /+ #if QT_CONFIG(regularexpression) 31 #endif +/ 32 33 34 version(QT_NO_VALIDATOR){}else 35 { 36 37 extern(C++, class) struct QValidatorPrivate; 38 39 class /+ Q_GUI_EXPORT +/ QValidator : QObject 40 { 41 mixin(Q_OBJECT); 42 public: 43 /+ explicit +/this(QObject parent = null); 44 ~this(); 45 46 enum State { 47 Invalid, 48 Intermediate, 49 Acceptable 50 } 51 /+ Q_ENUM(State) +/ 52 53 final void setLocale(ref const(QLocale) locale); 54 final QLocale locale() const; 55 56 /+ virtual +/ abstract State validate(ref QString , ref int ) const; 57 /+ virtual +/ void fixup(ref QString ) const; 58 59 /+ Q_SIGNALS +/public: 60 @QSignal final void changed(); 61 62 protected: 63 this(ref QObjectPrivate d, QObject parent); 64 this(ref QValidatorPrivate d, QObject parent); 65 66 private: 67 /+ Q_DISABLE_COPY(QValidator) +/ 68 /+ Q_DECLARE_PRIVATE(QValidator) +/ 69 } 70 71 class /+ Q_GUI_EXPORT +/ QIntValidator : QValidator 72 { 73 mixin(Q_OBJECT); 74 /+ Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged) 75 Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged) +/ 76 77 public: 78 /+ explicit +/this(QObject parent = null); 79 this(int bottom, int top, QObject parent = null); 80 ~this(); 81 82 override QValidator.State validate(ref QString , ref int ) const; 83 override void fixup(ref QString input) const; 84 85 final void setBottom(int); 86 final void setTop(int); 87 /+ virtual +/ void setRange(int bottom, int top); 88 89 final int bottom() const { return b; } 90 final int top() const { return t; } 91 /+ Q_SIGNALS +/public: 92 @QSignal final void bottomChanged(int bottom); 93 @QSignal final void topChanged(int top); 94 95 private: 96 /+ Q_DISABLE_COPY(QIntValidator) +/ 97 98 int b; 99 int t; 100 } 101 102 version(QT_NO_REGEXP){}else 103 { 104 105 extern(C++, class) struct QDoubleValidatorPrivate; 106 107 class /+ Q_GUI_EXPORT +/ QDoubleValidator : QValidator 108 { 109 mixin(Q_OBJECT); 110 /+ Q_PROPERTY(double bottom READ bottom WRITE setBottom NOTIFY bottomChanged) 111 Q_PROPERTY(double top READ top WRITE setTop NOTIFY topChanged) 112 Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged) 113 Q_PROPERTY(Notation notation READ notation WRITE setNotation NOTIFY notationChanged) +/ 114 115 public: 116 /+ explicit +/this(QObject parent = null); 117 this(double bottom, double top, int decimals, QObject parent = null); 118 ~this(); 119 120 enum Notation { 121 StandardNotation, 122 ScientificNotation 123 } 124 /+ Q_ENUM(Notation) +/ 125 override QValidator.State validate(ref QString , ref int ) const; 126 127 /+ virtual +/ void setRange(double bottom, double top, int decimals = 0); 128 final void setBottom(double); 129 final void setTop(double); 130 final void setDecimals(int); 131 final void setNotation(Notation); 132 133 final double bottom() const { return b; } 134 final double top() const { return t; } 135 final int decimals() const { return dec; } 136 final Notation notation() const; 137 138 /+ Q_SIGNALS +/public: 139 @QSignal final void bottomChanged(double bottom); 140 @QSignal final void topChanged(double top); 141 @QSignal final void decimalsChanged(int decimals); 142 @QSignal final void notationChanged(QDoubleValidator.Notation notation); 143 144 private: 145 /+ Q_DECLARE_PRIVATE(QDoubleValidator) +/ 146 /+ Q_DISABLE_COPY(QDoubleValidator) +/ 147 148 double b; 149 double t; 150 int dec; 151 } 152 153 154 class /+ Q_GUI_EXPORT +/ QRegExpValidator : QValidator 155 { 156 mixin(Q_OBJECT); 157 /+ Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp NOTIFY regExpChanged) +/ 158 159 public: 160 /+ explicit +/this(QObject parent = null); 161 /+ explicit +/this(ref const(QRegExp) rx, QObject parent = null); 162 ~this(); 163 164 /+ virtual +/ override QValidator.State validate(ref QString input, ref int pos) const; 165 166 final void setRegExp(ref const(QRegExp) rx); 167 final ref const(QRegExp) regExp() const { return r; } 168 169 /+ Q_SIGNALS +/public: 170 @QSignal final void regExpChanged(ref const(QRegExp) regExp); 171 172 private: 173 /+ Q_DISABLE_COPY(QRegExpValidator) +/ 174 175 QRegExp r; 176 } 177 178 } 179 180 /+ #if QT_CONFIG(regularexpression) +/ 181 182 extern(C++, class) struct QRegularExpressionValidatorPrivate; 183 184 class /+ Q_GUI_EXPORT +/ QRegularExpressionValidator : QValidator 185 { 186 mixin(Q_OBJECT); 187 /+ Q_PROPERTY(QRegularExpression regularExpression READ regularExpression WRITE setRegularExpression NOTIFY regularExpressionChanged) +/ 188 189 public: 190 /+ explicit +/this(QObject parent = null); 191 /+ explicit +/this(ref const(QRegularExpression) re, QObject parent = null); 192 ~this(); 193 194 /+ virtual +/ override QValidator.State validate(ref QString input, ref int pos) const; 195 196 final QRegularExpression regularExpression() const; 197 198 public /+ Q_SLOTS +/: 199 @QSlot final void setRegularExpression(ref const(QRegularExpression) re); 200 201 /+ Q_SIGNALS +/public: 202 @QSignal final void regularExpressionChanged(ref const(QRegularExpression) re); 203 204 private: 205 /+ Q_DISABLE_COPY(QRegularExpressionValidator) +/ 206 /+ Q_DECLARE_PRIVATE(QRegularExpressionValidator) +/ 207 } 208 209 /+ #endif +/ // QT_CONFIG(regularexpression) 210 211 } 212 213 version(QT_NO_VALIDATOR) 214 { 215 extern(C++, class) struct QValidator; 216 } 217 218