X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiTabular.cpp;h=2a6a26bb3aa7b86aa0b6154e938eab4bc45e0d12;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=91b68678a682101c8f44b729b7b4a475b35de334;hpb=8a3a2baf6db40aeb5f123577896e80455901a4f7;p=lyx.git diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 91b68678a6..2a6a26bb3a 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -6,6 +6,7 @@ * \author John Levon * \author Jürgen Spitzmüller * \author Herbert Voß + * \author Uwe Stöhr * * Full author contact details are available in file CREDITS. */ @@ -41,33 +42,48 @@ namespace frontend { GuiTabular::GuiTabular(GuiView & lv) : GuiDialog(lv, "tabular", qt_("Table Settings")), // tabular_ is initialised at dialog construction in initialiseParams() - tabular_(*lv.buffer(), 0, 0) + tabular_(&(lv.currentBufferView()->buffer()), 0, 0), + applying_(false) { active_cell_ = Tabular::npos; setupUi(this); + connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); + connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore())); + + // Manage the restore, ok, apply, restore and cancel/close buttons + bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); + bc().setOK(okPB); + bc().setApply(applyPB); + bc().setCancel(closePB); + bc().setRestore(restorePB); + widthED->setValidator(unsignedLengthValidator(widthED)); topspaceED->setValidator(new LengthValidator(topspaceED)); bottomspaceED->setValidator(new LengthValidator(bottomspaceED)); interlinespaceED->setValidator(new LengthValidator(interlinespaceED)); - connect(topspaceED, SIGNAL(returnPressed()), - this, SLOT(topspace_changed())); + widthUnitCB->setCurrentItem(Length::defaultUnit()); + + connect(topspaceED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(topspace_changed())); + this, SLOT(change_adaptor())); connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed())); - connect(bottomspaceED, SIGNAL(returnPressed()), - this, SLOT(bottomspace_changed())); + connect(bottomspaceED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(bottomspace_changed())); + this, SLOT(change_adaptor())); connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed())); - connect(interlinespaceED, SIGNAL(returnPressed()), - this, SLOT(interlinespace_changed())); + connect(interlinespaceED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(interlinespace_changed())); + this, SLOT(change_adaptor())); connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed())); connect(booktabsRB, SIGNAL(clicked(bool)), @@ -88,74 +104,66 @@ GuiTabular::GuiTabular(GuiView & lv) connect(longTabularCB, SIGNAL(toggled(bool)), TableAlignCB, SLOT(setDisabled(bool))); connect(hAlignCB, SIGNAL(activated(int)), - this, SLOT(hAlign_changed(int))); + this, SLOT(change_adaptor())); connect(vAlignCB, SIGNAL(activated(int)), - this, SLOT(vAlign_changed(int))); + this, SLOT(change_adaptor())); connect(multicolumnCB, SIGNAL(clicked()), - this, SLOT(multicolumn_clicked())); + this, SLOT(change_adaptor())); connect(newpageCB, SIGNAL(clicked()), - this, SLOT(ltNewpage_clicked())); + this, SLOT(change_adaptor())); + connect(captionStatusCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); connect(headerStatusCB, SIGNAL(clicked()), - this, SLOT(ltHeaderStatus_clicked())); + this, SLOT(change_adaptor())); connect(headerBorderAboveCB, SIGNAL(clicked()), - this, SLOT(ltHeaderBorderAbove_clicked())); + this, SLOT(change_adaptor())); connect(headerBorderBelowCB, SIGNAL(clicked()), - this, SLOT(ltHeaderBorderBelow_clicked())); + this, SLOT(change_adaptor())); connect(firstheaderStatusCB, SIGNAL(clicked()), - this, SLOT(ltFirstHeaderStatus_clicked())); + this, SLOT(change_adaptor())); connect(firstheaderBorderAboveCB, SIGNAL(clicked()), - this, SLOT(ltFirstHeaderBorderAbove_clicked())); + this, SLOT(change_adaptor())); connect(firstheaderBorderBelowCB, SIGNAL(clicked()), - this, SLOT(ltFirstHeaderBorderBelow_clicked())); + this, SLOT(change_adaptor())); connect(firstheaderNoContentsCB, SIGNAL(clicked()), - this, SLOT(ltFirstHeaderEmpty_clicked())); + this, SLOT(change_adaptor())); connect(footerStatusCB, SIGNAL(clicked()), - this, SLOT(ltFooterStatus_clicked())); + this, SLOT(change_adaptor())); connect(footerBorderAboveCB, SIGNAL(clicked()), - this, SLOT(ltFooterBorderAbove_clicked())); + this, SLOT(change_adaptor())); connect(footerBorderBelowCB, SIGNAL(clicked()), - this, SLOT(ltFooterBorderBelow_clicked())); + this, SLOT(change_adaptor())); connect(lastfooterStatusCB, SIGNAL(clicked()), - this, SLOT(ltLastFooterStatus_clicked())); + this, SLOT(change_adaptor())); connect(lastfooterBorderAboveCB, SIGNAL(clicked()), - this, SLOT(ltLastFooterBorderAbove_clicked())); + this, SLOT(change_adaptor())); connect(lastfooterBorderBelowCB, SIGNAL(clicked()), - this, SLOT(ltLastFooterBorderBelow_clicked())); + this, SLOT(change_adaptor())); connect(lastfooterNoContentsCB, SIGNAL(clicked()), - this, SLOT(ltLastFooterEmpty_clicked())); - connect(specialAlignmentED, SIGNAL(returnPressed()), - this, SLOT(specialAlignment_changed())); - connect(widthED, SIGNAL(editingFinished()), - this, SLOT(width_changed())); - connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(width_changed())); - connect(closePB, SIGNAL(clicked()), - this, SLOT(close_clicked())); - connect(borders, SIGNAL(topSet(bool)), - this, SLOT(topBorder_changed())); - connect(borders, SIGNAL(bottomSet(bool)), - this, SLOT(bottomBorder_changed())); - connect(borders, SIGNAL(rightSet(bool)), - this, SLOT(rightBorder_changed())); - connect(borders, SIGNAL(leftSet(bool)), - this, SLOT(leftBorder_changed())); + this, SLOT(change_adaptor())); + connect(specialAlignmentED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); + connect(widthED, SIGNAL(textChanged(QString)), + this, SLOT(change_adaptor())); + connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)), + this, SLOT(change_adaptor())); + connect(borders, SIGNAL(clicked()), + this, SLOT(change_adaptor())); connect(rotateTabularCB, SIGNAL(clicked()), - this, SLOT(rotateTabular())); + this, SLOT(change_adaptor())); connect(rotateCellCB, SIGNAL(clicked()), - this, SLOT(rotateCell())); + this, SLOT(change_adaptor())); connect(TableAlignCB, SIGNAL(activated(int)), - this, SLOT(tableAlignment_changed(int))); + this, SLOT(change_adaptor())); connect(longTabularCB, SIGNAL(clicked()), - this, SLOT(longTabular())); + this, SLOT(change_adaptor())); connect(leftRB, SIGNAL(clicked()), - this, SLOT(ltAlignment_clicked())); + this, SLOT(change_adaptor())); connect(centerRB, SIGNAL(clicked()), - this, SLOT(ltAlignment_clicked())); + this, SLOT(change_adaptor())); connect(rightRB, SIGNAL(clicked()), - this, SLOT(ltAlignment_clicked())); - - bc().setPolicy(ButtonPolicy::IgnorantPolicy); - + this, SLOT(change_adaptor())); + bc().addReadOnly(topspaceED); bc().addReadOnly(topspaceUnit); bc().addReadOnly(topspaceCO); @@ -173,7 +181,7 @@ GuiTabular::GuiTabular(GuiView & lv) bc().addReadOnly(rotateTabularCB); bc().addReadOnly(specialAlignmentED); bc().addReadOnly(widthED); - bc().addReadOnly(widthUnit); + bc().addReadOnly(widthUnitCB); bc().addReadOnly(hAlignCB); bc().addReadOnly(vAlignCB); bc().addReadOnly(TableAlignCB); @@ -219,34 +227,20 @@ void GuiTabular::change_adaptor() } -void GuiTabular::booktabsChanged(bool) -{ - changed(); - booktabs(booktabsRB->isChecked()); - update_borders(); -} - - void GuiTabular::topspace_changed() { switch (topspaceCO->currentIndex()) { case 0: { - set(Tabular::SET_TOP_SPACE, ""); topspaceED->setEnabled(false); topspaceUnit->setEnabled(false); break; } case 1: { - set(Tabular::SET_TOP_SPACE, "default"); topspaceED->setEnabled(false); topspaceUnit->setEnabled(false); break; } case 2: { - if (!topspaceED->text().isEmpty()) - set(Tabular::SET_TOP_SPACE, - widgetsToLength(topspaceED, - topspaceUnit)); if (!bc().policy().isReadOnly()) { topspaceED->setEnabled(true); topspaceUnit->setEnabled(true); @@ -262,22 +256,16 @@ void GuiTabular::bottomspace_changed() { switch (bottomspaceCO->currentIndex()) { case 0: { - set(Tabular::SET_BOTTOM_SPACE, ""); - bottomspaceED->setEnabled(false); - bottomspaceUnit->setEnabled(false); + bottomspaceED->setEnabled(false); + bottomspaceUnit->setEnabled(false); break; } case 1: { - set(Tabular::SET_BOTTOM_SPACE, "default"); bottomspaceED->setEnabled(false); bottomspaceUnit->setEnabled(false); break; } case 2: { - if (!bottomspaceED->text().isEmpty()) - set(Tabular::SET_BOTTOM_SPACE, - widgetsToLength(bottomspaceED, - bottomspaceUnit)); if (!bc().policy().isReadOnly()) { bottomspaceED->setEnabled(true); bottomspaceUnit->setEnabled(true); @@ -293,22 +281,16 @@ void GuiTabular::interlinespace_changed() { switch (interlinespaceCO->currentIndex()) { case 0: { - set(Tabular::SET_INTERLINE_SPACE, ""); - interlinespaceED->setEnabled(false); - interlinespaceUnit->setEnabled(false); + interlinespaceED->setEnabled(false); + interlinespaceUnit->setEnabled(false); break; } case 1: { - set(Tabular::SET_INTERLINE_SPACE, "default"); interlinespaceED->setEnabled(false); interlinespaceUnit->setEnabled(false); break; } case 2: { - if (!interlinespaceED->text().isEmpty()) - set(Tabular::SET_INTERLINE_SPACE, - widgetsToLength(interlinespaceED, - interlinespaceUnit)); if (!bc().policy().isReadOnly()) { interlinespaceED->setEnabled(true); interlinespaceUnit->setEnabled(true); @@ -320,359 +302,345 @@ void GuiTabular::interlinespace_changed() } -void GuiTabular::close_clicked() +void GuiTabular::booktabsChanged(bool) { - closeGUI(); - slotClose(); + if (booktabsRB->isChecked()) { + borders->setLeft(false); + borders->setRight(false); + borders->setLeftEnabled(false); + borders->setRightEnabled(false); + } else { + borders->setLeftEnabled(true); + borders->setRightEnabled(true); + } + // repaint the setborder widget + borders->update(); + changed(); } void GuiTabular::borderSet_clicked() { - set(Tabular::SET_ALL_LINES); - update_borders(); + borders->setTop(true); + borders->setBottom(true); + borders->setLeft(true); + borders->setRight(true); + // repaint the setborder widget + borders->update(); changed(); } void GuiTabular::borderUnset_clicked() { - set(Tabular::UNSET_ALL_LINES); - update_borders(); + borders->setTop(false); + borders->setBottom(false); + borders->setLeft(false); + borders->setRight(false); + // repaint the setborder widget + borders->update(); changed(); } -void GuiTabular::leftBorder_changed() +void GuiTabular::update_borders() { - set(Tabular::TOGGLE_LINE_LEFT); - changed(); + Tabular::idx_type const cell = getActiveCell(); + borders->setTop(tabular_.topLine(cell)); + borders->setBottom(tabular_.bottomLine(cell)); + borders->setLeft(tabular_.leftLine(cell)); + borders->setRight(tabular_.rightLine(cell)); + borders->setLeftEnabled(!booktabsRB->isChecked()); + borders->setRightEnabled(!booktabsRB->isChecked()); + // repaint the setborder widget + borders->update(); } -void GuiTabular::rightBorder_changed() -{ - set(Tabular::TOGGLE_LINE_RIGHT); - changed(); -} - +namespace { -void GuiTabular::topBorder_changed() +Length getColumnPWidth(Tabular const & t, size_t cell) { - set(Tabular::TOGGLE_LINE_TOP); - changed(); + return t.column_info[t.cellColumn(cell)].p_width; } -void GuiTabular::bottomBorder_changed() +Length getMColumnPWidth(Tabular const & t, size_t cell) { - set(Tabular::TOGGLE_LINE_BOTTOM); - changed(); + if (t.isMultiColumn(cell)) + return t.cellInfo(cell).p_width; + return Length(); } -void GuiTabular::specialAlignment_changed() +docstring getAlignSpecial(Tabular const & t, size_t cell, int what) { - string special = fromqstr(specialAlignmentED->text()); - setSpecial(special); - changed(); + if (what == Tabular::SET_SPECIAL_MULTI) + return t.cellInfo(cell).align_special; + return t.column_info[t.cellColumn(cell)].align_special; } - -void GuiTabular::width_changed() -{ - changed(); - string const width = widgetsToLength(widthED, widthUnit); - setWidth(width); } -void GuiTabular::multicolumn_clicked() +void GuiTabular::applyView() { - toggleMultiColumn(); - changed(); -} + applying_ = true; + Tabular::idx_type const cell = getActiveCell(); + Tabular::row_type const row = tabular_.cellRow(cell); + bool const multicol = tabular_.isMultiColumn(cell); -void GuiTabular::rotateTabular() -{ - rotateTabular(rotateTabularCB->isChecked()); - changed(); -} - + Tabular::Feature num = Tabular::ALIGN_LEFT; + Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT; -void GuiTabular::rotateCell() -{ - rotateCell(rotateCellCB->isChecked()); - changed(); -} + switch (hAlignCB->currentIndex()) { + case 0: + num = Tabular::ALIGN_LEFT; + multi_num = Tabular::M_ALIGN_LEFT; + break; + case 1: + num = Tabular::ALIGN_CENTER; + multi_num = Tabular::M_ALIGN_CENTER; + break; + case 2: + num = Tabular::ALIGN_RIGHT; + multi_num = Tabular::M_ALIGN_RIGHT; + break; + case 3: + num = Tabular::ALIGN_BLOCK; + //multi_num: no equivalent + break; + } + if (multicol) + set(multi_num); + else + set(num); + num = Tabular::VALIGN_MIDDLE; + multi_num = Tabular::M_VALIGN_MIDDLE; -void GuiTabular::hAlign_changed(int align) -{ - GuiTabular::HALIGN h = GuiTabular::LEFT; + switch (vAlignCB->currentIndex()) { + case 0: + num = Tabular::VALIGN_TOP; + multi_num = Tabular::M_VALIGN_TOP; + break; + case 1: + num = Tabular::VALIGN_MIDDLE; + multi_num = Tabular::M_VALIGN_MIDDLE; + break; + case 2: + num = Tabular::VALIGN_BOTTOM; + multi_num = Tabular::M_VALIGN_BOTTOM; + break; + } + if (multicol) + set(multi_num); + else + set(num); - switch (align) { - case 0: h = GuiTabular::LEFT; break; - case 1: h = GuiTabular::CENTER; break; - case 2: h = GuiTabular::RIGHT; break; - case 3: h = GuiTabular::BLOCK; break; + switch (TableAlignCB->currentIndex()) { + case 0: + set(Tabular::TABULAR_VALIGN_TOP); + break; + case 1: + set(Tabular::TABULAR_VALIGN_MIDDLE); + break; + case 2: + set(Tabular::TABULAR_VALIGN_BOTTOM); + break; } - halign(h); -} + string value; + value = fromqstr(specialAlignmentED->text()); + if (multicol) + set(Tabular::SET_SPECIAL_MULTI, value); + else + set(Tabular::SET_SPECIAL_COLUMN, value); -void GuiTabular::vAlign_changed(int align) -{ - GuiTabular::VALIGN v = GuiTabular::TOP; + value = widgetsToLength(widthED, widthUnitCB); + if (multicol) + set(Tabular::SET_MPWIDTH, value); + else + set(Tabular::SET_PWIDTH, value); - switch (align) { - case 0: v = GuiTabular::TOP; break; - case 1: v = GuiTabular::MIDDLE; break; - case 2: v = GuiTabular::BOTTOM; break; - } + if (multicolumnCB->isChecked() != multicol) + set(Tabular::MULTICOLUMN);; - valign(v); -} + if (rotateTabularCB->isChecked()) + set(Tabular::SET_ROTATE_TABULAR); + else + set(Tabular::UNSET_ROTATE_TABULAR); + if (rotateCellCB->isChecked()) + set(Tabular::SET_ROTATE_CELL); + else + set(Tabular::UNSET_ROTATE_CELL); -void GuiTabular::tableAlignment_changed(int align) -{ - switch (align) { - case 0: set(Tabular::TABULAR_VALIGN_TOP); + // Borders + if (borders->getLeft() != tabular_.leftLine(cell)) + set(Tabular::TOGGLE_LINE_LEFT); + if (borders->getRight() != tabular_.rightLine(cell)) + set(Tabular::TOGGLE_LINE_RIGHT); + if (borders->getTop() != tabular_.topLine(cell)) + set(Tabular::TOGGLE_LINE_TOP); + if (borders->getBottom() != tabular_.bottomLine(cell)) + set(Tabular::TOGGLE_LINE_BOTTOM); + + if (booktabsRB->isChecked()) + set(Tabular::SET_BOOKTABS); + else + set(Tabular::UNSET_BOOKTABS); + + switch (topspaceCO->currentIndex()) { + case 0: + set(Tabular::SET_TOP_SPACE, ""); break; - case 1: set(Tabular::TABULAR_VALIGN_MIDDLE); + case 1: + set(Tabular::SET_TOP_SPACE, "default"); break; - case 2: set(Tabular::TABULAR_VALIGN_BOTTOM); + case 2: + set(Tabular::SET_TOP_SPACE, + widgetsToLength(topspaceED, + topspaceUnit)); + break; + } + + switch (bottomspaceCO->currentIndex()) { + case 0: + set(Tabular::SET_BOTTOM_SPACE, ""); + break; + case 1: + set(Tabular::SET_BOTTOM_SPACE, "default"); + break; + case 2: + set(Tabular::SET_BOTTOM_SPACE, + widgetsToLength(bottomspaceED, + bottomspaceUnit)); break; } -} - - -void GuiTabular::longTabular() -{ - longTabular(longTabularCB->isChecked()); - changed(); -} - - -void GuiTabular::ltNewpage_clicked() -{ - set(Tabular::SET_LTNEWPAGE); - changed(); -} - -void GuiTabular::on_captionStatusCB_toggled() -{ - set(Tabular::TOGGLE_LTCAPTION); - changed(); -} + switch (interlinespaceCO->currentIndex()) { + case 0: + set(Tabular::SET_INTERLINE_SPACE, ""); + break; + case 1: + set(Tabular::SET_INTERLINE_SPACE, "default"); + break; + case 2: + set(Tabular::SET_INTERLINE_SPACE, + widgetsToLength(interlinespaceED, + interlinespaceUnit)); + break; + } + // Longtabular + if (longTabularCB->isChecked()) + set(Tabular::SET_LONGTABULAR); + else + set(Tabular::UNSET_LONGTABULAR); -void GuiTabular::ltHeaderStatus_clicked() -{ - bool enable = headerStatusCB->isChecked(); - if (enable) + if (headerStatusCB->isChecked()) set(Tabular::SET_LTHEAD, ""); else set(Tabular::UNSET_LTHEAD, ""); - changed(); -} - - -void GuiTabular::ltHeaderBorderAbove_clicked() -{ + if (headerBorderAboveCB->isChecked()) set(Tabular::SET_LTHEAD, "dl_above"); else set(Tabular::UNSET_LTHEAD, "dl_above"); - changed(); -} + if (headerBorderAboveCB->isChecked()) + set(Tabular::SET_LTHEAD, "dl_above"); + else + set(Tabular::UNSET_LTHEAD, "dl_above"); -void GuiTabular::ltHeaderBorderBelow_clicked() -{ if (headerBorderBelowCB->isChecked()) set(Tabular::SET_LTHEAD, "dl_below"); else set(Tabular::UNSET_LTHEAD, "dl_below"); - changed(); -} - -void GuiTabular::ltFirstHeaderBorderAbove_clicked() -{ if (firstheaderBorderAboveCB->isChecked()) set(Tabular::SET_LTFIRSTHEAD, "dl_above"); else set(Tabular::UNSET_LTFIRSTHEAD, "dl_above"); - changed(); -} - -void GuiTabular::ltFirstHeaderBorderBelow_clicked() -{ if (firstheaderBorderBelowCB->isChecked()) set(Tabular::SET_LTFIRSTHEAD, "dl_below"); else set(Tabular::UNSET_LTFIRSTHEAD, "dl_below"); - changed(); -} - -void GuiTabular::ltFirstHeaderStatus_clicked() -{ - bool enable = firstheaderStatusCB->isChecked(); - if (enable) + if (firstheaderStatusCB->isChecked()) set(Tabular::SET_LTFIRSTHEAD, ""); else set(Tabular::UNSET_LTFIRSTHEAD, ""); - changed(); -} - -void GuiTabular::ltFirstHeaderEmpty_clicked() -{ - bool enable = firstheaderNoContentsCB->isChecked(); - if (enable) + if (firstheaderNoContentsCB->isChecked()) set(Tabular::SET_LTFIRSTHEAD, "empty"); else set(Tabular::UNSET_LTFIRSTHEAD, "empty"); - changed(); -} - -void GuiTabular::ltFooterStatus_clicked() -{ - bool enable = footerStatusCB->isChecked(); - if (enable) + if (footerStatusCB->isChecked()) set(Tabular::SET_LTFOOT, ""); else set(Tabular::UNSET_LTFOOT, ""); - changed(); -} - -void GuiTabular::ltFooterBorderAbove_clicked() -{ if (footerBorderAboveCB->isChecked()) set(Tabular::SET_LTFOOT, "dl_above"); else set(Tabular::UNSET_LTFOOT, "dl_above"); - changed(); -} - -void GuiTabular::ltFooterBorderBelow_clicked() -{ if (footerBorderBelowCB->isChecked()) set(Tabular::SET_LTFOOT, "dl_below"); else set(Tabular::UNSET_LTFOOT, "dl_below"); - changed(); -} - -void GuiTabular::ltLastFooterStatus_clicked() -{ - bool enable = lastfooterStatusCB->isChecked(); - if (enable) + if (lastfooterStatusCB->isChecked()) set(Tabular::SET_LTLASTFOOT, ""); else set(Tabular::UNSET_LTLASTFOOT, ""); - changed(); -} - -void GuiTabular::ltLastFooterBorderAbove_clicked() -{ if (lastfooterBorderAboveCB->isChecked()) set(Tabular::SET_LTLASTFOOT, "dl_above"); else set(Tabular::UNSET_LTLASTFOOT, "dl_above"); - changed(); -} - -void GuiTabular::ltLastFooterBorderBelow_clicked() -{ if (lastfooterBorderBelowCB->isChecked()) set(Tabular::SET_LTLASTFOOT, "dl_below"); else set(Tabular::UNSET_LTLASTFOOT, "dl_below"); - changed(); -} - -void GuiTabular::ltLastFooterEmpty_clicked() -{ - bool enable = lastfooterNoContentsCB->isChecked(); - if (enable) + if (lastfooterNoContentsCB->isChecked()) set(Tabular::SET_LTLASTFOOT, "empty"); else set(Tabular::UNSET_LTLASTFOOT, "empty"); - changed(); -} + if (newpageCB->isChecked() != tabular_.getLTNewPage(row)) + set(Tabular::SET_LTNEWPAGE); + + if (captionStatusCB->isChecked() != tabular_.ltCaption(row)) + set(Tabular::TOGGLE_LTCAPTION); -void GuiTabular::ltAlignment_clicked() -{ if (leftRB->isChecked()) set(Tabular::LONGTABULAR_ALIGN_LEFT); else if (centerRB->isChecked()) set(Tabular::LONGTABULAR_ALIGN_CENTER); else if (rightRB->isChecked()) set(Tabular::LONGTABULAR_ALIGN_RIGHT); - changed(); -} - - -void GuiTabular::update_borders() -{ - Tabular::idx_type const cell = getActiveCell(); - borders->setTop(tabular_.topLine(cell)); - borders->setBottom(tabular_.bottomLine(cell)); - borders->setLeft(tabular_.leftLine(cell)); - borders->setRight(tabular_.rightLine(cell)); - // repaint the setborder widget - borders->update(); -} - - -namespace { - -Length getColumnPWidth(Tabular const & t, size_t cell) -{ - return t.column_info[t.cellColumn(cell)].p_width; -} - - -Length getMColumnPWidth(Tabular const & t, size_t cell) -{ - if (t.isMultiColumn(cell)) - return t.cellInfo(cell).p_width; - return Length(); -} - - -docstring getAlignSpecial(Tabular const & t, size_t cell, int what) -{ - if (what == Tabular::SET_SPECIAL_MULTI) - return t.cellInfo(cell).align_special; - return t.column_info[t.cellColumn(cell)].align_special; -} + applying_ = false; } - void GuiTabular::updateContents() { + if (applying_) + return; + initialiseParams(string()); - size_t const cell = getActiveCell(); + Tabular::idx_type const cell = getActiveCell(); Tabular::row_type const row = tabular_.cellRow(cell); Tabular::col_type const col = tabular_.cellColumn(cell); @@ -769,13 +737,15 @@ void GuiTabular::updateContents() interlinespaceCO->setEnabled(!isReadonly); string colwidth; - if (!pwidth.zero()) + if (!pwidth.zero()) { colwidth = pwidth.asString(); - lengthToWidgets(widthED, widthUnit, - colwidth, default_unit); + + lengthToWidgets(widthED, widthUnitCB, + colwidth, default_unit); + } widthED->setEnabled(!isReadonly); - widthUnit->setEnabled(!isReadonly); + widthUnitCB->setEnabled(!isReadonly); hAlignCB->clear(); hAlignCB->addItem(qt_("Left")); @@ -1004,100 +974,6 @@ void GuiTabular::updateContents() } -void GuiTabular::closeGUI() -{ - // ugly hack to auto-apply the stuff that hasn't been - // yet. don't let this continue to exist ... - - // Subtle here, we must /not/ apply any changes and - // then refer to tabular, as it will have been freed - // since the changes update the actual tabular_ - // - // apply the fixed width values - size_t const cell = getActiveCell(); - bool const multicol = tabular_.isMultiColumn(cell); - string width = widgetsToLength(widthED, widthUnit); - string width2; - - Length llen = getColumnPWidth(tabular_, cell); - Length llenMulti = getMColumnPWidth(tabular_, cell); - - if (multicol && !llenMulti.zero()) - width2 = llenMulti.asString(); - else if (!multicol && !llen.zero()) - width2 = llen.asString(); - - // apply the special alignment - docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text()); - docstring sa2; - - if (multicol) - sa2 = getAlignSpecial(tabular_, cell, - Tabular::SET_SPECIAL_MULTI); - else - sa2 = getAlignSpecial(tabular_, cell, - Tabular::SET_SPECIAL_COLUMN); - - if (sa1 != sa2) { - if (multicol) - set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1)); - else - set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1)); - } - - if (width != width2) { - if (multicol) - set(Tabular::SET_MPWIDTH, width); - else - set(Tabular::SET_PWIDTH, width); - } - - /* DO WE NEED THIS? - switch (topspaceCO->currentIndex()) { - case 0: - set(Tabular::SET_TOP_SPACE, ""); - break; - case 1: - set(Tabular::SET_TOP_SPACE, "default"); - break; - case 2: - set(Tabular::SET_TOP_SPACE, - widgetsToLength(topspaceED, - topspaceUnit)); - break; - } - - switch (bottomspaceCO->currentIndex()) { - case 0: - set(Tabular::SET_BOTTOM_SPACE, ""); - break; - case 1: - set(Tabular::SET_BOTTOM_SPACE, "default"); - break; - case 2: - set(Tabular::SET_BOTTOM_SPACE, - widgetsToLength(bottomspaceED, - bottomspaceUnit)); - break; - } - - switch (interlinespaceCO->currentIndex()) { - case 0: - set(Tabular::SET_INTERLINE_SPACE, ""); - break; - case 1: - set(Tabular::SET_INTERLINE_SPACE, "default"); - break; - case 2: - set(Tabular::SET_INTERLINE_SPACE, - widgetsToLength(interlinespaceED, - interlinespaceUnit)); - break; - } -*/ -} - - bool GuiTabular::initialiseParams(string const & data) { // try to get the current cell @@ -1121,7 +997,7 @@ bool GuiTabular::initialiseParams(string const & data) return true; } - InsetTabular tmp(const_cast(buffer())); + InsetTabular tmp(const_cast(&buffer())); InsetTabular::string2params(data, tmp); tabular_ = Tabular(tmp.tabular); return true; @@ -1134,7 +1010,7 @@ void GuiTabular::clearParams() // is still open. At that time, the buffer might not be available // anymore. if (isBufferAvailable()) { - InsetTabular tmp(const_cast(buffer())); + InsetTabular tmp(const_cast(&buffer())); tabular_ = tmp.tabular; } active_cell_ = Tabular::npos; @@ -1154,127 +1030,6 @@ void GuiTabular::set(Tabular::Feature f, string const & arg) } -void GuiTabular::setSpecial(string const & special) -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::SET_SPECIAL_MULTI, special); - else - set(Tabular::SET_SPECIAL_COLUMN, special); -} - - -void GuiTabular::setWidth(string const & width) -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::SET_MPWIDTH, width); - else - set(Tabular::SET_PWIDTH, width); - - updateView(); -} - - -void GuiTabular::toggleMultiColumn() -{ - set(Tabular::MULTICOLUMN); - updateView(); -} - - -void GuiTabular::rotateTabular(bool yes) -{ - if (yes) - set(Tabular::SET_ROTATE_TABULAR); - else - set(Tabular::UNSET_ROTATE_TABULAR); -} - - -void GuiTabular::rotateCell(bool yes) -{ - if (yes) - set(Tabular::SET_ROTATE_CELL); - else - set(Tabular::UNSET_ROTATE_CELL); -} - - -void GuiTabular::halign(GuiTabular::HALIGN h) -{ - Tabular::Feature num = Tabular::ALIGN_LEFT; - Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT; - - switch (h) { - case LEFT: - num = Tabular::ALIGN_LEFT; - multi_num = Tabular::M_ALIGN_LEFT; - break; - case CENTER: - num = Tabular::ALIGN_CENTER; - multi_num = Tabular::M_ALIGN_CENTER; - break; - case RIGHT: - num = Tabular::ALIGN_RIGHT; - multi_num = Tabular::M_ALIGN_RIGHT; - break; - case BLOCK: - num = Tabular::ALIGN_BLOCK; - //multi_num: no equivalent - break; - } - - if (tabular_.isMultiColumn(getActiveCell())) - set(multi_num); - else - set(num); -} - - -void GuiTabular::valign(GuiTabular::VALIGN v) -{ - Tabular::Feature num = Tabular::VALIGN_MIDDLE; - Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE; - - switch (v) { - case TOP: - num = Tabular::VALIGN_TOP; - multi_num = Tabular::M_VALIGN_TOP; - break; - case MIDDLE: - num = Tabular::VALIGN_MIDDLE; - multi_num = Tabular::M_VALIGN_MIDDLE; - break; - case BOTTOM: - num = Tabular::VALIGN_BOTTOM; - multi_num = Tabular::M_VALIGN_BOTTOM; - break; - } - - if (tabular_.isMultiColumn(getActiveCell())) - set(multi_num); - else - set(num); -} - - -void GuiTabular::booktabs(bool yes) -{ - if (yes) - set(Tabular::SET_BOOKTABS); - else - set(Tabular::UNSET_BOOKTABS); -} - - -void GuiTabular::longTabular(bool yes) -{ - if (yes) - set(Tabular::SET_LONGTABULAR); - else - set(Tabular::UNSET_LONGTABULAR); -} - - // to get the status of the longtable row settings bool GuiTabular::funcEnabled(Tabular::Feature f) const {