]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Validator.cpp
Also display the info about BibTeX databases in the TeX info panel.
[lyx.git] / src / frontends / qt4 / Validator.cpp
index 34141894971f0ca8020f2556b2adacc1909a9be3..7f5d5d45e283634838252b710757d72918d08223 100644 (file)
@@ -24,6 +24,7 @@
 #include "support/lstrings.h"
 
 #include <QLineEdit>
+#include <QLocale>
 #include <QWidget>
 
 using namespace std;
@@ -39,10 +40,13 @@ LengthValidator::LengthValidator(QWidget * parent)
 
 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)) ?
@@ -85,6 +89,14 @@ LengthValidator * unsignedLengthValidator(QLineEdit * ed)
 }
 
 
+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)
@@ -126,6 +138,18 @@ QValidator::State DoubleAutoValidator::validate(QString & input, int & pos) cons
 }
 
 
+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),