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
11 * Full author contact details are available in file CREDITS.
16 #include "GuiTabular.h"
18 #include "GuiApplication.h"
19 #include "GuiSetBorder.h"
21 #include "LengthCombo.h"
22 #include "qt_helpers.h"
23 #include "Validator.h"
25 #include "BufferView.h"
27 #include "FuncRequest.h"
28 #include "FuncStatus.h"
31 #include "insets/InsetTabular.h"
33 #include "support/debug.h"
36 #include <QPushButton>
37 #include <QRadioButton>
45 GuiTabular::GuiTabular(QWidget * parent)
46 : InsetParamsWidget(parent)
50 widthED->setValidator(unsignedLengthValidator(widthED));
51 topspaceED->setValidator(new LengthValidator(topspaceED));
52 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
53 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
55 widthUnitCB->setCurrentItem(Length::defaultUnit());
57 connect(topspaceED, SIGNAL(returnPressed()),
58 this, SLOT(checkEnabled()));
59 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
60 this, SLOT(checkEnabled()));
61 connect(topspaceCO, SIGNAL(activated(int)),
62 this, SLOT(checkEnabled()));
63 connect(bottomspaceED, SIGNAL(returnPressed()),
64 this, SLOT(checkEnabled()));
65 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
66 this, SLOT(checkEnabled()));
67 connect(bottomspaceCO, SIGNAL(activated(int)),
68 this, SLOT(checkEnabled()));
69 connect(interlinespaceED, SIGNAL(returnPressed()),
70 this, SLOT(checkEnabled()));
71 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
72 this, SLOT(checkEnabled()));
73 connect(interlinespaceCO, SIGNAL(activated(int)),
74 this, SLOT(checkEnabled()));
75 connect(booktabsRB, SIGNAL(clicked(bool)),
76 this, SLOT(checkEnabled()));
77 connect(borderDefaultRB, SIGNAL(clicked(bool)),
78 this, SLOT(checkEnabled()));
79 connect(borderSetPB, SIGNAL(clicked()),
80 this, SLOT(borderSet_clicked()));
81 connect(borderUnsetPB, SIGNAL(clicked()),
82 this, SLOT(borderUnset_clicked()));
83 connect(hAlignCB, SIGNAL(activated(int)),
84 this, SLOT(checkEnabled()));
85 connect(vAlignCB, SIGNAL(activated(int)),
86 this, SLOT(checkEnabled()));
87 connect(multicolumnCB, SIGNAL(clicked()),
88 this, SLOT(checkEnabled()));
89 connect(multirowCB, SIGNAL(clicked()),
90 this, SLOT(checkEnabled()));
91 connect(newpageCB, SIGNAL(clicked()),
92 this, SLOT(checkEnabled()));
93 connect(headerStatusCB, SIGNAL(clicked()),
94 this, SLOT(checkEnabled()));
95 connect(headerBorderAboveCB, SIGNAL(clicked()),
96 this, SLOT(checkEnabled()));
97 connect(headerBorderBelowCB, SIGNAL(clicked()),
98 this, SLOT(checkEnabled()));
99 connect(firstheaderStatusCB, SIGNAL(clicked()),
100 this, SLOT(checkEnabled()));
101 connect(firstheaderBorderAboveCB, SIGNAL(clicked()),
102 this, SLOT(checkEnabled()));
103 connect(firstheaderBorderBelowCB, SIGNAL(clicked()),
104 this, SLOT(checkEnabled()));
105 connect(firstheaderNoContentsCB, SIGNAL(clicked()),
106 this, SLOT(checkEnabled()));
107 connect(footerStatusCB, SIGNAL(clicked()),
108 this, SLOT(checkEnabled()));
109 connect(footerBorderAboveCB, SIGNAL(clicked()),
110 this, SLOT(checkEnabled()));
111 connect(footerBorderBelowCB, SIGNAL(clicked()),
112 this, SLOT(checkEnabled()));
113 connect(lastfooterStatusCB, SIGNAL(clicked()),
114 this, SLOT(checkEnabled()));
115 connect(lastfooterBorderAboveCB, SIGNAL(clicked()),
116 this, SLOT(checkEnabled()));
117 connect(lastfooterBorderBelowCB, SIGNAL(clicked()),
118 this, SLOT(checkEnabled()));
119 connect(lastfooterNoContentsCB, SIGNAL(clicked()),
120 this, SLOT(checkEnabled()));
121 connect(specialAlignmentED, SIGNAL(returnPressed()),
122 this, SLOT(checkEnabled()));
123 connect(widthED, SIGNAL(textEdited(QString)),
124 this, SLOT(checkEnabled()));
125 connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
126 this, SLOT(checkEnabled()));
127 connect(borders, SIGNAL(topSet(bool)),
128 this, SLOT(checkEnabled()));
129 connect(borders, SIGNAL(bottomSet(bool)),
130 this, SLOT(checkEnabled()));
131 connect(borders, SIGNAL(rightSet(bool)),
132 this, SLOT(checkEnabled()));
133 connect(borders, SIGNAL(leftSet(bool)),
134 this, SLOT(checkEnabled()));
135 connect(rotateTabularCB, SIGNAL(clicked()),
136 this, SLOT(checkEnabled()));
137 connect(rotateCellCB, SIGNAL(clicked()),
138 this, SLOT(checkEnabled()));
139 connect(TableAlignCB, SIGNAL(activated(int)),
140 this, SLOT(checkEnabled()));
141 connect(longTabularCB, SIGNAL(clicked()),
142 this, SLOT(checkEnabled()));
143 connect(leftRB, SIGNAL(clicked()),
144 this, SLOT(checkEnabled()));
145 connect(centerRB, SIGNAL(clicked()),
146 this, SLOT(checkEnabled()));
147 connect(rightRB, SIGNAL(clicked()),
148 this, SLOT(checkEnabled()));
151 // initialize the length validator
152 addCheckedWidget(widthED, fixedWidthColLA);
153 addCheckedWidget(topspaceED, topspaceLA);
154 addCheckedWidget(bottomspaceED, bottomspaceLA);
155 addCheckedWidget(interlinespaceED, interlinespaceLA);
159 void GuiTabular::checkEnabled()
161 hAlignCB->setEnabled(true);
162 vAlignCB->setEnabled(!multirowCB->isChecked()
163 && !widgetsToLength(widthED, widthUnitCB).empty());
165 topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
166 topspaceUnit->setEnabled(topspaceCO->currentIndex() == 2);
167 bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
168 bottomspaceUnit->setEnabled(bottomspaceCO->currentIndex() == 2);
169 interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
170 interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
172 bool const longtabular = longTabularCB->isChecked();
173 longtableGB->setEnabled(true);
174 newpageCB->setEnabled(longtabular);
175 alignmentGB->setEnabled(longtabular);
176 // longtables cannot have a vertical alignment
177 TableAlignCB->setDisabled(longtabular);
179 // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
180 // depending on the cursor position is very very unintuitive...
181 // We need some edit boxes to show which rows are header/footer/etc
182 // without having to move the cursor first.
183 headerStatusCB->setEnabled(longtabular);
184 headerBorderAboveCB->setEnabled(longtabular
185 && headerStatusCB->isChecked());
186 headerBorderBelowCB->setEnabled(longtabular
187 && headerStatusCB->isChecked());
189 // first header can only be suppressed when there is a header
190 // FIXME: old code also checked for
191 // tabular.haveLTHead() && !tabular.haveLTFirstHead());
192 firstheaderNoContentsCB->setEnabled(longtabular);
193 // check if setting a first header is allowed
194 // additionally check firstheaderNoContentsCB because when this is
195 // the case a first header makes no sense
196 // FIXME: verify that some previous row was not set.
197 firstheaderStatusCB->setEnabled(longtabular
198 && !firstheaderNoContentsCB->isChecked());
199 firstheaderBorderAboveCB->setEnabled(longtabular
200 && firstheaderStatusCB->isChecked());
201 firstheaderBorderBelowCB->setEnabled(longtabular
202 && firstheaderStatusCB->isChecked());
204 footerStatusCB->setEnabled(longtabular);
205 footerBorderAboveCB->setEnabled(longtabular
206 && footerBorderAboveCB->isChecked());
207 footerBorderBelowCB->setEnabled(longtabular
208 && footerBorderAboveCB->isChecked());
210 // last footer can only be suppressed when there is a footer
211 // FIXME: old code also checked for
212 // tabular.haveLTFoot() && !tabular.haveLTLastFoot());
213 lastfooterNoContentsCB->setEnabled(longtabular);
214 // check if setting a last footer is allowed
215 // additionally check lastfooterNoContentsCB because when this is
216 // the case a last footer makes no sense
217 lastfooterStatusCB->setEnabled(longtabular
218 && !lastfooterNoContentsCB->isChecked());
219 lastfooterBorderAboveCB->setEnabled(longtabular
220 && lastfooterBorderAboveCB->isChecked());
221 lastfooterBorderBelowCB->setEnabled(longtabular
222 && lastfooterBorderAboveCB->isChecked());
224 // FIXME: verify if previous row doesn't have a caption already.
225 captionStatusCB->setEnabled(longtabular);
227 // When a row is set as longtable caption, it must not be allowed
228 // to unset that this row is a multicolumn.
229 // FIXME: old code also checked for:
230 // funcEnabled(Tabular::MULTICOLUMN)
231 multicolumnCB->setEnabled(longtabular);
233 // FIXME: old code also checked for:
234 // funcEnabled(Tabular::MULTICOLUMN)
235 multirowCB->setEnabled(longtabular);
241 void GuiTabular::borderSet_clicked()
243 borders->setTop(true);
244 borders->setBottom(true);
245 borders->setLeft(true);
246 borders->setRight(true);
247 // repaint the setborder widget
253 void GuiTabular::borderUnset_clicked()
255 borders->setTop(false);
256 borders->setBottom(false);
257 borders->setLeft(false);
258 borders->setRight(false);
259 // repaint the setborder widget
265 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
268 param_str += featureAsString(f) + ' ' + arg;
272 void GuiTabular::setHAlign(string & param_str) const
274 int const align = hAlignCB->currentIndex();
276 enum HALIGN { LEFT, RIGHT, CENTER, BLOCK };
280 case 0: h = LEFT; break;
281 case 1: h = CENTER; break;
282 case 2: h = RIGHT; break;
283 case 3: h = BLOCK; break;
286 Tabular::Feature num = Tabular::ALIGN_LEFT;
287 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
291 num = Tabular::ALIGN_LEFT;
292 multi_num = Tabular::M_ALIGN_LEFT;
295 num = Tabular::ALIGN_CENTER;
296 multi_num = Tabular::M_ALIGN_CENTER;
299 num = Tabular::ALIGN_RIGHT;
300 multi_num = Tabular::M_ALIGN_RIGHT;
303 num = Tabular::ALIGN_BLOCK;
304 //multi_num: no equivalent
308 if (multicolumnCB->isChecked())
309 setParam(param_str, multi_num);
311 setParam(param_str, num);
315 void GuiTabular::setVAlign(string & param_str) const
317 int const align = vAlignCB->currentIndex();
318 enum VALIGN { TOP, MIDDLE, BOTTOM };
322 case 0: v = TOP; break;
323 case 1: v = MIDDLE; break;
324 case 2: v = BOTTOM; break;
327 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
328 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
332 num = Tabular::VALIGN_TOP;
333 multi_num = Tabular::M_VALIGN_TOP;
336 num = Tabular::VALIGN_MIDDLE;
337 multi_num = Tabular::M_VALIGN_MIDDLE;
340 num = Tabular::VALIGN_BOTTOM;
341 multi_num = Tabular::M_VALIGN_BOTTOM;
344 if (multicolumnCB->isChecked() || multirowCB->isChecked())
345 setParam(param_str, multi_num);
347 setParam(param_str, num);
351 void GuiTabular::setTableAlignment(string & param_str) const
353 int const align = TableAlignCB->currentIndex();
355 case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
357 case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
359 case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
365 docstring GuiTabular::dialogToParams() const
367 // FIXME: We should use Tabular directly.
368 string param_str = "tabular";
369 setHAlign(param_str);
370 setVAlign(param_str);
371 setTableAlignment(param_str);
373 if (booktabsRB->isChecked())
374 setParam(param_str, Tabular::SET_BOOKTABS);
376 setParam(param_str, Tabular::UNSET_BOOKTABS);
379 switch (topspaceCO->currentIndex()) {
381 setParam(param_str, Tabular::SET_TOP_SPACE, "none");
384 setParam(param_str, Tabular::SET_TOP_SPACE, "default");
387 if (!topspaceED->text().isEmpty())
388 setParam(param_str, Tabular::SET_TOP_SPACE,
389 widgetsToLength(topspaceED, topspaceUnit));
394 switch (bottomspaceCO->currentIndex()) {
396 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
399 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
402 if (!bottomspaceED->text().isEmpty())
403 setParam(param_str, Tabular::SET_BOTTOM_SPACE,
404 widgetsToLength(bottomspaceED,
410 switch (interlinespaceCO->currentIndex()) {
412 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
415 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
418 if (!interlinespaceED->text().isEmpty())
419 setParam(param_str, Tabular::SET_INTERLINE_SPACE,
420 widgetsToLength(interlinespaceED,
421 interlinespaceUnit));
426 if (borders->getTop() && borders->getBottom() && borders->getLeft()
427 && borders->getRight())
428 setParam(param_str, Tabular::SET_ALL_LINES);
429 else if (!borders->getTop() && !borders->getBottom() && !borders->getLeft()
430 && !borders->getRight())
431 setParam(param_str, Tabular::UNSET_ALL_LINES);
433 setParam(param_str, Tabular::SET_LINE_LEFT,
434 borders->getLeft() ? "true" : "false");
435 setParam(param_str, Tabular::SET_LINE_RIGHT,
436 borders->getRight() ? "true" : "false");
437 setParam(param_str, Tabular::SET_LINE_TOP,
438 borders->getTop() ? "true" : "false");
439 setParam(param_str, Tabular::SET_LINE_BOTTOM,
440 borders->getBottom() ? "true" : "false");
443 // apply the special alignment
444 string special = fromqstr(specialAlignmentED->text());
447 if (multicolumnCB->isChecked())
448 setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
449 else if (multirowCB->isChecked())
450 setParam(param_str, Tabular::SET_SPECIAL_MULTIROW, special);
452 setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
454 // apply the fixed width values
455 string width = widgetsToLength(widthED, widthUnitCB);
458 if (multicolumnCB->isChecked())
459 setParam(param_str, Tabular::SET_MPWIDTH, width);
461 setParam(param_str, Tabular::SET_PWIDTH, width);
464 if (multicolumnCB->isChecked())
465 setParam(param_str, Tabular::MULTICOLUMN);
467 if (multirowCB->isChecked())
468 setParam(param_str, Tabular::MULTIROW);
470 if (rotateTabularCB->isChecked())
471 setParam(param_str, Tabular::SET_ROTATE_TABULAR);
473 setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
475 if (rotateCellCB->isChecked())
476 setParam(param_str, Tabular::SET_ROTATE_CELL);
478 setParam(param_str, Tabular::UNSET_ROTATE_CELL);
480 if (longTabularCB->isChecked())
481 setParam(param_str, Tabular::SET_LONGTABULAR);
483 setParam(param_str, Tabular::UNSET_LONGTABULAR);
485 if (newpageCB->isChecked())
486 setParam(param_str, Tabular::SET_LTNEWPAGE);
488 if (captionStatusCB->isChecked())
489 setParam(param_str, Tabular::TOGGLE_LTCAPTION);
491 if (headerStatusCB->isChecked())
492 setParam(param_str, Tabular::SET_LTHEAD, "none");
494 setParam(param_str, Tabular::UNSET_LTHEAD, "none");
496 if (headerBorderAboveCB->isChecked())
497 setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
499 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
501 if (headerBorderBelowCB->isChecked())
502 setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
504 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
505 if (firstheaderBorderAboveCB->isChecked())
506 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
508 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
509 if (firstheaderBorderBelowCB->isChecked())
510 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
512 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
513 if (firstheaderStatusCB->isChecked())
514 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
516 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
517 if (firstheaderNoContentsCB->isChecked())
518 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
520 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
521 if (footerStatusCB->isChecked())
522 setParam(param_str, Tabular::SET_LTFOOT, "none");
524 setParam(param_str, Tabular::UNSET_LTFOOT, "none");
525 if (footerBorderAboveCB->isChecked())
526 setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
528 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
529 if (footerBorderBelowCB->isChecked())
530 setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
532 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
533 if (lastfooterStatusCB->isChecked())
534 setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
536 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
537 if (lastfooterBorderAboveCB->isChecked())
538 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
540 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
541 if (lastfooterBorderBelowCB->isChecked())
542 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
544 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
545 if (lastfooterNoContentsCB->isChecked())
546 setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
548 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
550 if (leftRB->isChecked())
551 setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
552 else if (centerRB->isChecked())
553 setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
554 else if (rightRB->isChecked())
555 setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
557 return from_utf8(param_str);
561 static Length getColumnPWidth(Tabular const & t, size_t cell)
563 return t.column_info[t.cellColumn(cell)].p_width;
567 static Length getMColumnPWidth(Tabular const & t, size_t cell)
569 if (t.isMultiColumn(cell) || t.isMultiRow(cell))
570 return t.cellInfo(cell).p_width;
575 static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
577 if (what == Tabular::SET_SPECIAL_MULTICOLUMN
578 || what == Tabular::SET_SPECIAL_MULTIROW)
579 return t.cellInfo(cell).align_special;
580 return t.column_info[t.cellColumn(cell)].align_special;
584 void GuiTabular::paramsToDialog(Inset const * inset)
586 InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
587 // Copy Tabular of current inset.
588 Tabular const & tabular = itab->tabular;
590 BufferView const * bv = guiApp->currentView()->currentBufferView();
591 size_t const cell = bv->cursor().idx();
593 Tabular::row_type const row = tabular.cellRow(cell);
594 Tabular::col_type const col = tabular.cellColumn(cell);
596 tabularRowED->setText(QString::number(row + 1));
597 tabularColumnED->setText(QString::number(col + 1));
599 bool const multicol = tabular.isMultiColumn(cell);
600 multicolumnCB->setChecked(multicol);
602 bool const multirow = tabular.isMultiRow(cell);
603 multirowCB->setChecked(multirow);
605 rotateCellCB->setChecked(tabular.getRotateCell(cell));
606 rotateTabularCB->setChecked(tabular.rotate);
608 longTabularCB->setChecked(tabular.is_long_tabular);
610 borders->setTop(tabular.topLine(cell));
611 borders->setBottom(tabular.bottomLine(cell));
612 borders->setLeft(tabular.leftLine(cell));
613 borders->setRight(tabular.rightLine(cell));
614 // repaint the setborder widget
617 Length::UNIT const default_unit = Length::defaultUnit();
619 ///////////////////////////////////
620 // Set width and alignment
624 special = getAlignSpecial(tabular, cell,
625 Tabular::SET_SPECIAL_MULTICOLUMN);
626 pwidth = getMColumnPWidth(tabular, cell);
627 } else if (multirow) {
628 special = getAlignSpecial(tabular, cell,
629 Tabular::SET_SPECIAL_MULTIROW);
630 pwidth = getMColumnPWidth(tabular, cell);
632 special = getAlignSpecial(tabular, cell,
633 Tabular::SET_SPECIAL_COLUMN);
634 pwidth = getColumnPWidth(tabular, cell);
640 colwidth = pwidth.asString();
641 lengthToWidgets(widthED, widthUnitCB,
642 colwidth, default_unit);
644 specialAlignmentED->setText(toqstr(special));
645 ///////////////////////////////////
648 borderDefaultRB->setChecked(!tabular.use_booktabs);
649 booktabsRB->setChecked(tabular.use_booktabs);
651 if (tabular.row_info[row].top_space.empty()
652 && !tabular.row_info[row].top_space_default) {
653 topspaceCO->setCurrentIndex(0);
654 } else if (tabular.row_info[row].top_space_default) {
655 topspaceCO->setCurrentIndex(1);
657 topspaceCO->setCurrentIndex(2);
658 lengthToWidgets(topspaceED,
660 tabular.row_info[row].top_space.asString(),
664 if (tabular.row_info[row].bottom_space.empty()
665 && !tabular.row_info[row].bottom_space_default) {
666 bottomspaceCO->setCurrentIndex(0);
667 } else if (tabular.row_info[row].bottom_space_default) {
668 bottomspaceCO->setCurrentIndex(1);
670 bottomspaceCO->setCurrentIndex(2);
671 lengthToWidgets(bottomspaceED,
673 tabular.row_info[row].bottom_space.asString(),
677 if (tabular.row_info[row].interline_space.empty()
678 && !tabular.row_info[row].interline_space_default) {
679 interlinespaceCO->setCurrentIndex(0);
680 } else if (tabular.row_info[row].interline_space_default) {
681 interlinespaceCO->setCurrentIndex(1);
683 interlinespaceCO->setCurrentIndex(2);
684 lengthToWidgets(interlinespaceED,
686 tabular.row_info[row].interline_space.asString(),
691 hAlignCB->addItem(qt_("Left"));
692 hAlignCB->addItem(qt_("Center"));
693 hAlignCB->addItem(qt_("Right"));
694 if (!multicol && !pwidth.zero())
695 hAlignCB->addItem(qt_("Justified"));
698 switch (tabular.getAlignment(cell)) {
702 case LYX_ALIGN_CENTER:
705 case LYX_ALIGN_RIGHT:
708 case LYX_ALIGN_BLOCK:
710 if (!multicol && !pwidth.zero())
718 hAlignCB->setCurrentIndex(align);
721 switch (tabular.getVAlignment(cell)) {
722 case Tabular::LYX_VALIGN_TOP:
725 case Tabular::LYX_VALIGN_MIDDLE:
728 case Tabular::LYX_VALIGN_BOTTOM:
737 vAlignCB->setCurrentIndex(valign);
740 switch (tabular.tabular_valignment) {
741 case Tabular::LYX_VALIGN_TOP:
744 case Tabular::LYX_VALIGN_MIDDLE:
747 case Tabular::LYX_VALIGN_BOTTOM:
754 TableAlignCB->setCurrentIndex(tableValign);
756 if (!tabular.is_long_tabular) {
757 headerStatusCB->setChecked(false);
758 headerBorderAboveCB->setChecked(false);
759 headerBorderBelowCB->setChecked(false);
760 firstheaderStatusCB->setChecked(false);
761 firstheaderBorderAboveCB->setChecked(false);
762 firstheaderBorderBelowCB->setChecked(false);
763 firstheaderNoContentsCB->setChecked(false);
764 footerStatusCB->setChecked(false);
765 footerBorderAboveCB->setChecked(false);
766 footerBorderBelowCB->setChecked(false);
767 lastfooterStatusCB->setChecked(false);
768 lastfooterBorderAboveCB->setChecked(false);
769 lastfooterBorderBelowCB->setChecked(false);
770 lastfooterNoContentsCB->setChecked(false);
771 newpageCB->setChecked(false);
772 captionStatusCB->blockSignals(true);
773 captionStatusCB->setChecked(false);
774 captionStatusCB->blockSignals(false);
777 // longtables cannot have a vertical alignment
778 TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
780 switch (tabular.longtabular_alignment) {
781 case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
782 leftRB->setChecked(true);
784 case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
785 centerRB->setChecked(true);
787 case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
788 rightRB->setChecked(true);
791 centerRB->setChecked(true);
794 captionStatusCB->blockSignals(true);
795 captionStatusCB->setChecked(tabular.ltCaption(row));
796 captionStatusCB->blockSignals(false);
800 bool row_set = tabular.getRowOfLTHead(row, ltt);
801 headerStatusCB->setChecked(row_set);
803 headerBorderAboveCB->setChecked(ltt.topDL);
804 headerBorderBelowCB->setChecked(ltt.bottomDL);
807 headerBorderAboveCB->setChecked(false);
808 headerBorderBelowCB->setChecked(false);
809 firstheaderNoContentsCB->setChecked(false);
813 row_set = tabular.getRowOfLTFirstHead(row, ltt);
814 firstheaderStatusCB->setChecked(row_set);
815 if (ltt.set && (!ltt.empty || !use_empty)) {
816 firstheaderBorderAboveCB->setChecked(ltt.topDL);
817 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
819 firstheaderBorderAboveCB->setChecked(false);
820 firstheaderBorderBelowCB->setChecked(false);
823 row_set = tabular.getRowOfLTFoot(row, ltt);
824 footerStatusCB->setChecked(row_set);
826 footerBorderAboveCB->setChecked(ltt.topDL);
827 footerBorderBelowCB->setChecked(ltt.bottomDL);
830 footerBorderAboveCB->setChecked(false);
831 footerBorderBelowCB->setChecked(false);
832 lastfooterNoContentsCB->setChecked(false);
836 row_set = tabular.getRowOfLTLastFoot(row, ltt);
837 lastfooterStatusCB->setChecked(row_set);
838 if (ltt.set && (!ltt.empty || !use_empty)) {
839 lastfooterBorderAboveCB->setChecked(ltt.topDL);
840 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
842 lastfooterBorderAboveCB->setChecked(false);
843 lastfooterBorderBelowCB->setChecked(false);
845 newpageCB->setChecked(tabular.getLTNewPage(row));
849 } // namespace frontend
852 #include "moc_GuiTabular.cpp"