]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Validator.h
Add missing initialization
[lyx.git] / src / frontends / qt4 / Validator.h
index ee3ae343697d3d76c8d01d90acdcddf1c3e77225..22e8d484d3d4b7ab02c3c50a817886eca23bd536 100644 (file)
@@ -62,6 +62,7 @@ public:
        void setBottom(Length const &);
        void setBottom(GlueLength const &);
        Length bottom() const { return b_; }
+       void setUnsigned(bool const u) { unsigned_ = u; }
        //@}
 
 private:
@@ -69,50 +70,71 @@ private:
        GlueLength g_;
        bool no_bottom_;
        bool glue_length_;
+       bool unsigned_;
 };
 
 
 /// @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;
 };