]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrintNomencl.cpp
removed unused includes
[lyx.git] / src / frontends / qt4 / GuiPrintNomencl.cpp
1 /**
2  * \file GuiPrintNomencl.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Spitzmüller
7  * \author Uwe Stöhr
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiPrintNomencl.h"
15
16 #include "LengthCombo.h"
17 #include "qt_helpers.h"
18 #include "Validator.h"
19
20 #include "FuncRequest.h"
21
22 #include "insets/InsetNomencl.h"
23
24 #include "support/gettext.h"
25 #include "support/lstrings.h"
26
27 using namespace std;
28
29 namespace lyx {
30 namespace frontend {
31
32 GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
33 {
34         setupUi(this);
35
36         connect(valueLE, SIGNAL(textChanged(QString)),
37                 this, SIGNAL(changed()));
38         connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
39                 this, SIGNAL(changed()));
40
41         valueLE->setValidator(unsignedLengthValidator(valueLE));
42
43         // initialize the length validator
44         addCheckedWidget(valueLE, valueLA);
45
46         setWidthCO->addItem(qt_("Default"),
47                 QVariant(toqstr("none")));
48         setWidthCO->addItem(qt_("Longest label width"),
49                 QVariant(toqstr("auto")));
50         setWidthCO->addItem(qt_("Custom"),
51                 QVariant(toqstr("custom")));
52 }
53
54
55 void GuiPrintNomencl::on_setWidthCO_activated(int i)
56 {
57         bool const custom =
58                 (setWidthCO->itemData(i).toString() == "custom");
59         valueLE->setEnabled(custom);
60         unitLC->setEnabled(custom);
61         valueLA->setEnabled(custom);
62         changed();
63 }
64
65
66 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
67 {
68         setWidthCO->setCurrentIndex(
69                 setWidthCO->findData(toqstr(params["set_width"])));
70         
71         lengthToWidgets(valueLE, unitLC,
72                         params["width"], Length::defaultUnit());
73
74         bool const custom =
75                 (setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
76         valueLE->setEnabled(custom);
77         unitLC->setEnabled(custom);
78         valueLA->setEnabled(custom);
79 }
80
81
82 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
83 {
84         InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
85         paramsToDialog(nomencl->params());
86 }
87
88
89 docstring GuiPrintNomencl::dialogToParams() const
90 {
91         InsetCommandParams params(insetCode());
92         docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
93                 setWidthCO->currentIndex()).toString());
94         params["set_width"] = set_width;
95         docstring width;
96         if (set_width == from_ascii("custom"))
97                 width = from_utf8(widgetsToLength(valueLE, unitLC));
98         params["width"] = width;
99         return from_ascii(InsetNomencl::params2string(params));
100 }
101
102
103 bool GuiPrintNomencl::checkWidgets() const
104 {
105         if (!InsetParamsWidget::checkWidgets())
106                 return false;
107         return setWidthCO->itemData(
108                         setWidthCO->currentIndex()).toString() != "custom"
109                 || !valueLE->text().isEmpty();
110 }
111
112 } // namespace frontend
113 } // namespace lyx
114
115
116 #include "moc_GuiPrintNomencl.cpp"