Fix UI for decimal table alignment (bug #8285)

Fixes 2 issues:
1. LyX uses for a decimal alignment a multicolumn and having for a cell a multicolumn _and_ a multirow is invalid LaTeX.
2. It was impossible to unset a decimal alignment via the context menu or toolbar button.
This commit is contained in:
Uwe Stöhr 2012-09-11 02:10:29 +02:00
parent 92363ce20d
commit 9d05ac5c91
2 changed files with 15 additions and 5 deletions

View File

@ -209,6 +209,13 @@ void GuiTabular::checkEnabled()
hAlignCO->setEnabled(!(multirowCB->isChecked() hAlignCO->setEnabled(!(multirowCB->isChecked()
&& !widgetsToLength(columnWidthED, columnWidthUnitLC).empty()) && !widgetsToLength(columnWidthED, columnWidthUnitLC).empty())
&& specialAlignmentED->text().isEmpty()); && specialAlignmentED->text().isEmpty());
// decimal alignment is only possible for non-multicol and non-multirow cells
if ((multicolumnCB->isChecked() || multirowCB->isChecked())
&& hAlignCO->findText(qt_("At Decimal Separator")))
hAlignCO->removeItem(3);
else if (!multicolumnCB->isChecked() && !multirowCB->isChecked()
&& !hAlignCO->findText(qt_("At Decimal Separator")))
hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
bool const dalign = bool const dalign =
hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal"); hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal");
decimalPointED->setEnabled(dalign); decimalPointED->setEnabled(dalign);
@ -304,8 +311,8 @@ void GuiTabular::checkEnabled()
captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION) captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION)
&& longtabular); && longtabular);
multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN)); multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN) && !dalign);
multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW)); multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW) && !dalign);
bool const enable_mr = multirowCB->isChecked(); bool const enable_mr = multirowCB->isChecked();
multirowOffsetLA->setEnabled(enable_mr); multirowOffsetLA->setEnabled(enable_mr);
multirowOffsetED->setEnabled(enable_mr); multirowOffsetED->setEnabled(enable_mr);
@ -824,7 +831,7 @@ void GuiTabular::paramsToDialog(Inset const * inset)
hAlignCO->addItem(qt_("Right"), toqstr("right")); hAlignCO->addItem(qt_("Right"), toqstr("right"));
if (!multicol && !pwidth.zero()) if (!multicol && !pwidth.zero())
hAlignCO->addItem(qt_("Justified"), toqstr("justified")); hAlignCO->addItem(qt_("Justified"), toqstr("justified"));
if (!multicol) if (!multicol && !multirow)
hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal")); hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
string align; string align;
@ -846,7 +853,7 @@ void GuiTabular::paramsToDialog(Inset const * inset)
} }
case LYX_ALIGN_DECIMAL: case LYX_ALIGN_DECIMAL:
{ {
if (!multicol) if (!multicol && !multirow)
align = "decimal"; align = "decimal";
break; break;
} }

View File

@ -5234,7 +5234,10 @@ void InsetTabular::tabularFeatures(Cursor & cur,
break; break;
case Tabular::ALIGN_DECIMAL: case Tabular::ALIGN_DECIMAL:
setAlign = LYX_ALIGN_DECIMAL; if (tabular.column_info[tabular.cellColumn(cur.idx())].alignment == LYX_ALIGN_DECIMAL)
setAlign = LYX_ALIGN_LEFT;
else
setAlign = LYX_ALIGN_DECIMAL;
break; break;
case Tabular::M_VALIGN_TOP: case Tabular::M_VALIGN_TOP: