]> git.lyx.org Git - features.git/commitdiff
Migrate GuiPrintNomencl to InsetParamsDialog.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 30 Oct 2010 20:14:57 +0000 (20:14 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 30 Oct 2010 20:14:57 +0000 (20:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35938 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiPrintNomencl.cpp
src/frontends/qt4/GuiPrintNomencl.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/InsetParamsDialog.cpp
src/frontends/qt4/ui/PrintNomenclUi.ui

index 3c5bd95b464c818e414cf735e51a0d5b44afc59b..2054f599442a5545684910913f0623f796cae068 100644 (file)
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
-#include <QLineEdit>
-#include <QPushButton>
-#include <QValidator>
-
 using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-GuiPrintNomencl::GuiPrintNomencl(GuiView & lv)
-       : GuiDialog(lv, "nomencl_print", qt_("Nomenclature settings")),
-         params_(insetCode("nomencl_print"))
+GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
 
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-
        connect(valueLE, SIGNAL(textChanged(QString)),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
        connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
 
        valueLE->setValidator(unsignedLengthValidator(valueLE));
 
-       // Manage the ok, apply, restore and cancel/close buttons
-       bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setApply(applyPB);
-       bc().setCancel(closePB);
-
-       // disable for read-only documents
-       bc().addReadOnly(valueLE);
-       bc().addReadOnly(unitLC);
-
        // initialize the length validator
-       bc().addCheckedLineEdit(valueLE, valueLA);
+       addCheckedWidget(valueLE, valueLA);
 
        setWidthCO->addItem(qt_("Default"),
                QVariant(toqstr("none")));
@@ -73,12 +53,6 @@ GuiPrintNomencl::GuiPrintNomencl(GuiView & lv)
 }
 
 
-void GuiPrintNomencl::change_adaptor()
-{
-       changed();
-}
-
-
 void GuiPrintNomencl::on_setWidthCO_activated(int i)
 {
        bool const custom =
@@ -91,73 +65,48 @@ void GuiPrintNomencl::on_setWidthCO_activated(int i)
 }
 
 
-void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & /*icp*/)
+void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
 {
        setWidthCO->setCurrentIndex(
-               setWidthCO->findData(toqstr(params_["set_width"])));
+               setWidthCO->findData(toqstr(params["set_width"])));
        
        lengthToWidgets(valueLE,
                        unitLC,
-                       params_["width"],
+                       params["width"],
                        Length::defaultUnit());
-
-       bc().setValid(isValid());
 }
 
 
-void GuiPrintNomencl::updateContents()
+void GuiPrintNomencl::paramsToDialog(Inset const * inset)
 {
-       bool const custom = (setWidthCO->itemData(
-                                 setWidthCO->currentIndex()).toString()
-                            == "custom");
-       valueLE->setEnabled(custom);
-       unitLC->setEnabled(custom);
-       valueLA->setEnabled(custom);
+       InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
+       paramsToDialog(nomencl->params());
 }
 
 
-void GuiPrintNomencl::applyView()
+docstring GuiPrintNomencl::dialogToParams() const
 {
+       InsetCommandParams params(insetCode());
        docstring const set_width = qstring_to_ucs4(setWidthCO->itemData(
                setWidthCO->currentIndex()).toString());
-       params_["set_width"] = set_width;
+       params["set_width"] = set_width;
        docstring width;
        if (set_width == from_ascii("custom"))
                width = from_utf8(widgetsToLength(valueLE, unitLC));
-       params_["width"] = width;
+       params["width"] = width;
+       return from_ascii(InsetNomencl::params2string(params));
 }
 
 
-bool GuiPrintNomencl::isValid() const
+bool GuiPrintNomencl::checkWidgets() const
 {
+       if (!InsetParamsWidget::checkWidgets())
+               return false;
        return setWidthCO->itemData(
                        setWidthCO->currentIndex()).toString() != "custom"
                || !valueLE->text().isEmpty();
 }
 
-
-bool GuiPrintNomencl::initialiseParams(std::string const & data)
-{
-       InsetCommand::string2params(data, params_);
-       paramsToDialog(params_);
-       return true;
-}
-
-
-void GuiPrintNomencl::dispatchParams()
-{
-       std::string const lfun = InsetCommand::params2string(params_);
-       dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-
-Dialog * createGuiPrintNomencl(GuiView & lv)
-{
-       return new GuiPrintNomencl(lv);
-}
-
-
 } // namespace frontend
 } // namespace lyx
 
index a03714061628db7c944fb351b9767074d68a404f..d4c0f8812692b2f3301cbdd58eede2e701a9677d 100644 (file)
 #ifndef GUIPRINTNOMENCL_H
 #define GUIPRINTNOMENCL_H
 
-#include "GuiDialog.h"
+#include "InsetParamsWidget.h"
 #include "ui_PrintNomenclUi.h"
 
