]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiTabular.cpp
If we are in a closeEvent, we don't want to close all buffers, because these may...
[lyx.git] / src / frontends / qt4 / GuiTabular.cpp
index c162f1fa0cd234487f9a44975fa84cfc9e81893c..25d5427685209530e292016148dc175876ff25df 100644 (file)
@@ -6,6 +6,7 @@
  * \author John Levon
  * \author Jürgen Spitzmüller
  * \author Herbert Voß
+ * \author Uwe Stöhr
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -52,6 +53,8 @@ GuiTabular::GuiTabular(GuiView & lv)
        bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
        interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
 
+       widthUnitCB->setCurrentItem(Length::defaultUnit());
+
        connect(topspaceED, SIGNAL(returnPressed()),
                this, SLOT(topspace_changed()));
        connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
@@ -84,6 +87,9 @@ GuiTabular::GuiTabular(GuiView & lv)
                newpageCB, SLOT(setEnabled(bool)));
        connect(longTabularCB, SIGNAL(toggled(bool)),
                alignmentGB, SLOT(setEnabled(bool)));
+       // longtables cannot have a vertical alignment
+       connect(longTabularCB, SIGNAL(toggled(bool)),
+               TableAlignCB, SLOT(setDisabled(bool)));
        connect(hAlignCB, SIGNAL(activated(int)),
                this, SLOT(hAlign_changed(int)));
        connect(vAlignCB, SIGNAL(activated(int)),
@@ -124,7 +130,7 @@ GuiTabular::GuiTabular(GuiView & lv)
                this, SLOT(specialAlignment_changed()));
        connect(widthED, SIGNAL(editingFinished()),
                this, SLOT(width_changed()));
-       connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+       connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
                this, SLOT(width_changed()));
        connect(closePB, SIGNAL(clicked()),
                this, SLOT(close_clicked()));
@@ -170,7 +176,7 @@ GuiTabular::GuiTabular(GuiView & lv)
        bc().addReadOnly(rotateTabularCB);
        bc().addReadOnly(specialAlignmentED);
        bc().addReadOnly(widthED);
-       bc().addReadOnly(widthUnit);
+       bc().addReadOnly(widthUnitCB);
        bc().addReadOnly(hAlignCB);
        bc().addReadOnly(vAlignCB);
        bc().addReadOnly(TableAlignCB);
@@ -379,7 +385,7 @@ void GuiTabular::specialAlignment_changed()
 void GuiTabular::width_changed()
 {
        changed();
-       string const width = widgetsToLength(widthED, widthUnit);
+       string const width = widgetsToLength(widthED, widthUnitCB);
        setWidth(width);
 }
 
@@ -766,13 +772,15 @@ void GuiTabular::updateContents()
        interlinespaceCO->setEnabled(!isReadonly);
 
        string colwidth;
-       if (!pwidth.zero())
+       if (!pwidth.zero()) {
                colwidth = pwidth.asString();
-       lengthToWidgets(widthED, widthUnit,
-               colwidth, default_unit);
+
+               lengthToWidgets(widthED, widthUnitCB,
+                       colwidth, default_unit);
+       }
 
        widthED->setEnabled(!isReadonly);
-       widthUnit->setEnabled(!isReadonly);
+       widthUnitCB->setEnabled(!isReadonly);
 
        hAlignCB->clear();
        hAlignCB->addItem(qt_("Left"));
@@ -826,7 +834,7 @@ void GuiTabular::updateContents()
        hAlignCB->setEnabled(true);
        vAlignCB->setEnabled(!pwidth.zero());
 
-       int tableValign = 0;
+       int tableValign = 1;
        switch (tabular_.tabular_valignment) {
        case Tabular::LYX_VALIGN_TOP:
                tableValign = 0;
@@ -864,7 +872,9 @@ void GuiTabular::updateContents()
                captionStatusCB->setChecked(false);
                captionStatusCB->blockSignals(false);
                return;
-       }
+       } else
+               // longtables cannot have a vertical alignment
+               TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
 
        switch (tabular_.longtabular_alignment) {
        case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
@@ -1011,7 +1021,7 @@ void GuiTabular::closeGUI()
        // apply the fixed width values
        size_t const cell = getActiveCell();
        bool const multicol = tabular_.isMultiColumn(cell);
-       string width = widgetsToLength(widthED, widthUnit);
+       string width = widgetsToLength(widthED, widthUnitCB);
        string width2;
 
        Length llen = getColumnPWidth(tabular_, cell);