]> git.lyx.org Git - features.git/commitdiff
Migrate GuiNomencl to InsetParamsDialog.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 27 Oct 2010 20:01:49 +0000 (20:01 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 27 Oct 2010 20:01:49 +0000 (20:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35869 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiNomencl.cpp
src/frontends/qt4/GuiNomencl.h
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/InsetParamsDialog.cpp
src/frontends/qt4/ui/NomenclUi.ui

index 6aa35f827810c6e0fdbce6367a8fd21dc2b0a722..8267aab4966bd9839f0164d7531092349fff0ff0 100644 (file)
 #include "GuiNomencl.h"
 
 #include "qt_helpers.h"
-#include "FuncRequest.h"
 
-#include "insets/InsetCommand.h"
-
-#include "support/debug.h"
-
-#include <QLabel>
-#include <QLineEdit>
+#include "insets/InsetNomencl.h"
 
 using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-GuiNomenclature::GuiNomenclature(GuiView & lv)
-       : GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
-         params_(insetCode("nomenclature"))
+GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
 {
        setupUi(this);
-
-       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(symbolED, SIGNAL(textChanged(QString)),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
        connect(descriptionTE, SIGNAL(textChanged()),
-               this, SLOT(change_adaptor()));
+               this, SIGNAL(changed()));
 
        setFocusProxy(descriptionTE);
-
-       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setCancel(closePB);
-       bc().addReadOnly(symbolED);
-       bc().addReadOnly(descriptionTE);
-       bc().addReadOnly(prefixED);
 }
 
 
-void GuiNomenclature::change_adaptor()
+void GuiNomenclature::paramsToDialog(Inset const * inset)
 {
-       changed();
-}
-
+       InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
+       InsetCommandParams const & params = nomencl->params();
 
-void GuiNomenclature::reject()
-{
-       slotClose();
-}
-
-
-void GuiNomenclature::paramsToDialog(InsetCommandParams const & /*icp*/)
-{
-       prefixED->setText(toqstr(params_["prefix"]));
-       symbolED->setText(toqstr(params_["symbol"]));
-       QString description = toqstr(params_["description"]);
+       prefixED->setText(toqstr(params["prefix"]));
+       symbolED->setText(toqstr(params["symbol"]));
+       QString description = toqstr(params["description"]);
        description.replace("\\\\","\n");
        descriptionTE->setPlainText(description);
        descriptionTE->setFocus();
-
-       bc().setValid(isValid());
 }
 
 
-void GuiNomenclature::applyView()
+docstring GuiNomenclature::dialogToParams() const
 {
-       params_["prefix"] = qstring_to_ucs4(prefixED->text());
-       params_["symbol"] = qstring_to_ucs4(symbolED->text());
+       InsetCommandParams params(insetCode());
+       params["prefix"] = qstring_to_ucs4(prefixED->text());
+       params["symbol"] = qstring_to_ucs4(symbolED->text());
        QString description = descriptionTE->toPlainText();
        description.replace('\n',"\\\\");
-       params_["description"] = qstring_to_ucs4(description);
+       params["description"] = qstring_to_ucs4(description);
+       return from_ascii(InsetNomencl::params2string("nomenclature", params));
 }
 
 
-bool GuiNomenclature::isValid()
+bool GuiNomenclature::checkWidgets() const
 {
+       if (!InsetParamsWidget::checkWidgets())
+               return false;
        QString const description = descriptionTE->toPlainText();
        return !symbolED->text().isEmpty() && !description.isEmpty();
 }
 
-
-bool GuiNomenclature::initialiseParams(std::string const & data)
-{
-       InsetCommand::string2params("nomenclature", data, params_);
-       paramsToDialog(params_);
-       return true;
-}
-
-
-void GuiNomenclature::dispatchParams()
-{
-       std::string const lfun = InsetCommand::params2string("nomenclature", params_);
-       dispatch(FuncRequest(getLfun(), lfun));
-}
-
-
-
-Dialog * createGuiNomenclature(GuiView & lv)
-{
-       return new GuiNomenclature(lv);
-}
-
-
 } // namespace frontend
 } // namespace lyx
 
index 0b83d2e0e28d0e12a97f1c048ab7fec6c5809508..502f8de53a8041dbac89a686a5b396ad72447bfd 100644 (file)
 #ifndef GUINOMENCLATURE_H
 #define GUINOMENCLATURE_H
 
-#include "GuiDialog.h"
 #include "ui_NomenclUi.h"
 
