move some stuff from the qt dialog into the controller.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6771 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-10 20:20:36 +00:00
parent 20f9a955de
commit b572c6ca4c
6 changed files with 257 additions and 175 deletions

View File

@ -18,6 +18,7 @@
#include "support/LAssert.h"
ControlTabular::ControlTabular(Dialog & parent)
: Dialog::Controller(parent), active_cell_(-1)
{}
@ -70,3 +71,151 @@ bool ControlTabular::useMetricUnits() const
{
return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
}
void ControlTabular::toggleTopLine()
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::M_TOGGLE_LINE_TOP);
else
set(LyXTabular::TOGGLE_LINE_TOP);
}
void ControlTabular::toggleBottomLine()
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
else
set(LyXTabular::TOGGLE_LINE_BOTTOM);
}
void ControlTabular::toggleLeftLine()
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::M_TOGGLE_LINE_LEFT);
else
set(LyXTabular::TOGGLE_LINE_LEFT);
}
void ControlTabular::toggleRightLine()
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::M_TOGGLE_LINE_RIGHT);
else
set(LyXTabular::TOGGLE_LINE_RIGHT);
}
void ControlTabular::setSpecial(string const & special)
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::SET_SPECIAL_MULTI, special);
else
set(LyXTabular::SET_SPECIAL_COLUMN, special);
}
void ControlTabular::setWidth(string const & width)
{
if (tabular().IsMultiColumn(getActiveCell()))
set(LyXTabular::SET_MPWIDTH, width);
else
set(LyXTabular::SET_PWIDTH, width);
dialog().view().update();
}
void ControlTabular::toggleMultiColumn()
{
set(LyXTabular::MULTICOLUMN);
dialog().view().update();
}
void ControlTabular::rotateTabular(bool yes)
{
if (yes)
set(LyXTabular::SET_ROTATE_TABULAR);
else
set(LyXTabular::UNSET_ROTATE_TABULAR);
}
void ControlTabular::rotateCell(bool yes)
{
if (yes)
set(LyXTabular::SET_ROTATE_CELL);
else
set(LyXTabular::UNSET_ROTATE_CELL);
}
void ControlTabular::halign(ControlTabular::HALIGN h)
{
LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
switch (h) {
case LEFT:
num = LyXTabular::ALIGN_LEFT;
multi_num = LyXTabular::M_ALIGN_LEFT;
break;
case CENTER:
num = LyXTabular::ALIGN_CENTER;
multi_num = LyXTabular::M_ALIGN_CENTER;
break;
case RIGHT:
num = LyXTabular::ALIGN_RIGHT;
multi_num = LyXTabular::M_ALIGN_RIGHT;
break;
case BLOCK:
num = LyXTabular::ALIGN_BLOCK;
//multi_num: no equivalent
break;
}
if (tabular().IsMultiColumn(getActiveCell()))
set(multi_num);
else
set(num);
}
void ControlTabular::valign(ControlTabular::VALIGN v)
{
LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
switch (v) {
case TOP:
num = LyXTabular::VALIGN_TOP;
multi_num = LyXTabular::M_VALIGN_TOP;
break;
case VCENTER:
num = LyXTabular::VALIGN_CENTER;
multi_num = LyXTabular::M_VALIGN_CENTER;
break;
case BOTTOM:
num = LyXTabular::VALIGN_BOTTOM;
multi_num = LyXTabular::M_VALIGN_BOTTOM;
break;
}
if (tabular().IsMultiColumn(getActiveCell()))
set(multi_num);
else
set(num);
}
void ControlTabular::longTabular(bool yes)
{
if (yes)
set(LyXTabular::SET_LONGTABULAR);
else
set(LyXTabular::UNSET_LONGTABULAR);
}

View File

@ -42,6 +42,31 @@ public:
/// set a parameter
void set(LyXTabular::Feature, string const & arg = string());
/// borders
void toggleTopLine();
void toggleBottomLine();
void toggleLeftLine();
void toggleRightLine();
void setSpecial(string const & special);
void setWidth(string const & width);
void toggleMultiColumn();
void rotateTabular(bool yes);
void rotateCell(bool yes);
enum HALIGN { LEFT, RIGHT, CENTER, BLOCK };
void halign(HALIGN h);
enum VALIGN { TOP, VCENTER, BOTTOM };
void valign(VALIGN h);
void longTabular(bool yes);
private:
///
int active_cell_;

