]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiParagraph.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiParagraph.cpp
index 835bd520ebc4b57eaada06c7e1221d1e963ffc71..6cad13767308076f0881beec28e7ee244d43d5a6 100644 (file)
@@ -135,7 +135,7 @@ void GuiParagraph::alignmentToRadioButtons(LyXAlignment align)
 }
 
 
-LyXAlignment GuiParagraph::getAlignmentFromDialog()
+LyXAlignment GuiParagraph::getAlignmentFromDialog() const
 {
        LyXAlignment alignment = LYX_ALIGN_NONE;
        RadioMap::const_iterator it = radioMap_.begin();
@@ -196,9 +196,9 @@ void GuiParagraph::on_restorePB_clicked()
 
 void GuiParagraph::applyView()
 {
-       ParagraphParameters & pp = params();
+       params_ = params();
 
-       pp.align(getAlignmentFromDialog());
+       params_.align(getAlignmentFromDialog());
 
        // get spacing
        Spacing::Space ls = Spacing::Default;
@@ -218,17 +218,17 @@ void GuiParagraph::applyView()
                break;
        case 4:
                ls = Spacing::Other;
-               other = fromqstr(linespacingValue->text());
+               other = widgetToDoubleStr(linespacingValue);
                break;
        }
 
        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();
 }
@@ -242,8 +242,7 @@ void GuiParagraph::updateView()
 
        // label width
        docstring const & labelwidth = pp.labelWidthString();
-       // FIXME We should not compare translated strings
-       if (labelwidth != _("Senseless with this layout!")) {
+       if (hasLabelwidth()) {
                labelwidthGB->setEnabled(true);
                labelWidth->setText(toqstr(labelwidth));
        } else {
@@ -282,7 +281,7 @@ void GuiParagraph::updateView()
        }
        linespacing->setCurrentIndex(ls);
        if (space.getSpace() == Spacing::Other) {
-               linespacingValue->setText(toqstr(space.getValueAsString()));
+               doubleToWidget(linespacingValue, space.getValue());
                linespacingValue->setEnabled(true);
        } else {
                linespacingValue->setText(QString());
@@ -307,42 +306,28 @@ void GuiParagraph::enableView(bool enable)
 }
 
 
-ParagraphParameters & GuiParagraph::params()
+ParagraphParameters const & GuiParagraph::params() const
 {
        if (haveMultiParSelection()) {
-               multiparsel_ = ParagraphParameters();
-               // FIXME: It would be nice to initialise the parameters that
-               // are common to all paragraphs.
-               return multiparsel_;
+               // FIXME: in case of multi-paragraph selection, it would be nice to
+               // initialise the parameters that are common to all paragraphs.
+               static ParagraphParameters empty;
+               return empty;
        }
-
-       return bufferview()->cursor().innerParagraph().params();
-}
-
-
-ParagraphParameters const & GuiParagraph::params() const
-{
        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();
@@ -368,6 +353,14 @@ LyXAlignment GuiParagraph::alignDefault() const
 }
 
 
+bool GuiParagraph::hasLabelwidth() const
+{
+       Layout layout = bufferview()->cursor().innerParagraph().layout();
+       return (layout.margintype == MARGIN_MANUAL
+               || layout.latextype == LATEX_BIB_ENVIRONMENT);
+}
+
+
 void GuiParagraph::saveSession() const
 {
        Dialog::saveSession();
@@ -394,4 +387,4 @@ Dialog * createGuiParagraph(GuiView & lv)
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiParagraph_moc.cpp"
+#include "moc_GuiParagraph.cpp"