#include "support/lstrings.h"
#include <QLineEdit>
+#include <QLocale>
#include <QWidget>
using namespace std;
QValidator::State LengthValidator::validate(QString & qtext, int &) const
{
- string const text = fromqstr(qtext);
- if (text.empty() || support::isStrDbl(text))
+ bool ok;
+ qtext.trimmed().toDouble(&ok);
+ if (qtext.isEmpty() || ok)
return QValidator::Acceptable;
+ string const text = fromqstr(qtext);
+
if (glue_length_) {
GlueLength gl;
return (isValidGlueLength(text, &gl)) ?
}
+LengthValidator * unsignedGlueLengthValidator(QLineEdit * ed)
+{
+ LengthValidator * v = new LengthValidator(ed);
+ v->setBottom(GlueLength());
+ return v;
+}
+
+
LengthAutoValidator::LengthAutoValidator(QWidget * parent, QString const autotext)
: LengthValidator(parent),
autotext_(autotext)
}
+NoNewLineValidator::NoNewLineValidator(QWidget * parent)
+ : QValidator(parent)
+{}
+
+
+QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const
+{
+ qtext.remove(QRegExp("[\\n\\r]"));
+ return QValidator::Acceptable;
+}
+
+
PathValidator::PathValidator(bool acceptable_if_empty,
QWidget * parent)
: QValidator(parent),