]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QTabularDialog.C
update ignore, and make sure to dist the lyx2lyx_version.py.in template file
[features.git] / src / frontends / qt2 / QTabularDialog.C
1 /**
2  * \file QTabularDialog.C
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  * \author Jürgen Spitzmüller
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "QTabularDialog.h"
16 #include "QTabular.h"
17 #include "validators.h"
18 #include "qt_helpers.h"
19
20 #include "controllers/ControlTabular.h"
21
22 #include <qcheckbox.h>
23 #include <qpushbutton.h>
24 #include <qlineedit.h>
25
26 using std::string;
27
28 namespace lyx {
29 namespace frontend {
30
31
32 QTabularDialog::QTabularDialog(QTabular * form)
33         : QTabularDialogBase(0, 0, false, 0),
34         form_(form)
35 {
36         connect(closePB, SIGNAL(clicked()),
37                 form, SLOT(slotClose()));
38
39         widthED->setValidator(unsignedLengthValidator(widthED));
40 }
41
42
43 void QTabularDialog::change_adaptor()
44 {
45         form_->changed();
46 }
47
48
49 void QTabularDialog::closeEvent(QCloseEvent * e)
50 {
51         form_->slotWMHide();
52         e->accept();
53 }
54
55
56 void QTabularDialog::close_clicked()
57 {
58         form_->closeGUI();
59 }
60
61
62 void QTabularDialog::borderSet_clicked()
63 {
64         form_->controller().set(LyXTabular::SET_ALL_LINES);
65         form_->update_borders();
66         form_->changed();
67 }
68
69
70 void QTabularDialog::borderUnset_clicked()
71 {
72         form_->controller().set(LyXTabular::UNSET_ALL_LINES);
73         form_->update_borders();
74         form_->changed();
75 }
76
77
78 void QTabularDialog::leftBorder_changed()
79 {
80         form_->controller().toggleLeftLine();
81         form_->changed();
82 }
83
84
85 void QTabularDialog::rightBorder_changed()
86 {
87         form_->controller().toggleRightLine();
88         form_->changed();
89 }
90
91
92 void QTabularDialog::topBorder_changed()
93 {
94         form_->controller().toggleTopLine();
95         form_->changed();
96 }
97
98
99 void QTabularDialog::bottomBorder_changed()
100 {
101         form_->controller().toggleBottomLine();
102         form_->changed();
103 }
104
105
106 void QTabularDialog::specialAlignment_changed()
107 {
108         string special = fromqstr(specialAlignmentED->text());
109         form_->controller().setSpecial(special);
110         form_->changed();
111 }
112
113
114 void QTabularDialog::width_changed()
115 {
116         form_->changed();
117         string const width = widgetsToLength(widthED, widthUnit);
118         form_->controller().setWidth(width);
119 }
120
121
122 void QTabularDialog::multicolumn_clicked()
123 {
124         form_->controller().toggleMultiColumn();
125         form_->changed();
126 }
127
128
129 void QTabularDialog::rotateTabular()
130 {
131         form_->controller().rotateTabular(rotateTabularCB->isChecked());
132         form_->changed();
133 }
134
135
136 void QTabularDialog::rotateCell()
137 {
138         form_->controller().rotateCell(rotateCellCB->isChecked());
139         form_->changed();
140 }
141
142
143 void QTabularDialog::hAlign_changed(int align)
144 {
145         ControlTabular::HALIGN h = ControlTabular::LEFT;
146
147         switch (align) {
148                 case 0: h = ControlTabular::LEFT; break;
149                 case 1: h = ControlTabular::CENTER; break;
150                 case 2: h = ControlTabular::RIGHT; break;
151                 case 3: h = ControlTabular::BLOCK; break;
152         }
153
154         form_->controller().halign(h);
155 }
156
157
158 void QTabularDialog::vAlign_changed(int align)
159 {
160         ControlTabular::VALIGN v = ControlTabular::TOP;
161
162         switch (align) {
163                 case 0: v = ControlTabular::TOP; break;
164                 case 1: v = ControlTabular::MIDDLE; break;
165                 case 2: v = ControlTabular::BOTTOM; break;
166         }
167
168         form_->controller().valign(v);
169 }
170
171
172 void QTabularDialog::longTabular()
173 {
174         form_->controller().longTabular(longTabularCB->isChecked());
175         form_->changed();
176 }
177
178
179 void QTabularDialog::ltNewpage_clicked()
180 {
181         form_->controller().set(LyXTabular::SET_LTNEWPAGE);
182         form_->changed();
183 }
184
185
186 void QTabularDialog::ltHeaderStatus_clicked()
187 {
188         bool enable(headerStatusCB->isChecked());
189         if (enable)
190                 form_->controller().set(LyXTabular::SET_LTHEAD, "");
191         else
192                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
193         headerBorderAboveCB->setEnabled(enable);
194         headerBorderBelowCB->setEnabled(enable);
195         firstheaderNoContentsCB->setEnabled(enable);
196         form_->changed();
197 }
198
199
200 void QTabularDialog::ltHeaderBorderAbove_clicked()
201 {
202         if (headerBorderAboveCB->isChecked())
203                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
204         else
205                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
206         form_->changed();
207 }
208
209
210 void QTabularDialog::ltHeaderBorderBelow_clicked()
211 {
212         if (headerBorderBelowCB->isChecked())
213                 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
214         else
215                 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
216         form_->changed();
217 }
218
219
220 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
221 {
222         if (firstheaderBorderAboveCB->isChecked())
223                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
224         else
225                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
226         form_->changed();
227 }
228
229
230 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
231 {
232         if (firstheaderBorderBelowCB->isChecked())
233                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
234         else
235                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
236         form_->changed();
237 }
238
239
240 void QTabularDialog::ltFirstHeaderStatus_clicked()
241 {
242         bool enable(firstheaderStatusCB->isChecked());
243         if (enable)
244                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
245         else
246                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
247         firstheaderBorderAboveCB->setEnabled(enable);
248         firstheaderBorderBelowCB->setEnabled(enable);
249         form_->changed();
250 }
251
252
253 void QTabularDialog::ltFirstHeaderEmpty_clicked()
254 {
255         bool enable(firstheaderNoContentsCB->isChecked());
256         if (enable)
257                 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
258         else
259                 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
260         firstheaderStatusCB->setEnabled(!enable);
261         firstheaderBorderAboveCB->setEnabled(!enable);
262         firstheaderBorderBelowCB->setEnabled(!enable);
263         form_->changed();
264 }
265
266
267 void QTabularDialog::ltFooterStatus_clicked()
268 {
269         bool enable(footerStatusCB->isChecked());
270         if (enable)
271                 form_->controller().set(LyXTabular::SET_LTFOOT, "");
272         else
273                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
274         footerBorderAboveCB->setEnabled(enable);
275         footerBorderBelowCB->setEnabled(enable);
276         lastfooterNoContentsCB->setEnabled(enable);
277         form_->changed();
278 }
279
280
281 void QTabularDialog::ltFooterBorderAbove_clicked()
282 {
283         if (footerBorderAboveCB->isChecked())
284                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
285         else
286                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
287         form_->changed();
288 }
289
290
291 void QTabularDialog::ltFooterBorderBelow_clicked()
292 {
293         if (footerBorderBelowCB->isChecked())
294                 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
295         else
296                 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
297         form_->changed();
298 }
299
300
301 void QTabularDialog::ltLastFooterStatus_clicked()
302 {
303         bool enable(lastfooterStatusCB->isChecked());
304         if (enable)
305                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
306         else
307                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
308         lastfooterBorderAboveCB->setEnabled(enable);
309         lastfooterBorderBelowCB->setEnabled(enable);
310         form_->changed();
311 }
312
313
314 void QTabularDialog::ltLastFooterBorderAbove_clicked()
315 {
316         if (lastfooterBorderAboveCB->isChecked())
317                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
318         else
319                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
320         form_->changed();
321 }
322
323
324 void QTabularDialog::ltLastFooterBorderBelow_clicked()
325 {
326         if (lastfooterBorderBelowCB->isChecked())
327                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
328         else
329                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
330         form_->changed();
331 }
332
333
334 void QTabularDialog::ltLastFooterEmpty_clicked()
335 {
336         bool enable(lastfooterNoContentsCB->isChecked());
337         if (enable)
338                 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
339         else
340                 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
341         lastfooterStatusCB->setEnabled(!enable);
342         lastfooterBorderAboveCB->setEnabled(!enable);
343         lastfooterBorderBelowCB->setEnabled(!enable);
344         form_->changed();
345 }
346
347 } // namespace frontend
348 } // namespace lyx