From b572c6ca4cc2884753a9d9504b890482fda2fce8 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 10 Apr 2003 20:20:36 +0000 Subject: [PATCH] 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 --- src/frontends/controllers/ControlTabular.C | 149 +++++++++++++++++++ src/frontends/controllers/ControlTabular.h | 25 ++++ src/frontends/qt2/ChangeLog | 6 + src/frontends/qt2/QTabularDialog.C | 162 ++++----------------- src/frontends/qt2/QTabularDialog.h | 6 +- src/frontends/qt2/ui/QTabularDialogBase.ui | 82 +++++------ 6 files changed, 256 insertions(+), 174 deletions(-) diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C index 6aa6f9c18a..8f83e0f1dd 100644 --- a/src/frontends/controllers/ControlTabular.C +++ b/src/frontends/controllers/ControlTabular.C @@ -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); +} diff --git a/src/frontends/controllers/ControlTabular.h b/src/frontends/controllers/ControlTabular.h index 37b8c136cf..76a059fc04 100644 --- a/src/frontends/controllers/ControlTabular.h +++ b/src/frontends/controllers/ControlTabular.h @@ -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_; diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 1f2ce8da6e..82d177b217 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,9 @@ +2003-04-10 John Levon + + * QTabularDialog.h: + * QTabularDialog.C: + * ui/QTabularDialog.ui: move stuff to controller + 2003-04-10 John Levon * ui/NumberingModuleBase.ui: bug 1032 diff --git a/src/frontends/qt2/QTabularDialog.C b/src/frontends/qt2/QTabularDialog.C index 88f52b2ec1..f3e15092bb 100644 --- a/src/frontends/qt2/QTabularDialog.C +++ b/src/frontends/qt2/QTabularDialog.C @@ -21,11 +21,13 @@ #include "lengthcombo.h" #include "qsetborder.h" #include "qt_helpers.h" +#include "debug.h" #include #include #include +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(); } diff --git a/src/frontends/qt2/QTabularDialog.h b/src/frontends/qt2/QTabularDialog.h index 7b7ed20ede..e9e7b64840 100644 --- a/src/frontends/qt2/QTabularDialog.h +++ b/src/frontends/qt2/QTabularDialog.h @@ -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(); diff --git a/src/frontends/qt2/ui/QTabularDialogBase.ui b/src/frontends/qt2/ui/QTabularDialogBase.ui index 0d1b3b6ece..0b6c4e128d 100644 --- a/src/frontends/qt2/ui/QTabularDialogBase.ui +++ b/src/frontends/qt2/ui/QTabularDialogBase.ui @@ -13,7 +13,7 @@ 0 0 - 463 + 480 383 @@ -262,7 +262,7 @@ text - Dele&te + Delete autoDefault @@ -435,7 +435,7 @@ toolTip - Rotate the table by 90° + Rotate the table by 90 degrees @@ -450,7 +450,7 @@ toolTip - Rotate this cell by 90° + Rotate this cell by 90 degrees @@ -1419,18 +1419,6 @@ QTabularDialogBase borderUnset_clicked() - - rotateTabularCB - stateChanged(int) - QTabularDialogBase - rotateTabular_checked(int) - - - rotateCellCB - stateChanged(int) - QTabularDialogBase - rotateCell_checked(int) - longTabularCB toggled(bool) @@ -1467,12 +1455,6 @@ QTabularDialogBase multicolumn_clicked() - - longTabularCB - stateChanged(int) - QTabularDialogBase - longTabular_changed(int) - newpageCB clicked() @@ -1611,43 +1593,61 @@ QTabularDialogBase leftBorder_changed() + + rotateTabularCB + clicked() + QTabularDialogBase + rotateTabular() + + + rotateCellCB + clicked() + QTabularDialogBase + rotateCell() + + + longTabularCB + clicked() + QTabularDialogBase + longTabular() + borderSet_clicked() borderUnset_clicked() border_toggled() + bottomBorder_changed() change_adaptor() + close_clicked() columnAppend_clicked() columnDelete_clicked() hAlign_changed(int) - vAlign_changed(int) - rotateTabular_checked(int) - rotateCell_checked(int) - multicolumn_clicked() - rowAppend_clicked() - rowDelete_clicked() leftBorder_changed() - rightBorder_changed() - topBorder_changed() - bottomBorder_changed() - longTabular_changed(int) - ltNewpage_clicked() - ltHeaderStatus_clicked() - ltHeaderBorderAbove_clicked() - ltHeaderBorderBelow_clicked() - ltFirstHeaderStatus_clicked() ltFirstHeaderBorderAbove_clicked() ltFirstHeaderBorderBelow_clicked() ltFirstHeaderEmpty_clicked() - ltFooterStatus_clicked() + ltFirstHeaderStatus_clicked() ltFooterBorderAbove_clicked() ltFooterBorderBelow_clicked() - ltLastFooterStatus_clicked() + ltFooterStatus_clicked() + ltHeaderBorderAbove_clicked() + ltHeaderBorderBelow_clicked() + ltHeaderStatus_clicked() ltLastFooterBorderAbove_clicked() ltLastFooterBorderBelow_clicked() ltLastFooterEmpty_clicked() + ltLastFooterStatus_clicked() + ltNewpage_clicked() + multicolumn_clicked() + longTabular() + rightBorder_changed() + rotateCell() + rotateTabular() + rowAppend_clicked() + rowDelete_clicked() + setEnabled(bool) specialAlignment_changed() + topBorder_changed() + vAlign_changed(int) width_changed() - close_clicked() - setEnabled(bool) TabWidget -- 2.39.5