2 * \file lengthvalidator.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
14 #include "lengthvalidator.h"
15 #include "qt_helpers.h"
17 #include "support/lstrings.h"
22 using lyx::support::isStrDbl;
26 LengthValidator::LengthValidator(QWidget * parent, const char * name)
27 : QValidator(parent, name),
28 no_bottom_(true), glue_length_(false)
32 QValidator::State LengthValidator::validate(QString & qtext, int &) const
34 string const text = fromqstr(qtext);
35 if (!text.empty() && isStrDbl(text))
36 return QValidator::Acceptable;
40 return (isValidGlueLength(text, &gl)) ?
41 QValidator::Acceptable : QValidator::Intermediate;
45 bool const valid_length = isValidLength(text, &l);
47 return QValidator::Intermediate;
50 return QValidator::Acceptable;
52 return b_.inPixels(100) <= l.inPixels(100) ?
53 QValidator::Acceptable : QValidator::Intermediate;
57 void LengthValidator::setBottom(LyXLength const & b)
64 void LengthValidator::setBottom(LyXGlueLength const & g)