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"
32 #include "insets/InsetTabular.h"
34 #include "support/debug.h"
37 #include <QPushButton>
38 #include <QRadioButton>
46 GuiTabular::GuiTabular(QWidget * parent)
47 : InsetParamsWidget(parent)
51 widthED->setValidator(unsignedLengthValidator(widthED));
52 topspaceED->setValidator(new LengthValidator(topspaceED));
53 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
54 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
56 widthUnitCB->setCurrentItem(Length::defaultUnit());
58 connect(topspaceED, SIGNAL(returnPressed()),
59 this, SLOT(checkEnabled()));
60 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
61 this, SLOT(checkEnabled()));
62 connect(topspaceCO, SIGNAL(activated(int)),
63 this, SLOT(checkEnabled()));
64 connect(bottomspaceED, SIGNAL(returnPressed()),
65 this, SLOT(checkEnabled()));
66 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
67 this, SLOT(checkEnabled()));
68 connect(bottomspaceCO, SIGNAL(activated(int)),
69 this, SLOT(checkEnabled()));
70 connect(interlinespaceED, SIGNAL(returnPressed()),
71 this, SLOT(checkEnabled()));
72 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
73 this, SLOT(checkEnabled()));
74 connect(interlinespaceCO, SIGNAL(activated(int)),
75 this, SLOT(checkEnabled()));
76 connect(booktabsRB, SIGNAL(clicked(bool)),
77 this, SLOT(checkEnabled()));
78 connect(borderDefaultRB, SIGNAL(clicked(bool)),
79 this, SLOT(checkEnabled()));
80 connect(borderSetPB, SIGNAL(clicked()),
81 this, SLOT(borderSet_clicked()));
82 connect(borderUnsetPB, SIGNAL(clicked()),
83 this, SLOT(borderUnset_clicked()));
84 connect(hAlignCB, SIGNAL(activated(int)),
85 this, SLOT(checkEnabled()));
86 connect(vAlignCB, SIGNAL(activated(int)),
87 this, SLOT(checkEnabled()));
88 connect(multicolumnCB, SIGNAL(clicked()),
89 this, SLOT(checkEnabled()));
90 connect(multirowCB, SIGNAL(clicked()),
91 this, SLOT(checkEnabled()));
92 connect(newpageCB, SIGNAL(clicked()),
93 this, SLOT(checkEnabled()));
94 connect(headerStatusCB, SIGNAL(clicked()),
95 this, SLOT(checkEnabled()));
96 connect(headerBorderAboveCB, SIGNAL(clicked()),
97 this, SLOT(checkEnabled()));
98 connect(headerBorderBelowCB, SIGNAL(clicked()),
99 this, SLOT(checkEnabled()));
100 connect(firstheaderStatusCB, SIGNAL(clicked()),
101 this, SLOT(checkEnabled()));
102 connect(firstheaderBorderAboveCB, SIGNAL(clicked()),
103 this, SLOT(checkEnabled()));
104 connect(firstheaderBorderBelowCB, SIGNAL(clicked()),
105 this, SLOT(checkEnabled()));
106 connect(firstheaderNoContentsCB, SIGNAL(clicked()),
107 this, SLOT(checkEnabled()));
108 connect(footerStatusCB, SIGNAL(clicked()),
109 this, SLOT(checkEnabled()));
110 connect(footerBorderAboveCB, SIGNAL(clicked()),
111 this, SLOT(checkEnabled()));
112 connect(footerBorderBelowCB, SIGNAL(clicked()),
113 this, SLOT(checkEnabled()));
114 connect(lastfooterStatusCB, SIGNAL(clicked()),
115 this, SLOT(checkEnabled()));
116 connect(lastfooterBorderAboveCB, SIGNAL(clicked()),
117 this, SLOT(checkEnabled()));
118 connect(lastfooterBorderBelowCB, SIGNAL(clicked()),
119 this, SLOT(checkEnabled()));
120 connect(lastfooterNoContentsCB, SIGNAL(clicked()),
121 this, SLOT(checkEnabled()));
122 connect(specialAlignmentED, SIGNAL(returnPressed()),
123 this, SLOT(checkEnabled()));
124 connect(widthED, SIGNAL(textEdited(QString)),
125 this, SLOT(checkEnabled()));
126 connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
127 this, SLOT(checkEnabled()));
128 connect(borders, SIGNAL(topSet(bool)),
129 this, SLOT(checkEnabled()));
130 connect(borders, SIGNAL(bottomSet(bool)),
131 this, SLOT(checkEnabled()));
132 connect(borders, SIGNAL(rightSet(bool)),
133 this, SLOT(checkEnabled()));
134 connect(borders, SIGNAL(leftSet(bool)),
135 this, SLOT(checkEnabled()));
136 connect(rotateTabularCB, SIGNAL(clicked()),
137 this, SLOT(checkEnabled()));
138 connect(rotateCellCB, SIGNAL(clicked()),
139 this, SLOT(checkEnabled()));
140 connect(TableAlignCB, SIGNAL(activated(int)),
141 this, SLOT(checkEnabled()));
142 connect(longTabularCB, SIGNAL(clicked()),
143 this, SLOT(checkEnabled()));
144 connect(leftRB, SIGNAL(clicked()),
145 this, SLOT(checkEnabled()));
146 connect(centerRB, SIGNAL(clicked()),
147 this, SLOT(checkEnabled()));
148 connect(rightRB, SIGNAL(clicked()),
149 this, SLOT(checkEnabled()));
152 // initialize the length validator
153 addCheckedWidget(widthED, fixedWidthColLA);
154 addCheckedWidget(topspaceED, topspaceLA);
155 addCheckedWidget(bottomspaceED, bottomspaceLA);
156 addCheckedWidget(interlinespaceED, interlinespaceLA);
160 void GuiTabular::checkEnabled()
162 hAlignCB->setEnabled(true);
164 hAlignCB->itemData(hAlignCB->currentIndex()).toString() == QString("decimal");
165 decimalPointLE->setEnabled(dalign);
166 decimalL->setEnabled(dalign);
168 vAlignCB->setEnabled(!multirowCB->isChecked()
169 && !widgetsToLength(widthED, widthUnitCB).empty());
171 topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
172 topspaceUnit->setEnabled(topspaceCO->currentIndex() == 2);
173 bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
174 bottomspaceUnit->setEnabled(bottomspaceCO->currentIndex() == 2);
175 interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
176 interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
178 bool const longtabular = longTabularCB->isChecked();
179 longtableGB->setEnabled(true);
180 newpageCB->setEnabled(longtabular);
181 alignmentGB->setEnabled(longtabular);
182 // longtables cannot have a vertical alignment
183 TableAlignCB->setDisabled(longtabular);
185 // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
186 // depending on the cursor position is very very unintuitive...
187 // We need some edit boxes to show which rows are header/footer/etc
188 // without having to move the cursor first.
189 headerStatusCB->setEnabled(longtabular);
190 headerBorderAboveCB->setEnabled(longtabular
191 && headerStatusCB->isChecked());
192 headerBorderBelowCB->setEnabled(longtabular
193 && headerStatusCB->isChecked());
195 // first header can only be suppressed when there is a header
196 // FIXME: old code also checked for
197 // tabular.haveLTHead() && !tabular.haveLTFirstHead());
198 firstheaderNoContentsCB->setEnabled(longtabular);
199 // check if setting a first header is allowed
200 // additionally check firstheaderNoContentsCB because when this is
201 // the case a first header makes no sense
202 firstheaderStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD)
203 && longtabular && !firstheaderNoContentsCB->isChecked());
204 firstheaderBorderAboveCB->setEnabled(longtabular
205 && firstheaderStatusCB->isChecked());
206 firstheaderBorderBelowCB->setEnabled(longtabular
207 && firstheaderStatusCB->isChecked());
209 footerStatusCB->setEnabled(longtabular);
210 footerBorderAboveCB->setEnabled(longtabular
211 && footerBorderAboveCB->isChecked());
212 footerBorderBelowCB->setEnabled(longtabular
213 && footerBorderAboveCB->isChecked());
215 // last footer can only be suppressed when there is a footer
216 // FIXME: old code also checked for
217 // tabular.haveLTFoot() && !tabular.haveLTLastFoot());
218 lastfooterNoContentsCB->setEnabled(longtabular);
219 // check if setting a last footer is allowed
220 // additionally check lastfooterNoContentsCB because when this is
221 // the case a last footer makes no sense
222 lastfooterStatusCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT)
223 && longtabular && !lastfooterNoContentsCB->isChecked());
224 lastfooterBorderAboveCB->setEnabled(longtabular
225 && lastfooterBorderAboveCB->isChecked());
226 lastfooterBorderBelowCB->setEnabled(longtabular
227 && lastfooterBorderAboveCB->isChecked());
229 captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION));
231 multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
232 multirowCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
238 void GuiTabular::borderSet_clicked()
240 borders->setTop(true);
241 borders->setBottom(true);
242 borders->setLeft(true);
243 borders->setRight(true);
244 // repaint the setborder widget
250 void GuiTabular::borderUnset_clicked()
252 borders->setTop(false);
253 borders->setBottom(false);
254 borders->setLeft(false);
255 borders->setRight(false);
256 // repaint the setborder widget
262 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
265 param_str += featureAsString(f) + ' ' + arg;
269 void GuiTabular::setHAlign(string & param_str) const
271 Tabular::Feature num = Tabular::ALIGN_LEFT;
272 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
274 fromqstr(hAlignCB->itemData(hAlignCB->currentIndex()).toString());
275 if (align == "left") {
276 num = Tabular::ALIGN_LEFT;
277 multi_num = Tabular::M_ALIGN_LEFT;
278 } else if (align == "center") {
279 num = Tabular::ALIGN_CENTER;
280 multi_num = Tabular::M_ALIGN_CENTER;
281 } else if (align == "right") {
282 num = Tabular::ALIGN_RIGHT;
283 multi_num = Tabular::M_ALIGN_RIGHT;
284 } else if (align == "justified") {
285 num = Tabular::ALIGN_BLOCK;
286 //multi_num: no equivalent
287 } else if (align == "decimal") {
288 num = Tabular::ALIGN_DECIMAL;
289 //multi_num: no equivalent
292 if (multicolumnCB->isChecked())
293 setParam(param_str, multi_num);
295 setParam(param_str, num);
299 void GuiTabular::setVAlign(string & param_str) const
301 int const align = vAlignCB->currentIndex();
302 enum VALIGN { TOP, MIDDLE, BOTTOM };
306 case 0: v = TOP; break;
307 case 1: v = MIDDLE; break;
308 case 2: v = BOTTOM; break;
311 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
312 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
316 num = Tabular::VALIGN_TOP;
317 multi_num = Tabular::M_VALIGN_TOP;
320 num = Tabular::VALIGN_MIDDLE;
321 multi_num = Tabular::M_VALIGN_MIDDLE;
324 num = Tabular::VALIGN_BOTTOM;
325 multi_num = Tabular::M_VALIGN_BOTTOM;
328 if (multicolumnCB->isChecked() || multirowCB->isChecked())
329 setParam(param_str, multi_num);
331 setParam(param_str, num);
335 void GuiTabular::setTableAlignment(string & param_str) const
337 int const align = TableAlignCB->currentIndex();
339 case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
341 case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
343 case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
349 docstring GuiTabular::dialogToParams() const
351 // FIXME: We should use Tabular directly.
352 string param_str = "tabular";
353 setHAlign(param_str);
355 // SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
356 string decimal_point = fromqstr(decimalPointLE->text());
357 if (decimal_point.empty())
358 decimal_point = lyxrc.default_decimal_point;
359 setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
361 setVAlign(param_str);
362 setTableAlignment(param_str);
364 if (booktabsRB->isChecked())
365 setParam(param_str, Tabular::SET_BOOKTABS);
367 setParam(param_str, Tabular::UNSET_BOOKTABS);
370 switch (topspaceCO->currentIndex()) {
372 setParam(param_str, Tabular::SET_TOP_SPACE, "none");
375 setParam(param_str, Tabular::SET_TOP_SPACE, "default");
378 if (!topspaceED->text().isEmpty())
379 setParam(param_str, Tabular::SET_TOP_SPACE,
380 widgetsToLength(topspaceED, topspaceUnit));
385 switch (bottomspaceCO->currentIndex()) {
387 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
390 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
393 if (!bottomspaceED->text().isEmpty())
394 setParam(param_str, Tabular::SET_BOTTOM_SPACE,
395 widgetsToLength(bottomspaceED,
401 switch (interlinespaceCO->currentIndex()) {
403 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
406 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
409 if (!interlinespaceED->text().isEmpty())
410 setParam(param_str, Tabular::SET_INTERLINE_SPACE,
411 widgetsToLength(interlinespaceED,
412 interlinespaceUnit));
417 if (borders->getTop() && borders->getBottom() && borders->getLeft()
418 && borders->getRight())
419 setParam(param_str, Tabular::SET_ALL_LINES);
420 else if (!borders->getTop() && !borders->getBottom() && !borders->getLeft()
421 && !borders->getRight())
422 setParam(param_str, Tabular::UNSET_ALL_LINES);
424 setParam(param_str, Tabular::SET_LINE_LEFT,
425 borders->getLeft() ? "true" : "false");
426 setParam(param_str, Tabular::SET_LINE_RIGHT,
427 borders->getRight() ? "true" : "false");
428 setParam(param_str, Tabular::SET_LINE_TOP,
429 borders->getTop() ? "true" : "false");
430 setParam(param_str, Tabular::SET_LINE_BOTTOM,
431 borders->getBottom() ? "true" : "false");
434 // apply the special alignment
435 string special = fromqstr(specialAlignmentED->text());
438 if (multicolumnCB->isChecked())
439 setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
440 else if (multirowCB->isChecked())
441 setParam(param_str, Tabular::SET_SPECIAL_MULTIROW, special);
443 setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
445 // apply the fixed width values
446 string width = widgetsToLength(widthED, widthUnitCB);
449 if (multicolumnCB->isChecked())
450 setParam(param_str, Tabular::SET_MPWIDTH, width);
452 setParam(param_str, Tabular::SET_PWIDTH, width);
455 if (multicolumnCB->isChecked())
456 setParam(param_str, Tabular::MULTICOLUMN);
458 if (multirowCB->isChecked())
459 setParam(param_str, Tabular::MULTIROW);
461 if (rotateTabularCB->isChecked())
462 setParam(param_str, Tabular::SET_ROTATE_TABULAR);
464 setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
466 if (rotateCellCB->isChecked())
467 setParam(param_str, Tabular::SET_ROTATE_CELL);
469 setParam(param_str, Tabular::UNSET_ROTATE_CELL);
471 if (longTabularCB->isChecked())
472 setParam(param_str, Tabular::SET_LONGTABULAR);
474 setParam(param_str, Tabular::UNSET_LONGTABULAR);
476 if (newpageCB->isChecked())
477 setParam(param_str, Tabular::SET_LTNEWPAGE);
479 if (captionStatusCB->isChecked())
480 setParam(param_str, Tabular::TOGGLE_LTCAPTION);
482 if (headerStatusCB->isChecked())
483 setParam(param_str, Tabular::SET_LTHEAD, "none");
485 setParam(param_str, Tabular::UNSET_LTHEAD, "none");
487 if (headerBorderAboveCB->isChecked())
488 setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
490 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
492 if (headerBorderBelowCB->isChecked())
493 setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
495 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
496 if (firstheaderBorderAboveCB->isChecked())
497 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
499 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
500 if (firstheaderBorderBelowCB->isChecked())
501 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
503 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
504 if (firstheaderStatusCB->isChecked())
505 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
507 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
508 if (firstheaderNoContentsCB->isChecked())
509 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
511 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
512 if (footerStatusCB->isChecked())
513 setParam(param_str, Tabular::SET_LTFOOT, "none");
515 setParam(param_str, Tabular::UNSET_LTFOOT, "none");
516 if (footerBorderAboveCB->isChecked())
517 setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
519 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
520 if (footerBorderBelowCB->isChecked())
521 setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
523 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
524 if (lastfooterStatusCB->isChecked())
525 setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
527 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
528 if (lastfooterBorderAboveCB->isChecked())
529 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
531 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
532 if (lastfooterBorderBelowCB->isChecked())
533 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
535 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
536 if (lastfooterNoContentsCB->isChecked())
537 setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
539 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
541 if (leftRB->isChecked())
542 setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
543 else if (centerRB->isChecked())
544 setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
545 else if (rightRB->isChecked())
546 setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
548 return from_utf8(param_str);
552 static Length getColumnPWidth(Tabular const & t, size_t cell)
554 return t.column_info[t.cellColumn(cell)].p_width;
558 static Length getMColumnPWidth(Tabular const & t, size_t cell)
560 if (t.isMultiColumn(cell) || t.isMultiRow(cell))
561 return t.cellInfo(cell).p_width;
566 static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
568 if (what == Tabular::SET_SPECIAL_MULTICOLUMN
569 || what == Tabular::SET_SPECIAL_MULTIROW)
570 return t.cellInfo(cell).align_special;
571 return t.column_info[t.cellColumn(cell)].align_special;
575 void GuiTabular::paramsToDialog(Inset const * inset)
577 InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
578 // Copy Tabular of current inset.
579 Tabular const & tabular = itab->tabular;
581 BufferView const * bv = guiApp->currentView()->currentBufferView();
582 size_t const cell = bv->cursor().idx();
584 Tabular::row_type const row = tabular.cellRow(cell);
585 Tabular::col_type const col = tabular.cellColumn(cell);
587 tabularRowED->setText(QString::number(row + 1));
588 tabularColumnED->setText(QString::number(col + 1));
590 bool const multicol = tabular.isMultiColumn(cell);
591 multicolumnCB->setChecked(multicol);
593 bool const multirow = tabular.isMultiRow(cell);
594 multirowCB->setChecked(multirow);
596 rotateCellCB->setChecked(tabular.getRotateCell(cell));
597 rotateTabularCB->setChecked(tabular.rotate);
599 longTabularCB->setChecked(tabular.is_long_tabular);
601 borders->setTop(tabular.topLine(cell));
602 borders->setBottom(tabular.bottomLine(cell));
603 borders->setLeft(tabular.leftLine(cell));
604 borders->setRight(tabular.rightLine(cell));
605 // repaint the setborder widget
608 Length::UNIT const default_unit = Length::defaultUnit();
610 ///////////////////////////////////
611 // Set width and alignment
615 special = getAlignSpecial(tabular, cell,
616 Tabular::SET_SPECIAL_MULTICOLUMN);
617 pwidth = getMColumnPWidth(tabular, cell);
618 } else if (multirow) {
619 special = getAlignSpecial(tabular, cell,
620 Tabular::SET_SPECIAL_MULTIROW);
621 pwidth = getMColumnPWidth(tabular, cell);
623 special = getAlignSpecial(tabular, cell,
624 Tabular::SET_SPECIAL_COLUMN);
625 pwidth = getColumnPWidth(tabular, cell);
631 colwidth = pwidth.asString();
632 lengthToWidgets(widthED, widthUnitCB,
633 colwidth, default_unit);
635 specialAlignmentED->setText(toqstr(special));
636 ///////////////////////////////////
639 borderDefaultRB->setChecked(!tabular.use_booktabs);
640 booktabsRB->setChecked(tabular.use_booktabs);
642 if (tabular.row_info[row].top_space.empty()
643 && !tabular.row_info[row].top_space_default) {
644 topspaceCO->setCurrentIndex(0);
645 } else if (tabular.row_info[row].top_space_default) {
646 topspaceCO->setCurrentIndex(1);
648 topspaceCO->setCurrentIndex(2);
649 lengthToWidgets(topspaceED,
651 tabular.row_info[row].top_space.asString(),
655 if (tabular.row_info[row].bottom_space.empty()
656 && !tabular.row_info[row].bottom_space_default) {
657 bottomspaceCO->setCurrentIndex(0);
658 } else if (tabular.row_info[row].bottom_space_default) {
659 bottomspaceCO->setCurrentIndex(1);
661 bottomspaceCO->setCurrentIndex(2);
662 lengthToWidgets(bottomspaceED,
664 tabular.row_info[row].bottom_space.asString(),
668 if (tabular.row_info[row].interline_space.empty()
669 && !tabular.row_info[row].interline_space_default) {
670 interlinespaceCO->setCurrentIndex(0);
671 } else if (tabular.row_info[row].interline_space_default) {
672 interlinespaceCO->setCurrentIndex(1);
674 interlinespaceCO->setCurrentIndex(2);
675 lengthToWidgets(interlinespaceED,
677 tabular.row_info[row].interline_space.asString(),
682 hAlignCB->addItem(qt_("Left"), toqstr("left"));
683 hAlignCB->addItem(qt_("Center"), toqstr("center"));
684 hAlignCB->addItem(qt_("Right"), toqstr("right"));
685 if (!multicol && !pwidth.zero())
686 hAlignCB->addItem(qt_("Justified"), toqstr("justified"));
688 hAlignCB->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
691 switch (tabular.getAlignment(cell)) {
695 case LYX_ALIGN_CENTER:
698 case LYX_ALIGN_RIGHT:
701 case LYX_ALIGN_BLOCK:
703 if (!multicol && !pwidth.zero())
707 case LYX_ALIGN_DECIMAL:
714 // we should never end up here
717 hAlignCB->setCurrentIndex(hAlignCB->findData(toqstr(align)));
720 QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
721 if (decimal_point.isEmpty())
722 decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
723 decimalPointLE->setText(decimal_point);
726 switch (tabular.getVAlignment(cell)) {
727 case Tabular::LYX_VALIGN_TOP:
730 case Tabular::LYX_VALIGN_MIDDLE:
733 case Tabular::LYX_VALIGN_BOTTOM:
742 vAlignCB->setCurrentIndex(valign);
745 switch (tabular.tabular_valignment) {
746 case Tabular::LYX_VALIGN_TOP:
749 case Tabular::LYX_VALIGN_MIDDLE:
752 case Tabular::LYX_VALIGN_BOTTOM:
759 TableAlignCB->setCurrentIndex(tableValign);
761 if (!tabular.is_long_tabular) {
762 headerStatusCB->setChecked(false);
763 headerBorderAboveCB->setChecked(false);
764 headerBorderBelowCB->setChecked(false);
765 firstheaderStatusCB->setChecked(false);
766 firstheaderBorderAboveCB->setChecked(false);
767 firstheaderBorderBelowCB->setChecked(false);
768 firstheaderNoContentsCB->setChecked(false);
769 footerStatusCB->setChecked(false);
770 footerBorderAboveCB->setChecked(false);
771 footerBorderBelowCB->setChecked(false);
772 lastfooterStatusCB->setChecked(false);
773 lastfooterBorderAboveCB->setChecked(false);
774 lastfooterBorderBelowCB->setChecked(false);
775 lastfooterNoContentsCB->setChecked(false);
776 newpageCB->setChecked(false);
777 captionStatusCB->blockSignals(true);
778 captionStatusCB->setChecked(false);
779 captionStatusCB->blockSignals(false);
783 // longtables cannot have a vertical alignment
784 TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
786 switch (tabular.longtabular_alignment) {
787 case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
788 leftRB->setChecked(true);
790 case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
791 centerRB->setChecked(true);
793 case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
794 rightRB->setChecked(true);
797 centerRB->setChecked(true);
800 captionStatusCB->blockSignals(true);
801 captionStatusCB->setChecked(tabular.ltCaption(row));
802 captionStatusCB->blockSignals(false);
806 bool row_set = tabular.getRowOfLTHead(row, ltt);
807 headerStatusCB->setChecked(row_set);
809 headerBorderAboveCB->setChecked(ltt.topDL);
810 headerBorderBelowCB->setChecked(ltt.bottomDL);
813 headerBorderAboveCB->setChecked(false);
814 headerBorderBelowCB->setChecked(false);
815 firstheaderNoContentsCB->setChecked(false);
819 row_set = tabular.getRowOfLTFirstHead(row, ltt);
820 firstheaderStatusCB->setChecked(row_set);
821 if (ltt.set && (!ltt.empty || !use_empty)) {
822 firstheaderBorderAboveCB->setChecked(ltt.topDL);
823 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
825 firstheaderBorderAboveCB->setChecked(false);
826 firstheaderBorderBelowCB->setChecked(false);
829 row_set = tabular.getRowOfLTFoot(row, ltt);
830 footerStatusCB->setChecked(row_set);
832 footerBorderAboveCB->setChecked(ltt.topDL);
833 footerBorderBelowCB->setChecked(ltt.bottomDL);
836 footerBorderAboveCB->setChecked(false);
837 footerBorderBelowCB->setChecked(false);
838 lastfooterNoContentsCB->setChecked(false);
842 row_set = tabular.getRowOfLTLastFoot(row, ltt);
843 lastfooterStatusCB->setChecked(row_set);
844 if (ltt.set && (!ltt.empty || !use_empty)) {
845 lastfooterBorderAboveCB->setChecked(ltt.topDL);
846 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
848 lastfooterBorderAboveCB->setChecked(false);
849 lastfooterBorderBelowCB->setChecked(false);
851 newpageCB->setChecked(tabular.getLTNewPage(row));
855 bool GuiTabular::funcEnabled(Tabular::Feature f) const
857 string cmd = "tabular " + featureAsString(f);
858 return getStatus(FuncRequest(LFUN_INSET_MODIFY, cmd)).enabled();
862 } // namespace frontend
865 #include "moc_GuiTabular.cpp"