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);
163 bool dalign = hAlignCB->currentText() == QString("Decimal");
164 decimalPointLE->setEnabled(dalign);
165 decimalL->setEnabled(dalign);
167 vAlignCB->setEnabled(!multirowCB->isChecked()
168 && !widgetsToLength(widthED, widthUnitCB).empty());
170 topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
171 topspaceUnit->setEnabled(topspaceCO->currentIndex() == 2);
172 bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
173 bottomspaceUnit->setEnabled(bottomspaceCO->currentIndex() == 2);
174 interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
175 interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
177 bool const longtabular = longTabularCB->isChecked();
178 longtableGB->setEnabled(true);
179 newpageCB->setEnabled(longtabular);
180 alignmentGB->setEnabled(longtabular);
181 // longtables cannot have a vertical alignment
182 TableAlignCB->setDisabled(longtabular);
184 // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
185 // depending on the cursor position is very very unintuitive...
186 // We need some edit boxes to show which rows are header/footer/etc
187 // without having to move the cursor first.
188 headerStatusCB->setEnabled(longtabular);
189 headerBorderAboveCB->setEnabled(longtabular
190 && headerStatusCB->isChecked());
191 headerBorderBelowCB->setEnabled(longtabular
192 && headerStatusCB->isChecked());
194 // first header can only be suppressed when there is a header
195 // FIXME: old code also checked for
196 // tabular.haveLTHead() && !tabular.haveLTFirstHead());
197 firstheaderNoContentsCB->setEnabled(longtabular);
198 // check if setting a first header is allowed
199 // additionally check firstheaderNoContentsCB because when this is
200 // the case a first header makes no sense
201 // FIXME: verify that some previous row was not set.
202 firstheaderStatusCB->setEnabled(longtabular
203 && !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(longtabular
223 && !lastfooterNoContentsCB->isChecked());
224 lastfooterBorderAboveCB->setEnabled(longtabular
225 && lastfooterBorderAboveCB->isChecked());
226 lastfooterBorderBelowCB->setEnabled(longtabular
227 && lastfooterBorderAboveCB->isChecked());
229 // FIXME: verify if previous row doesn't have a caption already.
230 captionStatusCB->setEnabled(longtabular);
232 // When a row is set as longtable caption, it must not be allowed
233 // to unset that this row is a multicolumn.
234 // FIXME: old code also checked for:
235 // funcEnabled(Tabular::MULTICOLUMN)
236 multicolumnCB->setEnabled(longtabular);
238 // FIXME: old code also checked for:
239 // funcEnabled(Tabular::MULTICOLUMN)
240 multirowCB->setEnabled(longtabular);
246 void GuiTabular::borderSet_clicked()
248 borders->setTop(true);
249 borders->setBottom(true);
250 borders->setLeft(true);
251 borders->setRight(true);
252 // repaint the setborder widget
258 void GuiTabular::borderUnset_clicked()
260 borders->setTop(false);
261 borders->setBottom(false);
262 borders->setLeft(false);
263 borders->setRight(false);
264 // repaint the setborder widget
270 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
273 param_str += featureAsString(f) + ' ' + arg;
277 void GuiTabular::setHAlign(string & param_str) const
279 Tabular::Feature num = Tabular::ALIGN_LEFT;
280 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
281 QString const align = hAlignCB->currentText();
282 if (align == qt_("Left")) {
283 num = Tabular::ALIGN_LEFT;
284 multi_num = Tabular::M_ALIGN_LEFT;
285 } else if (align == qt_("Center")) {
286 num = Tabular::ALIGN_CENTER;
287 multi_num = Tabular::M_ALIGN_CENTER;
288 } else if (align == qt_("Right")) {
289 num = Tabular::ALIGN_RIGHT;
290 multi_num = Tabular::M_ALIGN_RIGHT;
291 } else if (align == qt_("Justified")) {
292 num = Tabular::ALIGN_BLOCK;
293 //multi_num: no equivalent
294 } else if (align == qt_("Decimal")) {
295 num = Tabular::ALIGN_DECIMAL;
296 //multi_num: no equivalent
299 if (multicolumnCB->isChecked())
300 setParam(param_str, multi_num);
302 setParam(param_str, num);
306 void GuiTabular::setVAlign(string & param_str) const
308 int const align = vAlignCB->currentIndex();
309 enum VALIGN { TOP, MIDDLE, BOTTOM };
313 case 0: v = TOP; break;
314 case 1: v = MIDDLE; break;
315 case 2: v = BOTTOM; break;
318 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
319 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
323 num = Tabular::VALIGN_TOP;
324 multi_num = Tabular::M_VALIGN_TOP;
327 num = Tabular::VALIGN_MIDDLE;
328 multi_num = Tabular::M_VALIGN_MIDDLE;
331 num = Tabular::VALIGN_BOTTOM;
332 multi_num = Tabular::M_VALIGN_BOTTOM;
335 if (multicolumnCB->isChecked() || multirowCB->isChecked())
336 setParam(param_str, multi_num);
338 setParam(param_str, num);
342 void GuiTabular::setTableAlignment(string & param_str) const
344 int const align = TableAlignCB->currentIndex();
346 case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
348 case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
350 case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
356 docstring GuiTabular::dialogToParams() const
358 // FIXME: We should use Tabular directly.
359 string param_str = "tabular";
360 setHAlign(param_str);
362 // SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
363 string decimal_point = fromqstr(decimalPointLE->text());
364 if (decimal_point.empty())
365 decimal_point = lyxrc.default_decimal_point;
366 setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
368 setVAlign(param_str);
369 setTableAlignment(param_str);
371 if (booktabsRB->isChecked())
372 setParam(param_str, Tabular::SET_BOOKTABS);
374 setParam(param_str, Tabular::UNSET_BOOKTABS);
377 switch (topspaceCO->currentIndex()) {
379 setParam(param_str, Tabular::SET_TOP_SPACE, "none");
382 setParam(param_str, Tabular::SET_TOP_SPACE, "default");
385 if (!topspaceED->text().isEmpty())
386 setParam(param_str, Tabular::SET_TOP_SPACE,
387 widgetsToLength(topspaceED, topspaceUnit));
392 switch (bottomspaceCO->currentIndex()) {
394 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
397 setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
400 if (!bottomspaceED->text().isEmpty())
401 setParam(param_str, Tabular::SET_BOTTOM_SPACE,
402 widgetsToLength(bottomspaceED,
408 switch (interlinespaceCO->currentIndex()) {
410 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
413 setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
416 if (!interlinespaceED->text().isEmpty())
417 setParam(param_str, Tabular::SET_INTERLINE_SPACE,
418 widgetsToLength(interlinespaceED,
419 interlinespaceUnit));
424 if (borders->getTop() && borders->getBottom() && borders->getLeft()
425 && borders->getRight())
426 setParam(param_str, Tabular::SET_ALL_LINES);
427 else if (!borders->getTop() && !borders->getBottom() && !borders->getLeft()
428 && !borders->getRight())
429 setParam(param_str, Tabular::UNSET_ALL_LINES);
431 setParam(param_str, Tabular::SET_LINE_LEFT,
432 borders->getLeft() ? "true" : "false");
433 setParam(param_str, Tabular::SET_LINE_RIGHT,
434 borders->getRight() ? "true" : "false");
435 setParam(param_str, Tabular::SET_LINE_TOP,
436 borders->getTop() ? "true" : "false");
437 setParam(param_str, Tabular::SET_LINE_BOTTOM,
438 borders->getBottom() ? "true" : "false");
441 // apply the special alignment
442 string special = fromqstr(specialAlignmentED->text());
445 if (multicolumnCB->isChecked())
446 setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
447 else if (multirowCB->isChecked())
448 setParam(param_str, Tabular::SET_SPECIAL_MULTIROW, special);
450 setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
452 // apply the fixed width values
453 string width = widgetsToLength(widthED, widthUnitCB);
456 if (multicolumnCB->isChecked())
457 setParam(param_str, Tabular::SET_MPWIDTH, width);
459 setParam(param_str, Tabular::SET_PWIDTH, width);
462 if (multicolumnCB->isChecked())
463 setParam(param_str, Tabular::MULTICOLUMN);
465 if (multirowCB->isChecked())
466 setParam(param_str, Tabular::MULTIROW);
468 if (rotateTabularCB->isChecked())
469 setParam(param_str, Tabular::SET_ROTATE_TABULAR);
471 setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
473 if (rotateCellCB->isChecked())
474 setParam(param_str, Tabular::SET_ROTATE_CELL);
476 setParam(param_str, Tabular::UNSET_ROTATE_CELL);
478 if (longTabularCB->isChecked())
479 setParam(param_str, Tabular::SET_LONGTABULAR);
481 setParam(param_str, Tabular::UNSET_LONGTABULAR);
483 if (newpageCB->isChecked())
484 setParam(param_str, Tabular::SET_LTNEWPAGE);
486 if (captionStatusCB->isChecked())
487 setParam(param_str, Tabular::TOGGLE_LTCAPTION);
489 if (headerStatusCB->isChecked())
490 setParam(param_str, Tabular::SET_LTHEAD, "none");
492 setParam(param_str, Tabular::UNSET_LTHEAD, "none");
494 if (headerBorderAboveCB->isChecked())
495 setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
497 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
499 if (headerBorderBelowCB->isChecked())
500 setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
502 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
503 if (firstheaderBorderAboveCB->isChecked())
504 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
506 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
507 if (firstheaderBorderBelowCB->isChecked())
508 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
510 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
511 if (firstheaderStatusCB->isChecked())
512 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
514 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
515 if (firstheaderNoContentsCB->isChecked())
516 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
518 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
519 if (footerStatusCB->isChecked())
520 setParam(param_str, Tabular::SET_LTFOOT, "none");
522 setParam(param_str, Tabular::UNSET_LTFOOT, "none");
523 if (footerBorderAboveCB->isChecked())
524 setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
526 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
527 if (footerBorderBelowCB->isChecked())
528 setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
530 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
531 if (lastfooterStatusCB->isChecked())
532 setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
534 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
535 if (lastfooterBorderAboveCB->isChecked())
536 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
538 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
539 if (lastfooterBorderBelowCB->isChecked())
540 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
542 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
543 if (lastfooterNoContentsCB->isChecked())
544 setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
546 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
548 if (leftRB->isChecked())
549 setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
550 else if (centerRB->isChecked())
551 setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
552 else if (rightRB->isChecked())
553 setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
555 return from_utf8(param_str);
559 static Length getColumnPWidth(Tabular const & t, size_t cell)
561 return t.column_info[t.cellColumn(cell)].p_width;
565 static Length getMColumnPWidth(Tabular const & t, size_t cell)
567 if (t.isMultiColumn(cell) || t.isMultiRow(cell))
568 return t.cellInfo(cell).p_width;
573 static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
575 if (what == Tabular::SET_SPECIAL_MULTICOLUMN
576 || what == Tabular::SET_SPECIAL_MULTIROW)
577 return t.cellInfo(cell).align_special;
578 return t.column_info[t.cellColumn(cell)].align_special;
582 void GuiTabular::paramsToDialog(Inset const * inset)
584 InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
585 // Copy Tabular of current inset.
586 Tabular const & tabular = itab->tabular;
588 BufferView const * bv = guiApp->currentView()->currentBufferView();
589 size_t const cell = bv->cursor().idx();
591 Tabular::row_type const row = tabular.cellRow(cell);
592 Tabular::col_type const col = tabular.cellColumn(cell);
594 tabularRowED->setText(QString::number(row + 1));
595 tabularColumnED->setText(QString::number(col + 1));
597 bool const multicol = tabular.isMultiColumn(cell);
598 multicolumnCB->setChecked(multicol);
600 bool const multirow = tabular.isMultiRow(cell);
601 multirowCB->setChecked(multirow);
603 rotateCellCB->setChecked(tabular.getRotateCell(cell));
604 rotateTabularCB->setChecked(tabular.rotate);
606 longTabularCB->setChecked(tabular.is_long_tabular);
608 borders->setTop(tabular.topLine(cell));
609 borders->setBottom(tabular.bottomLine(cell));
610 borders->setLeft(tabular.leftLine(cell));
611 borders->setRight(tabular.rightLine(cell));
612 // repaint the setborder widget
615 Length::UNIT const default_unit = Length::defaultUnit();
617 ///////////////////////////////////
618 // Set width and alignment
622 special = getAlignSpecial(tabular, cell,
623 Tabular::SET_SPECIAL_MULTICOLUMN);
624 pwidth = getMColumnPWidth(tabular, cell);
625 } else if (multirow) {
626 special = getAlignSpecial(tabular, cell,
627 Tabular::SET_SPECIAL_MULTIROW);
628 pwidth = getMColumnPWidth(tabular, cell);
630 special = getAlignSpecial(tabular, cell,
631 Tabular::SET_SPECIAL_COLUMN);
632 pwidth = getColumnPWidth(tabular, cell);
638 colwidth = pwidth.asString();
639 lengthToWidgets(widthED, widthUnitCB,
640 colwidth, default_unit);
642 specialAlignmentED->setText(toqstr(special));
643 ///////////////////////////////////
646 borderDefaultRB->setChecked(!tabular.use_booktabs);
647 booktabsRB->setChecked(tabular.use_booktabs);
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(),
662 if (tabular.row_info[row].bottom_space.empty()
663 && !tabular.row_info[row].bottom_space_default) {
664 bottomspaceCO->setCurrentIndex(0);
665 } else if (tabular.row_info[row].bottom_space_default) {
666 bottomspaceCO->setCurrentIndex(1);
668 bottomspaceCO->setCurrentIndex(2);
669 lengthToWidgets(bottomspaceED,
671 tabular.row_info[row].bottom_space.asString(),
675 if (tabular.row_info[row].interline_space.empty()
676 && !tabular.row_info[row].interline_space_default) {
677 interlinespaceCO->setCurrentIndex(0);
678 } else if (tabular.row_info[row].interline_space_default) {
679 interlinespaceCO->setCurrentIndex(1);
681 interlinespaceCO->setCurrentIndex(2);
682 lengthToWidgets(interlinespaceED,
684 tabular.row_info[row].interline_space.asString(),
689 hAlignCB->addItem(qt_("Left"));
690 hAlignCB->addItem(qt_("Center"));
691 hAlignCB->addItem(qt_("Right"));
692 if (!multicol && !pwidth.zero())
693 hAlignCB->addItem(qt_("Justified"));
695 hAlignCB->addItem(qt_("Decimal"));
698 switch (tabular.getAlignment(cell)) {
702 case LYX_ALIGN_CENTER:
703 align = qt_("Center");
705 case LYX_ALIGN_RIGHT:
706 align = qt_("Right");
708 case LYX_ALIGN_BLOCK:
710 if (!multicol && !pwidth.zero())
711 align = qt_("Justified");
714 case LYX_ALIGN_DECIMAL:
717 align = qt_("Decimal");
721 // we should never end up here
724 hAlignCB->setCurrentIndex(hAlignCB->findText(align));
727 QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
728 if (decimal_point.isEmpty())
729 decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
730 decimalPointLE->setText(decimal_point);
733 switch (tabular.getVAlignment(cell)) {
734 case Tabular::LYX_VALIGN_TOP:
737 case Tabular::LYX_VALIGN_MIDDLE:
740 case Tabular::LYX_VALIGN_BOTTOM:
749 vAlignCB->setCurrentIndex(valign);
752 switch (tabular.tabular_valignment) {
753 case Tabular::LYX_VALIGN_TOP:
756 case Tabular::LYX_VALIGN_MIDDLE:
759 case Tabular::LYX_VALIGN_BOTTOM:
766 TableAlignCB->setCurrentIndex(tableValign);
768 if (!tabular.is_long_tabular) {
769 headerStatusCB->setChecked(false);
770 headerBorderAboveCB->setChecked(false);
771 headerBorderBelowCB->setChecked(false);
772 firstheaderStatusCB->setChecked(false);
773 firstheaderBorderAboveCB->setChecked(false);
774 firstheaderBorderBelowCB->setChecked(false);
775 firstheaderNoContentsCB->setChecked(false);
776 footerStatusCB->setChecked(false);
777 footerBorderAboveCB->setChecked(false);
778 footerBorderBelowCB->setChecked(false);
779 lastfooterStatusCB->setChecked(false);
780 lastfooterBorderAboveCB->setChecked(false);
781 lastfooterBorderBelowCB->setChecked(false);
782 lastfooterNoContentsCB->setChecked(false);
783 newpageCB->setChecked(false);
784 captionStatusCB->blockSignals(true);
785 captionStatusCB->setChecked(false);
786 captionStatusCB->blockSignals(false);
790 // longtables cannot have a vertical alignment
791 TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
793 switch (tabular.longtabular_alignment) {
794 case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
795 leftRB->setChecked(true);
797 case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
798 centerRB->setChecked(true);
800 case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
801 rightRB->setChecked(true);
804 centerRB->setChecked(true);
807 captionStatusCB->blockSignals(true);
808 captionStatusCB->setChecked(tabular.ltCaption(row));
809 captionStatusCB->blockSignals(false);
813 bool row_set = tabular.getRowOfLTHead(row, ltt);
814 headerStatusCB->setChecked(row_set);
816 headerBorderAboveCB->setChecked(ltt.topDL);
817 headerBorderBelowCB->setChecked(ltt.bottomDL);
820 headerBorderAboveCB->setChecked(false);
821 headerBorderBelowCB->setChecked(false);
822 firstheaderNoContentsCB->setChecked(false);
826 row_set = tabular.getRowOfLTFirstHead(row, ltt);
827 firstheaderStatusCB->setChecked(row_set);
828 if (ltt.set && (!ltt.empty || !use_empty)) {
829 firstheaderBorderAboveCB->setChecked(ltt.topDL);
830 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
832 firstheaderBorderAboveCB->setChecked(false);
833 firstheaderBorderBelowCB->setChecked(false);
836 row_set = tabular.getRowOfLTFoot(row, ltt);
837 footerStatusCB->setChecked(row_set);
839 footerBorderAboveCB->setChecked(ltt.topDL);
840 footerBorderBelowCB->setChecked(ltt.bottomDL);
843 footerBorderAboveCB->setChecked(false);
844 footerBorderBelowCB->setChecked(false);
845 lastfooterNoContentsCB->setChecked(false);
849 row_set = tabular.getRowOfLTLastFoot(row, ltt);
850 lastfooterStatusCB->setChecked(row_set);
851 if (ltt.set && (!ltt.empty || !use_empty)) {
852 lastfooterBorderAboveCB->setChecked(ltt.topDL);
853 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
855 lastfooterBorderAboveCB->setChecked(false);
856 lastfooterBorderBelowCB->setChecked(false);
858 newpageCB->setChecked(tabular.getLTNewPage(row));
862 } // namespace frontend
865 #include "moc_GuiTabular.cpp"