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