]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiTabular.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiTabular.cpp
index ef85e10121d6828bcef7e8ef88a03cd6bc881bf2..312b14fd874b0639e06be08b0158e5871db3de55 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "insets/InsetTabular.h"
 
+#include "support/convert.h"
 #include "support/debug.h"
 
 #include <QCheckBox>
@@ -126,7 +127,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()));
@@ -142,8 +143,12 @@ GuiTabular::GuiTabular(QWidget * parent)
                this, SLOT(checkEnabled()));
        connect(rotateTabularCB, SIGNAL(clicked()),
                this, SLOT(checkEnabled()));
+       connect(rotateTabularAngleSB, SIGNAL(valueChanged(int)),
+               this, SLOT(checkEnabled()));
        connect(rotateCellCB, SIGNAL(clicked()),
                this, SLOT(checkEnabled()));
+       connect(rotateCellAngleSB, SIGNAL(valueChanged(int)),
+               this, SLOT(checkEnabled()));
        connect(TableAlignCO, SIGNAL(activated(int)),
                this, SLOT(checkEnabled()));
        connect(longTabularCB, SIGNAL(clicked()),
@@ -199,24 +204,32 @@ void GuiTabular::checkEnabled()
        // if there is a LaTeX argument, the width and alignment will be overwritten
        // therefore disable them in this case
        columnWidthED->setEnabled(specialAlignmentED->text().isEmpty());
+       columnWidthUnitLC->setEnabled(specialAlignmentED->text().isEmpty());
        // if the column has a width, multirows are always left-aligned
        // therefore disable hAlignCB in this case
        hAlignCO->setEnabled(!(multirowCB->isChecked()
                && !widgetsToLength(columnWidthED, columnWidthUnitLC).empty())
                && specialAlignmentED->text().isEmpty());
+       // decimal alignment is only possible for non-multicol and non-multirow cells
+       if ((multicolumnCB->isChecked() || multirowCB->isChecked())
+               && hAlignCO->findData(toqstr("decimal")))
+               hAlignCO->removeItem(hAlignCO->findData(toqstr("decimal")));
+       else if (!multicolumnCB->isChecked() && !multirowCB->isChecked()
+               && hAlignCO->findData(toqstr("decimal")) == -1)
+               hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
        bool const dalign = 
                hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal");
        decimalPointED->setEnabled(dalign);
        decimalLA->setEnabled(dalign);
 
        bool const setwidth = TableAlignCO->currentText() == qt_("Middle")
-               && !longTabularCB->isChecked() && !rotateTabularCB->isChecked();
+               && !longTabularCB->isChecked();
        tabularWidthLA->setEnabled(setwidth);
        tabularWidthED->setEnabled(setwidth);
        tabularWidthUnitLC->setEnabled(setwidth);
 
-       bool const is_tabular_star = !tabularWidthED->text().isEmpty();
-       rotateTabularCB->setDisabled(is_tabular_star);
+       rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked());
+       rotateCellAngleSB->setEnabled(rotateCellCB->isChecked());
 
        bool const enable_valign =
                !multirowCB->isChecked()
@@ -234,6 +247,7 @@ void GuiTabular::checkEnabled()
        interlinespaceUnitLC->setEnabled(interlinespaceCO->currentIndex() == 2);
 
        // setting as longtable is not allowed when table is inside a float
+       bool const is_tabular_star = !tabularWidthED->text().isEmpty();
        longTabularCB->setEnabled(!is_tabular_star && funcEnabled(Tabular::SET_LONGTABULAR));
        bool const longtabular = longTabularCB->isChecked();
        longtableGB->setEnabled(true);
@@ -298,8 +312,10 @@ void GuiTabular::checkEnabled()
        captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION)
                && longtabular);
 
