]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiTabular.cpp
Do not show master's errors if compiling child
[lyx.git] / src / frontends / qt4 / GuiTabular.cpp
index 3e2fafccf58b60d9e17b49b1b6fa49c188b9e8cc..151a714ae974d976bc6b8ea8cc68e810fdbafe63 100644 (file)
@@ -45,7 +45,9 @@ namespace lyx {
 namespace frontend {
 
 GuiTabular::GuiTabular(QWidget * parent)
-       : InsetParamsWidget(parent)
+       : InsetParamsWidget(parent), firstheader_suppressable_(false),
+         lastfooter_suppressable_(false)
+
 {
        setupUi(this);
 
@@ -127,7 +129,7 @@ GuiTabular::GuiTabular(QWidget * parent)
                this, SLOT(checkEnabled()));
        connect(captionStatusCB, SIGNAL(clicked()),
                this, SLOT(checkEnabled()));
-       connect(specialAlignmentED, SIGNAL(editingFinished()),
+       connect(specialAlignmentED, SIGNAL(textEdited(const QString &)),
                this, SLOT(checkEnabled()));
        connect(columnWidthED, SIGNAL(textEdited(const QString &)),
                this, SLOT(checkEnabled()));
@@ -199,7 +201,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
@@ -217,7 +219,7 @@ void GuiTabular::checkEnabled()
        else if (!multicolumnCB->isChecked() && !multirowCB->isChecked()
                && hAlignCO->findData(toqstr("decimal")) == -1)
                hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
-       bool const dalign = 
+       bool const dalign =
                hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal");
        decimalPointED->setEnabled(dalign);
        decimalLA->setEnabled(dalign);
@@ -256,6 +258,12 @@ void GuiTabular::checkEnabled()
        // longtables and tabular* cannot have a vertical alignment
        TableAlignLA->setDisabled(is_tabular_star || longtabular);
        TableAlignCO->setDisabled(is_tabular_star || longtabular);
+       // longtable cannot be rotated (with rotating package)
+       // FIXME: Add support for [pdf]lscape
+       rotateTabularCB->setDisabled(longtabular);
+       rotateTabularLA->setDisabled(longtabular);
+       // this one would also be disabled with [pdf]lscape
+       rotateTabularAngleSB->setDisabled(longtabular);
 
        // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
        // depending on the cursor position is very very unintuitive...
@@ -321,6 +329,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();
 }
 
@@ -438,8 +455,7 @@ void GuiTabular::setTableAlignment(string & param_str) const
 
 docstring GuiTabular::dialogToParams() const
 {
-       // FIXME: We should use Tabular directly.
-       string param_str = "tabular from-dialog";
+       string param_str = "tabular";
 
        // table width
        string tabwidth = widgetsToLength(tabularWidthED, tabularWidthUnitLC);
@@ -746,7 +762,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 +781,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 +793,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();
@@ -1012,10 +1031,54 @@ void GuiTabular::paramsToDialog(Inset const * inset)
 }
 
 
+bool GuiTabular::checkWidgets(bool readonly) const
+{
+       tabularRowED->setReadOnly(readonly);
+       tabularColumnED->setReadOnly(readonly);
+       tabularWidthED->setReadOnly(readonly);
+       specialAlignmentED->setReadOnly(readonly);
+       columnWidthED->setReadOnly(readonly);
+       multirowOffsetED->setReadOnly(readonly);
+       decimalPointED->setReadOnly(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();
+}
+
+
 bool GuiTabular::funcEnabled(Tabular::Feature f) const
 {
-       string cmd = "tabular " + featureAsString(f);
-       return getStatus(FuncRequest(LFUN_INSET_MODIFY, cmd)).enabled();
+       FuncRequest r(LFUN_INSET_MODIFY, "tabular for-dialog" + featureAsString(f));
+       return getStatus(r).enabled();
 }