Andre Poenitz wrote: > I think I saw some code similar to > > void foo(LyXLength len); > > This should be > > void foo(LyXLength const & len);
Corrected in the attached patch. I will commit this if I hear no more objections. Jürgen
Index: QExternalDialog.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QExternalDialog.C,v retrieving revision 1.22 diff -p -u -r1.22 QExternalDialog.C --- QExternalDialog.C 2 Jun 2004 20:13:18 -0000 1.22 +++ QExternalDialog.C 22 Nov 2004 07:40:23 -0000 @@ -49,7 +49,8 @@ namespace { LengthValidator * unsignedLengthValidator(QLineEdit * ed) { LengthValidator * v = new LengthValidator(ed); - v->setBottom(LyXLength()); + LyXLength len = LyXLength(); + v->setBottom(len); return v; } Index: QVSpace.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QVSpace.C,v retrieving revision 1.7 diff -p -u -r1.7 QVSpace.C --- QVSpace.C 20 May 2004 09:36:28 -0000 1.7 +++ QVSpace.C 22 Nov 2004 07:40:23 -0000 @@ -19,6 +19,7 @@ #include "QVSpaceDialog.h" #include "Qt2BC.h" +#include "checkedwidgets.h" #include "lengthcombo.h" #include "qt_helpers.h" @@ -150,6 +151,9 @@ void QVSpace::build_dialog() bcview().addReadOnly(dialog_->unitCO); bcview().addReadOnly(dialog_->keepCB); + // initialize the length validator + addCheckedLineEdit(bcview(), dialog_->valueLE, dialog_->valueL); + // remove the %-items from the unit choice dialog_->unitCO->noPercents(); } Index: QVSpaceDialog.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QVSpaceDialog.C,v retrieving revision 1.8 diff -p -u -r1.8 QVSpaceDialog.C --- QVSpaceDialog.C 2 Jun 2004 20:13:18 -0000 1.8 +++ QVSpaceDialog.C 22 Nov 2004 07:40:23 -0000 @@ -16,6 +16,7 @@ #include "QVSpace.h" #include "lengthcombo.h" +#include "lengthvalidator.h" #include "qt_helpers.h" #include <qcombobox.h> @@ -27,6 +28,20 @@ namespace lyx { namespace frontend { + +namespace { + +LengthValidator * unsignedLengthValidator(QLineEdit * ed) +{ + LengthValidator * v = new LengthValidator(ed); + LyXGlueLength glen = LyXGlueLength(); + v->setBottom(glen); + return v; +} + +} // namespace anon + + QVSpaceDialog::QVSpaceDialog(QVSpace * form) : QVSpaceDialogBase(0, 0, false, 0), form_(form) @@ -37,6 +52,8 @@ QVSpaceDialog::QVSpaceDialog(QVSpace * f form_, SLOT(slotApply())); connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose())); + + valueLE->setValidator(unsignedLengthValidator(valueLE)); } @@ -55,7 +72,7 @@ void QVSpaceDialog::change_adaptor() void QVSpaceDialog::enableCustom(int) { - bool const enable = spacingCO->currentItem()==5; + bool const enable = spacingCO->currentItem() == 5; valueLE->setEnabled(enable); unitCO->setEnabled(enable); } Index: lengthcombo.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthcombo.C,v retrieving revision 1.19 diff -p -u -r1.19 lengthcombo.C --- lengthcombo.C 20 May 2004 09:36:28 -0000 1.19 +++ lengthcombo.C 22 Nov 2004 07:40:23 -0000 @@ -19,7 +19,7 @@ LengthCombo::LengthCombo(QWidget * parent, char * name) : QComboBox(parent, name) { - for (int i=0; i < num_units; i++) + for (int i = 0; i < num_units; i++) insertItem(unit_name_gui[i]); connect(this, SIGNAL(activated(int)), Index: lengthvalidator.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthvalidator.C,v retrieving revision 1.4 diff -p -u -r1.4 lengthvalidator.C --- lengthvalidator.C 20 May 2004 09:36:28 -0000 1.4 +++ lengthvalidator.C 22 Nov 2004 07:40:23 -0000 @@ -25,16 +25,24 @@ using std::string; LengthValidator::LengthValidator(QWidget * parent, const char * name) : QValidator(parent, name), - no_bottom_(true) + no_bottom_(true), glue_length_(false) {} 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_) { + LyXGlueLength gl; + if (isValidGlueLength(text, &gl)) + return QValidator::Acceptable; + else + return QValidator::Intermediate; + } + LyXLength l; bool const valid_length = isValidLength(text, &l); if (!valid_length) @@ -48,8 +56,16 @@ QValidator::State LengthValidator::valid } -void LengthValidator::setBottom(LyXLength b) +void LengthValidator::setBottom(LyXLength & b) { b_ = b; no_bottom_ = false; +} + + +bool LengthValidator::setBottom(LyXGlueLength & g) +{ + g_ = g; + no_bottom_ = false; + glue_length_ = true; } Index: lengthvalidator.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthvalidator.h,v retrieving revision 1.3 diff -p -u -r1.3 lengthvalidator.h --- lengthvalidator.h 10 Dec 2003 09:26:18 -0000 1.3 +++ lengthvalidator.h 22 Nov 2004 07:40:23 -0000 @@ -13,6 +13,7 @@ #define LENGTHVALIDATOR_H #include "lyxlength.h" +#include "lyxgluelength.h" #include <qvalidator.h> class QWidget; @@ -26,7 +27,8 @@ public: QValidator::State validate(QString &, int &) const; - void setBottom(LyXLength); + void setBottom(LyXLength &); + bool setBottom(LyXGlueLength &); LyXLength bottom() const { return b_; } private: @@ -36,7 +38,9 @@ private: #endif LyXLength b_; + LyXGlueLength g_; bool no_bottom_; + bool glue_length_; }; # endif // NOT LENGTHVALIDATOR_H