2 * \file QTabularDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "QTabularDialog.h"
17 #include "lengthcombo.h"
18 #include "validators.h"
19 #include "qt_helpers.h"
21 #include "controllers/ButtonController.h"
22 #include "controllers/ControlTabular.h"
24 #include <qcheckbox.h>
25 #include <qpushbutton.h>
26 #include <qradiobutton.h>
27 #include <qlineedit.h>
35 QTabularDialog::QTabularDialog(QTabular * form)
36 : QTabularDialogBase(0, 0, false, 0),
39 connect(closePB, SIGNAL(clicked()),
40 form, SLOT(slotClose()));
42 widthED->setValidator(unsignedLengthValidator(widthED));
43 topspaceED->setValidator(new LengthValidator(topspaceED));
44 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
45 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
49 void QTabularDialog::change_adaptor()
55 void QTabularDialog::closeEvent(QCloseEvent * e)
62 void QTabularDialog::close_clicked()
68 void QTabularDialog::borderSet_clicked()
70 form_->controller().set(LyXTabular::SET_ALL_LINES);
71 form_->update_borders();
76 void QTabularDialog::borderUnset_clicked()
78 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
79 form_->update_borders();
84 void QTabularDialog::leftBorder_changed()
86 form_->controller().toggleLeftLine();
91 void QTabularDialog::rightBorder_changed()
93 form_->controller().toggleRightLine();
98 void QTabularDialog::topBorder_changed()
100 form_->controller().toggleTopLine();
105 void QTabularDialog::bottomBorder_changed()
107 form_->controller().toggleBottomLine();
112 void QTabularDialog::specialAlignment_changed()
114 string special = fromqstr(specialAlignmentED->text());
115 form_->controller().setSpecial(special);
120 void QTabularDialog::width_changed()
123 string const width = widgetsToLength(widthED, widthUnit);
124 form_->controller().setWidth(width);
128 void QTabularDialog::topspace_changed()
130 switch(topspaceCO->currentItem()) {
132 form_->controller().set(LyXTabular::SET_TOP_SPACE, "");
133 topspaceED->setEnabled(false);
134 topspaceUnit->setEnabled(false);
138 form_->controller().set(LyXTabular::SET_TOP_SPACE, "default");
139 topspaceED->setEnabled(false);
140 topspaceUnit->setEnabled(false);
144 if (!topspaceED->text().isEmpty())
145 form_->controller().set(LyXTabular::SET_TOP_SPACE,
146 widgetsToLength(topspaceED, topspaceUnit));
147 if (!form_->bc().bp().isReadOnly()) {
148 topspaceED->setEnabled(true);
149 topspaceUnit->setEnabled(true);
158 void QTabularDialog::bottomspace_changed()
160 switch(bottomspaceCO->currentItem()) {
162 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
163 bottomspaceED->setEnabled(false);
164 bottomspaceUnit->setEnabled(false);
168 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
169 bottomspaceED->setEnabled(false);
170 bottomspaceUnit->setEnabled(false);
174 if (!bottomspaceED->text().isEmpty())
175 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE,
176 widgetsToLength(bottomspaceED, bottomspaceUnit));
177 if (!form_->bc().bp().isReadOnly()) {
178 bottomspaceED->setEnabled(true);
179 bottomspaceUnit->setEnabled(true);
188 void QTabularDialog::interlinespace_changed()
190 switch(interlinespaceCO->currentItem()) {
192 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
193 interlinespaceED->setEnabled(false);
194 interlinespaceUnit->setEnabled(false);
198 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
199 interlinespaceED->setEnabled(false);
200 interlinespaceUnit->setEnabled(false);
204 if (!interlinespaceED->text().isEmpty())
205 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE,
206 widgetsToLength(interlinespaceED, interlinespaceUnit));
207 if (!form_->bc().bp().isReadOnly()) {
208 interlinespaceED->setEnabled(true);
209 interlinespaceUnit->setEnabled(true);
218 void QTabularDialog::multicolumn_clicked()
220 form_->controller().toggleMultiColumn();
225 void QTabularDialog::rotateTabular()
227 form_->controller().rotateTabular(rotateTabularCB->isChecked());
232 void QTabularDialog::rotateCell()
234 form_->controller().rotateCell(rotateCellCB->isChecked());
239 void QTabularDialog::hAlign_changed(int align)
241 ControlTabular::HALIGN h = ControlTabular::LEFT;
244 case 0: h = ControlTabular::LEFT; break;
245 case 1: h = ControlTabular::CENTER; break;
246 case 2: h = ControlTabular::RIGHT; break;
247 case 3: h = ControlTabular::BLOCK; break;
250 form_->controller().halign(h);
254 void QTabularDialog::vAlign_changed(int align)
256 ControlTabular::VALIGN v = ControlTabular::TOP;
259 case 0: v = ControlTabular::TOP; break;
260 case 1: v = ControlTabular::MIDDLE; break;
261 case 2: v = ControlTabular::BOTTOM; break;
264 form_->controller().valign(v);
268 void QTabularDialog::longTabular()
270 form_->controller().longTabular(longTabularCB->isChecked());
275 void QTabularDialog::ltNewpage_clicked()
277 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
282 void QTabularDialog::ltHeaderStatus_clicked()
284 bool enable(headerStatusCB->isChecked());
286 form_->controller().set(LyXTabular::SET_LTHEAD, "");
288 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
289 headerBorderAboveCB->setEnabled(enable);
290 headerBorderBelowCB->setEnabled(enable);
291 firstheaderNoContentsCB->setEnabled(enable);
296 void QTabularDialog::ltHeaderBorderAbove_clicked()
298 if (headerBorderAboveCB->isChecked())
299 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
301 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
306 void QTabularDialog::ltHeaderBorderBelow_clicked()
308 if (headerBorderBelowCB->isChecked())
309 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
311 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
316 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
318 if (firstheaderBorderAboveCB->isChecked())
319 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
321 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
326 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
328 if (firstheaderBorderBelowCB->isChecked())
329 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
331 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
336 void QTabularDialog::ltFirstHeaderStatus_clicked()
338 bool enable(firstheaderStatusCB->isChecked());
340 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
342 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
343 firstheaderBorderAboveCB->setEnabled(enable);
344 firstheaderBorderBelowCB->setEnabled(enable);
349 void QTabularDialog::ltFirstHeaderEmpty_clicked()
351 bool enable(firstheaderNoContentsCB->isChecked());
353 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
355 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
356 firstheaderStatusCB->setEnabled(!enable);
357 firstheaderBorderAboveCB->setEnabled(!enable);
358 firstheaderBorderBelowCB->setEnabled(!enable);
363 void QTabularDialog::ltFooterStatus_clicked()
365 bool enable(footerStatusCB->isChecked());
367 form_->controller().set(LyXTabular::SET_LTFOOT, "");
369 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
370 footerBorderAboveCB->setEnabled(enable);
371 footerBorderBelowCB->setEnabled(enable);
372 lastfooterNoContentsCB->setEnabled(enable);
377 void QTabularDialog::ltFooterBorderAbove_clicked()
379 if (footerBorderAboveCB->isChecked())
380 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
382 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
387 void QTabularDialog::ltFooterBorderBelow_clicked()
389 if (footerBorderBelowCB->isChecked())
390 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
392 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
397 void QTabularDialog::ltLastFooterStatus_clicked()
399 bool enable(lastfooterStatusCB->isChecked());
401 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
403 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
404 lastfooterBorderAboveCB->setEnabled(enable);
405 lastfooterBorderBelowCB->setEnabled(enable);
410 void QTabularDialog::ltLastFooterBorderAbove_clicked()
412 if (lastfooterBorderAboveCB->isChecked())
413 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
415 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
420 void QTabularDialog::ltLastFooterBorderBelow_clicked()
422 if (lastfooterBorderBelowCB->isChecked())
423 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
425 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
430 void QTabularDialog::ltLastFooterEmpty_clicked()
432 bool enable(lastfooterNoContentsCB->isChecked());
434 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
436 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
437 lastfooterStatusCB->setEnabled(!enable);
438 lastfooterBorderAboveCB->setEnabled(!enable);
439 lastfooterBorderBelowCB->setEnabled(!enable);
444 void QTabularDialog::booktabs_clicked()
446 if (booktabsRB->isChecked())
447 form_->controller().set(LyXTabular::SET_BOOKTABS);
449 form_->controller().set(LyXTabular::UNSET_BOOKTABS);
450 form_->update_borders();
454 } // namespace frontend