From: Jürgen Spitzmüller Date: Fri, 3 Dec 2004 11:02:06 +0000 (+0000) Subject: length validators for the remaining qt dialogs X-Git-Tag: 1.6.10~14769 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1ce553b7fe3904972ba9ddfb82866f3713eede76;p=features.git length validators for the remaining qt dialogs git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9333 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 14c50dde9e..2992d03646 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,16 @@ +2004-12-03 Jürgen Spitzmüller + + * 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 * qt_helpers.[Ch]: new member function widgetsToLength diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 8b511831cf..493ed0e1dd 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -10,6 +10,7 @@ #include +#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: diff --git a/src/frontends/qt2/QDocumentDialog.C b/src/frontends/qt2/QDocumentDialog.C index 2198d6d2a0..c160e008c0 100644 --- a/src/frontends/qt2/QDocumentDialog.C +++ b/src/frontends/qt2/QDocumentDialog.C @@ -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 #include #include +#include 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)); } diff --git a/src/frontends/qt2/QExternalDialog.C b/src/frontends/qt2/QExternalDialog.C index 6e8825f473..65341e94f5 100644 --- a/src/frontends/qt2/QExternalDialog.C +++ b/src/frontends/qt2/QExternalDialog.C @@ -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)); } diff --git a/src/frontends/qt2/QGraphicsDialog.C b/src/frontends/qt2/QGraphicsDialog.C index bdf7d76d9b..77db081179 100644 --- a/src/frontends/qt2/QGraphicsDialog.C +++ b/src/frontends/qt2/QGraphicsDialog.C @@ -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)); } diff --git a/src/frontends/qt2/QPrefsDialog.C b/src/frontends/qt2/QPrefsDialog.C index 859fbeae45..83722d708d 100644 --- a/src/frontends/qt2/QPrefsDialog.C +++ b/src/frontends/qt2/QPrefsDialog.C @@ -49,6 +49,7 @@ #include #include #include +#include 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)); } diff --git a/src/frontends/qt2/QTabular.C b/src/frontends/qt2/QTabular.C index bac34940af..850b6d5316 100644 --- a/src/frontends/qt2/QTabular.C +++ b/src/frontends/qt2/QTabular.C @@ -12,6 +12,7 @@ #include +#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); } diff --git a/src/frontends/qt2/QTabularDialog.C b/src/frontends/qt2/QTabularDialog.C index 4d7b4ab159..1d55eb311a 100644 --- a/src/frontends/qt2/QTabularDialog.C +++ b/src/frontends/qt2/QTabularDialog.C @@ -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)); } diff --git a/src/frontends/qt2/lengthvalidator.C b/src/frontends/qt2/lengthvalidator.C index 5197fa597b..c7625b4e90 100644 --- a/src/frontends/qt2/lengthvalidator.C +++ b/src/frontends/qt2/lengthvalidator.C @@ -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_) {