]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiIndex.cpp
Rationalize the handling of makeTextClass().
[lyx.git] / src / frontends / qt4 / GuiIndex.cpp
1 /**
2  * \file GuiIndex.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiIndex.h"
14
15 #include "support/debug.h"
16 #include "qt_helpers.h"
17
18 #include <QLabel>
19 #include <QPushButton>
20 #include <QLineEdit>
21 #include <QCloseEvent>
22
23 using namespace std;
24
25 namespace lyx {
26 namespace frontend {
27
28 /////////////////////////////////////////////////////////////////
29 //
30 // Base implementation
31 //
32 /////////////////////////////////////////////////////////////////
33
34 GuiIndexDialogBase::GuiIndexDialogBase(GuiView & lv,
35                 docstring const & title, QString const & label, string const & name)
36         : GuiCommand(lv, name)
37 {
38         label_ = label;
39         setupUi(this);
40         setViewTitle(title);
41
42         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
43         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
44         connect(keywordED, SIGNAL(textChanged(const QString &)),
45                 this, SLOT(change_adaptor()));
46
47         setFocusProxy(keywordED);
48
49         keywordLA->setText(label_);
50
51         keywordED->setWhatsThis( qt_(
52                 "The format of the entry in the index.\n"
53                 "\n"
54                 "An entry can be specified as a sub-entry of\n"
55                 "another with \"!\":\n"
56                 "\n"
57                 "cars!mileage\n"
58                 "\n"
59                 "You can cross-refer to another entry like so:\n"
60                 "\n"
61                 "cars!mileage|see{economy}\n"
62                 "\n"
63                 "For further details refer to the local LaTeX\n"
64                 "documentation.\n")
65         );
66
67         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
68         bc().setOK(okPB);
69         bc().setCancel(closePB);
70         bc().addReadOnly(keywordED);
71 }
72
73
74 void GuiIndexDialogBase::change_adaptor()
75 {
76         changed();
77 }
78
79
80 void GuiIndexDialogBase::reject()
81 {
82         slotClose();
83 }
84
85
86 void GuiIndexDialogBase::closeEvent(QCloseEvent * e)
87 {
88         slotClose();
89         e->accept();
90 }
91
92
93 void GuiIndexDialogBase::updateContents()
94 {
95         docstring const contents = params_["name"];
96         keywordED->setText(toqstr(contents));
97         bc().setValid(!contents.empty());
98 }
99
100
101 void GuiIndexDialogBase::applyView()
102 {
103         params_["name"] = qstring_to_ucs4(keywordED->text());
104 }
105
106
107 bool GuiIndexDialogBase::isValid()
108 {
109         return !keywordED->text().isEmpty();
110 }
111
112
113 /////////////////////////////////////////////////////////////////
114 //
115 // Index Dialog
116 //
117 /////////////////////////////////////////////////////////////////
118
119
120 GuiIndex::GuiIndex(GuiView & lv)
121         : GuiIndexDialogBase(lv, _("Index Entry"), qt_("&Keyword:"), "index") 
122 {
123         keywordED->setWhatsThis( qt_(
124                 "The format of the entry in the index.\n"
125                 "\n"
126                 "An entry can be specified as a sub-entry of\n"
127                 "another with \"!\":\n"
128                 "\n"
129                 "cars!mileage\n"
130                 "\n"
131                 "You can cross-refer to another entry like so:\n"
132                 "\n"
133                 "cars!mileage|see{economy}\n"
134                 "\n"
135                 "For further details refer to the local LaTeX\n"
136                 "documentation.\n")
137         );
138 }
139
140
141 Dialog * createGuiIndex(GuiView & lv) { return new GuiIndex(lv); }
142
143
144 /////////////////////////////////////////////////////////////////
145 //
146 // Label Dialog
147 //
148 /////////////////////////////////////////////////////////////////
149
150 GuiLabel::GuiLabel(GuiView & lv)
151         : GuiIndexDialogBase(lv, _("Label"), qt_("&Label:"), "label")
152 {}
153
154
155 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
156
157
158 } // namespace frontend
159 } // namespace lyx
160
161 #include "GuiIndex_moc.cpp"