]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiTabular.cpp
Amend f441590c
[lyx.git] / src / frontends / qt4 / GuiTabular.cpp
index 55c3edab267e09c30bfd6fba92b99297988dea4a..495b2c62776aeb9105833791dba734f1bd42064b 100644 (file)
@@ -199,7 +199,7 @@ void GuiTabular::on_interlinespaceCO_activated(int index)
 }
 
 
-void GuiTabular::checkEnabled()
+void GuiTabular::enableWidgets() const
 {
        // if there is a LaTeX argument, the width and alignment will be overwritten
        // therefore disable them in this case
@@ -321,6 +321,15 @@ void GuiTabular::checkEnabled()
        multirowOffsetED->setEnabled(enable_mr);
        multirowOffsetUnitLC->setEnabled(enable_mr);
 
+       // Vertical lines cannot be set in formal tables
+       borders->setLeftEnabled(!booktabsRB->isChecked());
+       borders->setRightEnabled(!booktabsRB->isChecked());
+}
+
+
+void GuiTabular::checkEnabled()
+{
+       enableWidgets();
        changed();
 }
 
@@ -746,7 +755,8 @@ void GuiTabular::paramsToDialog(Inset const * inset)
        // Set width and alignment
 
        Length const tabwidth = tabular.tabularWidth();
-       if (tabwidth.zero())
+       if (tabwidth.zero()
+           && !(tabularWidthED->hasFocus() && tabularWidthED->text() == "0"))
                tabularWidthED->clear();
        else
                lengthToWidgets(tabularWidthED, tabularWidthUnitLC,
@@ -764,7 +774,8 @@ void GuiTabular::paramsToDialog(Inset const * inset)
                pwidth = getColumnPWidth(tabular, cell);
        }
        string colwidth;
-       if (pwidth.zero())
+       if (pwidth.zero()
+           && !(columnWidthED->hasFocus() && columnWidthED->text() == "0"))
                columnWidthED->clear();
        else {
                colwidth = pwidth.asString();
@@ -775,7 +786,8 @@ void GuiTabular::paramsToDialog(Inset const * inset)
        if (multirow)
                mroffset = getMROffset(tabular, cell);
        string offset;
-       if (mroffset.zero())
+       if (mroffset.zero()
+           && !(multirowOffsetED->hasFocus() && multirowOffsetED->text() == "0"))
                multirowOffsetED->clear();
        else {
                offset = mroffset.asString();
@@ -1016,37 +1028,41 @@ bool GuiTabular::checkWidgets(bool readonly) const
 {
        tabularRowED->setReadOnly(readonly);
        tabularColumnED->setReadOnly(readonly);
-       multicolumnCB->setEnabled(!readonly);
-       multirowCB->setEnabled(!readonly);
-       specialAlignmentED->setReadOnly(readonly);
-       rotateCellCB->setEnabled(!readonly);
-       rotateCellAngleSB->setEnabled(!readonly);
-       rotateTabularCB->setEnabled(!readonly);
-       rotateTabularAngleSB->setEnabled(!readonly);
-       longTabularCB->setEnabled(!readonly);
-       borders->setEnabled(!readonly);
        tabularWidthED->setReadOnly(readonly);
-       tabularWidthUnitLC->setEnabled(!readonly);
+       specialAlignmentED->setReadOnly(readonly);
        columnWidthED->setReadOnly(readonly);
-       columnWidthUnitLC->setEnabled(!readonly);
        multirowOffsetED->setReadOnly(readonly);
-       multirowOffsetUnitLC->setEnabled(!readonly);
-       setBordersGB->setEnabled(!readonly);
-       allBordersGB->setEnabled(!readonly);
-       borderStyleGB->setEnabled(!readonly);
-       booktabsRB->setEnabled(!readonly);
-       topspaceCO->setEnabled(!readonly);
-       topspaceUnitLC->setEnabled(!readonly);
-       bottomspaceCO->setEnabled(!readonly);
-       bottomspaceUnitLC->setEnabled(!readonly);
-       interlinespaceCO->setEnabled(!readonly);
-       interlinespaceUnitLC->setEnabled(!readonly);
-       hAlignCO->setEnabled(!readonly);
        decimalPointED->setReadOnly(readonly);
-       vAlignCO->setEnabled(!readonly);
-       TableAlignCO->setEnabled(!readonly);
-       longtableGB->setEnabled(!readonly);
-       alignmentGB->setEnabled(!readonly);
+
+       if (readonly) {
+               multicolumnCB->setEnabled(false);
+               multirowCB->setEnabled(false);
+               rotateCellCB->setEnabled(false);
+               rotateCellAngleSB->setEnabled(false);
+               rotateTabularCB->setEnabled(false);
+               rotateTabularAngleSB->setEnabled(false);
+               longTabularCB->setEnabled(false);
+               borders->setEnabled(false);
+               tabularWidthUnitLC->setEnabled(false);
+               columnWidthUnitLC->setEnabled(false);
+               multirowOffsetUnitLC->setEnabled(false);
+               setBordersGB->setEnabled(false);
+               allBordersGB->setEnabled(false);
+               borderStyleGB->setEnabled(false);
+               booktabsRB->setEnabled(false);
+               topspaceCO->setEnabled(false);
+               topspaceUnitLC->setEnabled(false);
+               bottomspaceCO->setEnabled(false);
+               bottomspaceUnitLC->setEnabled(false);
+               interlinespaceCO->setEnabled(false);
+               interlinespaceUnitLC->setEnabled(false);
+               hAlignCO->setEnabled(false);
+               vAlignCO->setEnabled(false);
+               TableAlignCO->setEnabled(false);
+               longtableGB->setEnabled(false);
+               alignmentGB->setEnabled(false);
+       } else
+               enableWidgets();
 
        return InsetParamsWidget::checkWidgets();
 }