-#include "insets/InsetCommandParams.h"
+#include "InsetParamsWidget.h"
 
 namespace lyx {
 namespace frontend {
 
-class GuiNomenclature : public GuiDialog, public Ui::NomenclUi
+class GuiNomenclature : public InsetParamsWidget, public Ui::NomenclUi
 {
        Q_OBJECT
 
 public:
-       GuiNomenclature(GuiView & lv);
-
-private Q_SLOTS:
-       void change_adaptor();
-       void reject();
-
-private:
-       ///
-       bool isValid();
-       /// Apply changes
-       void applyView();
-       /// update
-       void updateContents() {}
-       ///
-       bool initialiseParams(std::string const & data);
-       ///
-       void paramsToDialog(InsetCommandParams const & icp);
-       /// clean-up on hide.
-       void clearParams() { params_.clear(); }
-       /// clean-up on hide.
-       void dispatchParams();
-       ///
-       bool isBufferDependent() const { return true; }
+       GuiNomenclature(QWidget * parent = 0);
 
 private:
-       ///
-       InsetCommandParams params_;
+       /// \name InsetParamsWidget inherited methods
+       //@{
+       InsetCode insetCode() const { return NOMENCL_CODE; }
+       FuncCode creationCode() const { return LFUN_INSET_INSERT; }
+       void paramsToDialog(Inset const *);
+       docstring dialogToParams() const;
+       bool checkWidgets() const;
+       //@}
 };
 
 } // namespace frontend
index b20d38e22bcdaaab1fe47714239e7d8bff9617e4..c02c529ddd49c12431c25dc9bbb83b855164cc43 100644 (file)
@@ -3774,7 +3774,6 @@ Dialog * createGuiIndex(GuiView & lv);
 Dialog * createGuiListings(GuiView & lv);
 Dialog * createGuiLog(GuiView & lv);
 Dialog * createGuiMathMatrix(GuiView & lv);
-Dialog * createGuiNomenclature(GuiView & lv);
 Dialog * createGuiNote(GuiView & lv);
 Dialog * createGuiParagraph(GuiView & lv);
 Dialog * createGuiPhantom(GuiView & lv);
@@ -3849,8 +3848,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiDelimiter(*this);
        if (name == "mathmatrix")
                return createGuiMathMatrix(*this);
-       if (name == "nomenclature")
-               return createGuiNomenclature(*this);
        if (name == "nomencl_print")
                return createGuiPrintNomencl(*this);
        if (name == "note")
index c262336f82c6983e97378e4264b682177bbb3715..aefda94fae6055fdb97a76c2ec8aa45bc558e2ca 100644 (file)
 #include "GuiBranch.h"\r
 #include "GuiBibitem.h"\r
 #include "GuiERT.h"\r
+#include "GuiHSpace.h"\r
 #include "GuiHyperlink.h"\r
 #include "GuiInfo.h"\r
 #include "GuiLabel.h"\r
 #include "GuiLine.h"\r
-#include "GuiHSpace.h"\r
+#include "GuiNomencl.h"\r
 #include "GuiTabular.h"\r
 #include "GuiVSpace.h"\r
 #include "FloatPlacement.h"\r
@@ -249,6 +250,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
        case MATH_SPACE_CODE:\r
                widget = new GuiHSpace(true);\r
                break;\r
+       case NOMENCL_CODE:\r
+               widget = new GuiNomenclature;\r
+               break;\r
        case SPACE_CODE:\r
                widget = new GuiHSpace(false);\r
                break;\r
index e59f9f1106d25b5d9a6d11bbd0a30a14defcf66b..4e47cfa5cf4660f58d827fef1ad7c14fbd27e57c 100644 (file)
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>NomenclUi</class>
- <widget class="QDialog" name="NomenclUi" >
-  <property name="geometry" >
+ <widget class="QWidget" name="NomenclUi">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>254</width>
-    <height>165</height>
+    <height>172</height>
    </rect>
   </property>
-  <property name="windowTitle" >
-   <string/>
+  <property name="windowTitle">
+   <string>Nomenclature</string>
   </property>
-  <property name="sizeGripEnabled" >
-   <bool>true</bool>
-  </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="spacing">
     <number>6</number>
    </property>
-   <item row="2" column="1" >
-    <widget class="QLineEdit" name="prefixED" />
+   <item row="2" column="1">
+    <widget class="QLineEdit" name="prefixED"/>
    </item>
-   <item row="2" column="0" >
-    <widget class="QLabel" name="prefixLA" >
-     <property name="text" >
+   <item row="2" column="0">
+    <widget class="QLabel" name="prefixLA">
+     <property name="text">
       <string>Sort &amp;as:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>prefixED</cstring>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <widget class="QLabel" name="descrLA" >
-     <property name="text" >
+   <item row="1" column="0">
+    <widget class="QLabel" name="descrLA">
+     <property name="text">
       <string>&amp;Description:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>descriptionTE</cstring>
      </property>
     </widget>
    </item>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="symbolLA" >
-     <property name="text" >
+   <item row="0" column="0">
+    <widget class="QLabel" name="symbolLA">
+     <property name="text">
       <string>&amp;Symbol:</string>
      </property>
-     <property name="buddy" >
+     <property name="buddy">
       <cstring>symbolED</cstring>
      </property>
     </widget>
    </item>
-   <item row="0" column="1" >
-    <widget class="QLineEdit" name="symbolED" >
-     <property name="toolTip" >
+   <item row="0" column="1">
+    <widget class="QLineEdit" name="symbolED">
+     <property name="toolTip">
       <string/>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2" >
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::Expanding</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>20</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="okPB" >
-       <property name="text" >
-        <string>&amp;OK</string>
-       </property>
-       <property name="shortcut" >
-        <string>Alt+O</string>
-       </property>
-       <property name="default" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="closePB" >
-       <property name="text" >
-        <string>Cancel</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="1" column="1" >
-    <widget class="QTextEdit" name="descriptionTE" >
-     <property name="acceptRichText" >
+   <item row="1" column="1">
+    <widget class="QTextEdit" name="descriptionTE">
+     <property name="acceptRichText">
       <bool>false</bool>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
- <layoutdefault spacing="6" margin="11" />
+ <layoutdefault spacing="6" margin="11"/>
  <tabstops>
   <tabstop>symbolED</tabstop>
   <tabstop>descriptionTE</tabstop>
   <tabstop>prefixED</tabstop>
-  <tabstop>okPB</tabstop>
-  <tabstop>closePB</tabstop>
  </tabstops>
  <includes>
-  <include location="local" >qt_i18n.h</include>
+  <include location="local">qt_i18n.h</include>
  </includes>
  <resources/>
  <connections/>