From ee535fa8ea446ee987922528079df4d07b4750ce Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 27 Oct 2010 20:01:49 +0000 Subject: [PATCH] Migrate GuiNomencl to InsetParamsDialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35869 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiNomencl.cpp | 86 ++++-------------- src/frontends/qt4/GuiNomencl.h | 39 +++----- src/frontends/qt4/GuiView.cpp | 3 - src/frontends/qt4/InsetParamsDialog.cpp | 6 +- src/frontends/qt4/ui/NomenclUi.ui | 114 +++++++----------------- 5 files changed, 67 insertions(+), 181 deletions(-) diff --git a/src/frontends/qt4/GuiNomencl.cpp b/src/frontends/qt4/GuiNomencl.cpp index 6aa35f8278..8267aab496 100644 --- a/src/frontends/qt4/GuiNomencl.cpp +++ b/src/frontends/qt4/GuiNomencl.cpp @@ -14,108 +14,60 @@ #include "GuiNomencl.h" #include "qt_helpers.h" -#include "FuncRequest.h" -#include "insets/InsetCommand.h" - -#include "support/debug.h" - -#include -#include +#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(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 diff --git a/src/frontends/qt4/GuiNomencl.h b/src/frontends/qt4/GuiNomencl.h index 0b83d2e0e2..502f8de53a 100644 --- a/src/frontends/qt4/GuiNomencl.h +++ b/src/frontends/qt4/GuiNomencl.h @@ -14,46 +14,29 @@ #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 diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index b20d38e22b..c02c529ddd 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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") diff --git a/src/frontends/qt4/InsetParamsDialog.cpp b/src/frontends/qt4/InsetParamsDialog.cpp index c262336f82..aefda94fae 100644 --- a/src/frontends/qt4/InsetParamsDialog.cpp +++ b/src/frontends/qt4/InsetParamsDialog.cpp @@ -16,11 +16,12 @@ #include "GuiBranch.h" #include "GuiBibitem.h" #include "GuiERT.h" +#include "GuiHSpace.h" #include "GuiHyperlink.h" #include "GuiInfo.h" #include "GuiLabel.h" #include "GuiLine.h" -#include "GuiHSpace.h" +#include "GuiNomencl.h" #include "GuiTabular.h" #include "GuiVSpace.h" #include "FloatPlacement.h" @@ -249,6 +250,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code) case MATH_SPACE_CODE: widget = new GuiHSpace(true); break; + case NOMENCL_CODE: + widget = new GuiNomenclature; + break; case SPACE_CODE: widget = new GuiHSpace(false); break; diff --git a/src/frontends/qt4/ui/NomenclUi.ui b/src/frontends/qt4/ui/NomenclUi.ui index e59f9f1106..4e47cfa5cf 100644 --- a/src/frontends/qt4/ui/NomenclUi.ui +++ b/src/frontends/qt4/ui/NomenclUi.ui @@ -1,132 +1,82 @@ - + + NomenclUi - - + + 0 0 254 - 165 + 172 - - + + Nomenclature - - true - - - + + 9 - + 6 - - + + - - - + + + Sort &as: - + prefixED - - - + + + &Description: - + descriptionTE - - - + + + &Symbol: - + symbolED - - - + + + - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - &OK - - - Alt+O - - - true - - - - - - - Cancel - - - - - - - - + + + false - + symbolED descriptionTE prefixED - okPB - closePB - qt_i18n.h + qt_i18n.h -- 2.39.2