/// @returns a new @c LengthValidator that does not accept negative lengths.
LengthValidator * unsignedLengthValidator(QLineEdit *);
-//FIXME This should be generalized to take "text" as part of the
-//constructor and so to set what text we check for, rather than
-//hard-coding it as "auto". But see qt_helpers.h for reasons this
-//is not so trivial and an idea about how to do it. (RGH)
+
+/** @returns a new @c LengthValidator that does not accept negative lengths.
+ * but glue lengths.
+ */
+LengthValidator * unsignedGlueLengthValidator(QLineEdit *);
+
+
/** A class to ascertain whether the data passed to the @c validate()
- * member function can be interpretted as a GlueLength or is "auto".
+ * member function can be interpretted as a GlueLength or is @param autotext.
*/
class LengthAutoValidator : public LengthValidator
{
Q_OBJECT
public:
/// Define a validator for widget @c parent.
- LengthAutoValidator(QWidget * parent);
+ LengthAutoValidator(QWidget * parent, QString const autotext);
/** @returns QValidator::Acceptable if @c data is a GlueLength
* or is "auto". If not, returns QValidator::Intermediate.
*/
QValidator::State validate(QString & data, int &) const;
+
+private:
+ QString autotext_;
};
/// @returns a new @c LengthAutoValidator that does not accept negative lengths.
-LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit *);
+LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit *, QString const autotext);
-//FIXME As above, this should really take a text argument.
/**
* A class to determine whether the passed is a double
- * or is "auto".
+ * or is @param autotext.
*
*/
class DoubleAutoValidator : public QDoubleValidator
{
Q_OBJECT
public:
- DoubleAutoValidator(QWidget * parent);
+ DoubleAutoValidator(QWidget * parent, QString const autotext);
DoubleAutoValidator(double bottom, double top, int decimals,
QObject * parent);
QValidator::State validate(QString & input, int & pos) const;
+
+private:
+ QString autotext_;
+};
+
+
+// A class to ascertain that no newline characters are passed.
+class NoNewLineValidator : public QValidator
+{
+ Q_OBJECT
+public:
+ // Define a validator.
+ NoNewLineValidator(QWidget *);
+ // Remove newline characters from input.
+ QValidator::State validate(QString &, int &) const;
};