]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiPrintNomencl.cpp
Fix the tab ordering of GuiDocument components.
[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/debug.h"
25 #include "support/gettext.h"
26 #include "support/lstrings.h"
27
28 using namespace std;
29
30 namespace lyx {
31 namespace frontend {
32
33 GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
34 {
35         setupUi(this);
36
37         connect(valueLE, SIGNAL(textChanged(QString)),
38                 this, SIGNAL(changed()));
39         connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
40                 this, SIGNAL(changed()));
41
42         valueLE->setValidator(unsignedLengthValidator(valueLE));
43
44         // initialize the length validator
45         addCheckedWidget(valueLE, valueLA);
46
47         setWidthCO->addItem(qt_("Default"),
48                 QVariant(toqstr("none")));
49         setWidthCO->addItem(qt_("Longest label width"),
50                 QVariant(toqstr("auto")));
51         setWidthCO->addItem(qt_("Custom"),
52                 QVariant(toqstr("custom")));
53 }
54
55
56 void GuiPrintNomencl::on_setWidthCO_activated(int i)
57 {
58         bool const custom =
59                 (setWidthCO->itemData(i).toString()
60                  == "custom");
61         valueLE->setEnabled(custom);
62         unitLC->setEnabled(custom);
63         valueLA->setEnabled(custom);
64         changed();
65 }
66
67
68 void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
69 {
70         setWidthCO->setCurrentIndex(
71                 setWidthCO->findData(toqstr(params["set_width"])));
72         
73         lengthToWidgets(valueLE,
74                         unitLC,
75                         params["width"],
76                         Length::defaultUnit());
77 }
78
79
80 void GuiPrintNomencl::paramsToDialog(Inset const * inset)
81 {
82         InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
83         paramsToDialog(nomencl->params());
84 }
85
86
87 docstring GuiPrintNomencl::dialogToParams() const
88 {
89         InsetCommandParams params(insetCode());
90         docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
91                 setWidthCO->currentIndex()).toString());
92         params["set_width"] = set_width;
93         docstring width;
94         if (set_width == from_ascii("custom"))
95                 width = from_utf8(widgetsToLength(valueLE, unitLC));
96         params["width"] = width;
97         return from_ascii(InsetNomencl::params2string(params));
98 }
99
100
101 bool GuiPrintNomencl::checkWidgets() const
102 {
103         if (!InsetParamsWidget::checkWidgets())
104                 return false;
105         return setWidthCO->itemData(
106                         setWidthCO->currentIndex()).toString() != "custom"
107                 || !valueLE->text().isEmpty();
108 }
109
110 } // namespace frontend
111 } // namespace lyx
112
113
114 #include "moc_GuiPrintNomencl.cpp"