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()), this, SLOT(on_booktabsRB_toggled()));
61 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
62 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
63 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
64 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
65 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
66 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
67 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
68 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
69 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
70 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
71 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
72 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
73 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
74 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
75 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
76 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
77 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
78 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
79 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
80 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
81 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
82 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
83 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
84 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
85 connect(widthUnit, SIGNAL(selectionChanged(lyx::LyXLength::UNIT)), this, SLOT(width_changed()));
86 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
87 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
88 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
89 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
90 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
91 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
92 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
93 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
97 void QTabularDialog::change_adaptor()
103 void QTabularDialog::closeEvent(QCloseEvent * e)
110 void QTabularDialog::on_booktabsRB_toggled()
113 form_->controller().booktabs(booktabsRB->isChecked());
114 form_->update_borders();
118 void QTabularDialog::topspace_changed()
120 switch(topspaceCO->currentIndex()) {
122 form_->controller().set(LyXTabular::SET_TOP_SPACE, "");
123 topspaceED->setEnabled(false);
124 topspaceUnit->setEnabled(false);
128 form_->controller().set(LyXTabular::SET_TOP_SPACE, "default");
129 topspaceED->setEnabled(false);
130 topspaceUnit->setEnabled(false);
134 if (!topspaceED->text().isEmpty())
135 form_->controller().set(LyXTabular::SET_TOP_SPACE,
136 widgetsToLength(topspaceED, topspaceUnit));
137 if (!form_->bc().bp().isReadOnly()) {
138 topspaceED->setEnabled(true);
139 topspaceUnit->setEnabled(true);
148 void QTabularDialog::bottomspace_changed()
150 switch(bottomspaceCO->currentIndex()) {
152 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
153 bottomspaceED->setEnabled(false);
154 bottomspaceUnit->setEnabled(false);
158 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
159 bottomspaceED->setEnabled(false);
160 bottomspaceUnit->setEnabled(false);
164 if (!bottomspaceED->text().isEmpty())
165 form_->controller().set(LyXTabular::SET_BOTTOM_SPACE,
166 widgetsToLength(bottomspaceED, bottomspaceUnit));
167 if (!form_->bc().bp().isReadOnly()) {
168 bottomspaceED->setEnabled(true);
169 bottomspaceUnit->setEnabled(true);
178 void QTabularDialog::interlinespace_changed()
180 switch(interlinespaceCO->currentIndex()) {
182 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
183 interlinespaceED->setEnabled(false);
184 interlinespaceUnit->setEnabled(false);
188 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
189 interlinespaceED->setEnabled(false);
190 interlinespaceUnit->setEnabled(false);
194 if (!interlinespaceED->text().isEmpty())
195 form_->controller().set(LyXTabular::SET_INTERLINE_SPACE,
196 widgetsToLength(interlinespaceED, interlinespaceUnit));
197 if (!form_->bc().bp().isReadOnly()) {
198 interlinespaceED->setEnabled(true);
199 interlinespaceUnit->setEnabled(true);
208 void QTabularDialog::close_clicked()
215 void QTabularDialog::borderSet_clicked()
217 form_->controller().set(LyXTabular::SET_ALL_LINES);
218 form_->update_borders();
223 void QTabularDialog::borderUnset_clicked()
225 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
226 form_->update_borders();
231 void QTabularDialog::leftBorder_changed()
233 form_->controller().toggleLeftLine();
238 void QTabularDialog::rightBorder_changed()
240 form_->controller().toggleRightLine();
245 void QTabularDialog::topBorder_changed()
247 form_->controller().toggleTopLine();
252 void QTabularDialog::bottomBorder_changed()
254 form_->controller().toggleBottomLine();
259 void QTabularDialog::specialAlignment_changed()
261 string special = fromqstr(specialAlignmentED->text());
262 form_->controller().setSpecial(special);
267 void QTabularDialog::width_changed()
270 string const width = widgetsToLength(widthED, widthUnit);
271 form_->controller().setWidth(width);
275 void QTabularDialog::multicolumn_clicked()
277 form_->controller().toggleMultiColumn();
282 void QTabularDialog::rotateTabular()
284 form_->controller().rotateTabular(rotateTabularCB->isChecked());
289 void QTabularDialog::rotateCell()
291 form_->controller().rotateCell(rotateCellCB->isChecked());
296 void QTabularDialog::hAlign_changed(int align)
298 ControlTabular::HALIGN h = ControlTabular::LEFT;
301 case 0: h = ControlTabular::LEFT; break;
302 case 1: h = ControlTabular::CENTER; break;
303 case 2: h = ControlTabular::RIGHT; break;
304 case 3: h = ControlTabular::BLOCK; break;
307 form_->controller().halign(h);
311 void QTabularDialog::vAlign_changed(int align)
313 ControlTabular::VALIGN v = ControlTabular::TOP;
316 case 0: v = ControlTabular::TOP; break;
317 case 1: v = ControlTabular::MIDDLE; break;
318 case 2: v = ControlTabular::BOTTOM; break;
321 form_->controller().valign(v);
325 void QTabularDialog::longTabular()
327 form_->controller().longTabular(longTabularCB->isChecked());
332 void QTabularDialog::ltNewpage_clicked()
334 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
339 void QTabularDialog::ltHeaderStatus_clicked()
341 bool enable(headerStatusCB->isChecked());
343 form_->controller().set(LyXTabular::SET_LTHEAD, "");
345 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
346 headerBorderAboveCB->setEnabled(enable);
347 headerBorderBelowCB->setEnabled(enable);
348 firstheaderNoContentsCB->setEnabled(enable);
353 void QTabularDialog::ltHeaderBorderAbove_clicked()
355 if (headerBorderAboveCB->isChecked())
356 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
358 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_above");
363 void QTabularDialog::ltHeaderBorderBelow_clicked()
365 if (headerBorderBelowCB->isChecked())
366 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
368 form_->controller().set(LyXTabular::UNSET_LTHEAD, "dl_below");
373 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
375 if (firstheaderBorderAboveCB->isChecked())
376 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
378 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_above");
383 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
385 if (firstheaderBorderBelowCB->isChecked())
386 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
388 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "dl_below");
393 void QTabularDialog::ltFirstHeaderStatus_clicked()
395 bool enable(firstheaderStatusCB->isChecked());
397 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
399 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
400 firstheaderBorderAboveCB->setEnabled(enable);
401 firstheaderBorderBelowCB->setEnabled(enable);
406 void QTabularDialog::ltFirstHeaderEmpty_clicked()
408 bool enable(firstheaderNoContentsCB->isChecked());
410 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
412 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "empty");
413 firstheaderStatusCB->setEnabled(!enable);
414 firstheaderBorderAboveCB->setEnabled(!enable);
415 firstheaderBorderBelowCB->setEnabled(!enable);
420 void QTabularDialog::ltFooterStatus_clicked()
422 bool enable(footerStatusCB->isChecked());
424 form_->controller().set(LyXTabular::SET_LTFOOT, "");
426 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
427 footerBorderAboveCB->setEnabled(enable);
428 footerBorderBelowCB->setEnabled(enable);
429 lastfooterNoContentsCB->setEnabled(enable);
434 void QTabularDialog::ltFooterBorderAbove_clicked()
436 if (footerBorderAboveCB->isChecked())
437 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
439 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_above");
444 void QTabularDialog::ltFooterBorderBelow_clicked()
446 if (footerBorderBelowCB->isChecked())
447 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
449 form_->controller().set(LyXTabular::UNSET_LTFOOT, "dl_below");
454 void QTabularDialog::ltLastFooterStatus_clicked()
456 bool enable(lastfooterStatusCB->isChecked());
458 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
460 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
461 lastfooterBorderAboveCB->setEnabled(enable);
462 lastfooterBorderBelowCB->setEnabled(enable);
467 void QTabularDialog::ltLastFooterBorderAbove_clicked()
469 if (lastfooterBorderAboveCB->isChecked())
470 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
472 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_above");
477 void QTabularDialog::ltLastFooterBorderBelow_clicked()
479 if (lastfooterBorderBelowCB->isChecked())
480 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
482 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "dl_below");
487 void QTabularDialog::ltLastFooterEmpty_clicked()
489 bool enable(lastfooterNoContentsCB->isChecked());
491 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
493 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "empty");
494 lastfooterStatusCB->setEnabled(!enable);
495 lastfooterBorderAboveCB->setEnabled(!enable);
496 lastfooterBorderBelowCB->setEnabled(!enable);
500 } // namespace frontend
503 #include "QTabularDialog_moc.cpp"