+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
#include <config.h>
+#include "checkedwidgets.h"
#include "QDocument.h"
#include "QDocumentDialog.h"
#include "Qt2BC.h"
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);
}
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;
}
{
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:
#include "floatplacement.h"
#include "lengthcombo.h"
+#include "lengthvalidator.h"
#include "panelstack.h"
#include "qt_helpers.h"
#include <qpixmap.h>
#include <qcolor.h>
#include <qcolordialog.h>
+#include <qvalidator.h>
using lyx::support::token;
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)
{
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));
}
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));
}
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));
}
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qstring.h>
+#include <qvalidator.h>
using std::string;
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));
}
#include <config.h>
+#include "checkedwidgets.h"
#include "QTabular.h"
#include "QTabularDialog.h"
#include "Qt2BC.h"
bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
bcview().addReadOnly(dialog_->newpageCB);
+
+ // initialize the length validator
+ addCheckedLineEdit(bcview(), dialog_->widthED,
+ dialog_->fixedWidthColLA);
}
#include "QTabularDialog.h"
#include "QTabular.h"
+#include "lengthvalidator.h"
#include "qt_helpers.h"
#include "controllers/ControlTabular.h"
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));
}
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_) {