]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/InsetParamsWidget.cpp
GuiLabel: generalize initialiseParams() and transfer to InsetParamsWidget as this...
[lyx.git] / src / frontends / qt4 / InsetParamsWidget.cpp
1 // -*- C++ -*-\r
2 /**\r
3  * \file InsetParamsWidget.cpp\r
4  * This file is part of LyX, the document processor.\r
5  * Licence details can be found in the file COPYING.\r
6  *\r
7  * \author Abdelrazak Younes\r
8  *\r
9  * Full author contact details are available in file CREDITS.\r
10  */\r
11 \r
12 #include <config.h>\r
13 \r
14 #include "InsetParamsWidget.h"\r
15 \r
16 #include "insets/InsetCommand.h"\r
17 \r
18 #include "qt_helpers.h"\r
19 \r
20 #include <QLineEdit>\r
21 \r
22 namespace lyx {\r
23 \r
24 namespace frontend {\r
25 \r
26 CheckedWidget::CheckedWidget(QLineEdit * input, QWidget * label)\r
27         : input_(input), label_(label)\r
28 {\r
29 }\r
30 \r
31 \r
32 bool CheckedWidget::check() const\r
33 {\r
34         bool const valid = input_->hasAcceptableInput();\r
35         // Visual feedback.\r
36         setValid(input_, valid);\r
37         if (label_)\r
38                 setValid(label_, valid);\r
39         return valid;\r
40 }\r
41 \r
42 \r
43 \r
44 InsetParamsWidget::InsetParamsWidget(QWidget * parent) : QWidget(parent)\r
45 {\r
46 }\r
47 \r
48 \r
49 void InsetParamsWidget::addCheckedWidget(QLineEdit * input, QWidget * label)\r
50 {\r
51         checked_widgets_.append(CheckedWidget(input, label));\r
52 }\r
53 \r
54 \r
55 bool InsetParamsWidget::checkWidgets() const\r
56 {\r
57         bool valid = true;\r
58         Q_FOREACH(CheckedWidget const & le, checked_widgets_)\r
59                         valid &= le.check();\r
60         return valid;\r
61 }\r
62 \r
63 \r
64 bool InsetParamsWidget::initialiseParams(std::string const & data)\r
65 {\r
66         InsetCommandParams p(insetCode());\r
67         if (!InsetCommand::string2params(data, p))\r
68                 return false;\r
69         paramsToDialog(p);\r
70         return true;\r
71 }\r
72 \r
73 } // namespace frontend\r
74 } // namespace lyx\r
75 \r
76 #include "moc_InsetParamsWidget.cpp"\r