From 3410d6ad3ebd55fdbc1f625e90ef97f060bf60fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 29 Jan 2010 14:52:15 +0000 Subject: [PATCH] revert unintended commit parts. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33263 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiSetBorder.cpp | 8 +- src/frontends/qt4/GuiTabular.cpp | 934 ++++++++------ src/frontends/qt4/GuiTabular.h | 58 +- src/frontends/qt4/ui/TabularUi.ui | 1808 +++++++++++++--------------- 4 files changed, 1510 insertions(+), 1298 deletions(-) diff --git a/src/frontends/qt4/GuiSetBorder.cpp b/src/frontends/qt4/GuiSetBorder.cpp index 0d49f11127..dd13288e06 100644 --- a/src/frontends/qt4/GuiSetBorder.cpp +++ b/src/frontends/qt4/GuiSetBorder.cpp @@ -119,7 +119,7 @@ void GuiSetBorder::drawLeft(bool draw) { QColor col(draw ? Qt::black : Qt::white); if (!left_.enabled) - col = QColor(Qt::lightGray); + col = QColor("grey"); drawLine(col, m + l, m + l + 2, m + l, h - m - l - 1); } @@ -128,7 +128,7 @@ void GuiSetBorder::drawRight(bool draw) { QColor col(draw ? Qt::black : Qt::white); if (!right_.enabled) - col = QColor(Qt::lightGray); + col = QColor("grey"); drawLine(col, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1); } @@ -137,7 +137,7 @@ void GuiSetBorder::drawTop(bool draw) { QColor col(draw ? Qt::black : Qt::white); if (!top_.enabled) - col = QColor(Qt::lightGray); + col = QColor("grey"); drawLine(col, m + l + 2, m + l, w - m - l - 1, m + l); } @@ -146,7 +146,7 @@ void GuiSetBorder::drawBottom(bool draw) { QColor col(draw ? Qt::black : Qt::white); if (!bottom_.enabled) - col = QColor(Qt::lightGray); + col = QColor("grey"); drawLine(col, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1); } diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index 2a6a26bb3a..e66f97896d 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -42,25 +42,12 @@ namespace frontend { GuiTabular::GuiTabular(GuiView & lv) : GuiDialog(lv, "tabular", qt_("Table Settings")), // tabular_ is initialised at dialog construction in initialiseParams() - tabular_(&(lv.currentBufferView()->buffer()), 0, 0), - applying_(false) + tabular_(&(lv.currentBufferView()->buffer()), 0, 0) { 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)); @@ -68,22 +55,22 @@ GuiTabular::GuiTabular(GuiView & lv) widthUnitCB->setCurrentItem(Length::defaultUnit()); - connect(topspaceED, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); + connect(topspaceED, SIGNAL(returnPressed()), + this, SLOT(topspace_changed())); connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(change_adaptor())); + this, SLOT(topspace_changed())); connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed())); - connect(bottomspaceED, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); + connect(bottomspaceED, SIGNAL(returnPressed()), + this, SLOT(bottomspace_changed())); connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(change_adaptor())); + this, SLOT(bottomspace_changed())); connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed())); - connect(interlinespaceED, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); + connect(interlinespaceED, SIGNAL(returnPressed()), + this, SLOT(interlinespace_changed())); connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(change_adaptor())); + this, SLOT(interlinespace_changed())); connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed())); connect(booktabsRB, SIGNAL(clicked(bool)), @@ -104,66 +91,74 @@ GuiTabular::GuiTabular(GuiView & lv) connect(longTabularCB, SIGNAL(toggled(bool)), TableAlignCB, SLOT(setDisabled(bool))); connect(hAlignCB, SIGNAL(activated(int)), - this, SLOT(change_adaptor())); + this, SLOT(hAlign_changed(int))); connect(vAlignCB, SIGNAL(activated(int)), - this, SLOT(change_adaptor())); + this, SLOT(vAlign_changed(int))); connect(multicolumnCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(multicolumn_clicked())); connect(newpageCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); - connect(captionStatusCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltNewpage_clicked())); connect(headerStatusCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltHeaderStatus_clicked())); connect(headerBorderAboveCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltHeaderBorderAbove_clicked())); connect(headerBorderBelowCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltHeaderBorderBelow_clicked())); connect(firstheaderStatusCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFirstHeaderStatus_clicked())); connect(firstheaderBorderAboveCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFirstHeaderBorderAbove_clicked())); connect(firstheaderBorderBelowCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFirstHeaderBorderBelow_clicked())); connect(firstheaderNoContentsCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFirstHeaderEmpty_clicked())); connect(footerStatusCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFooterStatus_clicked())); connect(footerBorderAboveCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFooterBorderAbove_clicked())); connect(footerBorderBelowCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltFooterBorderBelow_clicked())); connect(lastfooterStatusCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltLastFooterStatus_clicked())); connect(lastfooterBorderAboveCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltLastFooterBorderAbove_clicked())); connect(lastfooterBorderBelowCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltLastFooterBorderBelow_clicked())); connect(lastfooterNoContentsCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); - connect(specialAlignmentED, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); - connect(widthED, SIGNAL(textChanged(QString)), - this, SLOT(change_adaptor())); + this, SLOT(ltLastFooterEmpty_clicked())); + connect(specialAlignmentED, SIGNAL(returnPressed()), + this, SLOT(specialAlignment_changed())); + connect(widthED, SIGNAL(editingFinished()), + this, SLOT(width_changed())); connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)), - this, SLOT(change_adaptor())); - connect(borders, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + 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())); connect(rotateTabularCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(rotateTabular())); connect(rotateCellCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(rotateCell())); connect(TableAlignCB, SIGNAL(activated(int)), - this, SLOT(change_adaptor())); + this, SLOT(tableAlignment_changed(int))); connect(longTabularCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(longTabular())); connect(leftRB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltAlignment_clicked())); connect(centerRB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); + this, SLOT(ltAlignment_clicked())); connect(rightRB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); - + this, SLOT(ltAlignment_clicked())); + + bc().setPolicy(ButtonPolicy::IgnorantPolicy); + bc().addReadOnly(topspaceED); bc().addReadOnly(topspaceUnit); bc().addReadOnly(topspaceCO); @@ -227,20 +222,34 @@ 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); @@ -256,16 +265,22 @@ void GuiTabular::bottomspace_changed() { switch (bottomspaceCO->currentIndex()) { case 0: { - bottomspaceED->setEnabled(false); - bottomspaceUnit->setEnabled(false); + set(Tabular::SET_BOTTOM_SPACE, ""); + 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); @@ -281,16 +296,22 @@ void GuiTabular::interlinespace_changed() { switch (interlinespaceCO->currentIndex()) { case 0: { - interlinespaceED->setEnabled(false); - interlinespaceUnit->setEnabled(false); + set(Tabular::SET_INTERLINE_SPACE, ""); + 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); @@ -302,43 +323,311 @@ void GuiTabular::interlinespace_changed() } -void GuiTabular::booktabsChanged(bool) +void GuiTabular::close_clicked() { - 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(); + closeGUI(); + slotClose(); } void GuiTabular::borderSet_clicked() { - borders->setTop(true); - borders->setBottom(true); - borders->setLeft(true); - borders->setRight(true); - // repaint the setborder widget - borders->update(); + set(Tabular::SET_ALL_LINES); + update_borders(); changed(); } void GuiTabular::borderUnset_clicked() { - borders->setTop(false); - borders->setBottom(false); - borders->setLeft(false); - borders->setRight(false); - // repaint the setborder widget - borders->update(); + set(Tabular::UNSET_ALL_LINES); + update_borders(); + changed(); +} + + +void GuiTabular::leftBorder_changed() +{ + set(Tabular::TOGGLE_LINE_LEFT); + changed(); +} + + +void GuiTabular::rightBorder_changed() +{ + set(Tabular::TOGGLE_LINE_RIGHT); + changed(); +} + + +void GuiTabular::topBorder_changed() +{ + set(Tabular::TOGGLE_LINE_TOP); + changed(); +} + + +void GuiTabular::bottomBorder_changed() +{ + set(Tabular::TOGGLE_LINE_BOTTOM); + changed(); +} + + +void GuiTabular::specialAlignment_changed() +{ + string special = fromqstr(specialAlignmentED->text()); + setSpecial(special); + changed(); +} + + +void GuiTabular::width_changed() +{ + changed(); + string const width = widgetsToLength(widthED, widthUnitCB); + setWidth(width); +} + + +void GuiTabular::multicolumn_clicked() +{ + toggleMultiColumn(); + changed(); +} + + +void GuiTabular::rotateTabular() +{ + rotateTabular(rotateTabularCB->isChecked()); + changed(); +} + + +void GuiTabular::rotateCell() +{ + rotateCell(rotateCellCB->isChecked()); + changed(); +} + + +void GuiTabular::hAlign_changed(int align) +{ + GuiTabular::HALIGN h = GuiTabular::LEFT; + + 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; + } + + halign(h); +} + + +void GuiTabular::vAlign_changed(int align) +{ + GuiTabular::VALIGN v = GuiTabular::TOP; + + switch (align) { + case 0: v = GuiTabular::TOP; break; + case 1: v = GuiTabular::MIDDLE; break; + case 2: v = GuiTabular::BOTTOM; break; + } + + valign(v); +} + + +void GuiTabular::tableAlignment_changed(int align) +{ + switch (align) { + case 0: set(Tabular::TABULAR_VALIGN_TOP); + break; + case 1: set(Tabular::TABULAR_VALIGN_MIDDLE); + break; + case 2: set(Tabular::TABULAR_VALIGN_BOTTOM); + 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(); +} + + +void GuiTabular::ltHeaderStatus_clicked() +{ + bool enable = headerStatusCB->isChecked(); + if (enable) + 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(); +} + + +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) + set(Tabular::SET_LTFIRSTHEAD, ""); + else + set(Tabular::UNSET_LTFIRSTHEAD, ""); + changed(); +} + + +void GuiTabular::ltFirstHeaderEmpty_clicked() +{ + bool enable = firstheaderNoContentsCB->isChecked(); + if (enable) + set(Tabular::SET_LTFIRSTHEAD, "empty"); + else + set(Tabular::UNSET_LTFIRSTHEAD, "empty"); + changed(); +} + + +void GuiTabular::ltFooterStatus_clicked() +{ + bool enable = footerStatusCB->isChecked(); + if (enable) + 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) + 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) + set(Tabular::SET_LTLASTFOOT, "empty"); + else + set(Tabular::UNSET_LTLASTFOOT, "empty"); + changed(); +} + + +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(); } @@ -350,8 +639,6 @@ void GuiTabular::update_borders() 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(); } @@ -383,264 +670,12 @@ docstring getAlignSpecial(Tabular const & t, size_t cell, int what) } -void GuiTabular::applyView() -{ - applying_ = true; - - Tabular::idx_type const cell = getActiveCell(); - Tabular::row_type const row = tabular_.cellRow(cell); - bool const multicol = tabular_.isMultiColumn(cell); - - Tabular::Feature num = Tabular::ALIGN_LEFT; - Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT; - - 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; - - 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 (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; - } - - string value; - - value = fromqstr(specialAlignmentED->text()); - if (multicol) - set(Tabular::SET_SPECIAL_MULTI, value); - else - set(Tabular::SET_SPECIAL_COLUMN, value); - - value = widgetsToLength(widthED, widthUnitCB); - if (multicol) - set(Tabular::SET_MPWIDTH, value); - else - set(Tabular::SET_PWIDTH, value); - - if (multicolumnCB->isChecked() != multicol) - set(Tabular::MULTICOLUMN);; - - 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); - - // 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::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; - } - - // Longtabular - if (longTabularCB->isChecked()) - set(Tabular::SET_LONGTABULAR); - else - set(Tabular::UNSET_LONGTABULAR); - - if (headerStatusCB->isChecked()) - set(Tabular::SET_LTHEAD, ""); - else - set(Tabular::UNSET_LTHEAD, ""); - - if (headerBorderAboveCB->isChecked()) - set(Tabular::SET_LTHEAD, "dl_above"); - else - set(Tabular::UNSET_LTHEAD, "dl_above"); - - if (headerBorderAboveCB->isChecked()) - set(Tabular::SET_LTHEAD, "dl_above"); - else - set(Tabular::UNSET_LTHEAD, "dl_above"); - - if (headerBorderBelowCB->isChecked()) - set(Tabular::SET_LTHEAD, "dl_below"); - else - set(Tabular::UNSET_LTHEAD, "dl_below"); - - if (firstheaderBorderAboveCB->isChecked()) - set(Tabular::SET_LTFIRSTHEAD, "dl_above"); - else - set(Tabular::UNSET_LTFIRSTHEAD, "dl_above"); - - if (firstheaderBorderBelowCB->isChecked()) - set(Tabular::SET_LTFIRSTHEAD, "dl_below"); - else - set(Tabular::UNSET_LTFIRSTHEAD, "dl_below"); - - if (firstheaderStatusCB->isChecked()) - set(Tabular::SET_LTFIRSTHEAD, ""); - else - set(Tabular::UNSET_LTFIRSTHEAD, ""); - - if (firstheaderNoContentsCB->isChecked()) - set(Tabular::SET_LTFIRSTHEAD, "empty"); - else - set(Tabular::UNSET_LTFIRSTHEAD, "empty"); - - if (footerStatusCB->isChecked()) - set(Tabular::SET_LTFOOT, ""); - else - set(Tabular::UNSET_LTFOOT, ""); - - if (footerBorderAboveCB->isChecked()) - set(Tabular::SET_LTFOOT, "dl_above"); - else - set(Tabular::UNSET_LTFOOT, "dl_above"); - - if (footerBorderBelowCB->isChecked()) - set(Tabular::SET_LTFOOT, "dl_below"); - else - set(Tabular::UNSET_LTFOOT, "dl_below"); - - if (lastfooterStatusCB->isChecked()) - set(Tabular::SET_LTLASTFOOT, ""); - else - set(Tabular::UNSET_LTLASTFOOT, ""); - - if (lastfooterBorderAboveCB->isChecked()) - set(Tabular::SET_LTLASTFOOT, "dl_above"); - else - set(Tabular::UNSET_LTLASTFOOT, "dl_above"); - - if (lastfooterBorderBelowCB->isChecked()) - set(Tabular::SET_LTLASTFOOT, "dl_below"); - else - set(Tabular::UNSET_LTLASTFOOT, "dl_below"); - - if (lastfooterNoContentsCB->isChecked()) - set(Tabular::SET_LTLASTFOOT, "empty"); - else - set(Tabular::UNSET_LTLASTFOOT, "empty"); - - if (newpageCB->isChecked() != tabular_.getLTNewPage(row)) - set(Tabular::SET_LTNEWPAGE); - - if (captionStatusCB->isChecked() != tabular_.ltCaption(row)) - set(Tabular::TOGGLE_LTCAPTION); - - 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); - - applying_ = false; -} - void GuiTabular::updateContents() { - if (applying_) - return; - initialiseParams(string()); - Tabular::idx_type const cell = getActiveCell(); + size_t const cell = getActiveCell(); Tabular::row_type const row = tabular_.cellRow(cell); Tabular::col_type const col = tabular_.cellColumn(cell); @@ -974,6 +1009,100 @@ 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, widthUnitCB); + 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 @@ -1030,6 +1159,127 @@ 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 { diff --git a/src/frontends/qt4/GuiTabular.h b/src/frontends/qt4/GuiTabular.h index e546e831ab..158a0ad6f1 100644 --- a/src/frontends/qt4/GuiTabular.h +++ b/src/frontends/qt4/GuiTabular.h @@ -37,18 +37,49 @@ private Q_SLOTS: void bottomspace_changed(); void interlinespace_changed(); void booktabsChanged(bool); + void close_clicked(); void borderSet_clicked(); void borderUnset_clicked(); + void leftBorder_changed(); + void rightBorder_changed(); + void topBorder_changed(); + void bottomBorder_changed(); + void multicolumn_clicked(); + void rotateTabular(); + void rotateCell(); + void hAlign_changed(int align); + void vAlign_changed(int align); + void tableAlignment_changed(int align); + void specialAlignment_changed(); + void width_changed(); + void longTabular(); + void ltNewpage_clicked(); + void ltHeaderStatus_clicked(); + void ltHeaderBorderAbove_clicked(); + void ltHeaderBorderBelow_clicked(); + void ltFirstHeaderStatus_clicked(); + void ltFirstHeaderBorderAbove_clicked(); + void ltFirstHeaderBorderBelow_clicked(); + void ltFirstHeaderEmpty_clicked(); + void ltFooterStatus_clicked(); + void ltFooterBorderAbove_clicked(); + void ltFooterBorderBelow_clicked(); + void ltLastFooterStatus_clicked(); + void ltLastFooterBorderAbove_clicked(); + void ltLastFooterBorderBelow_clicked(); + void ltLastFooterEmpty_clicked(); + void ltAlignment_clicked(); + void on_captionStatusCB_toggled(); private: /// bool isValid() { return true; } /// update borders void update_borders(); - /// - void applyView(); /// update void updateContents(); + /// save some values before closing the gui + void closeGUI(); /// bool initialiseParams(std::string const & data); /// clean-up on hide. @@ -65,14 +96,33 @@ private: /// set a parameter void set(Tabular::Feature, std::string const & arg = std::string()); + void setSpecial(std::string const & special); + + void setWidth(std::string const & width); + + void toggleMultiColumn(); + + void rotateTabular(bool yes); + void rotateCell(bool yes); + + enum HALIGN { LEFT, RIGHT, CENTER, BLOCK }; + + void halign(HALIGN h); + + enum VALIGN { TOP, MIDDLE, BOTTOM }; + + void valign(VALIGN h); + + void booktabs(bool yes); + + void longTabular(bool yes); + bool funcEnabled(Tabular::Feature f) const; /// Tabular::idx_type active_cell_; /// Tabular tabular_; - /// - bool applying_; }; } // namespace frontend diff --git a/src/frontends/qt4/ui/TabularUi.ui b/src/frontends/qt4/ui/TabularUi.ui index cea30780cf..6385ac9ea6 100644 --- a/src/frontends/qt4/ui/TabularUi.ui +++ b/src/frontends/qt4/ui/TabularUi.ui @@ -1,162 +1,188 @@ - + TabularUi - - + + 0 0 - 470 - 491 + 378 + 401 - + - + true - - + + 9 - + 6 - - - - + + + + 6 - - QTabWidget::Rounded - - + 0 - - + + + + Current cell: + + + + + + + + 0 + 0 + + + + + 40 + 32767 + + + + Qt::NoFocus + + + Current row position + + + + + + + + 0 + 0 + + + + + 40 + 32767 + + + + Qt::NoFocus + + + Current column position + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Close + + + false + + + + + + + + + + + + QTabWidget::Rounded + + + 0 + + + &Table Settings - - - 9 - - - 6 - - - - - true - - - Table-wide settings - - - - 9 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 153 - 20 - - - - - - - - true - - - Rotate the table by 90 degrees - - - &Rotate table 90 degrees - - - - - - - Vertical alignment of the table - - - 1 - - - - Top - - - - - Middle - - - - - Bottom - - - - - - - - Verti&cal alignment: - - - vAlignCB - - - - - - - - - + + + + Column settings - - - 9 - - - 6 - - - - - Merge cells + + + + + &Horizontal alignment: - - &Multicolumn + + hAlignCB - + + + + Horizontal alignment in column + + + + Justified + + + + + Left + + + + + Center + + + + + Right + + + + + - + Qt::Horizontal - + QSizePolicy::Expanding - + 40 20 @@ -164,47 +190,41 @@ - - - - Specifies the vertical alignment of this cell in relation to the baseline of the row. + + + + &Width: - - - Top - - - - - Middle - - - - - Bottom - - - - - - - - &Vertical alignment in row: - - - vAlignCB + + widthED - - - + + + + true + + + Fixed width of the column + + + + + + + + + + + + Qt::Horizontal - + QSizePolicy::Expanding - + 7 20 @@ -212,41 +232,47 @@ - - - - - - - true + + + + &Vertical alignment in row: - - Fixed width of the column - - - + + vAlignCB - - - - &Width: - - - widthED + + + + Specifies the vertical alignment of this cell in relation to the baseline of the row. + + + Top + + + + + Middle + + + + + Bottom + + - - - + + + Qt::Horizontal - + QSizePolicy::Expanding - + 40 20 @@ -254,64 +280,31 @@ - - - - Horizontal alignment in column + + + + Merge cells - - - Justified - - - - - Left - - - - - Center - - - - - Right - - - - - - - - &Horizontal alignment: - - - hAlignCB + + &Multicolumn - - - + + + Cell setting - - - 9 - - - 6 - - - - + + + + Rotate this cell by 90 degrees - + Rotate &cell 90 degrees @@ -319,459 +312,293 @@ - - - - 0 + + + + true - - 6 + + Table-wide settings + + + + + Verti&cal alignment: + + + vAlignCB + + + + + + + Vertical alignment of the table + + + 1 + + + + Top + + + + + Middle + + + + + Bottom + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 153 + 20 + + + + + + + + true + + + Rotate the table by 90 degrees + + + &Rotate table 90 degrees + + + + + + + + - - + + LaTe&X argument: - + specialAlignmentED - - + + Custom column format (LaTeX) + + + + Qt::Vertical + + + + 20 + 68 + + + + - - + + &Borders - - - 9 - - - 6 - - - - - Qt::Vertical - - - - 20 - 43 - - - - - - - - Additional Space - - - - 9 - - - 6 - - - - - T&op of row: - - - topspaceCO - - - - - - - - - - - - - - None - - - - - Default - - - - - Custom - - - - - - - - - None - - - - - Default - - - - - Custom - - - - - - - - - - - - - - Botto&m of row: - - - bottomspaceCO - - - - - - - - - - Bet&ween rows: - - - interlinespaceCO - - - - - - - - None - - - - - Default - - - - - Custom - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 44 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 63 - 20 - - - - - - - - Style - - - - 9 - - - 6 - - - - - Use formal (a.k.a. booktabs) border style (no vertical borders) - - - Fo&rmal - - - true - - - - - - - Use default (grid-like) border style - - - De&fault - - - - - - - - - - All Borders - - - - 9 - - - 6 - - - - - Set all borders of the current (selected) cell(s) - - - &Set - - - false - - - - - - - Unset all borders of the current (selected) cell(s) - - - C&lear - - - false - - - - - - - - - + + + + Set Borders - - + + 9 - + 6 - - - - - 0 - 0 + + + + 0 0 - + - - - + + + 0 0 0 - - - + + + 230 240 249 - - - + + + 255 255 255 - - - + + + 242 247 252 - - - + + + 115 120 124 - - - + + + 154 160 166 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 16 145 210 - - - + + + 255 255 255 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 232 232 232 @@ -780,153 +607,153 @@ - - - + + + 0 0 0 - - - + + + 230 240 249 - - - + + + 255 255 255 - - - + + + 255 255 255 - - - + + + 115 120 124 - - - + + + 154 160 166 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 16 145 210 - - - + + + 255 255 255 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 232 232 232 @@ -935,153 +762,153 @@ - - - + + + 128 128 128 - - - + + + 230 240 249 - - - + + + 255 255 255 - - - + + + 255 255 255 - - - + + + 115 120 124 - - - + + + 154 160 166 - - - + + + 0 0 0 - - - + + + 255 255 255 - - - + + + 128 128 128 - - - + + + 255 255 255 - - - + + + 255 255 255 - - - + + + 0 0 0 - - - + + + 16 145 210 - - - + + + 255 255 255 - - - + + + 0 0 255 - - - + + + 255 0 255 - - - + + + 232 232 232 @@ -1091,30 +918,28 @@ - + QFrame::StyledPanel - + QFrame::Sunken - - + + 9 - + 6 - - - - - 0 - 0 + + + + 0 0 - + Set borders of the current (selected) cell(s) @@ -1125,245 +950,468 @@ + + + + All Borders + + + + 9 + + + 6 + + + + + Set all borders of the current (selected) cell(s) + + + &Set + + + + + + + Unset all borders of the current (selected) cell(s) + + + C&lear + + + + + + + + + + Style + + + + 9 + + + 6 + + + + + Use formal (a.k.a. booktabs) border style (no vertical borders) + + + Fo&rmal + + + true + + + + + + + Use default (grid-like) border style + + + De&fault + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 63 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 44 + + + + + + + + Additional Space + + + + 9 + + + 6 + + + + + T&op of row: + + + topspaceCO + + + + + + + + + + + + + + None + + + + + Default + + + + + Custom + + + + + + + + + None + + + + + Default + + + + + Custom + + + + + + + + + + + + + + Botto&m of row: + + + bottomspaceCO + + + + + + + + + + Bet&ween rows: + + + interlinespaceCO + + + + + + + + None + + + + + Default + + + + + Custom + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 43 + + + + - - + + &Longtable - - - 9 - - - 6 - - - - + + + + Select for tables that span multiple pages - + &Use long table - - - + + + false - + Row settings - - - 9 - - - 6 - - - - + + + + Status - - - + + + Border above - - - + + + Border below - - - + + + Contents - - - + + + Header: - - - + + + Repeat this row as header on every (except the first) page - + on - - - + + + - + double - - - + + + double - - - + + + First header: - - - + + + This row is the header of the first page - + - + on - - - + + + double - - - + + + double - - - + + + Don't output the first header - + is empty - - - + + + Footer: - - - + + + Repeat this row as footer on every (except the last) page - + on - - - + + + double - - - + + + double - - - + + + Last footer: - - - + + + This row is the footer of the last page - + on - - - + + + double - - - + + + double - - - + + + Don't output the last footer - + is empty - - - + + + Caption: - - - + + + on - - - + + + false - + Set a page break on the current row - + Page &break on current row @@ -1371,44 +1419,38 @@ - - - + + + false - + Horizontal alignment of the longtable - + Longtable alignment - - - 9 - - - 6 - - - - + + + + Left - - - + + + Center - + true - - - + + + Right @@ -1416,154 +1458,23 @@ + + + + Qt::Vertical + + + + 20 + 91 + + + + - - - - 0 - - - 6 - - - - - &Restore - - - false - - - - - - - Qt::Horizontal - - - - 31 - 27 - - - - - - - - &OK - - - true - - - - - - - &Apply - - - false - - - - - - - &Cancel - - - false - - - - - - - - - 0 - - - 6 - - - - - Current cell: - - - - - - - - 0 - 0 - 0 - 0 - - - - - 40 - 32767 - - - - Qt::NoFocus - - - Current row position - - - - - - - - 0 - 0 - 0 - 0 - - - - - 40 - 32767 - - - - Qt::NoFocus - - - Current column position - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - @@ -1588,6 +1499,7 @@ rotateTabularCB rotateCellCB specialAlignmentED + closePB borderSetPB borderUnsetPB borderDefaultRB @@ -1619,7 +1531,7 @@ newpageCB - qt_i18n.h + qt_i18n.h