]> git.lyx.org Git - features.git/commitdiff
length validators for the remaining qt dialogs
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 3 Dec 2004 11:02:06 +0000 (11:02 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 3 Dec 2004 11:02:06 +0000 (11:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9333 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/QDocument.C
src/frontends/qt2/QDocumentDialog.C
src/frontends/qt2/QExternalDialog.C
src/frontends/qt2/QGraphicsDialog.C
src/frontends/qt2/QPrefsDialog.C
src/frontends/qt2/QTabular.C
src/frontends/qt2/QTabularDialog.C
src/frontends/qt2/lengthvalidator.C

index 14c50dde9e8abc40a8e67e065f11ecbd213d7f07..2992d03646bbbae47a6b905dd34a1679ae36cddc 100644 (file)
@@ -1,3 +1,16 @@
+2004-12-03  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * lengthvalidator.C: revert to correct if clause.
+       
+       * QDocument.C:
+       * QDocumentDialog.C:
+       * QTabular.C:
+       * QTabularDialog.C:
+       * QPrefs.C: implement length validators
+       
+       * QExternalDialog.C:
+       * QGraphicsDialog.C: chose correct validators
+
 2004-11-27  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * qt_helpers.[Ch]: new member function widgetsToLength
index 8b511831cf7d90ee4304231be4cc334da27ae7b3..493ed0e1dd9a17ad077e13f1531b1d42e4b49951 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <config.h>
 
+#include "checkedwidgets.h"
 #include "QDocument.h"
 #include "QDocumentDialog.h"
 #include "Qt2BC.h"
@@ -174,6 +175,27 @@ void QDocument::build_dialog()
        bcview().setApply(dialog_->applyPB);
        bcview().setCancel(dialog_->closePB);
        bcview().setRestore(dialog_->restorePB);
+       
+       // initialize the length validator
+       addCheckedLineEdit(bcview(), dialog_->textLayoutModule->skipLE);
+       addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperheightLE, 
+               dialog_->pageLayoutModule->paperheightL);
+       addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperwidthLE, 
+               dialog_->pageLayoutModule->paperwidthL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->topLE, 
+               dialog_->marginsModule->topL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->bottomLE, 
+               dialog_->marginsModule->bottomL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->innerLE, 
+               dialog_->marginsModule->innerL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->outerLE, 
+               dialog_->marginsModule->outerL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->headsepLE, 
+               dialog_->marginsModule->headsepL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->headheightLE, 
+               dialog_->marginsModule->headheightL);
+       addCheckedLineEdit(bcview(), dialog_->marginsModule->footskipLE, 
+               dialog_->marginsModule->footskipL);
 }
 
 
@@ -322,12 +344,10 @@ void QDocument::apply()
                break;
        case 3:
        {
-               LyXLength::UNIT unit =
-                       dialog_->textLayoutModule->skipLengthCO->
-                       currentLengthItem();
-               double length =
-                       dialog_->textLayoutModule->skipLE->text().toDouble();
-               VSpace vs = VSpace(LyXGlueLength(LyXLength(length,unit)));
+               VSpace vs = VSpace(
+                       widgetsToLength(dialog_->textLayoutModule->skipLE, 
+                               dialog_->textLayoutModule->skipLengthCO)
+                       );
                params.setDefSkip(vs);
                break;
        }
@@ -573,8 +593,9 @@ void QDocument::update_contents()
        {
                skip = 3;
                string const length = params.getDefSkip().asLyXCommand();
-               dialog_->textLayoutModule->skipLengthCO->setCurrentItem(LyXLength(length).unit());
-               dialog_->textLayoutModule->skipLE->setText(toqstr(tostr(LyXLength(length).value())));
+               lengthToWidgets(dialog_->textLayoutModule->skipLE, 
+                       dialog_->textLayoutModule->skipLengthCO, 
+                       length, defaultUnit);
                break;
        }
        default:
index 2198d6d2a06c0cd906e2be8bc8d97a33fb6a6dd9..c160e008c0e57d8fe1474ba79568f65e6f6a2c71 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "floatplacement.h"
 #include "lengthcombo.h"
+#include "lengthvalidator.h"
 #include "panelstack.h"
 #include "qt_helpers.h"
 
@@ -37,6 +38,7 @@
 #include <qpixmap.h>
 #include <qcolor.h>
 #include <qcolordialog.h>
+#include <qvalidator.h>
 
 using lyx::support::token;
 
@@ -45,6 +47,19 @@ using std::string;
 namespace lyx {
 namespace frontend {
 
+
+namespace {
+
+LengthValidator * unsignedLengthValidator(QLineEdit * ed)
+{
+       LengthValidator * v = new LengthValidator(ed);
+       v->setBottom(LyXLength());
+       return v;
+}
+
+} // namespace anon
+
+
 QDocumentDialog::QDocumentDialog(QDocument * form)
        : QDocumentDialogBase(0, 0, false, 0), form_(form)
 {
@@ -172,6 +187,30 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
                SLOT(branchDoubleClicked(QListViewItem *)));
        connect(branchesModule->colorPB, SIGNAL(clicked()), this, SLOT(toggleBranchColor()));
        branchesModule->branchesLV->setSorting(0);
+       
+       textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
+               textLayoutModule->lspacingLE));
+       
+       textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
+               textLayoutModule->skipLE));
+       pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
+               pageLayoutModule->paperheightLE));
+       pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
+               pageLayoutModule->paperwidthLE));
+       marginsModule->topLE->setValidator(unsignedLengthValidator(
+               marginsModule->topLE));
+       marginsModule->bottomLE->setValidator(unsignedLengthValidator(
+               marginsModule->bottomLE));
+       marginsModule->innerLE->setValidator(unsignedLengthValidator(
+               marginsModule->innerLE));
+       marginsModule->outerLE->setValidator(unsignedLengthValidator(
+               marginsModule->outerLE));
+       marginsModule->headsepLE->setValidator(unsignedLengthValidator(
+               marginsModule->headsepLE));
+       marginsModule->headheightLE->setValidator(unsignedLengthValidator(
+               marginsModule->headheightLE));
+       marginsModule->footskipLE->setValidator(unsignedLengthValidator(
+               marginsModule->footskipLE));
 }
 
 