-       multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
-       multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
+       multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN)
+               && !dalign && !multirowCB->isChecked());
+       multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW)
+               && !dalign && !multicolumnCB->isChecked());
        bool const enable_mr = multirowCB->isChecked();
        multirowOffsetLA->setEnabled(enable_mr);
        multirowOffsetED->setEnabled(enable_mr);
@@ -444,7 +460,7 @@ docstring GuiTabular::dialogToParams() const
 
        // apply the column alignment
        // multirows inherit the alignment from the column; if a column width
-       // is set, multicolumns are always left-aligned so that in this case
+       // is set, multirows are always left-aligned so that in this case
        // its alignment must not be applied (see bug #8084)
        if (!(multirowCB->isChecked() && width != "0pt"))
                setHAlign(param_str);
@@ -554,16 +570,18 @@ docstring GuiTabular::dialogToParams() const
                setParam(param_str, Tabular::SET_MULTIROW);
        else
                setParam(param_str, Tabular::UNSET_MULTIROW);
-       //
+       // store the table rotation angle
+       string const tabular_angle = convert<string>(rotateTabularAngleSB->value());
        if (rotateTabularCB->isChecked())
-               setParam(param_str, Tabular::SET_ROTATE_TABULAR);
+               setParam(param_str, Tabular::SET_ROTATE_TABULAR, tabular_angle);
        else
-               setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
-       //
+               setParam(param_str, Tabular::UNSET_ROTATE_TABULAR, tabular_angle);
+       // store the cell rotation angle
+       string const cell_angle = convert<string>(rotateCellAngleSB->value());
        if (rotateCellCB->isChecked())
-               setParam(param_str, Tabular::SET_ROTATE_CELL);
+               setParam(param_str, Tabular::SET_ROTATE_CELL, cell_angle);
        else
-               setParam(param_str, Tabular::UNSET_ROTATE_CELL);
+               setParam(param_str, Tabular::UNSET_ROTATE_CELL, cell_angle);
        //
        if (longTabularCB->isChecked())
                setParam(param_str, Tabular::SET_LONGTABULAR);
@@ -572,6 +590,8 @@ docstring GuiTabular::dialogToParams() const
        //
        if (newpageCB->isChecked())
                setParam(param_str, Tabular::SET_LTNEWPAGE);
+    else
+               setParam(param_str, Tabular::UNSET_LTNEWPAGE);
        //
        if (captionStatusCB->isChecked())
                setParam(param_str, Tabular::SET_LTCAPTION);
@@ -699,8 +719,17 @@ void GuiTabular::paramsToDialog(Inset const * inset)
        bool const multirow = tabular.isMultiRow(cell);
        multirowCB->setChecked(multirow);
 
-       rotateCellCB->setChecked(tabular.getRotateCell(cell));
-       rotateTabularCB->setChecked(tabular.rotate);
+       rotateCellCB->setChecked(tabular.getRotateCell(cell) != 0);
+       if (rotateCellCB->isChecked()) {
+               if (tabular.getRotateCell(cell) != 0)
+                       rotateCellAngleSB->setValue(tabular.getRotateCell(cell));
+               else
+                       rotateCellAngleSB->setValue(90);
+       }
+
+       rotateTabularCB->setChecked(tabular.rotate != 0);
+       if (rotateTabularCB->isChecked())
+               rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90);
 
        longTabularCB->setChecked(tabular.is_long_tabular);
 
@@ -805,7 +834,7 @@ void GuiTabular::paramsToDialog(Inset const * inset)
        hAlignCO->addItem(qt_("Right"), toqstr("right"));
        if (!multicol && !pwidth.zero())
                hAlignCO->addItem(qt_("Justified"), toqstr("justified"));
-       if (!multicol)
+       if (!multicol && !multirow)
                hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
 
        string align;
@@ -827,7 +856,7 @@ void GuiTabular::paramsToDialog(Inset const * inset)
                }
                case LYX_ALIGN_DECIMAL:
                {
-                       if (!multicol)
+                       if (!multicol && !multirow)
                                align = "decimal";
                        break;
                }