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 // FIXME: verify that some previous row was not set.
203 firstheaderStatusCB->setEnabled(longtabular
204 && !firstheaderNoContentsCB->isChecked());
205 firstheaderBorderAboveCB->setEnabled(longtabular
206 && firstheaderStatusCB->isChecked());
207 firstheaderBorderBelowCB->setEnabled(longtabular
208 && firstheaderStatusCB->isChecked());
210 footerStatusCB->setEnabled(longtabular);
211 footerBorderAboveCB->setEnabled(longtabular
212 && footerBorderAboveCB->isChecked());
213 footerBorderBelowCB->setEnabled(longtabular
214 && footerBorderAboveCB->isChecked());
216 // last footer can only be suppressed when there is a footer
217 // FIXME: old code also checked for
218 // tabular.haveLTFoot() && !tabular.haveLTLastFoot());
219 lastfooterNoContentsCB->setEnabled(longtabular);
220 // check if setting a last footer is allowed
221 // additionally check lastfooterNoContentsCB because when this is
222 // the case a last footer makes no sense
223 lastfooterStatusCB->setEnabled(longtabular
224 && !lastfooterNoContentsCB->isChecked());
225 lastfooterBorderAboveCB->setEnabled(longtabular
226 && lastfooterBorderAboveCB->isChecked());
227 lastfooterBorderBelowCB->setEnabled(longtabular
228 && lastfooterBorderAboveCB->isChecked());
230 captionStatusCB->setEnabled(getStatus(FuncRequest(LFUN_INSET_MODIFY, "tabular toggle-ltcaption")).enabled());
232 multicolumnCB->setEnabled(getStatus(FuncRequest(LFUN_INSET_MODIFY, "tabular multicolumn")).enabled());
233 multirowCB->setEnabled(getStatus(FuncRequest(LFUN_INSET_MODIFY, "tabular multirow")).enabled());
239 void GuiTabular::borderSet_clicked()
241 borders->setTop(true);
242 borders->setBottom(true);
243 borders->setLeft(true);
244 borders->setRight(true);
245 // repaint the setborder widget
251 void GuiTabular::borderUnset_clicked()
253 borders->setTop(false);
254 borders->setBottom(false);
255 borders->setLeft(false);
256 borders->setRight(false);
257 // repaint the setborder widget
263 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
266 param_str += featureAsString(f) + ' ' + arg;
270 void GuiTabular::setHAlign(string & param_str) const
272 Tabular::Feature num = Tabular::ALIGN_LEFT;
273 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
275 fromqstr(hAlignCB->itemData(hAlignCB->currentIndex()).toString());
276 if (align == "left") {
277 num = Tabular::ALIGN_LEFT;
278 multi_num = Tabular::M_ALIGN_LEFT;
279 } else if (align == "center") {
280 num = Tabular::ALIGN_CENTER;
281 multi_num = Tabular::M_ALIGN_CENTER;
282 } else if (align == "right") {
283 num = Tabular::ALIGN_RIGHT;
284 multi_num = Tabular::M_ALIGN_RIGHT;
285 } else if (align == "justified") {
286 num = Tabular::ALIGN_BLOCK;
287 //multi_num: no equivalent
288 } else if (align == "decimal") {
289 num = Tabular::ALIGN_DECIMAL;
290 //multi_num: no equivalent
293 if (multicolumnCB->isChecked())
294 setParam(param_str, multi_num);
296 setParam(param_str, num);
300 void GuiTabular::setVAlign(string & param_str) const
302 int const align = vAlignCB->currentIndex();
303 enum VALIGN { TOP, MIDDLE, BOTTOM };
307 case 0: v = TOP; break;
308 case 1: v = MIDDLE; break;
309 case 2: v = BOTTOM; break;
312 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
313 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
317 num = Tabular::VALIGN_TOP;
318 multi_num = Tabular::M_VALIGN_TOP;
321 num = Tabular::VALIGN_MIDDLE;
322 multi_num = Tabular::M_VALIGN_MIDDLE;
325 num = Tabular::VALIGN_BOTTOM;
326 multi_num = Tabular::M_VALIGN_BOTTOM;
329 if (multicolumnCB->isChecked() || multirowCB->isChecked())
330 setParam(param_str, multi_num);
332 setParam(param_str, num);
336 void GuiTabular::setTableAlignment(string & param_str) const
338 int const align = TableAlignCB->currentIndex();
340 case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
342 case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
344 case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
350 docstring GuiTabular::dialogToParams() const
352 // FIXME: We should use Tabular directly.
353 string param_str = "tabular";
354 setHAlign(param_str);
356 // SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
357 string decimal_point = fromqstr(decimalPointLE->text());
358 if (decimal_point.empty())
359 decimal_point = lyxrc.default_decimal_point;
360 setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
362 setVAlign(param_str);
363 setTableAlignment(param_str);
365 if (booktabsRB->isChecked())
366 setParam(param_str, Tabular::SET_BOOKTABS);
368 setParam(param_str, Tabular::UNSET_BOOKTABS);
371 switch (topspaceCO->currentIndex()) {
373 setParam(param_str, Tabular::SET_TOP_SPACE, "none");
376 setParam(param_str, Tabular::SET_TOP_SPACE, "default");
379 if (!topspaceED->text().isEmpty())
380 setParam(param_str, Tabular::SET_TOP_SPACE,
381 widgetsToLength(topspaceED, topspaceUnit));
386 switch (bottomspaceCO->currentIndex()) {
388 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
391 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
394 if (!bottomspaceED->text().isEmpty())
395 setParam(param_str, Tabular::SET_BOTTOM_SPACE,
396 widgetsToLength(bottomspaceED,
402 switch (interlinespaceCO->currentIndex()) {
404 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
407 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
410 if (!interlinespaceED->text().isEmpty())
411 setParam(param_str, Tabular::SET_INTERLINE_SPACE,
412 widgetsToLength(interlinespaceED,
413 interlinespaceUnit));
418 if (borders->getTop() && borders->getBottom() && borders->getLeft()
419 && borders->getRight())
420 setParam(param_str, Tabular::SET_ALL_LINES);
421 else if (!borders->getTop() && !borders->getBottom() && !borders->getLeft()
422 && !borders->getRight())
423 setParam(param_str, Tabular::UNSET_ALL_LINES);
425 setParam(param_str, Tabular::SET_LINE_LEFT,
426 borders->getLeft() ? "true" : "false");
427 setParam(param_str, Tabular::SET_LINE_RIGHT,
428 borders->getRight() ? "true" : "false");
429 setParam(param_str, Tabular::SET_LINE_TOP,
430 borders->getTop() ? "true" : "false");
431 setParam(param_str, Tabular::SET_LINE_BOTTOM,
432 borders->getBottom() ? "true" : "false");
435 // apply the special alignment
436 string special = fromqstr(specialAlignmentED->text());
439 if (multicolumnCB->isChecked())
440 setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
441 else if (multirowCB->isChecked())
442 setParam(param_str, Tabular::SET_SPECIAL_MULTIROW, special);
444 setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
446 // apply the fixed width values
447 string width = widgetsToLength(widthED, widthUnitCB);
450 if (multicolumnCB->isChecked())
451 setParam(param_str, Tabular::SET_MPWIDTH, width);
453 setParam(param_str, Tabular::SET_PWIDTH, width);
456 if (multicolumnCB->isChecked())
457 setParam(param_str, Tabular::MULTICOLUMN);
459 if (multirowCB->isChecked())
460 setParam(param_str, Tabular::MULTIROW);
462 if (rotateTabularCB->isChecked())
463 setParam(param_str, Tabular::SET_ROTATE_TABULAR);
465 setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
467 if (rotateCellCB->isChecked())
468 setParam(param_str, Tabular::SET_ROTATE_CELL);
470 setParam(param_str, Tabular::UNSET_ROTATE_CELL);
472 if (longTabularCB->isChecked())
473 setParam(param_str, Tabular::SET_LONGTABULAR);
475 setParam(param_str, Tabular::UNSET_LONGTABULAR);
477 if (newpageCB->isChecked())
478 setParam(param_str, Tabular::SET_LTNEWPAGE);
480 if (captionStatusCB->isChecked())
481 setParam(param_str, Tabular::TOGGLE_LTCAPTION);
483 if (headerStatusCB->isChecked())
484 setParam(param_str, Tabular::SET_LTHEAD, "none");
486 setParam(param_str, Tabular::UNSET_LTHEAD, "none");
488 if (headerBorderAboveCB->isChecked())
489 setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
491 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
493 if (headerBorderBelowCB->isChecked())
494 setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
496 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
497 if (firstheaderBorderAboveCB->isChecked())
498 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
500 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
501 if (firstheaderBorderBelowCB->isChecked())
502 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
504 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
505 if (firstheaderStatusCB->isChecked())
506 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
508 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
509 if (firstheaderNoContentsCB->isChecked())
510 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
512 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
513 if (footerStatusCB->isChecked())
514 setParam(param_str, Tabular::SET_LTFOOT, "none");
516 setParam(param_str, Tabular::UNSET_LTFOOT, "none");
517 if (footerBorderAboveCB->isChecked())
518 setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
520 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
521 if (footerBorderBelowCB->isChecked())
522 setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
524 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
525 if (lastfooterStatusCB->isChecked())
526 setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
528 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
529 if (lastfooterBorderAboveCB->isChecked())
530 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
532 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
533 if (lastfooterBorderBelowCB->isChecked())
534 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
536 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
537 if (lastfooterNoContentsCB->isChecked())
538 setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
540 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
542 if (leftRB->isChecked())
543 setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
544 else if (centerRB->isChecked())
545 setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
546 else if (rightRB->isChecked())
547 setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
549 return from_utf8(param_str);
553 static Length getColumnPWidth(Tabular const & t, size_t cell)
555 return t.column_info[t.cellColumn(cell)].p_width;
559 static Length getMColumnPWidth(Tabular const & t, size_t cell)
561 if (t.isMultiColumn(cell) || t.isMultiRow(cell))
562 return t.cellInfo(cell).p_width;
567 static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
569 if (what == Tabular::SET_SPECIAL_MULTICOLUMN
570 || what == Tabular::SET_SPECIAL_MULTIROW)
571 return t.cellInfo(cell).align_special;
572 return t.column_info[t.cellColumn(cell)].align_special;
576 void GuiTabular::paramsToDialog(Inset const * inset)
578 InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
579 // Copy Tabular of current inset.
580 Tabular const & tabular = itab->tabular;
582 BufferView const * bv = guiApp->currentView()->currentBufferView();
583 size_t const cell = bv->cursor().idx();
585 Tabular::row_type const row = tabular.cellRow(cell);
586 Tabular::col_type const col = tabular.cellColumn(cell);
588 tabularRowED->setText(QString::number(row + 1));
589 tabularColumnED->setText(QString::number(col + 1));
591 bool const multicol = tabular.isMultiColumn(cell);
592 multicolumnCB->setChecked(multicol);
594 bool const multirow = tabular.isMultiRow(cell);
595 multirowCB->setChecked(multirow);
597 rotateCellCB->setChecked(tabular.getRotateCell(cell));
598 rotateTabularCB->setChecked(tabular.rotate);
600 longTabularCB->setChecked(tabular.is_long_tabular);
602 borders->setTop(tabular.topLine(cell));
603 borders->setBottom(tabular.bottomLine(cell));
604 borders->setLeft(tabular.leftLine(cell));
605 borders->setRight(tabular.rightLine(cell));
606 // repaint the setborder widget
609 Length::UNIT const default_unit = Length::defaultUnit();
611 ///////////////////////////////////
612 // Set width and alignment
616 special = getAlignSpecial(tabular, cell,
617 Tabular::SET_SPECIAL_MULTICOLUMN);
618 pwidth = getMColumnPWidth(tabular, cell);
619 } else if (multirow) {
620 special = getAlignSpecial(tabular, cell,
621 Tabular::SET_SPECIAL_MULTIROW);
622 pwidth = getMColumnPWidth(tabular, cell);
624 special = getAlignSpecial(tabular, cell,
625 Tabular::SET_SPECIAL_COLUMN);
626 pwidth = getColumnPWidth(tabular, cell);
632 colwidth = pwidth.asString();
633 lengthToWidgets(widthED, widthUnitCB,
634 colwidth, default_unit);
636 specialAlignmentED->setText(toqstr(special));
637 ///////////////////////////////////
640 borderDefaultRB->setChecked(!tabular.use_booktabs);
641 booktabsRB->setChecked(tabular.use_booktabs);
643 if (tabular.row_info[row].top_space.empty()
644 && !tabular.row_info[row].top_space_default) {
645 topspaceCO->setCurrentIndex(0);
646 } else if (tabular.row_info[row].top_space_default) {
647 topspaceCO->setCurrentIndex(1);
649 topspaceCO->setCurrentIndex(2);
650 lengthToWidgets(topspaceED,
652 tabular.row_info[row].top_space.asString(),
656 if (tabular.row_info[row].bottom_space.empty()
657 && !tabular.row_info[row].bottom_space_default) {
658 bottomspaceCO->setCurrentIndex(0);
659 } else if (tabular.row_info[row].bottom_space_default) {
660 bottomspaceCO->setCurrentIndex(1);
662 bottomspaceCO->setCurrentIndex(2);
663 lengthToWidgets(bottomspaceED,
665 tabular.row_info[row].bottom_space.asString(),
669 if (tabular.row_info[row].interline_space.empty()
670 && !tabular.row_info[row].interline_space_default) {
671 interlinespaceCO->setCurrentIndex(0);
672 } else if (tabular.row_info[row].interline_space_default) {
673 interlinespaceCO->setCurrentIndex(1);
675 interlinespaceCO->setCurrentIndex(2);
676 lengthToWidgets(interlinespaceED,
678 tabular.row_info[row].interline_space.asString(),
683 hAlignCB->addItem(qt_("Left"), toqstr("left"));
684 hAlignCB->addItem(qt_("Center"), toqstr("center"));
685 hAlignCB->addItem(qt_("Right"), toqstr("right"));
686 if (!multicol && !pwidth.zero())
687 hAlignCB->addItem(qt_("Justified"), toqstr("justified"));
689 hAlignCB->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
692 switch (tabular.getAlignment(cell)) {
696 case LYX_ALIGN_CENTER:
699 case LYX_ALIGN_RIGHT:
702 case LYX_ALIGN_BLOCK:
704 if (!multicol && !pwidth.zero())
708 case LYX_ALIGN_DECIMAL:
715 // we should never end up here
718 hAlignCB->setCurrentIndex(hAlignCB->findData(toqstr(align)));
721 QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
722 if (decimal_point.isEmpty())
723 decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
724 decimalPointLE->setText(decimal_point);
727 switch (tabular.getVAlignment(cell)) {
728 case Tabular::LYX_VALIGN_TOP:
731 case Tabular::LYX_VALIGN_MIDDLE:
734 case Tabular::LYX_VALIGN_BOTTOM:
743 vAlignCB->setCurrentIndex(valign);
746 switch (tabular.tabular_valignment) {
747 case Tabular::LYX_VALIGN_TOP:
750 case Tabular::LYX_VALIGN_MIDDLE:
753 case Tabular::LYX_VALIGN_BOTTOM:
760 TableAlignCB->setCurrentIndex(tableValign);
762 if (!tabular.is_long_tabular) {
763 headerStatusCB->setChecked(false);
764 headerBorderAboveCB->setChecked(false);
765 headerBorderBelowCB->setChecked(false);
766 firstheaderStatusCB->setChecked(false);
767 firstheaderBorderAboveCB->setChecked(false);
768 firstheaderBorderBelowCB->setChecked(false);
769 firstheaderNoContentsCB->setChecked(false);
770 footerStatusCB->setChecked(false);
771 footerBorderAboveCB->setChecked(false);
772 footerBorderBelowCB->setChecked(false);
773 lastfooterStatusCB->setChecked(false);
774 lastfooterBorderAboveCB->setChecked(false);
775 lastfooterBorderBelowCB->setChecked(false);
776 lastfooterNoContentsCB->setChecked(false);
777 newpageCB->setChecked(false);
778 captionStatusCB->blockSignals(true);
779 captionStatusCB->setChecked(false);
780 captionStatusCB->blockSignals(false);
784 // longtables cannot have a vertical alignment
785 TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
787 switch (tabular.longtabular_alignment) {
788 case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
789 leftRB->setChecked(true);
791 case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
792 centerRB->setChecked(true);
794 case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
795 rightRB->setChecked(true);
798 centerRB->setChecked(true);
801 captionStatusCB->blockSignals(true);
802 captionStatusCB->setChecked(tabular.ltCaption(row));
803 captionStatusCB->blockSignals(false);
807 bool row_set = tabular.getRowOfLTHead(row, ltt);
808 headerStatusCB->setChecked(row_set);
810 headerBorderAboveCB->setChecked(ltt.topDL);
811 headerBorderBelowCB->setChecked(ltt.bottomDL);
814 headerBorderAboveCB->setChecked(false);
815 headerBorderBelowCB->setChecked(false);
816 firstheaderNoContentsCB->setChecked(false);
820 row_set = tabular.getRowOfLTFirstHead(row, ltt);
821 firstheaderStatusCB->setChecked(row_set);
822 if (ltt.set && (!ltt.empty || !use_empty)) {
823 firstheaderBorderAboveCB->setChecked(ltt.topDL);
824 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
826 firstheaderBorderAboveCB->setChecked(false);
827 firstheaderBorderBelowCB->setChecked(false);
830 row_set = tabular.getRowOfLTFoot(row, ltt);
831 footerStatusCB->setChecked(row_set);
833 footerBorderAboveCB->setChecked(ltt.topDL);
834 footerBorderBelowCB->setChecked(ltt.bottomDL);
837 footerBorderAboveCB->setChecked(false);
838 footerBorderBelowCB->setChecked(false);
839 lastfooterNoContentsCB->setChecked(false);
843 row_set = tabular.getRowOfLTLastFoot(row, ltt);
844 lastfooterStatusCB->setChecked(row_set);
845 if (ltt.set && (!ltt.empty || !use_empty)) {
846 lastfooterBorderAboveCB->setChecked(ltt.topDL);
847 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
849 lastfooterBorderAboveCB->setChecked(false);
850 lastfooterBorderBelowCB->setChecked(false);
852 newpageCB->setChecked(tabular.getLTNewPage(row));
856 } // namespace frontend
859 #include "moc_GuiTabular.cpp"