index 6e8825f473038b821f050cbc8a11f53c2ff1b8c3..65341e94f5a32b5c4d72dce8abd81a07fc04744f 100644 (file)
@@ -78,9 +78,7 @@ QExternalDialog::QExternalDialog(QExternal * form)
        xrED->setValidator(new QIntValidator(xrED));
        ytED->setValidator(new QIntValidator(ytED));
 
-       // The width is initially set to 'scale' and so should accept
-       // a pure number only.
-       widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
+       widthED->setValidator(unsignedLengthValidator(widthED));
        heightED->setValidator(unsignedLengthValidator(heightED));
 }
 
index bdf7d76d9bdbce19a27ceec57f96034acabeaf54..77db081179c3f0282a69017d98a07f844976fa57 100644 (file)
@@ -67,8 +67,7 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form)
        rtX->setValidator(new QIntValidator(rtX));
        rtY->setValidator(new QIntValidator(rtY));
                
-       displayscale->setValidator(new QDoubleValidator(0, 1000, 2, 
-               displayscale));
+       displayscale->setValidator(new QIntValidator(displayscale));
        height->setValidator(unsignedLengthValidator(height));
        width->setValidator(unsignedLengthValidator(width));
 }
index 859fbeae45a9dd26f4a94f4d33bf0d12160837f3..83722d708d4e43b44a03db40880bb855bac99c28 100644 (file)
@@ -49,6 +49,7 @@
 #include <qpushbutton.h>
 #include <qspinbox.h>
 #include <qstring.h>
+#include <qvalidator.h>
 
 using std::string;
 
@@ -276,6 +277,28 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
        connect(screenfontsModule->screenHugerED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(identityModule->nameED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(identityModule->emailED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
+       
+       // initialize the validators
+       screenfontsModule->screenTinyED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenTinyED));
+       screenfontsModule->screenSmallestED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenSmallestED));
+       screenfontsModule->screenSmallerED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenSmallerED));
+       screenfontsModule->screenSmallED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenSmallED));
+       screenfontsModule->screenNormalED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenNormalED));
+       screenfontsModule->screenLargeED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenLargeED));
+       screenfontsModule->screenLargerED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenLargerED));
+       screenfontsModule->screenLargestED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenLargestED));
+       screenfontsModule->screenHugeED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenHugeED));
+       screenfontsModule->screenHugerED->setValidator(new QDoubleValidator(
+               screenfontsModule->screenHugerED));
 }
 
 
index bac34940af461ae4463679a185f577dad51ee773..850b6d53161c179d486e5dae4d293148d8e7a594 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <config.h>
 
+#include "checkedwidgets.h"
 #include "QTabular.h"
 #include "QTabularDialog.h"
 #include "Qt2BC.h"
@@ -75,6 +76,10 @@ void QTabular::build_dialog()
        bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
        bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
        bcview().addReadOnly(dialog_->newpageCB);
+       
+       // initialize the length validator
+       addCheckedLineEdit(bcview(), dialog_->widthED, 
+               dialog_->fixedWidthColLA);
 }
 
 
index 4d7b4ab1593c64d880d0671fa68bb9b954a4a92b..1d55eb311a313a076dac4bed5cf1d94ce8daae76 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "QTabularDialog.h"
 #include "QTabular.h"
+#include "lengthvalidator.h"
 #include "qt_helpers.h"
 
 #include "controllers/ControlTabular.h"
@@ -28,12 +29,26 @@ namespace lyx {
 namespace frontend {
 
 
+namespace {
+
+LengthValidator * unsignedLengthValidator(QLineEdit * ed)
+{
+       LengthValidator * v = new LengthValidator(ed);
+       v->setBottom(LyXLength());
+       return v;
+}
+
+} // namespace anon
+
+
 QTabularDialog::QTabularDialog(QTabular * form)
        : QTabularDialogBase(0, 0, false, 0),
        form_(form)
 {
        connect(closePB, SIGNAL(clicked()),
                form, SLOT(slotClose()));
+               
+       widthED->setValidator(unsignedLengthValidator(widthED));
 }
 
 
index 5197fa597bae11799b64f0d658453391650d568e..c7625b4e90c148af820bf07b41fa7837133dad33 100644 (file)
@@ -32,7 +32,7 @@ LengthValidator::LengthValidator(QWidget * parent, const char * name)
 QValidator::State LengthValidator::validate(QString & qtext, int &) const
 {
        string const text = fromqstr(qtext);
-       if (!text.empty() && isStrDbl(text))
+       if (text.empty() || isStrDbl(text))
                return QValidator::Acceptable;
 
        if (glue_length_) {