]> git.lyx.org Git - lyx.git/commitdiff
Fix left/right border UI when toggling formal
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 1 Apr 2019 07:26:09 +0000 (09:26 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 1 Apr 2019 16:48:07 +0000 (18:48 +0200)
Fixes: #9835
(cherry picked from commit 00de6c4be7db826e0035a412b0e19ffe940a5a44)

src/frontends/qt4/GuiTabular.cpp
src/frontends/qt4/GuiTabular.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
status.23x

index 63cd3836c0c67d19b8c8a7f1129e9b55acec691c..e4719d170b95166b18ab5a633a814758c5d8708f 100644 (file)
@@ -47,7 +47,8 @@ namespace frontend {
 
 GuiTabular::GuiTabular(QWidget * parent)
        : InsetParamsWidget(parent), firstheader_suppressable_(false),
-         lastfooter_suppressable_(false)
+         lastfooter_suppressable_(false), orig_leftborder_(GuiSetBorder::LINE_UNDEF),
+         orig_rightborder_(GuiSetBorder::LINE_UNDEF)
 
 {
        setupUi(this);
@@ -79,9 +80,9 @@ GuiTabular::GuiTabular(QWidget * parent)
        connect(interlinespaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
                this, SLOT(checkEnabled()));
        connect(booktabsRB, SIGNAL(clicked(bool)),
-               this, SLOT(checkEnabled()));
+               this, SLOT(booktabs_toggled(bool)));
        connect(borderDefaultRB, SIGNAL(clicked(bool)),
-               this, SLOT(checkEnabled()));
+               this, SLOT(nonbooktabs_toggled(bool)));
        connect(borderSetPB, SIGNAL(clicked()),
                this, SLOT(borderSet_clicked()));
        connect(borderUnsetPB, SIGNAL(clicked()),
@@ -365,6 +366,25 @@ void GuiTabular::borderUnset_clicked()
 }
 
 
+void GuiTabular::booktabs_toggled(bool const check)
+{
+       // when switching from formal, restore the left/right lines
+       if (!check) {
+               borders->setLeft(orig_leftborder_);
+               borders->setRight(orig_rightborder_);
+       }
+       // repaint the setborder widget
+       borders->update();
+       checkEnabled();
+}
+
+
+void GuiTabular::nonbooktabs_toggled(bool const check)
+{
+       booktabs_toggled(!check);
+}
+
+
 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
 {
        param_str += ' ';
@@ -769,7 +789,7 @@ void GuiTabular::paramsToDialog(Inset const * inset)
        }
 
        // In what follows, we check the borders of all selected cells,
-       // and if there are diverging settings, we use the LINE_UNDECIDED
+       // and if there are diverging settings, we use the LINE_UNDEF
        // border status.
        GuiSetBorder::BorderState lt = GuiSetBorder::LINE_UNDEF;
        GuiSetBorder::BorderState lb = GuiSetBorder::LINE_UNDEF;
@@ -793,12 +813,18 @@ void GuiTabular::paramsToDialog(Inset const * inset)
                                lb = borderState(lb, tabular.bottomLine(cc));
                                ll = borderState(ll, tabular.leftLine(cc));
                                lr = borderState(lr, tabular.rightLine(cc));
+                               // store left/right borders for the case of formal/nonformal switch
+                               orig_leftborder_ = borderState(ll, tabular.leftLine(cc, true));
+                               orig_rightborder_ = borderState(lr, tabular.rightLine(cc, true));
                        }
        } else {
                lt = tabular.topLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
                lb = tabular.bottomLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
                ll = tabular.leftLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
                lr = tabular.rightLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
+               // store left/right borders for the case of formal/nonformal switch
+               orig_leftborder_ = tabular.leftLine(cell, true) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
+               orig_rightborder_ = tabular.rightLine(cell, true) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
        }
        borders->setTop(lt);
        borders->setBottom(lb);
index 2cba4810aa461073acc2fd8e5d200e70a9925b57..f56abdacfbdaa5b02b4e0b6cb7ec8037b58735f5 100644 (file)
@@ -33,6 +33,8 @@ private Q_SLOTS:
        void checkEnabled();
        void borderSet_clicked();
        void borderUnset_clicked();
+       void booktabs_toggled(bool const check);
+       void nonbooktabs_toggled(bool const check);
        void on_topspaceCO_activated(int index);
        void on_bottomspaceCO_activated(int index);
        void on_interlinespaceCO_activated(int index);
@@ -67,6 +69,10 @@ private:
        bool firstheader_suppressable_;
        ///
        bool lastfooter_suppressable_;
+       ///
+       GuiSetBorder::BorderState orig_leftborder_;
+       ///
+       GuiSetBorder::BorderState orig_rightborder_;
 };
 
 } // namespace frontend
index f9a78e1d6b9de4d844b0033d2c64c90d9076b242..375d7561b68c7875c2c4af573821692f44fc2236 100644 (file)
@@ -956,17 +956,17 @@ bool Tabular::bottomLine(idx_type const cell) const
 }
 
 
-bool Tabular::leftLine(idx_type cell) const
+bool Tabular::leftLine(idx_type cell, bool const ignore_bt) const
 {
-       if (use_booktabs)
+       if (use_booktabs && !ignore_bt)
                return false;
        return cellInfo(cell).left_line;
 }
 
 
-bool Tabular::rightLine(idx_type cell) const
+bool Tabular::rightLine(idx_type cell, bool const ignore_bt) const
 {
-       if (use_booktabs)
+       if (use_booktabs && !ignore_bt)
                return false;
        return cellInfo(cell).right_line;
 }
index 1a8bf33243fcb6df9dc975ed35c1ca3c1c8e37e4..ddb02763fcb2a5e409156c77a36dba56eac5170d 100644 (file)
@@ -402,9 +402,13 @@ public:
        /// Returns true if there is a topline, returns false if not
        bool bottomLine(idx_type cell) const;
        /// Returns true if there is a topline, returns false if not
-       bool leftLine(idx_type cell) const;
+       /// If \p ignore_bt is true, we return the state as if booktabs was
+       /// not used
+       bool leftLine(idx_type cell, bool const ignore_bt = false) const;
        /// Returns true if there is a topline, returns false if not
-       bool rightLine(idx_type cell) const;
+       /// If \p ignore_bt is true, we return the state as if booktabs was
+       /// not used
+       bool rightLine(idx_type cell, bool const ignore_bt = false) const;
 
        /// return space occupied by the second horizontal line and
        /// interline space above row \p row in pixels
index edfeea5175117969d89d63a90512db45a4602500..7a75ce55e734b03bf205644ed2c5dbcc6c3799fe 100644 (file)
@@ -178,6 +178,8 @@ What's new
 
 - Fix display of formal table bottom line with multirows (bug 11445).
 
+- Fix left/right border UI when toggling formal table style (bug 9835).
+
 
 * INTERNALS