From 14875e5e31d77e8bbfb51668ae6d91a7920ad917 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 29 Sep 2008 10:18:37 +0000 Subject: [PATCH] Properly fix http://bugzilla.lyx.org/show_bug.cgi?id=5285 by using lfun machinery in all cases. Also fixes dialog view in case of multipar selection. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26617 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiParagraph.cpp | 52 +++++++++++++----------------- src/frontends/qt4/GuiParagraph.h | 6 ++-- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 835bd520eb..c991025e31 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -196,9 +196,15 @@ void GuiParagraph::on_restorePB_clicked() void GuiParagraph::applyView() { - ParagraphParameters & pp = params(); + if (haveMultiParSelection()) { + // FIXME: in case of multi-paragraph selection, it would be nice to + // initialise the parameters that are common to all paragraphs. + params_ = ParagraphParameters(); + } else { + params_ = bufferview()->cursor().innerParagraph().params(); + } - pp.align(getAlignmentFromDialog()); + params_.align(getAlignmentFromDialog()); // get spacing Spacing::Space ls = Spacing::Default; @@ -223,12 +229,12 @@ void GuiParagraph::applyView() } Spacing const spacing(ls, other); - pp.spacing(spacing); + params_.spacing(spacing); // label width - pp.labelWidthString(qstring_to_ucs4(labelWidth->text())); + params_.labelWidthString(qstring_to_ucs4(labelWidth->text())); // indendation - pp.noindent(!indentCB->isChecked()); + params_.noindent(!indentCB->isChecked()); dispatchParams(); } @@ -307,42 +313,28 @@ void GuiParagraph::enableView(bool enable) } -ParagraphParameters & GuiParagraph::params() -{ - if (haveMultiParSelection()) { - multiparsel_ = ParagraphParameters(); - // FIXME: It would be nice to initialise the parameters that - // are common to all paragraphs. - return multiparsel_; - } - - return bufferview()->cursor().innerParagraph().params(); -} - - ParagraphParameters const & GuiParagraph::params() const { + if (haveMultiParSelection()) { + // FIXME: in case of multi-paragraph selection, it would be nice to + // initialise the parameters that are common to all paragraphs. + params_ = ParagraphParameters(); + return params_; + } return bufferview()->cursor().innerParagraph().params(); } void GuiParagraph::dispatchParams() { - if (haveMultiParSelection()) { - ostringstream data; - multiparsel_.write(data); - FuncRequest const fr(getLfun(), data.str()); - dispatch(fr); - return; - } - - bufferview()->updateMetrics(); - bufferview()->buffer().changed(); - bufferview()->buffer().markDirty(); + ostringstream data; + params_.write(data); + FuncRequest const fr(getLfun(), data.str()); + dispatch(fr); } -bool GuiParagraph::haveMultiParSelection() +bool GuiParagraph::haveMultiParSelection() const { Cursor const & cur = bufferview()->cursor(); return cur.selection() && cur.selBegin().pit() != cur.selEnd().pit(); diff --git a/src/frontends/qt4/GuiParagraph.h b/src/frontends/qt4/GuiParagraph.h index 429284fc4d..42677f5603 100644 --- a/src/frontends/qt4/GuiParagraph.h +++ b/src/frontends/qt4/GuiParagraph.h @@ -59,11 +59,9 @@ private: /// LyXAlignment getAlignmentFromDialog(); /// - ParagraphParameters & params(); - /// ParagraphParameters const & params() const; /// - bool haveMultiParSelection(); + bool haveMultiParSelection() const; /// bool canIndent() const; /// @@ -96,7 +94,7 @@ private: /// QString alignDefaultLabel_; /// - ParagraphParameters multiparsel_; + mutable ParagraphParameters params_; }; } // namespace frontend