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 "validators.h"
18 #include "qt_helpers.h"
20 #include "controllers/ButtonController.h"
21 #include "controllers/ControlTabular.h"
23 #include <QCloseEvent>
25 #include <QPushButton>
26 #include <QRadioButton>
35 QTabularDialog::QTabularDialog(QTabular * form)
40 widthED->setValidator(unsignedLengthValidator(widthED));
41 topspaceED->setValidator(new LengthValidator(topspaceED));
42 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
43 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
45 connect(topspaceED, SIGNAL(returnPressed()),
46 this, SLOT(topspace_changed()));
47 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)),
48 this, SLOT(topspace_changed()));
49 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
50 connect(bottomspaceED, SIGNAL(returnPressed()),
51 this, SLOT(bottomspace_changed()));
52 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)),
53 this, SLOT(bottomspace_changed()));
54 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
55 connect(interlinespaceED, SIGNAL(returnPressed()),
56 this, SLOT(interlinespace_changed()));
57 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)),
58 this, SLOT(interlinespace_changed()));
59 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
60 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
61 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
62 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
63 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
64 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
65 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
66 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
67 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
68 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
69 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
70 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
71 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
72 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
73 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
74 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
75 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
76 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
77 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
78 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
79 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
80 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
81 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
82 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
83 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
84 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
85 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
86 connect(widthUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), this, SLOT(width_changed()));
87 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
88 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
89 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
90 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
91 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
92 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
93 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
94 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
98 void QTabularDialog::change_adaptor()
104 void QTabularDialog::closeEvent(QCloseEvent * e)
111 void QTabularDialog::booktabsChanged(bool)
114 form_->controller().booktabs(booktabsRB->isChecked());
115 form_->update_borders();
119 void QTabularDialog::topspace_changed()
121 switch(topspaceCO->currentIndex()) {
123 form_->controller().set(LyXTabular::SET_TOP_SPACE, "");
124 topspaceED->setEnabled(false);
125 topspaceUnit->setEnabled(false);
129 form_->controller().set(LyXTabular::SET_TOP_SPACE, "default");
130 topspaceED->setEnabled(false);
131 topspaceUnit->setEnabled(false);
135 if (!topspaceED->text().isEmpty())
136 form_->controller().set(LyXTabular::SET_TOP_SPACE,
137 widgetsToLength(topspaceED, topspaceUnit));
138 if (!form_->bc().bp().isReadOnly()) {
139 topspaceED->setEnabled(true);
140 topspaceUnit->setEnabled(true);
149 void QTabularDialog::bottomspace_changed()
151 switch(bottomspaceCO->currentIndex()) {
153 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
154 bottomspaceED->setEnabled(false);
155 bottomspaceUnit->setEnabled(false);
159 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
160 bottomspaceED->setEnabled(false);
161 bottomspaceUnit->setEnabled(false);
165 if (!bottomspaceED->text().isEmpty())
166 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE,
167 widgetsToLength(bottomspaceED, bottomspaceUnit));
168 if (!form_->bc().bp().isReadOnly()) {
169 bottomspaceED->setEnabled(true);
170 bottomspaceUnit->setEnabled(true);
179 void QTabularDialog::interlinespace_changed()
181 switch(interlinespaceCO->currentIndex()) {
183 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
184 interlinespaceED->setEnabled(false);
185 interlinespaceUnit->setEnabled(false);
189 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
190 interlinespaceED->setEnabled(false);
191 interlinespaceUnit->setEnabled(false);
195 if (!interlinespaceED->text().isEmpty())
196 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE,
197 widgetsToLength(interlinespaceED, interlinespaceUnit));
198 if (!form_->bc().bp().isReadOnly()) {
199 interlinespaceED->setEnabled(true);
200 interlinespaceUnit->setEnabled(true);
209 void QTabularDialog::close_clicked()
216 void QTabularDialog::borderSet_clicked()
218 form_->controller().set(LyXTabular::SET_ALL_LINES);
219 form_->update_borders();
224 void QTabularDialog::borderUnset_clicked()
226 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
227 form_->update_borders();
232 void QTabularDialog::leftBorder_changed()
234 form_->controller().toggleLeftLine();
239 void QTabularDialog::rightBorder_changed()
241 form_->controller().toggleRightLine();
246 void QTabularDialog::topBorder_changed()
248 form_->controller().toggleTopLine();
253 void QTabularDialog::bottomBorder_changed()
255 form_->controller().toggleBottomLine();
260 void QTabularDialog::specialAlignment_changed()
262 string special = fromqstr(specialAlignmentED->text());
263 form_->controller().setSpecial(special);
268 void QTabularDialog::width_changed()
271 string const width = widgetsToLength(widthED, widthUnit);
272 form_->controller().setWidth(width);
276 void QTabularDialog::multicolumn_clicked()
278 form_->controller().toggleMultiColumn();
283 void QTabularDialog::rotateTabular()
285 form_->controller().rotateTabular(rotateTabularCB->isChecked());
290 void QTabularDialog::rotateCell()
292 form_->controller().rotateCell(rotateCellCB->isChecked());
297 void QTabularDialog::hAlign_changed(int align)
299 ControlTabular::HALIGN h = ControlTabular::LEFT;
302 case 0: h = ControlTabular::LEFT; break;
303 case 1: h = ControlTabular::CENTER; break;
304 case 2: h = ControlTabular::RIGHT; break;
305 case 3: h = ControlTabular::BLOCK; break;
308 form_->controller().halign(h);
312 void QTabularDialog::vAlign_changed(int align)
314 ControlTabular::VALIGN v = ControlTabular::TOP;
317 case 0: v = ControlTabular::TOP; break;
318 case 1: v = ControlTabular::MIDDLE; break;
319 case 2: v = ControlTabular::BOTTOM; break;
322 form_->controller().valign(v);
326 void QTabularDialog::longTabular()
328 form_->controller().longTabular(longTabularCB->isChecked());
333 void QTabularDialog::ltNewpage_clicked()
335 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
340 void QTabularDialog::ltHeaderStatus_clicked()
342 bool enable(headerStatusCB->isChecked());
344 form_->controller().set(LyXTabular::SET_LTHEAD, "");
346 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
347 headerBorderAboveCB->setEnabled(enable);
348 headerBorderBelowCB->setEnabled(enable);
349 firstheaderNoContentsCB->setEnabled(enable);
354 void QTabularDialog::ltHeaderBorderAbove_clicked()
356 if (headerBorderAboveCB->isChecked())
357 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
359 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
364 void QTabularDialog::ltHeaderBorderBelow_clicked()
366 if (headerBorderBelowCB->isChecked())
367 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
369 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
374 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
376 if (firstheaderBorderAboveCB->isChecked())
377 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
379 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
384 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
386 if (firstheaderBorderBelowCB->isChecked())
387 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
389 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
394 void QTabularDialog::ltFirstHeaderStatus_clicked()
396 bool enable(firstheaderStatusCB->isChecked());
398 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
400 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
401 firstheaderBorderAboveCB->setEnabled(enable);
402 firstheaderBorderBelowCB->setEnabled(enable);
407 void QTabularDialog::ltFirstHeaderEmpty_clicked()
409 bool enable(firstheaderNoContentsCB->isChecked());
411 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
413 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
414 firstheaderStatusCB->setEnabled(!enable);
415 firstheaderBorderAboveCB->setEnabled(!enable);
416 firstheaderBorderBelowCB->setEnabled(!enable);
421 void QTabularDialog::ltFooterStatus_clicked()
423 bool enable(footerStatusCB->isChecked());
425 form_->controller().set(LyXTabular::SET_LTFOOT, "");
427 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
428 footerBorderAboveCB->setEnabled(enable);
429 footerBorderBelowCB->setEnabled(enable);
430 lastfooterNoContentsCB->setEnabled(enable);
435 void QTabularDialog::ltFooterBorderAbove_clicked()
437 if (footerBorderAboveCB->isChecked())
438 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
440 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
445 void QTabularDialog::ltFooterBorderBelow_clicked()
447 if (footerBorderBelowCB->isChecked())
448 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
450 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
455 void QTabularDialog::ltLastFooterStatus_clicked()
457 bool enable(lastfooterStatusCB->isChecked());
459 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
461 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
462 lastfooterBorderAboveCB->setEnabled(enable);
463 lastfooterBorderBelowCB->setEnabled(enable);
468 void QTabularDialog::ltLastFooterBorderAbove_clicked()
470 if (lastfooterBorderAboveCB->isChecked())
471 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
473 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
478 void QTabularDialog::ltLastFooterBorderBelow_clicked()
480 if (lastfooterBorderBelowCB->isChecked())
481 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
483 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
488 void QTabularDialog::ltLastFooterEmpty_clicked()
490 bool enable(lastfooterNoContentsCB->isChecked());
492 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
494 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
495 lastfooterStatusCB->setEnabled(!enable);
496 lastfooterBorderAboveCB->setEnabled(!enable);
497 lastfooterBorderBelowCB->setEnabled(!enable);
501 } // namespace frontend
504 #include "QTabularDialog_moc.cpp"