2 * \file qt2/checkedwidgets.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
13 #include "checkedwidgets.h"
22 void addCheckedLineEdit(BCView & bcview,
23 QLineEdit * input, QLabel * label)
25 bcview.addCheckedWidget(new CheckedLineEdit(input, label));
31 void setWarningColor(QWidget * widget)
33 // Qt 2.3 does not have
34 // widget->setPaletteForegroundColor(QColor(255, 0, 0));
35 // So copy the appropriate parts of the function here:
36 QPalette pal = widget->palette();
37 pal.setColor(QPalette::Active,
38 QColorGroup::Foreground,
40 widget->setPalette(pal);
44 void setWidget(bool valid, QLineEdit * input, QLabel * label)
47 input->unsetPalette();
49 setWarningColor(input);
55 label->unsetPalette();
57 setWarningColor(label);
63 CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QLabel * label)
64 : input_(input), label_(label)
68 bool CheckedLineEdit::check() const
70 QValidator const * validator = input_->validator();
74 QString t = input_->text();
76 bool const valid = validator->validate(t, p) == QValidator::Acceptable;
79 setWidget(valid, input_, label_);
84 } // namespace frontend