#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
#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
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);
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")
#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
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
-<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 &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>&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>&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>&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/>