#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LyX.h"
+#include "LyXRC.h"
#include "insets/InsetTabular.h"
{
setupUi(this);
- widthED->setValidator(unsignedLengthValidator(widthED));
+ tabularWidthED->setValidator(unsignedLengthValidator(tabularWidthED));
+ columnWidthED->setValidator(unsignedLengthValidator(columnWidthED));
+ multirowOffsetED->setValidator(new LengthValidator(multirowOffsetED));
topspaceED->setValidator(new LengthValidator(topspaceED));
bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
- widthUnitCB->setCurrentItem(Length::defaultUnit());
+ tabularWidthUnitLC->setCurrentItem(Length::defaultUnit());
+ columnWidthUnitLC->setCurrentItem(Length::defaultUnit());
+ multirowOffsetUnitLC->setCurrentItem(Length::defaultUnit());
+ topspaceUnitLC->setCurrentItem(Length::defaultUnit());
+ bottomspaceUnitLC->setCurrentItem(Length::defaultUnit());
+ interlinespaceUnitLC->setCurrentItem(Length::defaultUnit());
- connect(topspaceED, SIGNAL(returnPressed()),
+ connect(topspaceED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
- connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ connect(topspaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SLOT(checkEnabled()));
- connect(topspaceCO, SIGNAL(activated(int)),
+ connect(bottomspaceED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
- connect(bottomspaceED, SIGNAL(returnPressed()),
+ connect(bottomspaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SLOT(checkEnabled()));
- connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ connect(interlinespaceED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
- connect(bottomspaceCO, SIGNAL(activated(int)),
- this, SLOT(checkEnabled()));
- connect(interlinespaceED, SIGNAL(returnPressed()),
- this, SLOT(checkEnabled()));
- connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
- this, SLOT(checkEnabled()));
- connect(interlinespaceCO, SIGNAL(activated(int)),
+ connect(interlinespaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SLOT(checkEnabled()));
connect(booktabsRB, SIGNAL(clicked(bool)),
this, SLOT(checkEnabled()));
this, SLOT(checkEnabled()));
connect(borderSetPB, SIGNAL(clicked()),
this, SLOT(borderSet_clicked()));
- connect(borderUnsetPB, SIGNAL(clicked()),
+ connect(borderUnsetPB, SIGNAL(clicked()),
this, SLOT(borderUnset_clicked()));
- connect(longTabularCB, SIGNAL(toggled(bool)),
- longtableGB, SLOT(setEnabled(bool)));
- connect(longTabularCB, SIGNAL(toggled(bool)),
- 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(checkEnabled()));
- connect(vAlignCB, SIGNAL(activated(int)),
+ connect(hAlignCO, SIGNAL(activated(int)),
+ this, SLOT(checkEnabled()));
+ connect(vAlignCO, SIGNAL(activated(int)),
this, SLOT(checkEnabled()));
connect(multicolumnCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
connect(multirowCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
+ connect(multirowOffsetED, SIGNAL(textEdited(const QString &)),
+ this, SLOT(checkEnabled()));
+ connect(multirowOffsetUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(checkEnabled()));
connect(newpageCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
connect(headerStatusCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
connect(lastfooterNoContentsCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
- connect(specialAlignmentED, SIGNAL(returnPressed()),
+ connect(captionStatusCB, SIGNAL(clicked()),
+ this, SLOT(checkEnabled()));
+ connect(specialAlignmentED, SIGNAL(editingFinished()),
this, SLOT(checkEnabled()));
- connect(widthED, SIGNAL(textEdited(QString)),
+ connect(columnWidthED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
- connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ connect(columnWidthUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
this, SLOT(checkEnabled()));
connect(borders, SIGNAL(topSet(bool)),
this, SLOT(checkEnabled()));
this, SLOT(checkEnabled()));
connect(rotateCellCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
- connect(TableAlignCB, SIGNAL(activated(int)),
+ connect(TableAlignCO, SIGNAL(activated(int)),
this, SLOT(checkEnabled()));
connect(longTabularCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
this, SLOT(checkEnabled()));
connect(rightRB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
-
-
+ connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
+ this, SLOT(checkEnabled()));
+
+ decimalPointED->setInputMask("X; ");
+ decimalPointED->setMaxLength(1);
+
// initialize the length validator
- addCheckedWidget(widthED, fixedWidthColLA);
+ addCheckedWidget(columnWidthED, columnWidthLA);
+ addCheckedWidget(multirowOffsetED, multirowOffsetLA);
addCheckedWidget(topspaceED, topspaceLA);
addCheckedWidget(bottomspaceED, bottomspaceLA);
addCheckedWidget(interlinespaceED, interlinespaceLA);
+ addCheckedWidget(tabularWidthED, tabularWidthLA);
+}
+
+
+void GuiTabular::on_topspaceCO_activated(int index)
+{
+ bool const enable = (index == 2);
+ topspaceED->setEnabled(enable);
+ topspaceUnitLC->setEnabled(enable);
+}
+
+
+void GuiTabular::on_bottomspaceCO_activated(int index)
+{
+ bool const enable = (index == 2);
+ bottomspaceED->setEnabled(enable);
+ bottomspaceUnitLC->setEnabled(enable);
+}
+
+
+void GuiTabular::on_interlinespaceCO_activated(int index)
+{
+ bool const enable = (index == 2);
+ interlinespaceED->setEnabled(enable);
+ interlinespaceUnitLC->setEnabled(enable);
}
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());
+ // 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());
+ 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();
+ tabularWidthLA->setEnabled(setwidth);
+ tabularWidthED->setEnabled(setwidth);
+ tabularWidthUnitLC->setEnabled(setwidth);
+
+ bool const is_tabular_star = !tabularWidthED->text().isEmpty();
+ rotateTabularCB->setDisabled(is_tabular_star);
+
+ bool const enable_valign =
+ !multirowCB->isChecked()
+ && !widgetsToLength(columnWidthED, columnWidthUnitLC).empty()
+ && specialAlignmentED->text().isEmpty();
+ vAlignCO->setEnabled(enable_valign);
+ vAlignLA->setEnabled(enable_valign);
+
+ topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
- topspaceUnit->setEnabled(topspaceCO->currentIndex() == 2);
+ topspaceUnitLC->setEnabled(topspaceCO->currentIndex() == 2);
bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
- bottomspaceUnit->setEnabled(bottomspaceCO->currentIndex() == 2);
+ bottomspaceUnitLC->setEnabled(bottomspaceCO->currentIndex() == 2);
interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
- interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
+ interlinespaceUnitLC->setEnabled(interlinespaceCO->currentIndex() == 2);
+
+ // setting as longtable is not allowed when table is inside a float
+ longTabularCB->setEnabled(!is_tabular_star && funcEnabled(Tabular::SET_LONGTABULAR));
+ bool const longtabular = longTabularCB->isChecked();
+ longtableGB->setEnabled(true);
+ newpageCB->setEnabled(longtabular);
+ alignmentGB->setEnabled(longtabular);
+ // longtables and tabular* cannot have a vertical alignment
+ TableAlignLA->setDisabled(is_tabular_star || longtabular);
+ TableAlignCO->setDisabled(is_tabular_star || longtabular);
+
+ // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
+ // depending on the cursor position is very very unintuitive...
+ // We need some edit boxes to show which rows are header/footer/etc
+ // without having to move the cursor first.
+ headerStatusCB->setEnabled(longtabular);
+ headerBorderAboveCB->setEnabled(longtabular
+ && headerStatusCB->isChecked());
+ headerBorderBelowCB->setEnabled(longtabular
+ && headerStatusCB->isChecked());
+
+ // first header can only be suppressed when there is a header
+ // firstheader_suppressable_ is set in paramsToDialog
+ firstheaderNoContentsCB->setEnabled(longtabular && firstheader_suppressable_);
+ // check if setting a first header is allowed
+ // additionally check firstheaderNoContentsCB because when this is
+ // the case a first header makes no sense
+ firstheaderStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD)
+ && longtabular && !firstheaderNoContentsCB->isChecked());
+ firstheaderBorderAboveCB->setEnabled(longtabular
+ && firstheaderStatusCB->isChecked());
+ firstheaderBorderBelowCB->setEnabled(longtabular
+ && firstheaderStatusCB->isChecked());
+
+ footerStatusCB->setEnabled(longtabular);
+ footerBorderAboveCB->setEnabled(longtabular
+ && footerBorderAboveCB->isChecked());
+ footerBorderBelowCB->setEnabled(longtabular
+ && footerBorderAboveCB->isChecked());
+
+ // last footer can only be suppressed when there is a footer
+ // lastfooter_suppressable_ is set in paramsToDialog
+ lastfooterNoContentsCB->setEnabled(longtabular && lastfooter_suppressable_);
+ // check if setting a last footer is allowed
+ // additionally check lastfooterNoContentsCB because when this is
+ // the case a last footer makes no sense
+ lastfooterStatusCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT)
+ && longtabular && !lastfooterNoContentsCB->isChecked());
+ lastfooterBorderAboveCB->setEnabled(longtabular
+ && lastfooterBorderAboveCB->isChecked());
+ lastfooterBorderBelowCB->setEnabled(longtabular
+ && lastfooterBorderAboveCB->isChecked());
+
+ captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION)
+ && longtabular);
+
+ multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
+ multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
+ bool const enable_mr = multirowCB->isChecked();
+ multirowOffsetLA->setEnabled(enable_mr);
+ multirowOffsetED->setEnabled(enable_mr);
+ multirowOffsetUnitLC->setEnabled(enable_mr);
+
changed();
}
}
-// to get the status of the longtable row settings
-static bool funcEnabled(Tabular::Feature f)
-{
- return getStatus(
- FuncRequest(LFUN_INSET_MODIFY, featureAsString(f))).enabled();
-}
-
-
void GuiTabular::setHAlign(string & param_str) const
{
- int const align = hAlignCB->currentIndex();
-
- enum HALIGN { LEFT, RIGHT, CENTER, BLOCK };
- HALIGN h = LEFT;
-
- switch (align) {
- case 0: h = LEFT; break;
- case 1: h = CENTER; break;
- case 2: h = RIGHT; break;
- case 3: h = BLOCK; break;
- }
-
Tabular::Feature num = Tabular::ALIGN_LEFT;
Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
-
- switch (h) {
- case LEFT:
- num = Tabular::ALIGN_LEFT;
- multi_num = Tabular::M_ALIGN_LEFT;
- break;
- case CENTER:
- num = Tabular::ALIGN_CENTER;
- multi_num = Tabular::M_ALIGN_CENTER;
- break;
- case RIGHT:
- num = Tabular::ALIGN_RIGHT;
- multi_num = Tabular::M_ALIGN_RIGHT;
- break;
- case BLOCK:
- num = Tabular::ALIGN_BLOCK;
- //multi_num: no equivalent
- break;
+ string const align =
+ fromqstr(hAlignCO->itemData(hAlignCO->currentIndex()).toString());
+ if (align == "left") {
+ num = Tabular::ALIGN_LEFT;
+ multi_num = Tabular::M_ALIGN_LEFT;
+ } else if (align == "center") {
+ num = Tabular::ALIGN_CENTER;
+ multi_num = Tabular::M_ALIGN_CENTER;
+ } else if (align == "right") {
+ num = Tabular::ALIGN_RIGHT;
+ multi_num = Tabular::M_ALIGN_RIGHT;
+ } else if (align == "justified") {
+ num = Tabular::ALIGN_BLOCK;
+ //multi_num: no equivalent
+ } else if (align == "decimal") {
+ num = Tabular::ALIGN_DECIMAL;
+ //multi_num: no equivalent
}
if (multicolumnCB->isChecked())
void GuiTabular::setVAlign(string & param_str) const
{
- int const align = vAlignCB->currentIndex();
+ int const align = vAlignCO->currentIndex();
enum VALIGN { TOP, MIDDLE, BOTTOM };
VALIGN v = TOP;
void GuiTabular::setTableAlignment(string & param_str) const
{
- int const align = TableAlignCB->currentIndex();
+ int const align = TableAlignCO->currentIndex();
switch (align) {
case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
break;
docstring GuiTabular::dialogToParams() const
{
// FIXME: We should use Tabular directly.
- string param_str = "tabular";
+ string param_str = "tabular from-dialog";
+
+ // table width
+ string tabwidth = widgetsToLength(tabularWidthED, tabularWidthUnitLC);
+ if (tabwidth.empty())
+ tabwidth = "0pt";
+ setParam(param_str, Tabular::SET_TABULAR_WIDTH, tabwidth);
+
+ // apply the fixed width values
+ // this must be done before applying the column alignment
+ // because its value influences the alignment of multirow cells
+ string width = widgetsToLength(columnWidthED, columnWidthUnitLC);
+ if (width.empty())
+ width = "0pt";
+ if (multicolumnCB->isChecked())
+ setParam(param_str, Tabular::SET_MPWIDTH, width);
+ else
+ setParam(param_str, Tabular::SET_PWIDTH, width);
+
+ // apply the column alignment
setHAlign(param_str);
+
+ // SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
+ string decimal_point = fromqstr(decimalPointED->text());
+ if (decimal_point.empty())
+ decimal_point = lyxrc.default_decimal_point;
+ setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
+
setVAlign(param_str);
setTableAlignment(param_str);
//
case 2:
if (!topspaceED->text().isEmpty())
setParam(param_str, Tabular::SET_TOP_SPACE,
- widgetsToLength(topspaceED, topspaceUnit));
+ widgetsToLength(topspaceED, topspaceUnitLC));
break;
}
if (!bottomspaceED->text().isEmpty())
setParam(param_str, Tabular::SET_BOTTOM_SPACE,
widgetsToLength(bottomspaceED,
- bottomspaceUnit));
+ bottomspaceUnitLC));
break;
}
if (!interlinespaceED->text().isEmpty())
setParam(param_str, Tabular::SET_INTERLINE_SPACE,
widgetsToLength(interlinespaceED,
- interlinespaceUnit));
+ interlinespaceUnitLC));
break;
}
&& !borders->getRight())
setParam(param_str, Tabular::UNSET_ALL_LINES);
else {
- if (borders->getLeft() != left_border_set_)
- setParam(param_str, Tabular::TOGGLE_LINE_LEFT);
- if (borders->getRight() != right_border_set_)
- setParam(param_str, Tabular::TOGGLE_LINE_RIGHT);
- if (borders->getTop() != top_border_set_)
- setParam(param_str, Tabular::TOGGLE_LINE_TOP);
- if (borders->getBottom() != bottom_border_set_)
- setParam(param_str, Tabular::TOGGLE_LINE_BOTTOM);
+ setParam(param_str, Tabular::SET_LINE_LEFT,
+ borders->getLeft() ? "true" : "false");
+ setParam(param_str, Tabular::SET_LINE_RIGHT,
+ borders->getRight() ? "true" : "false");
+ setParam(param_str, Tabular::SET_LINE_TOP,
+ borders->getTop() ? "true" : "false");
+ setParam(param_str, Tabular::SET_LINE_BOTTOM,
+ borders->getBottom() ? "true" : "false");
}
// apply the special alignment
special = "none";
if (multicolumnCB->isChecked())
setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
- else if (multirowCB->isChecked())
- setParam(param_str, Tabular::SET_SPECIAL_MULTIROW, special);
else
setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
- // apply the fixed width values
- string width = widgetsToLength(widthED, widthUnitCB);
- if (width.empty())
- width = "0pt";
+ //
if (multicolumnCB->isChecked())
- setParam(param_str, Tabular::SET_MPWIDTH, width);
+ setParam(param_str, Tabular::SET_MULTICOLUMN);
else
- setParam(param_str, Tabular::SET_PWIDTH, width);
+ setParam(param_str, Tabular::UNSET_MULTICOLUMN);
- //
- if (multicolumnCB->isChecked())
- setParam(param_str, Tabular::MULTICOLUMN);
+ // apply the multirow offset
+ string mroffset = widgetsToLength(multirowOffsetED, multirowOffsetUnitLC);
+ if (mroffset.empty())
+ mroffset = "0pt";
+ if (multirowCB->isChecked())
+ setParam(param_str, Tabular::SET_MROFFSET, mroffset);
//
if (multirowCB->isChecked())
- setParam(param_str, Tabular::MULTIROW);
+ setParam(param_str, Tabular::SET_MULTIROW);
+ else
+ setParam(param_str, Tabular::UNSET_MULTIROW);
//
if (rotateTabularCB->isChecked())
setParam(param_str, Tabular::SET_ROTATE_TABULAR);
setParam(param_str, Tabular::SET_LTNEWPAGE);
//
if (captionStatusCB->isChecked())
- setParam(param_str, Tabular::TOGGLE_LTCAPTION);
+ setParam(param_str, Tabular::SET_LTCAPTION);
+ else
+ setParam(param_str, Tabular::UNSET_LTCAPTION);
//
if (headerStatusCB->isChecked())
setParam(param_str, Tabular::SET_LTHEAD, "none");
}
+static Length getMROffset(Tabular const & t, size_t cell)
+{
+ if (t.isMultiRow(cell))
+ return t.cellInfo(cell).mroffset;
+ return Length();
+}
+
+
static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
{
- if (what == Tabular::SET_SPECIAL_MULTICOLUMN
- || what == Tabular::SET_SPECIAL_MULTIROW)
+ if (what == Tabular::SET_SPECIAL_MULTICOLUMN)
return t.cellInfo(cell).align_special;
return t.column_info[t.cellColumn(cell)].align_special;
}
longTabularCB->setChecked(tabular.is_long_tabular);
- //
- top_border_set_ = tabular.topLine(cell);
- bottom_border_set_ = tabular.bottomLine(cell);
- left_border_set_ = tabular.leftLine(cell);
- right_border_set_ = tabular.rightLine(cell);
- borders->setTop(top_border_set_);
- borders->setBottom(bottom_border_set_);
- borders->setLeft(left_border_set_);
- borders->setRight(right_border_set_);
+ borders->setTop(tabular.topLine(cell));
+ borders->setBottom(tabular.bottomLine(cell));
+ borders->setLeft(tabular.leftLine(cell));
+ borders->setRight(tabular.rightLine(cell));
// repaint the setborder widget
borders->update();
+ Length::UNIT const default_unit = Length::defaultUnit();
+
+ ///////////////////////////////////
+ // Set width and alignment
+
+ Length const tabwidth = tabular.tabularWidth();
+ if (tabwidth.zero())
+ tabularWidthED->clear();
+ else
+ lengthToWidgets(tabularWidthED, tabularWidthUnitLC,
+ tabwidth.asString(), default_unit);
+
Length pwidth;
docstring special;
-
if (multicol) {
special = getAlignSpecial(tabular, cell,
Tabular::SET_SPECIAL_MULTICOLUMN);
pwidth = getMColumnPWidth(tabular, cell);
- } else if (multirow) {
- special = getAlignSpecial(tabular, cell,
- Tabular::SET_SPECIAL_MULTIROW);
- pwidth = getMColumnPWidth(tabular, cell);
} else {
special = getAlignSpecial(tabular, cell,
Tabular::SET_SPECIAL_COLUMN);
pwidth = getColumnPWidth(tabular, cell);
}
-
+ string colwidth;
+ if (pwidth.zero())
+ columnWidthED->clear();
+ else {
+ colwidth = pwidth.asString();
+ lengthToWidgets(columnWidthED, columnWidthUnitLC,
+ colwidth, default_unit);
+ }
+ Length mroffset;
+ if (multirow)
+ mroffset = getMROffset(tabular, cell);
+ string offset;
+ if (mroffset.zero())
+ multirowOffsetED->clear();
+ else {
+ offset = mroffset.asString();
+ lengthToWidgets(multirowOffsetED, multirowOffsetUnitLC,
+ offset, default_unit);
+ }
specialAlignmentED->setText(toqstr(special));
+ ///////////////////////////////////
- Length::UNIT const default_unit = Length::defaultUnit();
borderDefaultRB->setChecked(!tabular.use_booktabs);
booktabsRB->setChecked(tabular.use_booktabs);
} else {
topspaceCO->setCurrentIndex(2);
lengthToWidgets(topspaceED,
- topspaceUnit,
+ topspaceUnitLC,
tabular.row_info[row].top_space.asString(),
default_unit);
}
} else {
bottomspaceCO->setCurrentIndex(2);
lengthToWidgets(bottomspaceED,
- bottomspaceUnit,
+ bottomspaceUnitLC,
tabular.row_info[row].bottom_space.asString(),
default_unit);
}
} else {
interlinespaceCO->setCurrentIndex(2);
lengthToWidgets(interlinespaceED,
- interlinespaceUnit,
+ interlinespaceUnitLC,
tabular.row_info[row].interline_space.asString(),
default_unit);
}
- string colwidth;
- if (!pwidth.zero()) {
- colwidth = pwidth.asString();
-
- lengthToWidgets(widthED, widthUnitCB,
- colwidth, default_unit);
- }
- hAlignCB->clear();
- hAlignCB->addItem(qt_("Left"));
- hAlignCB->addItem(qt_("Center"));
- hAlignCB->addItem(qt_("Right"));
+ hAlignCO->clear();
+ hAlignCO->addItem(qt_("Left"), toqstr("left"));
+ hAlignCO->addItem(qt_("Center"), toqstr("center"));
+ hAlignCO->addItem(qt_("Right"), toqstr("right"));
if (!multicol && !pwidth.zero())
- hAlignCB->addItem(qt_("Justified"));
+ hAlignCO->addItem(qt_("Justified"), toqstr("justified"));
+ if (!multicol)
+ hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
- int align = 0;
+ string align;
switch (tabular.getAlignment(cell)) {
- case LYX_ALIGN_LEFT:
- align = 0;
- break;
- case LYX_ALIGN_CENTER:
- align = 1;
- break;
- case LYX_ALIGN_RIGHT:
- align = 2;
- break;
- case LYX_ALIGN_BLOCK:
- {
- if (!multicol && !pwidth.zero())
- align = 3;
- break;
- }
- default:
- align = 0;
- break;
+ case LYX_ALIGN_LEFT:
+ align = "left";
+ break;
+ case LYX_ALIGN_CENTER:
+ align = "center";
+ break;
+ case LYX_ALIGN_RIGHT:
+ align = "right";
+ break;
+ case LYX_ALIGN_BLOCK:
+ {
+ if (!multicol && !pwidth.zero())
+ align = "justified";
+ break;
+ }
+ case LYX_ALIGN_DECIMAL:
+ {
+ if (!multicol)
+ align = "decimal";
+ break;
+ }
+ default:
+ // we should never end up here
+ break;
}
- hAlignCB->setCurrentIndex(align);
+ hAlignCO->setCurrentIndex(hAlignCO->findData(toqstr(align)));
+
+ //
+ QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
+ if (decimal_point.isEmpty())
+ decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
+ decimalPointED->setText(decimal_point);
int valign = 0;
switch (tabular.getVAlignment(cell)) {
}
if (pwidth.zero())
valign = 0;
- vAlignCB->setCurrentIndex(valign);
-
- hAlignCB->setEnabled(true);
- if (!multirow && !pwidth.zero())
- vAlignCB->setEnabled(true);
+ vAlignCO->setCurrentIndex(valign);
int tableValign = 1;
switch (tabular.tabular_valignment) {
tableValign = 0;
break;
}
- TableAlignCB->setCurrentIndex(tableValign);
+ TableAlignCO->setCurrentIndex(tableValign);
if (!tabular.is_long_tabular) {
headerStatusCB->setChecked(false);
lastfooterBorderBelowCB->setChecked(false);
lastfooterNoContentsCB->setChecked(false);
newpageCB->setChecked(false);
- newpageCB->setEnabled(false);
captionStatusCB->blockSignals(true);
captionStatusCB->setChecked(false);
captionStatusCB->blockSignals(false);
+ checkEnabled();
return;
} else {
// longtables cannot have a vertical alignment
- TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
+ TableAlignCO->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
}
switch (tabular.longtabular_alignment) {
case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
captionStatusCB->setChecked(tabular.ltCaption(row));
captionStatusCB->blockSignals(false);
- // FIXME: shouldn't this be handled by GuiDialog?
- // FIXME: Some of them should be handled directly in TabularUI.ui
- firstheaderBorderAboveCB->setEnabled(
- funcEnabled(Tabular::SET_LTFIRSTHEAD));
- firstheaderBorderBelowCB->setEnabled(
- funcEnabled(Tabular::SET_LTFIRSTHEAD));
- // first header can only be suppressed when there is a header
- firstheaderNoContentsCB->setEnabled(tabular.haveLTHead()
- && !tabular.haveLTFirstHead());
-
- //firstheaderStatusCB->setEnabled(
- // !firstheaderNoContentsCB->isChecked());
- headerBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
- headerBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
- headerStatusCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
-
- footerBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
- footerBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
- footerStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
-
- lastfooterBorderAboveCB->setEnabled(
- funcEnabled(Tabular::SET_LTLASTFOOT));
- lastfooterBorderBelowCB->setEnabled(
- funcEnabled(Tabular::SET_LTLASTFOOT));
- // last footer can only be suppressed when there is a footer
- lastfooterNoContentsCB->setEnabled(tabular.haveLTFoot()
- && !tabular.haveLTLastFoot());
-
- captionStatusCB->setEnabled(
- funcEnabled(Tabular::TOGGLE_LTCAPTION));
- // When a row is set as longtable caption, it must not be allowed
- // to unset that this row is a multicolumn.
- multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
- multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
-
Tabular::ltType ltt;
bool use_empty;
bool row_set = tabular.getRowOfLTHead(row, ltt);
} else {
headerBorderAboveCB->setChecked(false);
headerBorderBelowCB->setChecked(false);
- headerBorderAboveCB->setEnabled(false);
- headerBorderBelowCB->setEnabled(false);
firstheaderNoContentsCB->setChecked(false);
- firstheaderNoContentsCB->setEnabled(false);
use_empty = false;
}
row_set = tabular.getRowOfLTFirstHead(row, ltt);
- // check if setting a first header is allowed
- // additionally check firstheaderNoContentsCB because when this is
- // the case a first header makes no sense
- firstheaderStatusCB->setEnabled(
- funcEnabled(Tabular::SET_LTFIRSTHEAD)
- && !firstheaderNoContentsCB->isChecked());
firstheaderStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
firstheaderBorderAboveCB->setChecked(ltt.topDL);
firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
} else {
- firstheaderBorderAboveCB->setEnabled(false);
- firstheaderBorderBelowCB->setEnabled(false);
firstheaderBorderAboveCB->setChecked(false);
firstheaderBorderBelowCB->setChecked(false);
- if (use_empty) {
- if (ltt.empty)
- firstheaderStatusCB->setEnabled(false);
- }
}
row_set = tabular.getRowOfLTFoot(row, ltt);
} else {
footerBorderAboveCB->setChecked(false);
footerBorderBelowCB->setChecked(false);
- footerBorderAboveCB->setEnabled(false);
- footerBorderBelowCB->setEnabled(false);
lastfooterNoContentsCB->setChecked(false);
- lastfooterNoContentsCB->setEnabled(false);
use_empty = false;
}
row_set = tabular.getRowOfLTLastFoot(row, ltt);
- // check if setting a last footer is allowed
- // additionally check lastfooterNoContentsCB because when this is
- // the case a last footer makes no sense
- lastfooterStatusCB->setEnabled(
- funcEnabled(Tabular::SET_LTLASTFOOT)
- && !lastfooterNoContentsCB->isChecked());
lastfooterStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
lastfooterBorderAboveCB->setChecked(ltt.topDL);
lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
} else {
- lastfooterBorderAboveCB->setEnabled(false);
- lastfooterBorderBelowCB->setEnabled(false);
lastfooterBorderAboveCB->setChecked(false);
lastfooterBorderBelowCB->setChecked(false);
- if (use_empty) {
- if (ltt.empty)
- lastfooterStatusCB->setEnabled(false);
- }
}
newpageCB->setChecked(tabular.getLTNewPage(row));
+
+ // first header can only be suppressed when there is a header
+ firstheader_suppressable_ = tabular.haveLTHead()
+ && !tabular.haveLTFirstHead();
+ // last footer can only be suppressed when there is a footer
+ lastfooter_suppressable_ = tabular.haveLTFoot()
+ && !tabular.haveLTLastFoot();
+
+ // after setting the features, check if they are enabled
+ checkEnabled();
+}
+
+
+bool GuiTabular::funcEnabled(Tabular::Feature f) const
+{
+ string cmd = "tabular " + featureAsString(f);
+ return getStatus(FuncRequest(LFUN_INSET_MODIFY, cmd)).enabled();
}