X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FValidator.h;h=22e8d484d3d4b7ab02c3c50a817886eca23bd536;hb=1f10969bb5c5f36017bf5ba8671381b09945cf57;hp=686dd06fecc69667a3fcff6146afd699c74f3c09;hpb=8c5f097b5d59cc157b39a08fa5d3f5fa82cf1e4f;p=lyx.git diff --git a/src/frontends/qt4/Validator.h b/src/frontends/qt4/Validator.h index 686dd06fec..22e8d484d3 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,78 +50,92 @@ 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_; } + void setUnsigned(bool const u) { unsigned_ = u; } //@} 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_; + 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 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; +public: + 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_; }; -// Forward declarations -class LyXRC; -namespace frontend { class KernelDocType; } +// 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; +}; /** A class to ascertain whether the data passed to the @c validate() @@ -145,15 +163,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 +175,7 @@ private: /// @returns the PathValidator attached to the widget, or 0. PathValidator * getPathValidator(QLineEdit *); +} // namespace frontend } // namespace lyx # endif // NOT VALIDATOR_H