-#include "insets/InsetCommandParams.h"
-
-
 namespace lyx {
 namespace frontend {
 
-class GuiPrintNomencl : public GuiDialog, public Ui::PrintNomenclUi
+class GuiPrintNomencl : public InsetParamsWidget, public Ui::PrintNomenclUi
 {
        Q_OBJECT
 
 public:
-       GuiPrintNomencl(GuiView & lv);
+       GuiPrintNomencl(QWidget * parent = 0);
 
 private Q_SLOTS:
-       void change_adaptor();
        void on_setWidthCO_activated(int);
 
 private:
-       /// Apply changes
-       void applyView();
-       /// Update dialog before showing it
-       void updateContents();
-       ///
-       bool initialiseParams(std::string const & data);
-       ///
-       void paramsToDialog(InsetCommandParams const & icp);
-       ///
-       void clearParams() { params_.clear(); }
-       ///
-       void dispatchParams();
-       ///
-       bool isBufferDependent() const { return true; }
-       ///
-       bool isValid() const;
-
-       ///
-       InsetCommandParams params_;
+       /// \name InsetParamsWidget inherited methods
+       //@{
+       InsetCode insetCode() const { return NOMENCL_PRINT_CODE; }
+       FuncCode creationCode() const { return LFUN_INSET_INSERT; }
+       void paramsToDialog(Inset const *);
+       void paramsToDialog(InsetCommandParams const &);
+       docstring dialogToParams() const;
+       bool checkWidgets() const;
+       //@}
 };
 
 } // namespace frontend
index bc79914c01ad58cbc2e835b7e1f0ba74b8af57a3..eb689ce56b5d5291f78e22bd3d218c2766f397e9 100644 (file)
@@ -3754,7 +3754,6 @@ Dialog * createGuiPhantom(GuiView & lv);
 Dialog * createGuiPreferences(GuiView & lv);
 Dialog * createGuiPrint(GuiView & lv);
 Dialog * createGuiPrintindex(GuiView & lv);
-Dialog * createGuiPrintNomencl(GuiView & lv);
 Dialog * createGuiRef(GuiView & lv);
 Dialog * createGuiSearch(GuiView & lv);
 Dialog * createGuiSearchAdv(GuiView & lv);
@@ -3822,8 +3821,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiDelimiter(*this);
        if (name == "mathmatrix")
                return createGuiMathMatrix(*this);
-       if (name == "nomencl_print")
-               return createGuiPrintNomencl(*this);
        if (name == "note")
                return createGuiNote(*this);
        if (name == "paragraph")
index 17b41080194c6ab8279a2c55287f05814244f0c8..698cf899bf77711e294e4340807255a9436018e0 100644 (file)
@@ -22,6 +22,7 @@
 #include "GuiLabel.h"\r
 #include "GuiLine.h"\r
 #include "GuiNomenclature.h"\r
+#include "GuiPrintNomencl.h"\r
 #include "GuiTabular.h"\r
 #include "GuiVSpace.h"\r
 #include "FloatPlacement.h"\r
@@ -255,6 +256,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
        case NOMENCL_CODE:\r
                widget = new GuiNomenclature;\r
                break;\r
+       case NOMENCL_PRINT_CODE:\r
+               widget = new GuiPrintNomencl;\r
+               break;\r
        case SPACE_CODE:\r
                widget = new GuiHSpace(false);\r
                break;\r
index b352270a78f57245084ba2805ffc5c090a541be7..d5f2cd625aa8e62eb19d9744f2bc1fd4882c61a7 100644 (file)
@@ -1,19 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>PrintNomenclUi</class>
- <widget class="QDialog" name="PrintNomenclUi">
+ <widget class="QWidget" name="PrintNomenclUi">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>280</width>
-    <height>119</height>
+    <width>336</width>
+    <height>80</height>
    </rect>
   </property>
   <property name="windowTitle">
-   <string/>
-  </property>
-  <property name="sizeGripEnabled">
-   <bool>true</bool>
+   <string>&quot;Nomenclature settings&quot;</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="0" colspan="2">
    <item row="1" column="3">
     <widget class="LengthCombo" name="unitLC"/>
    </item>
-   <item row="2" column="0">
-    <spacer name="horizontalSpacer">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>74</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="2" column="1" colspan="3">
-    <layout class="QHBoxLayout">
-     <item>
-      <widget class="QPushButton" name="okPB">
-       <property name="text">
-        <string>&amp;OK</string>
-       </property>
-       <property name="autoDefault">
-        <bool>false</bool>
-       </property>
-       <property name="default">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="applyPB">
-       <property name="text">
-        <string>&amp;Apply</string>
-       </property>
-       <property name="autoDefault">
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="closePB">
-       <property name="text">
-        <string>&amp;Close</string>
-       </property>
-       <property name="autoDefault">
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
   </layout>
  </widget>
  <customwidgets>
  </customwidgets>
  <tabstops>
   <tabstop>valueLE</tabstop>
-  <tabstop>okPB</tabstop>
-  <tabstop>applyPB</tabstop>
-  <tabstop>closePB</tabstop>
  </tabstops>
  <includes>
   <include location="local">qt_i18n.h</include>