]> git.lyx.org Git - lyx.git/commitdiff
move some stuff from the qt dialog into the controller.
authorJohn Levon <levon@movementarian.org>
Thu, 10 Apr 2003 20:20:36 +0000 (20:20 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 10 Apr 2003 20:20:36 +0000 (20:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6771 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlTabular.C
src/frontends/controllers/ControlTabular.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QTabularDialog.C
src/frontends/qt2/QTabularDialog.h
src/frontends/qt2/ui/QTabularDialogBase.ui

index 6aa6f9c18a9b942983c1f855a6b5a8a8c6397a9c..8f83e0f1ddb671a913c7e5947f0344ad702276f4 100644 (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);
+}
index 37b8c136cf1dfbafd266e9e1e676e6888a097097..76a059fc04c9f82cbab0c39e45cadcce4f670714 100644 (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_;
index 1f2ce8da6e5e74c3dd9ae1dabffd64ffa96e8e11..82d177b217c8aaf72dc5b4ab11ca10aecc0c7e37 100644 (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
index 88f52b2ec1d7c66ab4411a86581a6980b11fb8e9..f3e15092bb024f88dfe8cd16fd727795a8f06006 100644 (file)
 #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();
 }
 
index 7b7ed20edeb8667dd1c8cebc3b4f298bd1e879b6..e9e7b64840772cf9aed4319bf48caeaebd521929 100644 (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();
index 0d1b3b6eceadbd787167288e0042eed28659d686..0b6c4e128dd23b2867493f8858372c3744c3da94 100644 (file)
@@ -13,7 +13,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>463</width>
+            <width>480</width>
             <height>383</height>
         </rect>
     </property>
                                 </property>
                                 <property stdset="1">
                                     <name>text</name>
-                                    <string>Dele&amp;te</string>
+                                    <string>Delete</string>
                                 </property>
                                 <property stdset="1">
                                     <name>autoDefault</name>
                                 </property>
                                 <property>
                                     <name>toolTip</name>
-                                    <string>Rotate the table by 90°</string>
+                                    <string>Rotate the table by 90 degrees</string>
                                 </property>
                             </widget>
                             <widget>
                                 </property>
                                 <property>
                                     <name>toolTip</name>
-                                    <string>Rotate this cell by 90°</string>
+                                    <string>Rotate this cell by 90 degrees</string>
                                 </property>
                             </widget>
                         </vbox>
         <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>
         <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>
         <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">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>
-    <slot access="protected">close_clicked()</slot>
-    <slot access="public">setEnabled(bool)</slot>
 </connections>
 <tabstops>
     <tabstop>TabWidget</tabstop>