]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/InsetParamsWidget.cpp
Fix up 'Reduce metrics updates from 4 to 1 when loading file'
[lyx.git] / src / frontends / qt / InsetParamsWidget.cpp
1 // -*- C++ -*-
2 /**
3  * \file InsetParamsWidget.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetParamsWidget.h"
15
16 #include "insets/Inset.h"
17 #include "qt_helpers.h"
18
19 #include <QLineEdit>
20
21 namespace lyx {
22
23 namespace frontend {
24
25 CheckedWidget::CheckedWidget(QLineEdit * input, QWidget * label)
26         : input_(input), label_(label)
27 {
28 }
29
30
31 bool CheckedWidget::check() const
32 {
33         // Ignore if widget is disabled.
34         if (!input_->isEnabled())
35                 return true;
36
37         bool const valid = input_->hasAcceptableInput();
38         // Visual feedback.
39         setValid(input_, valid);
40         if (label_)
41                 setValid(label_, valid);
42         return valid;
43 }
44
45
46 QString InsetParamsWidget::dialogTitle() const
47 {
48         return toqstr(insetName(insetCode()));
49 }
50
51
52 void InsetParamsWidget::addCheckedWidget(QLineEdit * input, QWidget * label)
53 {
54         checked_widgets_.append(CheckedWidget(input, label));
55 }
56
57
58 bool InsetParamsWidget::checkWidgets(bool) const
59 {
60         bool valid = true;
61         Q_FOREACH(CheckedWidget const & le, checked_widgets_)
62                         valid &= le.check();
63         return valid;
64 }
65
66 } // namespace frontend
67 } // namespace lyx
68
69 #include "moc_InsetParamsWidget.cpp"