View File

@ -1,3 +1,9 @@
2003-04-10 John Levon <levon@movementarian.org>
* QTabularDialog.h:
* QTabularDialog.C:
* ui/QTabularDialog.ui: move stuff to controller
2003-04-10 John Levon <levon@movementarian.org>
* ui/NumberingModuleBase.ui: bug 1032

View File

@ -21,11 +21,13 @@
#include "lengthcombo.h"
#include "qsetborder.h"
#include "qt_helpers.h"
#include "debug.h"
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
using std::endl;
QTabularDialog::QTabularDialog(QTabular * form)
: QTabularDialogBase(0, 0, false, 0),
@ -92,54 +94,30 @@ void QTabularDialog::borderUnset_clicked()
}
namespace {
bool isMulticolumnCell(QTabular * form)
{
LyXTabular const & tabular = form->controller().tabular();
int const cell = form->controller().getActiveCell();
return tabular.IsMultiColumn(cell);
}
}
void QTabularDialog::leftBorder_changed()
{
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
else
form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
form_->controller().toggleLeftLine();
form_->changed();
}
void QTabularDialog::rightBorder_changed()
{
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
else
form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
form_->controller().toggleRightLine();
form_->changed();
}
void QTabularDialog::topBorder_changed()
{
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
else
form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
form_->controller().toggleTopLine();
form_->changed();
}
void QTabularDialog::bottomBorder_changed()
{
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
else
form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
form_->controller().toggleBottomLine();
form_->changed();
}
@ -147,150 +125,74 @@ void QTabularDialog::bottomBorder_changed()
void QTabularDialog::specialAlignment_changed()
{
string special = fromqstr(specialAlignmentED->text());
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
else
form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
form_->controller().setSpecial(special);
form_->changed();
}
void QTabularDialog::width_changed()
{
form_->changed();
string const width =
LyXLength(widthED->text().toDouble(),
widthUnit->currentLengthItem()).asString();
if (isMulticolumnCell(form_))
form_->controller().set(LyXTabular::SET_MPWIDTH, width);
else
form_->controller().set(LyXTabular::SET_PWIDTH, width);
form_->changed();
form_->update_contents();
form_->controller().setWidth(width);
}
void QTabularDialog::multicolumn_clicked()
{
form_->controller().set(LyXTabular::MULTICOLUMN);
form_->controller().toggleMultiColumn();
form_->changed();
form_->update_contents();
}
void QTabularDialog::rotateTabular_checked(int state)
void QTabularDialog::rotateTabular()
{
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
break;
case 1:
// "no change state", should not happen
break;
case 2:
form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
break;
}
form_->controller().rotateTabular(rotateTabularCB->isChecked());
form_->changed();
}
void QTabularDialog::rotateCell_checked(int state)
void QTabularDialog::rotateCell()
{
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
break;
case 1:
// "no change state", should not happen
break;
case 2:
form_->controller().set(LyXTabular::SET_ROTATE_CELL);
break;
}
form_->controller().rotateCell(rotateCellCB->isChecked());
form_->changed();
}
void QTabularDialog::hAlign_changed(int align)
{
LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
ControlTabular::HALIGN h;
switch (align) {
case 0:
{
num = LyXTabular::ALIGN_LEFT;
multi_num = LyXTabular::M_ALIGN_LEFT;
break;
}
case 1:
{
num = LyXTabular::ALIGN_CENTER;
multi_num = LyXTabular::M_ALIGN_CENTER;
break;
}
case 2:
{
num = LyXTabular::ALIGN_RIGHT;
multi_num = LyXTabular::M_ALIGN_RIGHT;
break;
case 3:
{
num = LyXTabular::ALIGN_BLOCK;
//multi_num: no equivalent
break;
}
}
case 0: h = ControlTabular::LEFT; break;
case 1: h = ControlTabular::CENTER; break;
case 2: h = ControlTabular::RIGHT; break;
case 3: h = ControlTabular::BLOCK; break;
}
if (isMulticolumnCell(form_))
form_->controller().set(multi_num);
else
form_->controller().set(num);
form_->controller().halign(h);
}
void QTabularDialog::vAlign_changed(int align)
{
LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
ControlTabular::VALIGN v;
switch (align) {
case 0:
{
num = LyXTabular::VALIGN_TOP;
multi_num = LyXTabular::M_VALIGN_TOP;
break;
}
case 1:
{
num = LyXTabular::VALIGN_CENTER;
multi_num = LyXTabular::M_VALIGN_CENTER;
break;
}
case 2:
{
num = LyXTabular::VALIGN_BOTTOM;
multi_num = LyXTabular::M_VALIGN_BOTTOM;
break;
}
case 0: v = ControlTabular::TOP; break;
case 1: v = ControlTabular::VCENTER; break;
case 2: v = ControlTabular::BOTTOM; break;
}
if (isMulticolumnCell(form_))
form_->controller().set(multi_num);
else
form_->controller().set(num);
form_->controller().valign(v);
}
void QTabularDialog::longTabular_changed(int state)
void QTabularDialog::longTabular()
{
switch (state) {
case 0:
form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
break;
case 1:
// "no change state", should not happen
break;
case 2:
form_->controller().set(LyXTabular::SET_LONGTABULAR);
break;
}
form_->controller().longTabular(longTabularCB->isChecked());
form_->changed();
}

