3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "CheckedLineEdit.h"
16 #include "GuiTabular.h"
19 #include "LengthCombo.h"
20 #include "Validator.h"
21 #include "qt_helpers.h"
23 #include "controllers/ButtonController.h"
24 #include "controllers/ControlTabular.h"
26 #include "support/convert.h"
28 #include <QCloseEvent>
30 #include <QPushButton>
31 #include <QRadioButton>
34 #include "GuiSetBorder.h"
41 /////////////////////////////////////////////////////////////////////
45 /////////////////////////////////////////////////////////////////////
47 GuiTabularDialog::GuiTabularDialog(GuiTabular * form)
52 widthED->setValidator(unsignedLengthValidator(widthED));
53 topspaceED->setValidator(new LengthValidator(topspaceED));
54 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
55 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
57 connect(topspaceED, SIGNAL(returnPressed()),
58 this, SLOT(topspace_changed()));
59 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
60 this, SLOT(topspace_changed()));
61 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
62 connect(bottomspaceED, SIGNAL(returnPressed()),
63 this, SLOT(bottomspace_changed()));
64 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
65 this, SLOT(bottomspace_changed()));
66 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
67 connect(interlinespaceED, SIGNAL(returnPressed()),
68 this, SLOT(interlinespace_changed()));
69 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
70 this, SLOT(interlinespace_changed()));
71 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
72 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
73 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
74 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
75 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
76 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
77 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
78 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
79 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
80 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
81 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
82 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
83 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
84 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
85 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
86 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
87 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
88 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
89 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
90 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
91 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
92 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
93 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
94 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
95 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
96 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
97 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
98 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
99 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
100 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
101 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
102 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
103 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
104 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
105 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
106 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
110 void GuiTabularDialog::change_adaptor()
116 void GuiTabularDialog::closeEvent(QCloseEvent * e)
123 void GuiTabularDialog::booktabsChanged(bool)
126 form_->controller().booktabs(booktabsRB->isChecked());
127 form_->update_borders();
131 void GuiTabularDialog::topspace_changed()
133 switch(topspaceCO->currentIndex()) {
135 form_->controller().set(Tabular::SET_TOP_SPACE, "");
136 topspaceED->setEnabled(false);
137 topspaceUnit->setEnabled(false);
141 form_->controller().set(Tabular::SET_TOP_SPACE, "default");
142 topspaceED->setEnabled(false);
143 topspaceUnit->setEnabled(false);
147 if (!topspaceED->text().isEmpty())
148 form_->controller().set(Tabular::SET_TOP_SPACE,
149 widgetsToLength(topspaceED, topspaceUnit));
150 if (!form_->bc().bp().isReadOnly()) {
151 topspaceED->setEnabled(true);
152 topspaceUnit->setEnabled(true);
161 void GuiTabularDialog::bottomspace_changed()
163 switch(bottomspaceCO->currentIndex()) {
165 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "");
166 bottomspaceED->setEnabled(false);
167 bottomspaceUnit->setEnabled(false);
171 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "default");
172 bottomspaceED->setEnabled(false);
173 bottomspaceUnit->setEnabled(false);
177 if (!bottomspaceED->text().isEmpty())
178 form_->controller().set(Tabular::SET_BOTTOM_SPACE,
179 widgetsToLength(bottomspaceED, bottomspaceUnit));
180 if (!form_->bc().bp().isReadOnly()) {
181 bottomspaceED->setEnabled(true);
182 bottomspaceUnit->setEnabled(true);
191 void GuiTabularDialog::interlinespace_changed()
193 switch(interlinespaceCO->currentIndex()) {
195 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "");
196 interlinespaceED->setEnabled(false);
197 interlinespaceUnit->setEnabled(false);
201 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "default");
202 interlinespaceED->setEnabled(false);
203 interlinespaceUnit->setEnabled(false);
207 if (!interlinespaceED->text().isEmpty())
208 form_->controller().set(Tabular::SET_INTERLINE_SPACE,
209 widgetsToLength(interlinespaceED, interlinespaceUnit));
210 if (!form_->bc().bp().isReadOnly()) {
211 interlinespaceED->setEnabled(true);
212 interlinespaceUnit->setEnabled(true);
221 void GuiTabularDialog::close_clicked()
228 void GuiTabularDialog::borderSet_clicked()
230 form_->controller().set(Tabular::SET_ALL_LINES);
231 form_->update_borders();
236 void GuiTabularDialog::borderUnset_clicked()
238 form_->controller().set(Tabular::UNSET_ALL_LINES);
239 form_->update_borders();
244 void GuiTabularDialog::leftBorder_changed()
246 form_->controller().toggleLeftLine();
251 void GuiTabularDialog::rightBorder_changed()
253 form_->controller().toggleRightLine();
258 void GuiTabularDialog::topBorder_changed()
260 form_->controller().toggleTopLine();
265 void GuiTabularDialog::bottomBorder_changed()
267 form_->controller().toggleBottomLine();
272 void GuiTabularDialog::specialAlignment_changed()
274 string special = fromqstr(specialAlignmentED->text());
275 form_->controller().setSpecial(special);
280 void GuiTabularDialog::width_changed()
283 string const width = widgetsToLength(widthED, widthUnit);
284 form_->controller().setWidth(width);
288 void GuiTabularDialog::multicolumn_clicked()
290 form_->controller().toggleMultiColumn();
295 void GuiTabularDialog::rotateTabular()
297 form_->controller().rotateTabular(rotateTabularCB->isChecked());
302 void GuiTabularDialog::rotateCell()
304 form_->controller().rotateCell(rotateCellCB->isChecked());
309 void GuiTabularDialog::hAlign_changed(int align)
311 ControlTabular::HALIGN h = ControlTabular::LEFT;
314 case 0: h = ControlTabular::LEFT; break;
315 case 1: h = ControlTabular::CENTER; break;
316 case 2: h = ControlTabular::RIGHT; break;
317 case 3: h = ControlTabular::BLOCK; break;
320 form_->controller().halign(h);
324 void GuiTabularDialog::vAlign_changed(int align)
326 ControlTabular::VALIGN v = ControlTabular::TOP;
329 case 0: v = ControlTabular::TOP; break;
330 case 1: v = ControlTabular::MIDDLE; break;
331 case 2: v = ControlTabular::BOTTOM; break;
334 form_->controller().valign(v);
338 void GuiTabularDialog::longTabular()
340 form_->controller().longTabular(longTabularCB->isChecked());
345 void GuiTabularDialog::ltNewpage_clicked()
347 form_->controller().set(Tabular::SET_LTNEWPAGE);
352 void GuiTabularDialog::ltHeaderStatus_clicked()
354 bool enable(headerStatusCB->isChecked());
356 form_->controller().set(Tabular::SET_LTHEAD, "");
358 form_->controller().set(Tabular::UNSET_LTHEAD, "");
359 headerBorderAboveCB->setEnabled(enable);
360 headerBorderBelowCB->setEnabled(enable);
361 firstheaderNoContentsCB->setEnabled(enable);
366 void GuiTabularDialog::ltHeaderBorderAbove_clicked()
368 if (headerBorderAboveCB->isChecked())
369 form_->controller().set(Tabular::SET_LTHEAD, "dl_above");
371 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_above");
376 void GuiTabularDialog::ltHeaderBorderBelow_clicked()
378 if (headerBorderBelowCB->isChecked())
379 form_->controller().set(Tabular::SET_LTHEAD, "dl_below");
381 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_below");
386 void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
388 if (firstheaderBorderAboveCB->isChecked())
389 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
391 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
396 void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
398 if (firstheaderBorderBelowCB->isChecked())
399 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
401 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
406 void GuiTabularDialog::ltFirstHeaderStatus_clicked()
408 bool enable(firstheaderStatusCB->isChecked());
410 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "");
412 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
413 firstheaderBorderAboveCB->setEnabled(enable);
414 firstheaderBorderBelowCB->setEnabled(enable);
419 void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
421 bool enable(firstheaderNoContentsCB->isChecked());
423 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
425 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
426 firstheaderStatusCB->setEnabled(!enable);
427 firstheaderBorderAboveCB->setEnabled(!enable);
428 firstheaderBorderBelowCB->setEnabled(!enable);
433 void GuiTabularDialog::ltFooterStatus_clicked()
435 bool enable(footerStatusCB->isChecked());
437 form_->controller().set(Tabular::SET_LTFOOT, "");
439 form_->controller().set(Tabular::UNSET_LTFOOT, "");
440 footerBorderAboveCB->setEnabled(enable);
441 footerBorderBelowCB->setEnabled(enable);
442 lastfooterNoContentsCB->setEnabled(enable);
447 void GuiTabularDialog::ltFooterBorderAbove_clicked()
449 if (footerBorderAboveCB->isChecked())
450 form_->controller().set(Tabular::SET_LTFOOT, "dl_above");
452 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_above");
457 void GuiTabularDialog::ltFooterBorderBelow_clicked()
459 if (footerBorderBelowCB->isChecked())
460 form_->controller().set(Tabular::SET_LTFOOT, "dl_below");
462 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_below");
467 void GuiTabularDialog::ltLastFooterStatus_clicked()
469 bool enable(lastfooterStatusCB->isChecked());
471 form_->controller().set(Tabular::SET_LTLASTFOOT, "");
473 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "");
474 lastfooterBorderAboveCB->setEnabled(enable);
475 lastfooterBorderBelowCB->setEnabled(enable);
480 void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
482 if (lastfooterBorderAboveCB->isChecked())
483 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
485 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
490 void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
492 if (lastfooterBorderBelowCB->isChecked())
493 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
495 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
500 void GuiTabularDialog::ltLastFooterEmpty_clicked()
502 bool enable(lastfooterNoContentsCB->isChecked());
504 form_->controller().set(Tabular::SET_LTLASTFOOT, "empty");
506 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
507 lastfooterStatusCB->setEnabled(!enable);
508 lastfooterBorderAboveCB->setEnabled(!enable);
509 lastfooterBorderBelowCB->setEnabled(!enable);
514 /////////////////////////////////////////////////////////////////////
518 /////////////////////////////////////////////////////////////////////
520 typedef QController<ControlTabular, GuiView<GuiTabularDialog> > tabular_base_class;
522 GuiTabular::GuiTabular(Dialog & parent)
523 : tabular_base_class(parent, _("Table Settings"))
528 void GuiTabular::build_dialog()
530 dialog_.reset(new GuiTabularDialog(this));
532 bcview().setCancel(dialog_->closePB);
534 bcview().addReadOnly(dialog_->topspaceED);
535 bcview().addReadOnly(dialog_->topspaceUnit);
536 bcview().addReadOnly(dialog_->topspaceCO);
537 bcview().addReadOnly(dialog_->bottomspaceED);
538 bcview().addReadOnly(dialog_->bottomspaceUnit);
539 bcview().addReadOnly(dialog_->bottomspaceCO);
540 bcview().addReadOnly(dialog_->interlinespaceED);
541 bcview().addReadOnly(dialog_->interlinespaceUnit);
542 bcview().addReadOnly(dialog_->interlinespaceCO);
543 bcview().addReadOnly(dialog_->borderDefaultRB);
544 bcview().addReadOnly(dialog_->booktabsRB);
546 bcview().addReadOnly(dialog_->multicolumnCB);
547 bcview().addReadOnly(dialog_->rotateCellCB);
548 bcview().addReadOnly(dialog_->rotateTabularCB);
549 bcview().addReadOnly(dialog_->specialAlignmentED);
550 bcview().addReadOnly(dialog_->widthED);
551 bcview().addReadOnly(dialog_->widthUnit);
552 bcview().addReadOnly(dialog_->hAlignCB);
553 bcview().addReadOnly(dialog_->vAlignCB);
554 bcview().addReadOnly(dialog_->borderSetPB);
555 bcview().addReadOnly(dialog_->borderUnsetPB);
556 bcview().addReadOnly(dialog_->borders);
557 bcview().addReadOnly(dialog_->longTabularCB);
558 bcview().addReadOnly(dialog_->headerStatusCB);
559 bcview().addReadOnly(dialog_->headerBorderAboveCB);
560 bcview().addReadOnly(dialog_->headerBorderBelowCB);
561 bcview().addReadOnly(dialog_->firstheaderStatusCB);
562 bcview().addReadOnly(dialog_->firstheaderBorderAboveCB);
563 bcview().addReadOnly(dialog_->firstheaderBorderBelowCB);
564 bcview().addReadOnly(dialog_->firstheaderNoContentsCB);
565 bcview().addReadOnly(dialog_->footerStatusCB);
566 bcview().addReadOnly(dialog_->footerBorderAboveCB);
567 bcview().addReadOnly(dialog_->footerBorderBelowCB);
568 bcview().addReadOnly(dialog_->lastfooterStatusCB);
569 bcview().addReadOnly(dialog_->lastfooterBorderAboveCB);
570 bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
571 bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
572 bcview().addReadOnly(dialog_->newpageCB);
574 // initialize the length validator
575 addCheckedLineEdit(bcview(), dialog_->widthED,
576 dialog_->fixedWidthColLA);
577 addCheckedLineEdit(bcview(), dialog_->topspaceED,
578 dialog_->topspaceLA);
579 addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
580 dialog_->bottomspaceLA);
581 addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
582 dialog_->interlinespaceLA);
586 bool GuiTabular::isValid()
592 void GuiTabular::update_borders()
594 Tabular const & tabular = controller().tabular();
595 Tabular::idx_type const cell = controller().getActiveCell();
596 bool const isMulticolumnCell = tabular.isMultiColumn(cell);
598 if (!isMulticolumnCell) {
599 dialog_->borders->setLeftEnabled(true);
600 dialog_->borders->setRightEnabled(true);
601 dialog_->borders->setTop(tabular.topLine(cell, true));
602 dialog_->borders->setBottom(tabular.bottomLine(cell, true));
603 dialog_->borders->setLeft(tabular.leftLine(cell, true));
604 dialog_->borders->setRight(tabular.rightLine(cell, true));
605 // repaint the setborder widget
606 dialog_->borders->update();
610 dialog_->borders->setTop(tabular.topLine(cell));
611 dialog_->borders->setBottom(tabular.bottomLine(cell));
612 // pay attention to left/right lines: they are only allowed
613 // to set if we are in first/last cell of row or if the left/right
614 // cell is also a multicolumn.
615 if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
616 dialog_->borders->setLeftEnabled(true);
617 dialog_->borders->setLeft(tabular.leftLine(cell));
619 dialog_->borders->setLeft(false);
620 dialog_->borders->setLeftEnabled(false);
622 if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
623 dialog_->borders->setRightEnabled(true);
624 dialog_->borders->setRight(tabular.rightLine(cell));
626 dialog_->borders->setRight(false);
627 dialog_->borders->setRightEnabled(false);
629 // repaint the setborder widget
630 dialog_->borders->update();
634 void GuiTabular::update_contents()
636 controller().initialiseParams(string());
638 Tabular const & tabular(controller().tabular());
639 Tabular::idx_type const cell = controller().getActiveCell();
641 Tabular::row_type const row(tabular.row_of_cell(cell));
642 Tabular::col_type const col(tabular.column_of_cell(cell));
644 dialog_->tabularRowED->setText(toqstr(convert<string>(row + 1)));
645 dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
647 bool const multicol(tabular.isMultiColumn(cell));
649 dialog_->multicolumnCB->setChecked(multicol);
651 dialog_->rotateCellCB->setChecked(tabular.getRotateCell(cell));
652 dialog_->rotateTabularCB->setChecked(tabular.getRotateTabular());
654 dialog_->longTabularCB->setChecked(tabular.isLongTabular());
662 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
663 pwidth = tabular.getMColumnPWidth(cell);
665 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
666 pwidth = tabular.getColumnPWidth(cell);
669 dialog_->specialAlignmentED->setText(toqstr(special));
671 bool const isReadonly = bc().bp().isReadOnly();
672 dialog_->specialAlignmentED->setEnabled(!isReadonly);
674 Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN;
676 dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
677 dialog_->booktabsRB->setChecked(tabular.useBookTabs());
679 if (tabular.row_info[row].top_space.empty()
680 && !tabular.row_info[row].top_space_default) {
681 dialog_->topspaceCO->setCurrentIndex(0);
682 } else if (tabular.row_info[row].top_space_default) {
683 dialog_->topspaceCO->setCurrentIndex(1);
685 dialog_->topspaceCO->setCurrentIndex(2);
686 lengthToWidgets(dialog_->topspaceED,
687 dialog_->topspaceUnit,
688 tabular.row_info[row].top_space.asString(),
691 dialog_->topspaceED->setEnabled(!isReadonly
692 && (dialog_->topspaceCO->currentIndex() == 2));
693 dialog_->topspaceUnit->setEnabled(!isReadonly
694 && (dialog_->topspaceCO->currentIndex() == 2));
695 dialog_->topspaceCO->setEnabled(!isReadonly);
697 if (tabular.row_info[row].bottom_space.empty()
698 && !tabular.row_info[row].bottom_space_default) {
699 dialog_->bottomspaceCO->setCurrentIndex(0);
700 } else if (tabular.row_info[row].bottom_space_default) {
701 dialog_->bottomspaceCO->setCurrentIndex(1);
703 dialog_->bottomspaceCO->setCurrentIndex(2);
704 lengthToWidgets(dialog_->bottomspaceED,
705 dialog_->bottomspaceUnit,
706 tabular.row_info[row].bottom_space.asString(),
709 dialog_->bottomspaceED->setEnabled(!isReadonly
710 && (dialog_->bottomspaceCO->currentIndex() == 2));
711 dialog_->bottomspaceUnit->setEnabled(!isReadonly
712 && (dialog_->bottomspaceCO->currentIndex() == 2));
713 dialog_->bottomspaceCO->setEnabled(!isReadonly);
715 if (tabular.row_info[row].interline_space.empty()
716 && !tabular.row_info[row].interline_space_default) {
717 dialog_->interlinespaceCO->setCurrentIndex(0);
718 } else if (tabular.row_info[row].interline_space_default) {
719 dialog_->interlinespaceCO->setCurrentIndex(1);
721 dialog_->interlinespaceCO->setCurrentIndex(2);
722 lengthToWidgets(dialog_->interlinespaceED,
723 dialog_->interlinespaceUnit,
724 tabular.row_info[row].interline_space.asString(),
727 dialog_->interlinespaceED->setEnabled(!isReadonly
728 && (dialog_->interlinespaceCO->currentIndex() == 2));
729 dialog_->interlinespaceUnit->setEnabled(!isReadonly
730 && (dialog_->interlinespaceCO->currentIndex() == 2));
731 dialog_->interlinespaceCO->setEnabled(!isReadonly);
735 colwidth = pwidth.asString();
736 lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
737 colwidth, default_unit);
739 dialog_->widthED->setEnabled(!isReadonly);
740 dialog_->widthUnit->setEnabled(!isReadonly);
742 dialog_->hAlignCB->clear();
743 dialog_->hAlignCB->addItem(qt_("Left"));
744 dialog_->hAlignCB->addItem(qt_("Center"));
745 dialog_->hAlignCB->addItem(qt_("Right"));
746 if (!multicol && !pwidth.zero())
747 dialog_->hAlignCB->addItem(qt_("Justified"));
750 switch (tabular.getAlignment(cell)) {
754 case LYX_ALIGN_CENTER:
757 case LYX_ALIGN_RIGHT:
760 case LYX_ALIGN_BLOCK:
762 if (!multicol && !pwidth.zero())
770 dialog_->hAlignCB->setCurrentIndex(align);
773 switch (tabular.getVAlignment(cell)) {
774 case Tabular::LYX_VALIGN_TOP:
777 case Tabular::LYX_VALIGN_MIDDLE:
780 case Tabular::LYX_VALIGN_BOTTOM:
789 dialog_->vAlignCB->setCurrentIndex(valign);
791 dialog_->hAlignCB->setEnabled(true);
792 dialog_->vAlignCB->setEnabled(!pwidth.zero());
794 if (!tabular.isLongTabular()) {
795 dialog_->headerStatusCB->setChecked(false);
796 dialog_->headerBorderAboveCB->setChecked(false);
797 dialog_->headerBorderBelowCB->setChecked(false);
798 dialog_->firstheaderStatusCB->setChecked(false);
799 dialog_->firstheaderBorderAboveCB->setChecked(false);
800 dialog_->firstheaderBorderBelowCB->setChecked(false);
801 dialog_->firstheaderNoContentsCB->setChecked(false);
802 dialog_->footerStatusCB->setChecked(false);
803 dialog_->footerBorderAboveCB->setChecked(false);
804 dialog_->footerBorderBelowCB->setChecked(false);
805 dialog_->lastfooterStatusCB->setChecked(false);
806 dialog_->lastfooterBorderAboveCB->setChecked(false);
807 dialog_->lastfooterBorderBelowCB->setChecked(false);
808 dialog_->lastfooterNoContentsCB->setChecked(false);
809 dialog_->newpageCB->setChecked(false);
810 dialog_->newpageCB->setEnabled(false);
816 bool row_set = tabular.getRowOfLTHead(row, ltt);
817 dialog_->headerStatusCB->setChecked(row_set);
819 dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
820 dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
823 dialog_->headerBorderAboveCB->setChecked(false);
824 dialog_->headerBorderBelowCB->setChecked(false);
825 dialog_->headerBorderAboveCB->setEnabled(false);
826 dialog_->headerBorderBelowCB->setEnabled(false);
827 dialog_->firstheaderNoContentsCB->setChecked(false);
828 dialog_->firstheaderNoContentsCB->setEnabled(false);
832 row_set = tabular.getRowOfLTFirstHead(row, ltt);
833 dialog_->firstheaderStatusCB->setChecked(row_set);
834 if (ltt.set && (!ltt.empty || !use_empty)) {
835 dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
836 dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
838 dialog_->firstheaderBorderAboveCB->setEnabled(false);
839 dialog_->firstheaderBorderBelowCB->setEnabled(false);
840 dialog_->firstheaderBorderAboveCB->setChecked(false);
841 dialog_->firstheaderBorderBelowCB->setChecked(false);
843 dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
845 dialog_->firstheaderStatusCB->setEnabled(false);
849 row_set = tabular.getRowOfLTFoot(row, ltt);
850 dialog_->footerStatusCB->setChecked(row_set);
852 dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
853 dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
856 dialog_->footerBorderAboveCB->setChecked(false);
857 dialog_->footerBorderBelowCB->setChecked(false);
858 dialog_->footerBorderAboveCB->setEnabled(false);
859 dialog_->footerBorderBelowCB->setEnabled(false);
860 dialog_->lastfooterNoContentsCB->setChecked(false);
861 dialog_->lastfooterNoContentsCB->setEnabled(false);
865 row_set = tabular.getRowOfLTLastFoot(row, ltt);
866 dialog_->lastfooterStatusCB->setChecked(row_set);
867 if (ltt.set && (!ltt.empty || !use_empty)) {
868 dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
869 dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
871 dialog_->lastfooterBorderAboveCB->setEnabled(false);
872 dialog_->lastfooterBorderBelowCB->setEnabled(false);
873 dialog_->lastfooterBorderAboveCB->setChecked(false);
874 dialog_->lastfooterBorderBelowCB->setChecked(false);
876 dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
878 dialog_->lastfooterStatusCB->setEnabled(false);
881 dialog_->newpageCB->setChecked(tabular.getLTNewPage(row));
885 void GuiTabular::closeGUI()
887 // ugly hack to auto-apply the stuff that hasn't been
888 // yet. don't let this continue to exist ...
890 // Subtle here, we must /not/ apply any changes and
891 // then refer to tabular, as it will have been freed
892 // since the changes update the actual controller().tabular()
893 Tabular const & tabular(controller().tabular());
895 // apply the fixed width values
896 Tabular::idx_type const cell = controller().getActiveCell();
897 bool const multicol = tabular.isMultiColumn(cell);
898 string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
901 Length llen = tabular.getColumnPWidth(cell);
902 Length llenMulti = tabular.getMColumnPWidth(cell);
904 if (multicol && !llenMulti.zero())
905 width2 = llenMulti.asString();
906 else if (!multicol && !llen.zero())
907 width2 = llen.asString();
909 // apply the special alignment
910 docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
914 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
916 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
920 controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
922 controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
925 if (width != width2) {
927 controller().set(Tabular::SET_MPWIDTH, width);
929 controller().set(Tabular::SET_PWIDTH, width);
933 switch (dialog_->topspaceCO->currentIndex()) {
935 controller().set(Tabular::SET_TOP_SPACE, "");
938 controller().set(Tabular::SET_TOP_SPACE, "default");
941 controller().set(Tabular::SET_TOP_SPACE,
942 widgetsToLength(dialog_->topspaceED,
943 dialog_->topspaceUnit));
947 switch (dialog_->bottomspaceCO->currentIndex()) {
949 controller().set(Tabular::SET_BOTTOM_SPACE, "");
952 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
955 controller().set(Tabular::SET_BOTTOM_SPACE,
956 widgetsToLength(dialog_->bottomspaceED,
957 dialog_->bottomspaceUnit));
961 switch (dialog_->interlinespaceCO->currentIndex()) {
963 controller().set(Tabular::SET_INTERLINE_SPACE, "");
966 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
969 controller().set(Tabular::SET_INTERLINE_SPACE,
970 widgetsToLength(dialog_->interlinespaceED,
971 dialog_->interlinespaceUnit));
977 } // namespace frontend
980 #include "GuiTabular_moc.cpp"