2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiTabular.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
|
|
|
* \author Herbert Voß
|
2009-07-13 23:25:47 +00:00
|
|
|
* \author Uwe Stöhr
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiTabular.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
#include "GuiApplication.h"
|
2007-08-31 22:16:11 +00:00
|
|
|
#include "GuiSetBorder.h"
|
2008-04-21 13:33:39 +00:00
|
|
|
#include "GuiView.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "LengthCombo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-10-06 09:19:53 +00:00
|
|
|
#include "Validator.h"
|
|
|
|
|
2008-04-21 13:33:39 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "Cursor.h"
|
|
|
|
#include "FuncRequest.h"
|
2009-02-10 18:08:09 +00:00
|
|
|
#include "FuncStatus.h"
|
2010-02-09 16:11:13 +00:00
|
|
|
#include "LyX.h"
|
2010-06-05 07:44:44 +00:00
|
|
|
#include "LyXRC.h"
|
2008-04-21 13:33:39 +00:00
|
|
|
|
2007-10-06 09:19:53 +00:00
|
|
|
#include "insets/InsetTabular.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-04-24 17:46:08 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
GuiTabular::GuiTabular(QWidget * parent)
|
|
|
|
: InsetParamsWidget(parent)
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
|
|
|
topspaceED->setValidator(new LengthValidator(topspaceED));
|
|
|
|
bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
|
|
|
|
interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
|
|
|
|
|
2009-07-16 07:47:02 +00:00
|
|
|
widthUnitCB->setCurrentItem(Length::defaultUnit());
|
|
|
|
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(topspaceED, SIGNAL(returnPressed()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(topspaceCO, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(bottomspaceED, SIGNAL(returnPressed()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(bottomspaceCO, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(interlinespaceED, SIGNAL(returnPressed()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(interlinespaceCO, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(booktabsRB, SIGNAL(clicked(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(borderDefaultRB, SIGNAL(clicked(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(borderSetPB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(borderSet_clicked()));
|
|
|
|
connect(borderUnsetPB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(borderUnset_clicked()));
|
|
|
|
connect(hAlignCB, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(vAlignCB, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(multicolumnCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-02-11 01:07:54 +00:00
|
|
|
connect(multirowCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(newpageCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(headerStatusCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(headerBorderAboveCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(headerBorderBelowCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(firstheaderStatusCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(firstheaderBorderAboveCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(firstheaderBorderBelowCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(firstheaderNoContentsCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(footerStatusCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(footerBorderAboveCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(footerBorderBelowCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(lastfooterStatusCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(lastfooterBorderAboveCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(lastfooterBorderBelowCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(lastfooterNoContentsCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(specialAlignmentED, SIGNAL(returnPressed()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
|
|
|
connect(widthED, SIGNAL(textEdited(QString)),
|
|
|
|
this, SLOT(checkEnabled()));
|
2009-07-11 14:43:30 +00:00
|
|
|
connect(widthUnitCB, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(borders, SIGNAL(topSet(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(borders, SIGNAL(bottomSet(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(borders, SIGNAL(rightSet(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
connect(borders, SIGNAL(leftSet(bool)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(rotateTabularCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(rotateCellCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-07-11 13:09:45 +00:00
|
|
|
connect(TableAlignCB, SIGNAL(activated(int)),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-05-17 09:36:07 +00:00
|
|
|
connect(longTabularCB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-07-11 13:09:45 +00:00
|
|
|
connect(leftRB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-07-11 13:09:45 +00:00
|
|
|
connect(centerRB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2009-07-11 13:09:45 +00:00
|
|
|
connect(rightRB, SIGNAL(clicked()),
|
2010-02-18 08:28:46 +00:00
|
|
|
this, SLOT(checkEnabled()));
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2009-07-11 13:09:45 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
// initialize the length validator
|
2010-02-18 08:28:46 +00:00
|
|
|
addCheckedWidget(widthED, fixedWidthColLA);
|
|
|
|
addCheckedWidget(topspaceED, topspaceLA);
|
|
|
|
addCheckedWidget(bottomspaceED, bottomspaceLA);
|
|
|
|
addCheckedWidget(interlinespaceED, interlinespaceLA);
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
void GuiTabular::checkEnabled()
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
2010-10-20 22:35:05 +00:00
|
|
|
// multirows don't have their own alignment
|
|
|
|
hAlignCB->setEnabled(!multirowCB->isChecked());
|
2010-08-14 15:10:53 +00:00
|
|
|
bool dalign =
|
|
|
|
hAlignCB->itemData(hAlignCB->currentIndex()).toString() == QString("decimal");
|
2010-06-05 07:44:44 +00:00
|
|
|
decimalPointLE->setEnabled(dalign);
|
|
|
|
decimalL->setEnabled(dalign);
|
|
|
|
|
2010-03-06 19:08:10 +00:00
|
|
|
vAlignCB->setEnabled(!multirowCB->isChecked()
|
|
|
|
&& !widgetsToLength(widthED, widthUnitCB).empty());
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
|
|
|
|
topspaceUnit->setEnabled(topspaceCO->currentIndex() == 2);
|
|
|
|
bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
|
|
|
|
bottomspaceUnit->setEnabled(bottomspaceCO->currentIndex() == 2);
|
|
|
|
interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
|
|
|
|
interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
|
2010-03-06 19:08:10 +00:00
|
|
|
|
2010-10-29 01:18:18 +00:00
|
|
|
// setting as longtable is not allowed when table is inside a float
|
|
|
|
longTabularCB->setEnabled(funcEnabled(Tabular::SET_LONGTABULAR));
|
2010-03-06 19:08:10 +00:00
|
|
|
bool const longtabular = longTabularCB->isChecked();
|
|
|
|
longtableGB->setEnabled(true);
|
|
|
|
newpageCB->setEnabled(longtabular);
|
|
|
|
alignmentGB->setEnabled(longtabular);
|
|
|
|
// longtables cannot have a vertical alignment
|
|
|
|
TableAlignCB->setDisabled(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
|
|
|
|
// FIXME: old code also checked for
|
|
|
|
// tabular.haveLTHead() && !tabular.haveLTFirstHead());
|
|
|
|
firstheaderNoContentsCB->setEnabled(longtabular);
|
|
|
|
// check if setting a first header is allowed
|
|
|
|
// additionally check firstheaderNoContentsCB because when this is
|
|
|
|
// the case a first header makes no sense
|
2010-08-25 06:25:07 +00:00
|
|
|
firstheaderStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD)
|
2010-08-25 02:56:27 +00:00
|
|
|
&& longtabular && !firstheaderNoContentsCB->isChecked());
|
2010-03-06 19:08:10 +00:00
|
|
|
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
|
|
|
|
// FIXME: old code also checked for
|
|
|
|
// tabular.haveLTFoot() && !tabular.haveLTLastFoot());
|
|
|
|
lastfooterNoContentsCB->setEnabled(longtabular);
|
|
|
|
// check if setting a last footer is allowed
|
|
|
|
// additionally check lastfooterNoContentsCB because when this is
|
|
|
|
// the case a last footer makes no sense
|
2010-08-25 06:25:07 +00:00
|
|
|
lastfooterStatusCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT)
|
2010-08-25 02:56:27 +00:00
|
|
|
&& longtabular && !lastfooterNoContentsCB->isChecked());
|
2010-03-06 19:08:10 +00:00
|
|
|
lastfooterBorderAboveCB->setEnabled(longtabular
|
|
|
|
&& lastfooterBorderAboveCB->isChecked());
|
|
|
|
lastfooterBorderBelowCB->setEnabled(longtabular
|
|
|
|
&& lastfooterBorderAboveCB->isChecked());
|
|
|
|
|
2010-10-29 01:38:58 +00:00
|
|
|
captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION)
|
|
|
|
&& longtabular);
|
2010-08-25 02:36:02 +00:00
|
|
|
|
2010-08-25 06:25:07 +00:00
|
|
|
multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
|
2010-08-25 06:37:37 +00:00
|
|
|
multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
|
2010-03-06 19:08:10 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
changed();
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 09:19:53 +00:00
|
|
|
void GuiTabular::borderSet_clicked()
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
borders->setTop(true);
|
|
|
|
borders->setBottom(true);
|
|
|
|
borders->setLeft(true);
|
|
|
|
borders->setRight(true);
|
|
|
|
// repaint the setborder widget
|
|
|
|
borders->update();
|
|
|
|
checkEnabled();
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 09:19:53 +00:00
|
|
|
void GuiTabular::borderUnset_clicked()
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
borders->setTop(false);
|
|
|
|
borders->setBottom(false);
|
|
|
|
borders->setLeft(false);
|
|
|
|
borders->setRight(false);
|
|
|
|
// repaint the setborder widget
|
|
|
|
borders->update();
|
|
|
|
checkEnabled();
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
param_str += ' ';
|
|
|
|
param_str += featureAsString(f) + ' ' + arg;
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
void GuiTabular::setHAlign(string & param_str) const
|
2007-04-24 17:46:08 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
Tabular::Feature num = Tabular::ALIGN_LEFT;
|
|
|
|
Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
|
2010-08-14 15:10:53 +00:00
|
|
|
string const align =
|
|
|
|
fromqstr(hAlignCB->itemData(hAlignCB->currentIndex()).toString());
|
|
|
|
if (align == "left") {
|
2010-06-05 07:44:44 +00:00
|
|
|
num = Tabular::ALIGN_LEFT;
|
|
|
|
multi_num = Tabular::M_ALIGN_LEFT;
|
2010-08-14 15:10:53 +00:00
|
|
|
} else if (align == "center") {
|
2010-06-05 07:44:44 +00:00
|
|
|
num = Tabular::ALIGN_CENTER;
|
|
|
|
multi_num = Tabular::M_ALIGN_CENTER;
|
2010-08-14 15:10:53 +00:00
|
|
|
} else if (align == "right") {
|
2010-06-05 07:44:44 +00:00
|
|
|
num = Tabular::ALIGN_RIGHT;
|
|
|
|
multi_num = Tabular::M_ALIGN_RIGHT;
|
2010-08-14 15:10:53 +00:00
|
|
|
} else if (align == "justified") {
|
2010-06-05 07:44:44 +00:00
|
|
|
num = Tabular::ALIGN_BLOCK;
|
|
|
|
//multi_num: no equivalent
|
2010-08-14 15:10:53 +00:00
|
|
|
} else if (align == "decimal") {
|
2010-06-05 07:44:44 +00:00
|
|
|
num = Tabular::ALIGN_DECIMAL;
|
|
|
|
//multi_num: no equivalent
|
2010-02-18 08:28:46 +00:00
|
|
|
}
|
2007-04-24 17:46:08 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
if (multicolumnCB->isChecked())
|
|
|
|
setParam(param_str, multi_num);
|
|
|
|
else
|
|
|
|
setParam(param_str, num);
|
2010-01-29 14:52:15 +00:00
|
|
|
}
|
2007-04-24 17:46:08 +00:00
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
void GuiTabular::setVAlign(string & param_str) const
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
int const align = vAlignCB->currentIndex();
|
|
|
|
enum VALIGN { TOP, MIDDLE, BOTTOM };
|
|
|
|
VALIGN v = TOP;
|
2010-01-29 14:52:15 +00:00
|
|
|
|
|
|
|
switch (align) {
|
2010-02-18 08:28:46 +00:00
|
|
|
case 0: v = TOP; break;
|
|
|
|
case 1: v = MIDDLE; break;
|
|
|
|
case 2: v = BOTTOM; break;
|
2007-04-24 17:46:08 +00:00
|
|
|
}
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
Tabular::Feature num = Tabular::VALIGN_MIDDLE;
|
|
|
|
Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
|
2007-04-24 17:46:08 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
switch (v) {
|
|
|
|
case TOP:
|
|
|
|
num = Tabular::VALIGN_TOP;
|
|
|
|
multi_num = Tabular::M_VALIGN_TOP;
|
|
|
|
break;
|
|
|
|
case MIDDLE:
|
|
|
|
num = Tabular::VALIGN_MIDDLE;
|
|
|
|
multi_num = Tabular::M_VALIGN_MIDDLE;
|
|
|
|
break;
|
|
|
|
case BOTTOM:
|
|
|
|
num = Tabular::VALIGN_BOTTOM;
|
|
|
|
multi_num = Tabular::M_VALIGN_BOTTOM;
|
|
|
|
break;
|
2010-01-29 14:52:15 +00:00
|
|
|
}
|
2010-02-18 08:28:46 +00:00
|
|
|
if (multicolumnCB->isChecked() || multirowCB->isChecked())
|
|
|
|
setParam(param_str, multi_num);
|
|
|
|
else
|
|
|
|
setParam(param_str, num);
|
2010-01-29 14:52:15 +00:00
|
|
|
}
|
2007-04-24 17:46:08 +00:00
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
void GuiTabular::setTableAlignment(string & param_str) const
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
int const align = TableAlignCB->currentIndex();
|
2010-01-29 14:52:15 +00:00
|
|
|
switch (align) {
|
2010-02-18 08:28:46 +00:00
|
|
|
case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
|
2010-01-29 14:44:21 +00:00
|
|
|
break;
|
2010-02-18 08:28:46 +00:00
|
|
|
case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
|
2010-01-29 14:44:21 +00:00
|
|
|
break;
|
2010-02-18 08:28:46 +00:00
|
|
|
case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
|
2009-07-11 13:09:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-01-29 14:52:15 +00:00
|
|
|
}
|
2007-04-24 17:46:08 +00:00
|
|
|
|
2008-05-04 07:51:50 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
docstring GuiTabular::dialogToParams() const
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
// FIXME: We should use Tabular directly.
|
|
|
|
string param_str = "tabular";
|
|
|
|
setHAlign(param_str);
|
2010-06-05 07:44:44 +00:00
|
|
|
|
|
|
|
// SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
|
|
|
|
string decimal_point = fromqstr(decimalPointLE->text());
|
|
|
|
if (decimal_point.empty())
|
|
|
|
decimal_point = lyxrc.default_decimal_point;
|
|
|
|
setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
setVAlign(param_str);
|
|
|
|
setTableAlignment(param_str);
|
|
|
|
//
|
|
|
|
if (booktabsRB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_BOOKTABS);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_BOOKTABS);
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
switch (topspaceCO->currentIndex()) {
|
|
|
|
case 0:
|
|
|
|
setParam(param_str, Tabular::SET_TOP_SPACE, "none");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
setParam(param_str, Tabular::SET_TOP_SPACE, "default");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!topspaceED->text().isEmpty())
|
|
|
|
setParam(param_str, Tabular::SET_TOP_SPACE,
|
|
|
|
widgetsToLength(topspaceED, topspaceUnit));
|
|
|
|
break;
|
|
|
|
}
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
switch (bottomspaceCO->currentIndex()) {
|
|
|
|
case 0:
|
|
|
|
setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!bottomspaceED->text().isEmpty())
|
|
|
|
setParam(param_str, Tabular::SET_BOTTOM_SPACE,
|
|
|
|
widgetsToLength(bottomspaceED,
|
|
|
|
bottomspaceUnit));
|
|
|
|
break;
|
|
|
|
}
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
switch (interlinespaceCO->currentIndex()) {
|
|
|
|
case 0:
|
|
|
|
setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!interlinespaceED->text().isEmpty())
|
|
|
|
setParam(param_str, Tabular::SET_INTERLINE_SPACE,
|
|
|
|
widgetsToLength(interlinespaceED,
|
|
|
|
interlinespaceUnit));
|
|
|
|
break;
|
|
|
|
}
|
2008-05-04 07:51:50 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
if (borders->getTop() && borders->getBottom() && borders->getLeft()
|
|
|
|
&& borders->getRight())
|
|
|
|
setParam(param_str, Tabular::SET_ALL_LINES);
|
|
|
|
else if (!borders->getTop() && !borders->getBottom() && !borders->getLeft()
|
|
|
|
&& !borders->getRight())
|
|
|
|
setParam(param_str, Tabular::UNSET_ALL_LINES);
|
2010-02-19 08:20:58 +00:00
|
|
|
else {
|
2010-02-19 10:03:03 +00:00
|
|
|
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");
|
2010-02-19 08:20:58 +00:00
|
|
|
}
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
// apply the special alignment
|
|
|
|
string special = fromqstr(specialAlignmentED->text());
|
|
|
|
if (special.empty())
|
|
|
|
special = "none";
|
|
|
|
if (multicolumnCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
|
|
|
|
else if (multirowCB->isChecked())
|
2010-10-30 10:41:46 +00:00
|
|
|
//FIXME SET_SPECIAL_MULTIROW not implemented!
|
|
|
|
setParam(param_str, Tabular::SET_SPECIAL_MULTIROW);
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
// 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);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::SET_PWIDTH, width);
|
2007-04-24 17:46:08 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
if (multicolumnCB->isChecked())
|
2010-10-29 04:09:49 +00:00
|
|
|
setParam(param_str, Tabular::SET_MULTICOLUMN);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_MULTICOLUMN);
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
if (multirowCB->isChecked())
|
2010-10-29 04:09:49 +00:00
|
|
|
setParam(param_str, Tabular::SET_MULTIROW);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_MULTIROW);
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
if (rotateTabularCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_ROTATE_TABULAR);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_ROTATE_TABULAR);
|
|
|
|
//
|
|
|
|
if (rotateCellCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_ROTATE_CELL);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_ROTATE_CELL);
|
|
|
|
//
|
|
|
|
if (longTabularCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LONGTABULAR);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_LONGTABULAR);
|
|
|
|
//
|
|
|
|
if (newpageCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTNEWPAGE);
|
|
|
|
//
|
|
|
|
if (captionStatusCB->isChecked())
|
2010-10-29 04:09:49 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTCAPTION);
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_LTCAPTION);
|
2010-02-18 08:28:46 +00:00
|
|
|
//
|
|
|
|
if (headerStatusCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTHEAD, "none");
|
|
|
|
else
|
|
|
|
setParam(param_str, Tabular::UNSET_LTHEAD, "none");
|
|
|
|
//
|
2010-01-29 14:44:21 +00:00
|
|
|
if (headerBorderAboveCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
|
2010-01-29 14:44:21 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
|
|
|
|
//
|
2007-04-24 17:46:08 +00:00
|
|
|
if (headerBorderBelowCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (firstheaderBorderAboveCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (firstheaderBorderBelowCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
|
|
|
|
if (firstheaderStatusCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
|
|
|
|
if (firstheaderNoContentsCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
|
|
|
|
if (footerStatusCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTFOOT, "none");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFOOT, "none");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (footerBorderAboveCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (footerBorderBelowCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
|
|
|
|
if (lastfooterStatusCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (lastfooterBorderAboveCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
|
2007-04-24 17:46:08 +00:00
|
|
|
if (lastfooterBorderBelowCB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
|
|
|
|
if (lastfooterNoContentsCB->isChecked())
|
|
|
|
setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
|
2007-04-24 17:46:08 +00:00
|
|
|
else
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-07-11 13:09:45 +00:00
|
|
|
if (leftRB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
|
2009-07-11 13:09:45 +00:00
|
|
|
else if (centerRB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
|
2009-07-11 13:09:45 +00:00
|
|
|
else if (rightRB->isChecked())
|
2010-02-18 08:28:46 +00:00
|
|
|
setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
|
2009-07-11 13:09:45 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
return from_utf8(param_str);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
static Length getColumnPWidth(Tabular const & t, size_t cell)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-01-29 14:52:15 +00:00
|
|
|
return t.column_info[t.cellColumn(cell)].p_width;
|
|
|
|
}
|
2010-01-29 14:44:21 +00:00
|
|
|
|
2010-01-29 14:52:15 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
static Length getMColumnPWidth(Tabular const & t, size_t cell)
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-11 01:07:54 +00:00
|
|
|
if (t.isMultiColumn(cell) || t.isMultiRow(cell))
|
2010-01-29 14:52:15 +00:00
|
|
|
return t.cellInfo(cell).p_width;
|
|
|
|
return Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-11 01:07:54 +00:00
|
|
|
if (what == Tabular::SET_SPECIAL_MULTICOLUMN
|
|
|
|
|| what == Tabular::SET_SPECIAL_MULTIROW)
|
2010-01-29 14:52:15 +00:00
|
|
|
return t.cellInfo(cell).align_special;
|
|
|
|
return t.column_info[t.cellColumn(cell)].align_special;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
void GuiTabular::paramsToDialog(Inset const * inset)
|
2010-01-29 14:52:15 +00:00
|
|
|
{
|
2010-02-18 08:28:46 +00:00
|
|
|
InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
|
|
|
|
// Copy Tabular of current inset.
|
|
|
|
Tabular const & tabular = itab->tabular;
|
2010-02-11 10:38:41 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
BufferView const * bv = guiApp->currentView()->currentBufferView();
|
|
|
|
size_t const cell = bv->cursor().idx();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
Tabular::row_type const row = tabular.cellRow(cell);
|
|
|
|
Tabular::col_type const col = tabular.cellColumn(cell);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-11 21:27:57 +00:00
|
|
|
tabularRowED->setText(QString::number(row + 1));
|
|
|
|
tabularColumnED->setText(QString::number(col + 1));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
bool const multicol = tabular.isMultiColumn(cell);
|
2007-09-05 20:33:29 +00:00
|
|
|
multicolumnCB->setChecked(multicol);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-18 08:28:46 +00:00
|
|
|
bool const multirow = tabular.isMultiRow(cell);
|
2010-02-11 01:07:54 +00:00
|
|
|
multirowCB->setChecked(multirow);
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
rotateCellCB->setChecked(tabular.getRotateCell(cell));
|
|
|
|
rotateTabularCB->setChecked(tabular.rotate);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
longTabularCB->setChecked(tabular.is_long_tabular);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-19 10:03:03 +00:00
|
|
|
borders->setTop(tabular.topLine(cell));
|
|
|
|
borders->setBottom(tabular.bottomLine(cell));
|
|
|
|
borders->setLeft(tabular.leftLine(cell));
|
|
|
|
borders->setRight(tabular.rightLine(cell));
|
2010-02-18 08:28:46 +00:00
|
|
|
// repaint the setborder widget
|
|
|
|
borders->update();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-19 10:25:20 +00:00
|
|
|
Length::UNIT const default_unit = Length::defaultUnit();
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
// Set width and alignment
|
2007-04-28 12:58:49 +00:00
|
|
|
Length pwidth;
|
2007-01-05 17:11:32 +00:00
|
|
|
docstring special;
|
2006-03-05 17:24:44 +00:00
|
|
|
if (multicol) {
|
2010-02-11 10:38:41 +00:00
|
|
|
special = getAlignSpecial(tabular, cell,
|
2010-02-11 01:07:54 +00:00
|
|
|
Tabular::SET_SPECIAL_MULTICOLUMN);
|
2010-02-11 10:38:41 +00:00
|
|
|
pwidth = getMColumnPWidth(tabular, cell);
|
2010-02-11 01:07:54 +00:00
|
|
|
} else if (multirow) {
|
2010-02-11 10:38:41 +00:00
|
|
|
special = getAlignSpecial(tabular, cell,
|
2010-02-11 01:07:54 +00:00
|
|
|
Tabular::SET_SPECIAL_MULTIROW);
|
2010-02-11 10:38:41 +00:00
|
|
|
pwidth = getMColumnPWidth(tabular, cell);
|
2006-03-05 17:24:44 +00:00
|
|
|
} else {
|
2010-02-11 10:38:41 +00:00
|
|
|
special = getAlignSpecial(tabular, cell,
|
2009-05-17 09:36:07 +00:00
|
|
|
Tabular::SET_SPECIAL_COLUMN);
|
2010-02-11 10:38:41 +00:00
|
|
|
pwidth = getColumnPWidth(tabular, cell);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
2010-02-19 10:25:20 +00:00
|
|
|
string colwidth;
|
|
|
|
if (pwidth.zero())
|
|
|
|
widthED->clear();
|
|
|
|
else {
|
|
|
|
colwidth = pwidth.asString();
|
|
|
|
lengthToWidgets(widthED, widthUnitCB,
|
|
|
|
colwidth, default_unit);
|
|
|
|
}
|
2007-09-05 20:33:29 +00:00
|
|
|
specialAlignmentED->setText(toqstr(special));
|
2010-02-19 10:25:20 +00:00
|
|
|
///////////////////////////////////
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
borderDefaultRB->setChecked(!tabular.use_booktabs);
|
|
|
|
booktabsRB->setChecked(tabular.use_booktabs);
|
2006-07-03 19:13:56 +00:00
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
if (tabular.row_info[row].top_space.empty()
|
|
|
|
&& !tabular.row_info[row].top_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
topspaceCO->setCurrentIndex(0);
|
2010-02-11 10:38:41 +00:00
|
|
|
} else if (tabular.row_info[row].top_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
topspaceCO->setCurrentIndex(1);
|
2006-07-03 19:13:56 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
topspaceCO->setCurrentIndex(2);
|
|
|
|
lengthToWidgets(topspaceED,
|
|
|
|
topspaceUnit,
|
2010-02-11 10:38:41 +00:00
|
|
|
tabular.row_info[row].top_space.asString(),
|
2006-07-03 19:13:56 +00:00
|
|
|
default_unit);
|
|
|
|
}
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
if (tabular.row_info[row].bottom_space.empty()
|
|
|
|
&& !tabular.row_info[row].bottom_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
bottomspaceCO->setCurrentIndex(0);
|
2010-02-11 10:38:41 +00:00
|
|
|
} else if (tabular.row_info[row].bottom_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
bottomspaceCO->setCurrentIndex(1);
|
2006-07-03 19:13:56 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
bottomspaceCO->setCurrentIndex(2);
|
|
|
|
lengthToWidgets(bottomspaceED,
|
|
|
|
bottomspaceUnit,
|
2010-02-11 10:38:41 +00:00
|
|
|
tabular.row_info[row].bottom_space.asString(),
|
2006-07-03 19:13:56 +00:00
|
|
|
default_unit);
|
|
|
|
}
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
if (tabular.row_info[row].interline_space.empty()
|
|
|
|
&& !tabular.row_info[row].interline_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
interlinespaceCO->setCurrentIndex(0);
|
2010-02-11 10:38:41 +00:00
|
|
|
} else if (tabular.row_info[row].interline_space_default) {
|
2007-09-05 20:33:29 +00:00
|
|
|
interlinespaceCO->setCurrentIndex(1);
|
2006-07-03 19:13:56 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
interlinespaceCO->setCurrentIndex(2);
|
|
|
|
lengthToWidgets(interlinespaceED,
|
|
|
|
interlinespaceUnit,
|
2010-02-11 10:38:41 +00:00
|
|
|
tabular.row_info[row].interline_space.asString(),
|
2006-07-03 19:13:56 +00:00
|
|
|
default_unit);
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
hAlignCB->clear();
|
2010-08-14 15:10:53 +00:00
|
|
|
hAlignCB->addItem(qt_("Left"), toqstr("left"));
|
|
|
|
hAlignCB->addItem(qt_("Center"), toqstr("center"));
|
|
|
|
hAlignCB->addItem(qt_("Right"), toqstr("right"));
|
2006-03-05 17:24:44 +00:00
|
|
|
if (!multicol && !pwidth.zero())
|
2010-08-14 15:10:53 +00:00
|
|
|
hAlignCB->addItem(qt_("Justified"), toqstr("justified"));
|
2010-06-05 07:44:44 +00:00
|
|
|
if (!multicol)
|
2010-08-14 15:10:53 +00:00
|
|
|
hAlignCB->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-08-14 15:10:53 +00:00
|
|
|
string align;
|
2010-02-11 10:38:41 +00:00
|
|
|
switch (tabular.getAlignment(cell)) {
|
2010-06-05 07:44:44 +00:00
|
|
|
case LYX_ALIGN_LEFT:
|
2010-08-14 15:10:53 +00:00
|
|
|
align = "left";
|
2010-06-05 07:44:44 +00:00
|
|
|
break;
|
|
|
|
case LYX_ALIGN_CENTER:
|
2010-08-14 15:10:53 +00:00
|
|
|
align = "center";
|
2010-06-05 07:44:44 +00:00
|
|
|
break;
|
|
|
|
case LYX_ALIGN_RIGHT:
|
2010-08-14 15:10:53 +00:00
|
|
|
align = "right";
|
2010-06-05 07:44:44 +00:00
|
|
|
break;
|
|
|
|
case LYX_ALIGN_BLOCK:
|
|
|
|
{
|
|
|
|
if (!multicol && !pwidth.zero())
|
2010-08-14 15:10:53 +00:00
|
|
|
align = "justified";
|
2010-06-05 07:44:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LYX_ALIGN_DECIMAL:
|
|
|
|
{
|
|
|
|
if (!multicol)
|
2010-08-14 15:10:53 +00:00
|
|
|
align = "decimal";
|
2010-06-05 07:44:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
// we should never end up here
|
|
|
|
break;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
2010-08-14 15:10:53 +00:00
|
|
|
hAlignCB->setCurrentIndex(hAlignCB->findData(toqstr(align)));
|
2010-06-05 07:44:44 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
|
|
|
|
if (decimal_point.isEmpty())
|
|
|
|
decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
|
|
|
|
decimalPointLE->setText(decimal_point);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
int valign = 0;
|
2010-02-11 10:38:41 +00:00
|
|
|
switch (tabular.getVAlignment(cell)) {
|
2007-04-26 13:39:14 +00:00
|
|
|
case Tabular::LYX_VALIGN_TOP:
|
2006-03-05 17:24:44 +00:00
|
|
|
valign = 0;
|
|
|
|
break;
|
2007-04-26 13:39:14 +00:00
|
|
|
case Tabular::LYX_VALIGN_MIDDLE:
|
2006-03-05 17:24:44 +00:00
|
|
|
valign = 1;
|
|
|
|
break;
|
2007-04-26 13:39:14 +00:00
|
|
|
case Tabular::LYX_VALIGN_BOTTOM:
|
2006-03-05 17:24:44 +00:00
|
|
|
valign = 2;
|
|
|
|
break;
|
|
|
|
default:
|
2008-11-17 11:58:14 +00:00
|
|
|
valign = 0;
|
2006-03-05 17:24:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pwidth.zero())
|
2008-11-17 11:58:14 +00:00
|
|
|
valign = 0;
|
2007-09-05 20:33:29 +00:00
|
|
|
vAlignCB->setCurrentIndex(valign);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-07-11 14:33:05 +00:00
|
|
|
int tableValign = 1;
|
2010-02-11 10:38:41 +00:00
|
|
|
switch (tabular.tabular_valignment) {
|
2009-07-11 13:09:45 +00:00
|
|
|
case Tabular::LYX_VALIGN_TOP:
|
|
|
|
tableValign = 0;
|
|
|
|
break;
|
|
|
|
case Tabular::LYX_VALIGN_MIDDLE:
|
|
|
|
tableValign = 1;
|
|
|
|
break;
|
|
|
|
case Tabular::LYX_VALIGN_BOTTOM:
|
|
|
|
tableValign = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tableValign = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TableAlignCB->setCurrentIndex(tableValign);
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
if (!tabular.is_long_tabular) {
|
2007-09-05 20:33:29 +00:00
|
|
|
headerStatusCB->setChecked(false);
|
|
|
|
headerBorderAboveCB->setChecked(false);
|
|
|
|
headerBorderBelowCB->setChecked(false);
|
|
|
|
firstheaderStatusCB->setChecked(false);
|
|
|
|
firstheaderBorderAboveCB->setChecked(false);
|
|
|
|
firstheaderBorderBelowCB->setChecked(false);
|
|
|
|
firstheaderNoContentsCB->setChecked(false);
|
|
|
|
footerStatusCB->setChecked(false);
|
|
|
|
footerBorderAboveCB->setChecked(false);
|
|
|
|
footerBorderBelowCB->setChecked(false);
|
|
|
|
lastfooterStatusCB->setChecked(false);
|
|
|
|
lastfooterBorderAboveCB->setChecked(false);
|
|
|
|
lastfooterBorderBelowCB->setChecked(false);
|
|
|
|
lastfooterNoContentsCB->setChecked(false);
|
|
|
|
newpageCB->setChecked(false);
|
2008-05-04 07:51:50 +00:00
|
|
|
captionStatusCB->blockSignals(true);
|
|
|
|
captionStatusCB->setChecked(false);
|
|
|
|
captionStatusCB->blockSignals(false);
|
2010-06-05 07:44:44 +00:00
|
|
|
checkEnabled();
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
2010-02-18 08:28:46 +00:00
|
|
|
} else {
|
2009-07-11 14:33:05 +00:00
|
|
|
// longtables cannot have a vertical alignment
|
|
|
|
TableAlignCB->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
|
2010-02-18 08:28:46 +00:00
|
|
|
}
|
2010-02-11 10:38:41 +00:00
|
|
|
switch (tabular.longtabular_alignment) {
|
2009-07-11 13:09:45 +00:00
|
|
|
case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
|
|
|
|
leftRB->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
|
|
|
|
centerRB->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
|
|
|
|
rightRB->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
centerRB->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
2008-05-04 07:51:50 +00:00
|
|
|
captionStatusCB->blockSignals(true);
|
2010-02-11 10:38:41 +00:00
|
|
|
captionStatusCB->setChecked(tabular.ltCaption(row));
|
2008-05-04 07:51:50 +00:00
|
|
|
captionStatusCB->blockSignals(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-26 13:39:14 +00:00
|
|
|
Tabular::ltType ltt;
|
2006-03-05 17:24:44 +00:00
|
|
|
bool use_empty;
|
2010-02-11 10:38:41 +00:00
|
|
|
bool row_set = tabular.getRowOfLTHead(row, ltt);
|
2007-09-05 20:33:29 +00:00
|
|
|
headerStatusCB->setChecked(row_set);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (ltt.set) {
|
2007-09-05 20:33:29 +00:00
|
|
|
headerBorderAboveCB->setChecked(ltt.topDL);
|
|
|
|
headerBorderBelowCB->setChecked(ltt.bottomDL);
|
2006-03-05 17:24:44 +00:00
|
|
|
use_empty = true;
|
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
headerBorderAboveCB->setChecked(false);
|
|
|
|
headerBorderBelowCB->setChecked(false);
|
|
|
|
firstheaderNoContentsCB->setChecked(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
use_empty = false;
|
|
|
|
}
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
row_set = tabular.getRowOfLTFirstHead(row, ltt);
|
2007-09-05 20:33:29 +00:00
|
|
|
firstheaderStatusCB->setChecked(row_set);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (ltt.set && (!ltt.empty || !use_empty)) {
|
2007-09-05 20:33:29 +00:00
|
|
|
firstheaderBorderAboveCB->setChecked(ltt.topDL);
|
|
|
|
firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
|
2006-03-05 17:24:44 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
firstheaderBorderAboveCB->setChecked(false);
|
|
|
|
firstheaderBorderBelowCB->setChecked(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
row_set = tabular.getRowOfLTFoot(row, ltt);
|
2007-09-05 20:33:29 +00:00
|
|
|
footerStatusCB->setChecked(row_set);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (ltt.set) {
|
2007-09-05 20:33:29 +00:00
|
|
|
footerBorderAboveCB->setChecked(ltt.topDL);
|
|
|
|
footerBorderBelowCB->setChecked(ltt.bottomDL);
|
2006-03-05 17:24:44 +00:00
|
|
|
use_empty = true;
|
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
footerBorderAboveCB->setChecked(false);
|
|
|
|
footerBorderBelowCB->setChecked(false);
|
|
|
|
lastfooterNoContentsCB->setChecked(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
use_empty = false;
|
|
|
|
}
|
|
|
|
|
2010-02-11 10:38:41 +00:00
|
|
|
row_set = tabular.getRowOfLTLastFoot(row, ltt);
|
2009-02-09 00:06:32 +00:00
|
|
|
lastfooterStatusCB->setChecked(row_set);
|
2006-03-05 17:24:44 +00:00
|
|
|
if (ltt.set && (!ltt.empty || !use_empty)) {
|
2007-09-05 20:33:29 +00:00
|
|
|
lastfooterBorderAboveCB->setChecked(ltt.topDL);
|
|
|
|
lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
|
2006-03-05 17:24:44 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
lastfooterBorderAboveCB->setChecked(false);
|
|
|
|
lastfooterBorderBelowCB->setChecked(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
2010-02-11 10:38:41 +00:00
|
|
|
newpageCB->setChecked(tabular.getLTNewPage(row));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-25 06:25:07 +00:00
|
|
|
bool GuiTabular::funcEnabled(Tabular::Feature f) const
|
|
|
|
{
|
|
|
|
string cmd = "tabular " + featureAsString(f);
|
|
|
|
return getStatus(FuncRequest(LFUN_INSET_MODIFY, cmd)).enabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 17:46:08 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiTabular.cpp"
|