Juergen Spitzmueller <[EMAIL PROTECTED]> writes: | 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();
LyXLength len; | + v->setBottom(len); | return v; | } | | 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 | @@ -27,6 +28,20 @@ | namespace lyx { | namespace frontend { | | + | +namespace { | + | +LengthValidator * unsignedLengthValidator(QLineEdit * ed) | +{ | + LengthValidator * v = new LengthValidator(ed); | + LyXGlueLength glen = LyXGlueLength(); LyXGlueLength glen; | + v->setBottom(glen); | + return v; | +} I really dont' like these returning pointers. | + | +} // namespace anon | + | + | QVSpaceDialog::QVSpaceDialog(QVSpace * form) | : QVSpaceDialogBase(0, 0, false, 0), | form_(form) | 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 | { is qtext in-out-argument? if not make it const. The "int&" also look stragne. | 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)) Why is this taking a pointer? | + return QValidator::Acceptable; | + else | + return QValidator::Intermediate; | + } return (isValidGlueLength(text, &gl) ? QValidator::Acceptable : 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) | { why? should at least be "const &" | b_ = b; | no_bottom_ = false; | +} | + | + | +bool LengthValidator::setBottom(LyXGlueLength & g) ditto | +{ | + 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 &); double-ditto -- Lgb