]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWrap.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiWrap.cpp
index 7c31e48b1be6e6419de003d74a2dd8216d7f8e7a..c2e53575f80adc2fe4e5ee590084bfe6e0338bee 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
 #include "Validator.h"
 #include "FuncRequest.h"
 
-#include "insets/InsetWrap.h"
-
+#include "support/gettext.h"
 #include "support/lstrings.h"
 
 #include <QLineEdit>
-#include <QCloseEvent>
 #include <QPushButton>
 
 using namespace std;
@@ -31,22 +29,23 @@ namespace lyx {
 namespace frontend {
 
 GuiWrap::GuiWrap(GuiView & lv)
-       : GuiDialog(lv, "wrap")
+       : GuiDialog(lv, "wrap", qt_("Wrap Float Settings"))
 {
        setupUi(this);
-       setViewTitle(_("Wrap Float Settings"));
 
        connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
+       connect(valignCO, SIGNAL(highlighted(QString)),
+               this, SLOT(change_adaptor()));
+       connect(floatCB, SIGNAL(stateChanged(int)),
+               this, SLOT(change_adaptor()));
        connect(widthED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
        connect(widthUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
                this, SLOT(change_adaptor()));
-       connect(valignCO, SIGNAL(highlighted(QString)),
-               this, SLOT(change_adaptor()));
        connect(overhangCB, SIGNAL(stateChanged(int)),
                this, SLOT(change_adaptor()));
        connect(overhangED, SIGNAL(textChanged(QString)),
@@ -69,9 +68,10 @@ GuiWrap::GuiWrap(GuiView & lv)
        bc().setApply(applyPB);
        bc().setCancel(closePB);
 
+       bc().addReadOnly(valignCO);
+       bc().addReadOnly(floatCB);
        bc().addReadOnly(widthED);
        bc().addReadOnly(widthUnitLC);
-       bc().addReadOnly(valignCO);
        bc().addReadOnly(overhangCB);
        bc().addReadOnly(overhangED);
        bc().addReadOnly(overhangUnitLC);
@@ -84,13 +84,6 @@ GuiWrap::GuiWrap(GuiView & lv)
 }
 
 
-void GuiWrap::closeEvent(QCloseEvent * e)
-{
-       slotClose();
-       e->accept();
-}
-
-
 void GuiWrap::change_adaptor()
 {
        changed();
@@ -124,32 +117,47 @@ void GuiWrap::applyView()
                // in InsetWrap.cpp
                params_.lines = 0;
 
+       bool floatOn = false;
+       if (floatCB->checkState() == Qt::Checked)
+               floatOn = true;
        switch (valignCO->currentIndex()) {
        case 0:
-               params_.placement = "o";
+               if (floatOn)
+                       params_.placement = "O";
+               else
+                       params_.placement = "o";
                break;
        case 1:
-               params_.placement = "i";
+               if (floatOn)
+                       params_.placement = "I";
+               else
+                       params_.placement = "i";
                break;
        case 2:
-               params_.placement = "l";
+               if (floatOn)
+                       params_.placement = "L";
+               else
+                       params_.placement = "l";
                break;
        case 3:
-               params_.placement = "r";
+               if (floatOn)
+                       params_.placement = "R";
+               else
+                       params_.placement = "r";
                break;
        }
 }
 
 
-void GuiWrap::updateContents()
+void GuiWrap::paramsToDialog(InsetWrapParams const & params)
 {
        // 0pt is a legal width now, it yields a
        // wrapfloat just wide enough for the contents.
-       Length len_w = params_.width;
+       Length len_w = params.width;
        widthED->setText(QString::number(len_w.value()));
        widthUnitLC->setCurrentItem(len_w.unit());
 
-       Length len_o(params_.overhang);
+       Length len_o(params.overhang);
        overhangED->setText(QString::number(len_o.value()));
        overhangUnitLC->setCurrentItem(len_o.unit());
        if (len_o.value() == 0)
@@ -157,27 +165,32 @@ void GuiWrap::updateContents()
        else
                overhangCB->setCheckState(Qt::Checked);
 
-       linesSB->setValue(params_.lines);
-       if (params_.lines == 0)
+       linesSB->setValue(params.lines);
+       if (params.lines == 0)
                linesCB->setCheckState(Qt::Unchecked);
        else
                linesCB->setCheckState(Qt::Checked);
 
        int item = 0;
-       if (params_.placement == "i")
+       if (params.placement == "i" || params.placement == "I")
                item = 1;
-       else if (params_.placement == "l")
+       else if (params.placement == "l" || params.placement == "L")
                item = 2;
-       else if (params_.placement == "r")
+       else if (params.placement == "r" || params.placement == "R")
                item = 3;
 
        valignCO->setCurrentIndex(item);
+
+       if (params.placement == "O" || params.placement == "I"
+               || params.placement == "L" || params.placement == "R")
+               floatCB->setCheckState(Qt::Checked);
 }
 
 
 bool GuiWrap::initialiseParams(string const & data)
 {
-       InsetWrapMailer::string2params(data, params_);
+       InsetWrap::string2params(data, params_);
+       paramsToDialog(params_);
        return true;
 }
 
@@ -190,7 +203,7 @@ void GuiWrap::clearParams()
 
 void GuiWrap::dispatchParams()
 {
-       string const lfun = InsetWrapMailer::params2string(params_);
+       string const lfun = InsetWrap::params2string(params_);
        dispatch(FuncRequest(getLfun(), lfun));
 }
 
@@ -202,4 +215,4 @@ Dialog * createGuiWrap(GuiView & lv) { return new GuiWrap(lv); }
 } // namespace lyx
 
 
-#include "GuiWrap_moc.cpp"
+#include "moc_GuiWrap.cpp"