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 "GuiTabular.h"
17 #include "ControlTabular.h"
18 #include "GuiSetBorder.h"
19 #include "LengthCombo.h"
20 #include "Validator.h"
21 #include "qt_helpers.h"
23 #include "support/convert.h"
25 #include <QCloseEvent>
27 #include <QPushButton>
28 #include <QRadioButton>
37 GuiTabularDialog::GuiTabularDialog(LyXView & lv)
38 : GuiDialog(lv, "tabular")
41 setViewTitle(_("Table Settings"));
42 setController(new ControlTabular(*this));
44 widthED->setValidator(unsignedLengthValidator(widthED));
45 topspaceED->setValidator(new LengthValidator(topspaceED));
46 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
47 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
49 connect(topspaceED, SIGNAL(returnPressed()),
50 this, SLOT(topspace_changed()));
51 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
52 this, SLOT(topspace_changed()));
53 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
54 connect(bottomspaceED, SIGNAL(returnPressed()),
55 this, SLOT(bottomspace_changed()));
56 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
57 this, SLOT(bottomspace_changed()));
58 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
59 connect(interlinespaceED, SIGNAL(returnPressed()),
60 this, SLOT(interlinespace_changed()));
61 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
62 this, SLOT(interlinespace_changed()));
63 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
64 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
65 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
66 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
67 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
68 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
69 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
70 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
71 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
72 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
73 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
74 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
75 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
76 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
77 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
78 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
79 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
80 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
81 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
82 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
83 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
84 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
85 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
86 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
87 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
88 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
89 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
90 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
91 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
92 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
93 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
94 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
95 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
96 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
97 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
98 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
100 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
101 bc().setCancel(closePB);
103 bc().addReadOnly(topspaceED);
104 bc().addReadOnly(topspaceUnit);
105 bc().addReadOnly(topspaceCO);
106 bc().addReadOnly(bottomspaceED);
107 bc().addReadOnly(bottomspaceUnit);
108 bc().addReadOnly(bottomspaceCO);
109 bc().addReadOnly(interlinespaceED);
110 bc().addReadOnly(interlinespaceUnit);
111 bc().addReadOnly(interlinespaceCO);
112 bc().addReadOnly(borderDefaultRB);
113 bc().addReadOnly(booktabsRB);
115 bc().addReadOnly(multicolumnCB);
116 bc().addReadOnly(rotateCellCB);
117 bc().addReadOnly(rotateTabularCB);
118 bc().addReadOnly(specialAlignmentED);
119 bc().addReadOnly(widthED);
120 bc().addReadOnly(widthUnit);
121 bc().addReadOnly(hAlignCB);
122 bc().addReadOnly(vAlignCB);
123 bc().addReadOnly(borderSetPB);
124 bc().addReadOnly(borderUnsetPB);
125 bc().addReadOnly(borders);
126 bc().addReadOnly(longTabularCB);
127 bc().addReadOnly(headerStatusCB);
128 bc().addReadOnly(headerBorderAboveCB);
129 bc().addReadOnly(headerBorderBelowCB);
130 bc().addReadOnly(firstheaderStatusCB);
131 bc().addReadOnly(firstheaderBorderAboveCB);
132 bc().addReadOnly(firstheaderBorderBelowCB);
133 bc().addReadOnly(firstheaderNoContentsCB);
134 bc().addReadOnly(footerStatusCB);
135 bc().addReadOnly(footerBorderAboveCB);
136 bc().addReadOnly(footerBorderBelowCB);
137 bc().addReadOnly(lastfooterStatusCB);
138 bc().addReadOnly(lastfooterBorderAboveCB);
139 bc().addReadOnly(lastfooterBorderBelowCB);
140 bc().addReadOnly(lastfooterNoContentsCB);
141 bc().addReadOnly(newpageCB);
143 // initialize the length validator
144 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
145 bc().addCheckedLineEdit(topspaceED, topspaceLA);
146 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
147 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
151 ControlTabular & GuiTabularDialog::controller() const
153 return static_cast<ControlTabular &>(Dialog::controller());
157 void GuiTabularDialog::change_adaptor()
163 void GuiTabularDialog::closeEvent(QCloseEvent * e)
170 void GuiTabularDialog::booktabsChanged(bool)
173 controller().booktabs(booktabsRB->isChecked());
178 void GuiTabularDialog::topspace_changed()
180 switch(topspaceCO->currentIndex()) {
182 controller().set(Tabular::SET_TOP_SPACE, "");
183 topspaceED->setEnabled(false);
184 topspaceUnit->setEnabled(false);
188 controller().set(Tabular::SET_TOP_SPACE, "default");
189 topspaceED->setEnabled(false);
190 topspaceUnit->setEnabled(false);
194 if (!topspaceED->text().isEmpty())
195 controller().set(Tabular::SET_TOP_SPACE,
196 widgetsToLength(topspaceED, topspaceUnit));
197 if (!bc().policy().isReadOnly()) {
198 topspaceED->setEnabled(true);
199 topspaceUnit->setEnabled(true);
208 void GuiTabularDialog::bottomspace_changed()
210 switch(bottomspaceCO->currentIndex()) {
212 controller().set(Tabular::SET_BOTTOM_SPACE, "");
213 bottomspaceED->setEnabled(false);
214 bottomspaceUnit->setEnabled(false);
218 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
219 bottomspaceED->setEnabled(false);
220 bottomspaceUnit->setEnabled(false);
224 if (!bottomspaceED->text().isEmpty())
225 controller().set(Tabular::SET_BOTTOM_SPACE,
226 widgetsToLength(bottomspaceED, bottomspaceUnit));
227 if (!bc().policy().isReadOnly()) {
228 bottomspaceED->setEnabled(true);
229 bottomspaceUnit->setEnabled(true);
238 void GuiTabularDialog::interlinespace_changed()
240 switch(interlinespaceCO->currentIndex()) {
242 controller().set(Tabular::SET_INTERLINE_SPACE, "");
243 interlinespaceED->setEnabled(false);
244 interlinespaceUnit->setEnabled(false);
248 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
249 interlinespaceED->setEnabled(false);
250 interlinespaceUnit->setEnabled(false);
254 if (!interlinespaceED->text().isEmpty())
255 controller().set(Tabular::SET_INTERLINE_SPACE,
256 widgetsToLength(interlinespaceED, interlinespaceUnit));
257 if (!bc().policy().isReadOnly()) {
258 interlinespaceED->setEnabled(true);
259 interlinespaceUnit->setEnabled(true);
268 void GuiTabularDialog::close_clicked()
275 void GuiTabularDialog::borderSet_clicked()
277 controller().set(Tabular::SET_ALL_LINES);
283 void GuiTabularDialog::borderUnset_clicked()
285 controller().set(Tabular::UNSET_ALL_LINES);
291 void GuiTabularDialog::leftBorder_changed()
293 controller().toggleLeftLine();
298 void GuiTabularDialog::rightBorder_changed()
300 controller().toggleRightLine();
305 void GuiTabularDialog::topBorder_changed()
307 controller().toggleTopLine();
312 void GuiTabularDialog::bottomBorder_changed()
314 controller().toggleBottomLine();
319 void GuiTabularDialog::specialAlignment_changed()
321 string special = fromqstr(specialAlignmentED->text());
322 controller().setSpecial(special);
327 void GuiTabularDialog::width_changed()
330 string const width = widgetsToLength(widthED, widthUnit);
331 controller().setWidth(width);
335 void GuiTabularDialog::multicolumn_clicked()
337 controller().toggleMultiColumn();
342 void GuiTabularDialog::rotateTabular()
344 controller().rotateTabular(rotateTabularCB->isChecked());
349 void GuiTabularDialog::rotateCell()
351 controller().rotateCell(rotateCellCB->isChecked());
356 void GuiTabularDialog::hAlign_changed(int align)
358 ControlTabular::HALIGN h = ControlTabular::LEFT;
361 case 0: h = ControlTabular::LEFT; break;
362 case 1: h = ControlTabular::CENTER; break;
363 case 2: h = ControlTabular::RIGHT; break;
364 case 3: h = ControlTabular::BLOCK; break;
367 controller().halign(h);
371 void GuiTabularDialog::vAlign_changed(int align)
373 ControlTabular::VALIGN v = ControlTabular::TOP;
376 case 0: v = ControlTabular::TOP; break;
377 case 1: v = ControlTabular::MIDDLE; break;
378 case 2: v = ControlTabular::BOTTOM; break;
381 controller().valign(v);
385 void GuiTabularDialog::longTabular()
387 controller().longTabular(longTabularCB->isChecked());
392 void GuiTabularDialog::ltNewpage_clicked()
394 controller().set(Tabular::SET_LTNEWPAGE);
399 void GuiTabularDialog::ltHeaderStatus_clicked()
401 bool enable(headerStatusCB->isChecked());
403 controller().set(Tabular::SET_LTHEAD, "");
405 controller().set(Tabular::UNSET_LTHEAD, "");
406 headerBorderAboveCB->setEnabled(enable);
407 headerBorderBelowCB->setEnabled(enable);
408 firstheaderNoContentsCB->setEnabled(enable);
413 void GuiTabularDialog::ltHeaderBorderAbove_clicked()
415 if (headerBorderAboveCB->isChecked())
416 controller().set(Tabular::SET_LTHEAD, "dl_above");
418 controller().set(Tabular::UNSET_LTHEAD, "dl_above");
423 void GuiTabularDialog::ltHeaderBorderBelow_clicked()
425 if (headerBorderBelowCB->isChecked())
426 controller().set(Tabular::SET_LTHEAD, "dl_below");
428 controller().set(Tabular::UNSET_LTHEAD, "dl_below");
433 void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
435 if (firstheaderBorderAboveCB->isChecked())
436 controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
438 controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
443 void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
445 if (firstheaderBorderBelowCB->isChecked())
446 controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
448 controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
453 void GuiTabularDialog::ltFirstHeaderStatus_clicked()
455 bool enable(firstheaderStatusCB->isChecked());
457 controller().set(Tabular::SET_LTFIRSTHEAD, "");
459 controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
460 firstheaderBorderAboveCB->setEnabled(enable);
461 firstheaderBorderBelowCB->setEnabled(enable);
466 void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
468 bool enable(firstheaderNoContentsCB->isChecked());
470 controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
472 controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
473 firstheaderStatusCB->setEnabled(!enable);
474 firstheaderBorderAboveCB->setEnabled(!enable);
475 firstheaderBorderBelowCB->setEnabled(!enable);
480 void GuiTabularDialog::ltFooterStatus_clicked()
482 bool enable(footerStatusCB->isChecked());
484 controller().set(Tabular::SET_LTFOOT, "");
486 controller().set(Tabular::UNSET_LTFOOT, "");
487 footerBorderAboveCB->setEnabled(enable);
488 footerBorderBelowCB->setEnabled(enable);
489 lastfooterNoContentsCB->setEnabled(enable);
494 void GuiTabularDialog::ltFooterBorderAbove_clicked()
496 if (footerBorderAboveCB->isChecked())
497 controller().set(Tabular::SET_LTFOOT, "dl_above");
499 controller().set(Tabular::UNSET_LTFOOT, "dl_above");
504 void GuiTabularDialog::ltFooterBorderBelow_clicked()
506 if (footerBorderBelowCB->isChecked())
507 controller().set(Tabular::SET_LTFOOT, "dl_below");
509 controller().set(Tabular::UNSET_LTFOOT, "dl_below");
514 void GuiTabularDialog::ltLastFooterStatus_clicked()
516 bool enable(lastfooterStatusCB->isChecked());
518 controller().set(Tabular::SET_LTLASTFOOT, "");
520 controller().set(Tabular::UNSET_LTLASTFOOT, "");
521 lastfooterBorderAboveCB->setEnabled(enable);
522 lastfooterBorderBelowCB->setEnabled(enable);
527 void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
529 if (lastfooterBorderAboveCB->isChecked())
530 controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
532 controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
537 void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
539 if (lastfooterBorderBelowCB->isChecked())
540 controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
542 controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
547 void GuiTabularDialog::ltLastFooterEmpty_clicked()
549 bool enable(lastfooterNoContentsCB->isChecked());
551 controller().set(Tabular::SET_LTLASTFOOT, "empty");
553 controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
554 lastfooterStatusCB->setEnabled(!enable);
555 lastfooterBorderAboveCB->setEnabled(!enable);
556 lastfooterBorderBelowCB->setEnabled(!enable);
561 void GuiTabularDialog::update_borders()
563 Tabular const & tabular = controller().tabular();
564 Tabular::idx_type const cell = controller().getActiveCell();
565 bool const isMulticolumnCell = tabular.isMultiColumn(cell);
567 if (!isMulticolumnCell) {
568 borders->setLeftEnabled(true);
569 borders->setRightEnabled(true);
570 borders->setTop(tabular.topLine(cell, true));
571 borders->setBottom(tabular.bottomLine(cell, true));
572 borders->setLeft(tabular.leftLine(cell, true));
573 borders->setRight(tabular.rightLine(cell, true));
574 // repaint the setborder widget
579 borders->setTop(tabular.topLine(cell));
580 borders->setBottom(tabular.bottomLine(cell));
581 // pay attention to left/right lines: they are only allowed
582 // to set if we are in first/last cell of row or if the left/right
583 // cell is also a multicolumn.
584 if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
585 borders->setLeftEnabled(true);
586 borders->setLeft(tabular.leftLine(cell));
588 borders->setLeft(false);
589 borders->setLeftEnabled(false);
591 if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
592 borders->setRightEnabled(true);
593 borders->setRight(tabular.rightLine(cell));
595 borders->setRight(false);
596 borders->setRightEnabled(false);
598 // repaint the setborder widget
603 void GuiTabularDialog::update_contents()
605 controller().initialiseParams(string());
607 Tabular const & tabular(controller().tabular());
608 Tabular::idx_type const cell = controller().getActiveCell();
610 Tabular::row_type const row = tabular.cellRow(cell);
611 Tabular::col_type const col = tabular.cellColumn(cell);
613 tabularRowED->setText(toqstr(convert<string>(row + 1)));
614 tabularColumnED->setText(toqstr(convert<string>(col + 1)));
616 bool const multicol(tabular.isMultiColumn(cell));
618 multicolumnCB->setChecked(multicol);
620 rotateCellCB->setChecked(tabular.getRotateCell(cell));
621 rotateTabularCB->setChecked(tabular.getRotateTabular());
623 longTabularCB->setChecked(tabular.isLongTabular());
631 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
632 pwidth = tabular.getMColumnPWidth(cell);
634 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
635 pwidth = tabular.getColumnPWidth(cell);
638 specialAlignmentED->setText(toqstr(special));
640 bool const isReadonly = bc().policy().isReadOnly();
641 specialAlignmentED->setEnabled(!isReadonly);
643 Length::UNIT default_unit =
644 controller().useMetricUnits() ? Length::CM : Length::IN;
646 borderDefaultRB->setChecked(!tabular.useBookTabs());
647 booktabsRB->setChecked(tabular.useBookTabs());
649 if (tabular.row_info[row].top_space.empty()
650 && !tabular.row_info[row].top_space_default) {
651 topspaceCO->setCurrentIndex(0);
652 } else if (tabular.row_info[row].top_space_default) {
653 topspaceCO->setCurrentIndex(1);
655 topspaceCO->setCurrentIndex(2);
656 lengthToWidgets(topspaceED,
658 tabular.row_info[row].top_space.asString(),
661 topspaceED->setEnabled(!isReadonly
662 && (topspaceCO->currentIndex() == 2));
663 topspaceUnit->setEnabled(!isReadonly
664 && (topspaceCO->currentIndex() == 2));
665 topspaceCO->setEnabled(!isReadonly);
667 if (tabular.row_info[row].bottom_space.empty()
668 && !tabular.row_info[row].bottom_space_default) {
669 bottomspaceCO->setCurrentIndex(0);
670 } else if (tabular.row_info[row].bottom_space_default) {
671 bottomspaceCO->setCurrentIndex(1);
673 bottomspaceCO->setCurrentIndex(2);
674 lengthToWidgets(bottomspaceED,
676 tabular.row_info[row].bottom_space.asString(),
679 bottomspaceED->setEnabled(!isReadonly
680 && (bottomspaceCO->currentIndex() == 2));
681 bottomspaceUnit->setEnabled(!isReadonly
682 && (bottomspaceCO->currentIndex() == 2));
683 bottomspaceCO->setEnabled(!isReadonly);
685 if (tabular.row_info[row].interline_space.empty()
686 && !tabular.row_info[row].interline_space_default) {
687 interlinespaceCO->setCurrentIndex(0);
688 } else if (tabular.row_info[row].interline_space_default) {
689 interlinespaceCO->setCurrentIndex(1);
691 interlinespaceCO->setCurrentIndex(2);
692 lengthToWidgets(interlinespaceED,
694 tabular.row_info[row].interline_space.asString(),
697 interlinespaceED->setEnabled(!isReadonly
698 && (interlinespaceCO->currentIndex() == 2));
699 interlinespaceUnit->setEnabled(!isReadonly
700 && (interlinespaceCO->currentIndex() == 2));
701 interlinespaceCO->setEnabled(!isReadonly);
705 colwidth = pwidth.asString();
706 lengthToWidgets(widthED, widthUnit,
707 colwidth, default_unit);
709 widthED->setEnabled(!isReadonly);
710 widthUnit->setEnabled(!isReadonly);
713 hAlignCB->addItem(qt_("Left"));
714 hAlignCB->addItem(qt_("Center"));
715 hAlignCB->addItem(qt_("Right"));
716 if (!multicol && !pwidth.zero())
717 hAlignCB->addItem(qt_("Justified"));
720 switch (tabular.getAlignment(cell)) {
724 case LYX_ALIGN_CENTER:
727 case LYX_ALIGN_RIGHT:
730 case LYX_ALIGN_BLOCK:
732 if (!multicol && !pwidth.zero())
740 hAlignCB->setCurrentIndex(align);
743 switch (tabular.getVAlignment(cell)) {
744 case Tabular::LYX_VALIGN_TOP:
747 case Tabular::LYX_VALIGN_MIDDLE:
750 case Tabular::LYX_VALIGN_BOTTOM:
759 vAlignCB->setCurrentIndex(valign);
761 hAlignCB->setEnabled(true);
762 vAlignCB->setEnabled(!pwidth.zero());
764 if (!tabular.isLongTabular()) {
765 headerStatusCB->setChecked(false);
766 headerBorderAboveCB->setChecked(false);
767 headerBorderBelowCB->setChecked(false);
768 firstheaderStatusCB->setChecked(false);
769 firstheaderBorderAboveCB->setChecked(false);
770 firstheaderBorderBelowCB->setChecked(false);
771 firstheaderNoContentsCB->setChecked(false);
772 footerStatusCB->setChecked(false);
773 footerBorderAboveCB->setChecked(false);
774 footerBorderBelowCB->setChecked(false);
775 lastfooterStatusCB->setChecked(false);
776 lastfooterBorderAboveCB->setChecked(false);
777 lastfooterBorderBelowCB->setChecked(false);
778 lastfooterNoContentsCB->setChecked(false);
779 newpageCB->setChecked(false);
780 newpageCB->setEnabled(false);
786 bool row_set = tabular.getRowOfLTHead(row, ltt);
787 headerStatusCB->setChecked(row_set);
789 headerBorderAboveCB->setChecked(ltt.topDL);
790 headerBorderBelowCB->setChecked(ltt.bottomDL);
793 headerBorderAboveCB->setChecked(false);
794 headerBorderBelowCB->setChecked(false);
795 headerBorderAboveCB->setEnabled(false);
796 headerBorderBelowCB->setEnabled(false);
797 firstheaderNoContentsCB->setChecked(false);
798 firstheaderNoContentsCB->setEnabled(false);
802 row_set = tabular.getRowOfLTFirstHead(row, ltt);
803 firstheaderStatusCB->setChecked(row_set);
804 if (ltt.set && (!ltt.empty || !use_empty)) {
805 firstheaderBorderAboveCB->setChecked(ltt.topDL);
806 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
808 firstheaderBorderAboveCB->setEnabled(false);
809 firstheaderBorderBelowCB->setEnabled(false);
810 firstheaderBorderAboveCB->setChecked(false);
811 firstheaderBorderBelowCB->setChecked(false);
813 firstheaderNoContentsCB->setChecked(ltt.empty);
815 firstheaderStatusCB->setEnabled(false);
819 row_set = tabular.getRowOfLTFoot(row, ltt);
820 footerStatusCB->setChecked(row_set);
822 footerBorderAboveCB->setChecked(ltt.topDL);
823 footerBorderBelowCB->setChecked(ltt.bottomDL);
826 footerBorderAboveCB->setChecked(false);
827 footerBorderBelowCB->setChecked(false);
828 footerBorderAboveCB->setEnabled(false);
829 footerBorderBelowCB->setEnabled(false);
830 lastfooterNoContentsCB->setChecked(false);
831 lastfooterNoContentsCB->setEnabled(false);
835 row_set = tabular.getRowOfLTLastFoot(row, ltt);
836 lastfooterStatusCB->setChecked(row_set);
837 if (ltt.set && (!ltt.empty || !use_empty)) {
838 lastfooterBorderAboveCB->setChecked(ltt.topDL);
839 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
841 lastfooterBorderAboveCB->setEnabled(false);
842 lastfooterBorderBelowCB->setEnabled(false);
843 lastfooterBorderAboveCB->setChecked(false);
844 lastfooterBorderBelowCB->setChecked(false);
846 lastfooterNoContentsCB->setChecked(ltt.empty);
848 lastfooterStatusCB->setEnabled(false);
851 newpageCB->setChecked(tabular.getLTNewPage(row));
855 void GuiTabularDialog::closeGUI()
857 // ugly hack to auto-apply the stuff that hasn't been
858 // yet. don't let this continue to exist ...
860 // Subtle here, we must /not/ apply any changes and
861 // then refer to tabular, as it will have been freed
862 // since the changes update the actual controller().tabular()
863 Tabular const & tabular(controller().tabular());
865 // apply the fixed width values
866 Tabular::idx_type const cell = controller().getActiveCell();
867 bool const multicol = tabular.isMultiColumn(cell);
868 string width = widgetsToLength(widthED, widthUnit);
871 Length llen = tabular.getColumnPWidth(cell);
872 Length llenMulti = tabular.getMColumnPWidth(cell);
874 if (multicol && !llenMulti.zero())
875 width2 = llenMulti.asString();
876 else if (!multicol && !llen.zero())
877 width2 = llen.asString();
879 // apply the special alignment
880 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
884 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
886 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
890 controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
892 controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
895 if (width != width2) {
897 controller().set(Tabular::SET_MPWIDTH, width);
899 controller().set(Tabular::SET_PWIDTH, width);
903 switch (topspaceCO->currentIndex()) {
905 controller().set(Tabular::SET_TOP_SPACE, "");
908 controller().set(Tabular::SET_TOP_SPACE, "default");
911 controller().set(Tabular::SET_TOP_SPACE,
912 widgetsToLength(topspaceED,
917 switch (bottomspaceCO->currentIndex()) {
919 controller().set(Tabular::SET_BOTTOM_SPACE, "");
922 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
925 controller().set(Tabular::SET_BOTTOM_SPACE,
926 widgetsToLength(bottomspaceED,
931 switch (interlinespaceCO->currentIndex()) {
933 controller().set(Tabular::SET_INTERLINE_SPACE, "");
936 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
939 controller().set(Tabular::SET_INTERLINE_SPACE,
940 widgetsToLength(interlinespaceED,
941 interlinespaceUnit));
947 } // namespace frontend
950 #include "GuiTabular_moc.cpp"