X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FValidator.h;h=36250bbdca924721211af2eb446d1e4a39937803;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=f4da36bd9f56d43bef8278c1331cb5aad126a1f4;hpb=00e305c9d9bd8b0ff54b6c58adb6192d5934ed60;p=lyx.git diff --git a/src/frontends/qt4/Validator.h b/src/frontends/qt4/Validator.h index f4da36bd9f..36250bbdca 100644 --- a/src/frontends/qt4/Validator.h +++ b/src/frontends/qt4/Validator.h @@ -25,8 +25,8 @@ #ifndef VALIDATOR_H #define VALIDATOR_H -#include "LyXLength.h" -#include "LyXGlueLength.h" +#include "Length.h" +#include "Dialog.h" // KernelDocType #include @@ -36,8 +36,12 @@ class QLineEdit; namespace lyx { +class LyXRC; + +namespace frontend { + /** A class to ascertain whether the data passed to the @c validate() - * member function can be interpretted as a LyXGlueLength. + * member function can be interpretted as a GlueLength. */ class LengthValidator : public QValidator { @@ -46,28 +50,23 @@ public: /// Define a validator for widget @c parent. LengthValidator(QWidget * parent); - /** @returns QValidator::Acceptable if @c data is a LyXGlueLength. + /** @returns QValidator::Acceptable if @c data is a GlueLength. * If not, returns QValidator::Intermediate. */ QValidator::State validate(QString & data, int &) const; /** @name Bottom - * Set and retrieve the minimum allowed LyXLength value. + * Set and retrieve the minimum allowed Length value. */ //@{ - void setBottom(LyXLength const &); - void setBottom(LyXGlueLength const &); - LyXLength bottom() const { return b_; } + void setBottom(Length const &); + void setBottom(GlueLength const &); + Length bottom() const { return b_; } //@} private: -#if defined(Q_DISABLE_COPY) - LengthValidator( const LengthValidator & ); - LengthValidator& operator=( const LengthValidator & ); -#endif - - LyXLength b_; - LyXGlueLength g_; + Length b_; + GlueLength g_; bool no_bottom_; bool glue_length_; }; @@ -76,48 +75,53 @@ private: /// @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 LyXGlueLength or is "auto". + * member function can be interpretted as a GlueLength or is @param autotext. */ class LengthAutoValidator : public LengthValidator { Q_OBJECT - public: +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 LyXGlueLength + /** @returns QValidator::Acceptable if @c data is a GlueLength * or is "auto". If not, returns QValidator::Intermediate. */ - QValidator::State validate(QString & data, int &) const; + 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 { +class DoubleAutoValidator : public QDoubleValidator +{ Q_OBJECT - public: - DoubleAutoValidator(QWidget * parent); - DoubleAutoValidator(double bottom, double top, int decimals, - QObject * parent); - QValidator::State validate(QString & input, int & pos) const; -}; - -// Forward declarations -class LyXRC; +public: + DoubleAutoValidator(QWidget * parent, QString const autotext); + DoubleAutoValidator(double bottom, double top, int decimals, + QObject * parent); + QValidator::State validate(QString & input, int & pos) const; -namespace frontend { class KernelDocType; } +private: + QString autotext_; +}; /** A class to ascertain whether the data passed to the @c validate() @@ -145,15 +149,9 @@ public: * @param lyxrc contains a @c tex_allows_spaces member that * is used to define what is legal. */ - void setChecker(frontend::KernelDocType const & doc_type, - LyXRC const & lyxrc); + void setChecker(KernelDocType const & doc_type, LyXRC const & lyxrc); private: -#if defined(Q_DISABLE_COPY) - PathValidator(const PathValidator &); - PathValidator & operator=(const PathValidator &); -#endif - bool acceptable_if_empty_; bool latex_doc_; bool tex_allows_spaces_; @@ -163,6 +161,7 @@ private: /// @returns the PathValidator attached to the widget, or 0. PathValidator * getPathValidator(QLineEdit *); +} // namespace frontend } // namespace lyx # endif // NOT VALIDATOR_H