mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Migrate GuiNomencl to InsetParamsDialog.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35869 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
585f8b9fda
commit
ee535fa8ea
@ -14,108 +14,60 @@
|
||||
#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
|
||||
|
||||
|
@ -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();
|
||||
GuiNomenclature(QWidget * parent = 0);
|
||||
|
||||
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; }
|
||||
|
||||
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
|
||||
|
@ -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")
|
||||
|
@ -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;
|
||||
|
@ -1,132 +1,82 @@
|
||||
<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/>
|
||||
|
Loading…
Reference in New Issue
Block a user