+2004-11-22 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * lengthvalidator.[Ch]: add GlueLength validator
+ * QVSpace.C:
+ * QVSpaceDialog.C: use GlueLength validator
+
+ * lengthcombo.C: whitespace
+
2004-11-17 Lars Gullik Bjonnes <larsbj@gullik.net>
* QPrefsDialog.h: include LColor.h to satisfy concept checks.
#include "QVSpaceDialog.h"
#include "Qt2BC.h"
+#include "checkedwidgets.h"
#include "lengthcombo.h"
#include "qt_helpers.h"
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();
}
#include "QVSpace.h"
#include "lengthcombo.h"
+#include "lengthvalidator.h"
#include "qt_helpers.h"
#include <qcombobox.h>
namespace lyx {
namespace frontend {
+
+namespace {
+
+LengthValidator * unsignedLengthValidator(QLineEdit * ed)
+{
+ LengthValidator * v = new LengthValidator(ed);
+ v->setBottom(LyXGlueLength());
+ return v;
+}
+
+} // namespace anon
+
+
QVSpaceDialog::QVSpaceDialog(QVSpace * form)
: QVSpaceDialogBase(0, 0, false, 0),
form_(form)
form_, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()),
form_, SLOT(slotClose()));
+
+ valueLE->setValidator(unsignedLengthValidator(valueLE));
}
void QVSpaceDialog::enableCustom(int)
{
- bool const enable = spacingCO->currentItem()==5;
+ bool const enable = spacingCO->currentItem() == 5;
valueLE->setEnabled(enable);
unitCO->setEnabled(enable);
}
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)),
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;
+ return (isValidGlueLength(text, &gl)) ?
+ QValidator::Acceptable : QValidator::Intermediate;
+ }
+
LyXLength l;
bool const valid_length = isValidLength(text, &l);
if (!valid_length)
}
-void LengthValidator::setBottom(LyXLength b)
+void LengthValidator::setBottom(LyXLength const & b)
{
b_ = b;
no_bottom_ = false;
}
+
+
+void LengthValidator::setBottom(LyXGlueLength const & g)
+{
+ g_ = g;
+ no_bottom_ = false;
+ glue_length_ = true;
+}
#define LENGTHVALIDATOR_H
#include "lyxlength.h"
+#include "lyxgluelength.h"
#include <qvalidator.h>
class QWidget;
QValidator::State validate(QString &, int &) const;
- void setBottom(LyXLength);
+ void setBottom(LyXLength const &);
+ void setBottom(LyXGlueLength const &);
LyXLength bottom() const { return b_; }
private:
#endif
LyXLength b_;
+ LyXGlueLength g_;
bool no_bottom_;
+ bool glue_length_;
};
# endif // NOT LENGTHVALIDATOR_H