View File

@ -39,13 +39,13 @@ protected slots:
virtual void topBorder_changed();
virtual void bottomBorder_changed();
virtual void multicolumn_clicked();
virtual void rotateTabular_checked(int state);
virtual void rotateCell_checked(int state);
virtual void rotateTabular();
virtual void rotateCell();
virtual void hAlign_changed(int align);
virtual void vAlign_changed(int align);
virtual void specialAlignment_changed();
virtual void width_changed();
virtual void longTabular_changed(int state);
virtual void longTabular();
virtual void ltNewpage_clicked();
virtual void ltHeaderStatus_clicked();
virtual void ltHeaderBorderAbove_clicked();

View File

@ -13,7 +13,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>463</width>
<width>480</width>
<height>383</height>
</rect>
</property>
@ -262,7 +262,7 @@
</property>
<property stdset="1">
<name>text</name>
<string>Dele&amp;te</string>
<string>Delete</string>
</property>
<property stdset="1">
<name>autoDefault</name>
@ -435,7 +435,7 @@
</property>
<property>
<name>toolTip</name>
<string>Rotate the table by 90°</string>
<string>Rotate the table by 90 degrees</string>
</property>
</widget>
<widget>
@ -450,7 +450,7 @@
</property>
<property>
<name>toolTip</name>
<string>Rotate this cell by 90°</string>
<string>Rotate this cell by 90 degrees</string>
</property>
</widget>
</vbox>
@ -1419,18 +1419,6 @@
<receiver>QTabularDialogBase</receiver>
<slot>borderUnset_clicked()</slot>
</connection>
<connection>
<sender>rotateTabularCB</sender>
<signal>stateChanged(int)</signal>
<receiver>QTabularDialogBase</receiver>
<slot>rotateTabular_checked(int)</slot>
</connection>
<connection>
<sender>rotateCellCB</sender>
<signal>stateChanged(int)</signal>
<receiver>QTabularDialogBase</receiver>
<slot>rotateCell_checked(int)</slot>
</connection>
<connection>
<sender>longTabularCB</sender>
<signal>toggled(bool)</signal>
@ -1467,12 +1455,6 @@
<receiver>QTabularDialogBase</receiver>
<slot>multicolumn_clicked()</slot>
</connection>
<connection>
<sender>longTabularCB</sender>
<signal>stateChanged(int)</signal>
<receiver>QTabularDialogBase</receiver>
<slot>longTabular_changed(int)</slot>
</connection>
<connection>
<sender>newpageCB</sender>
<signal>clicked()</signal>
@ -1611,43 +1593,61 @@
<receiver>QTabularDialogBase</receiver>
<slot>leftBorder_changed()</slot>
</connection>
<connection>
<sender>rotateTabularCB</sender>
<signal>clicked()</signal>
<receiver>QTabularDialogBase</receiver>
<slot>rotateTabular()</slot>
</connection>
<connection>
<sender>rotateCellCB</sender>
<signal>clicked()</signal>
<receiver>QTabularDialogBase</receiver>
<slot>rotateCell()</slot>
</connection>
<connection>
<sender>longTabularCB</sender>
<signal>clicked()</signal>
<receiver>QTabularDialogBase</receiver>
<slot>longTabular()</slot>
</connection>
<slot access="protected">borderSet_clicked()</slot>
<slot access="protected">borderUnset_clicked()</slot>
<slot access="protected">border_toggled()</slot>
<slot access="protected">bottomBorder_changed()</slot>
<slot access="protected">change_adaptor()</slot>
<slot access="protected">close_clicked()</slot>
<slot access="protected">columnAppend_clicked()</slot>
<slot access="protected">columnDelete_clicked()</slot>
<slot access="protected">hAlign_changed(int)</slot>
<slot access="protected">vAlign_changed(int)</slot>
<slot access="protected">rotateTabular_checked(int)</slot>
<slot access="protected">rotateCell_checked(int)</slot>
<slot access="protected">multicolumn_clicked()</slot>
<slot access="protected">rowAppend_clicked()</slot>
<slot access="protected">rowDelete_clicked()</slot>
<slot access="protected">leftBorder_changed()</slot>
<slot access="protected">rightBorder_changed()</slot>
<slot access="protected">topBorder_changed()</slot>
<slot access="protected">bottomBorder_changed()</slot>
<slot access="protected">longTabular_changed(int)</slot>
<slot access="protected">ltNewpage_clicked()</slot>
<slot access="protected">ltHeaderStatus_clicked()</slot>
<slot access="protected">ltHeaderBorderAbove_clicked()</slot>
<slot access="protected">ltHeaderBorderBelow_clicked()</slot>
<slot access="protected">ltFirstHeaderStatus_clicked()</slot>
<slot access="protected">ltFirstHeaderBorderAbove_clicked()</slot>
<slot access="protected">ltFirstHeaderBorderBelow_clicked()</slot>
<slot access="protected">ltFirstHeaderEmpty_clicked()</slot>
<slot access="protected">ltFooterStatus_clicked()</slot>
<slot access="protected">ltFirstHeaderStatus_clicked()</slot>
<slot access="protected">ltFooterBorderAbove_clicked()</slot>
<slot access="protected">ltFooterBorderBelow_clicked()</slot>
<slot access="protected">ltLastFooterStatus_clicked()</slot>
<slot access="protected">ltFooterStatus_clicked()</slot>
<slot access="protected">ltHeaderBorderAbove_clicked()</slot>
<slot access="protected">ltHeaderBorderBelow_clicked()</slot>
<slot access="protected">ltHeaderStatus_clicked()</slot>
<slot access="protected">ltLastFooterBorderAbove_clicked()</slot>
<slot access="protected">ltLastFooterBorderBelow_clicked()</slot>
<slot access="protected">ltLastFooterEmpty_clicked()</slot>
<slot access="protected">specialAlignment_changed()</slot>
<slot access="protected">width_changed()</slot>
<slot access="protected">close_clicked()</slot>
<slot access="protected">ltLastFooterStatus_clicked()</slot>
<slot access="protected">ltNewpage_clicked()</slot>
<slot access="protected">multicolumn_clicked()</slot>
<slot access="public">longTabular()</slot>
<slot access="protected">rightBorder_changed()</slot>
<slot access="protected">rotateCell()</slot>
<slot access="protected">rotateTabular()</slot>
<slot access="protected">rowAppend_clicked()</slot>
<slot access="protected">rowDelete_clicked()</slot>
<slot access="public">setEnabled(bool)</slot>
<slot access="protected">specialAlignment_changed()</slot>
<slot access="protected">topBorder_changed()</slot>
<slot access="protected">vAlign_changed(int)</slot>
<slot access="protected">width_changed()</slot>
</connections>
<tabstops>
<tabstop>TabWidget</tabstop>