mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
Migrate GuiBibitem to InsetParamsWidget.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33547 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
656caf4078
commit
85c782bde8
@ -11,8 +11,8 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "GuiBibitem.h"
|
#include "GuiBibitem.h"
|
||||||
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "FuncRequest.h"
|
|
||||||
|
|
||||||
#include "insets/InsetCommand.h"
|
#include "insets/InsetCommand.h"
|
||||||
|
|
||||||
@ -24,73 +24,42 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
GuiBibitem::GuiBibitem(GuiView & lv)
|
GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
|
||||||
: GuiDialog(lv, "bibitem", qt_("Bibliography Entry Settings")),
|
|
||||||
params_(insetCode("bibitem"))
|
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
||||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
||||||
|
|
||||||
connect(keyED, SIGNAL(textChanged(QString)),
|
connect(keyED, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SIGNAL(changed()));
|
||||||
connect(labelED, SIGNAL(textChanged(QString)),
|
connect(labelED, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(change_adaptor()));
|
this, SIGNAL(changed()));
|
||||||
|
|
||||||
bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
|
|
||||||
bc().setOK(okPB);
|
|
||||||
bc().setCancel(closePB);
|
|
||||||
bc().addReadOnly(keyED);
|
|
||||||
bc().addReadOnly(labelED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBibitem::change_adaptor()
|
void GuiBibitem::paramsToDialog(Inset const * inset)
|
||||||
{
|
{
|
||||||
changed();
|
InsetCommand const * ic = static_cast<InsetCommand const *>(inset);
|
||||||
|
InsetCommandParams const & params = ic->params();
|
||||||
|
keyED->setText(toqstr(params["key"]));
|
||||||
|
labelED->setText(toqstr(params["label"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBibitem::updateContents()
|
docstring GuiBibitem::dialogToParams() const
|
||||||
{
|
{
|
||||||
keyED->setText(toqstr(params_["key"]));
|
InsetCommandParams params(insetCode());
|
||||||
labelED->setText(toqstr(params_["label"]));
|
params["key"] = qstring_to_ucs4(keyED->text());
|
||||||
|
params["label"] = qstring_to_ucs4(labelED->text());
|
||||||
|
return from_utf8(InsetCommand::params2string("bibitem", params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBibitem::applyView()
|
bool GuiBibitem::checkWidgets() const
|
||||||
{
|
|
||||||
params_["key"] = qstring_to_ucs4(keyED->text());
|
|
||||||
params_["label"] = qstring_to_ucs4(labelED->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GuiBibitem::isValid()
|
|
||||||
{
|
{
|
||||||
|
if (!InsetParamsWidget::checkWidgets())
|
||||||
|
return false;
|
||||||
return !keyED->text().isEmpty();
|
return !keyED->text().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GuiBibitem::initialiseParams(std::string const & data)
|
|
||||||
{
|
|
||||||
// The name passed with LFUN_INSET_APPLY is also the name
|
|
||||||
// used to identify the mailer.
|
|
||||||
InsetCommand::string2params("bibitem", data, params_);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiBibitem::dispatchParams()
|
|
||||||
{
|
|
||||||
std::string const lfun = InsetCommand::params2string("bibitem", params_);
|
|
||||||
dispatch(FuncRequest(getLfun(), lfun));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -13,44 +13,30 @@
|
|||||||
#ifndef GUIBIBITEM_H
|
#ifndef GUIBIBITEM_H
|
||||||
#define GUIBIBITEM_H
|
#define GUIBIBITEM_H
|
||||||
|
|
||||||
#include "GuiDialog.h"
|
#include "InsetParamsWidget.h"
|
||||||
#include "ui_BibitemUi.h"
|
#include "ui_BibitemUi.h"
|
||||||
|
|
||||||
#include "insets/InsetCommandParams.h"
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiBibitem : public GuiDialog, public Ui::BibitemUi
|
class GuiBibitem : public InsetParamsWidget, public Ui::BibitemUi
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
GuiBibitem(GuiView & lv);
|
GuiBibitem(QWidget * parent = 0);
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void change_adaptor();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
/// \name DialogView inherited methods
|
||||||
bool isValid();
|
//@{
|
||||||
/// Apply changes
|
InsetCode insetCode() const { return BIBITEM_CODE; }
|
||||||
void applyView();
|
FuncCode creationCode() const { return LFUN_INSET_INSERT; }
|
||||||
/// update
|
void paramsToDialog(Inset const *);
|
||||||
void updateContents();
|
docstring dialogToParams() const;
|
||||||
///
|
bool checkWidgets() const;
|
||||||
bool initialiseParams(std::string const & data);
|
//@}
|
||||||
/// clean-up on hide.
|
|
||||||
void clearParams() { params_.clear(); }
|
|
||||||
/// clean-up on hide.
|
|
||||||
void dispatchParams();
|
|
||||||
///
|
|
||||||
bool isBufferDependent() const { return true; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
InsetCommandParams params_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -3452,7 +3452,6 @@ Dialog * createDialog(GuiView & lv, string const & name);
|
|||||||
|
|
||||||
// will be replaced by a proper factory...
|
// will be replaced by a proper factory...
|
||||||
Dialog * createGuiAbout(GuiView & lv);
|
Dialog * createGuiAbout(GuiView & lv);
|
||||||
Dialog * createGuiBibitem(GuiView & lv);
|
|
||||||
Dialog * createGuiBibtex(GuiView & lv);
|
Dialog * createGuiBibtex(GuiView & lv);
|
||||||
Dialog * createGuiChanges(GuiView & lv);
|
Dialog * createGuiChanges(GuiView & lv);
|
||||||
Dialog * createGuiCharacter(GuiView & lv);
|
Dialog * createGuiCharacter(GuiView & lv);
|
||||||
@ -3505,8 +3504,6 @@ Dialog * GuiView::build(string const & name)
|
|||||||
|
|
||||||
if (name == "aboutlyx")
|
if (name == "aboutlyx")
|
||||||
return createGuiAbout(*this);
|
return createGuiAbout(*this);
|
||||||
if (name == "bibitem")
|
|
||||||
return createGuiBibitem(*this);
|
|
||||||
if (name == "bibtex")
|
if (name == "bibtex")
|
||||||
return createGuiBibtex(*this);
|
return createGuiBibtex(*this);
|
||||||
if (name == "changes")
|
if (name == "changes")
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "GuiBox.h"
|
#include "GuiBox.h"
|
||||||
#include "GuiBranch.h"
|
#include "GuiBranch.h"
|
||||||
|
#include "GuiBibitem.h"
|
||||||
#include "GuiERT.h"
|
#include "GuiERT.h"
|
||||||
#include "GuiInfo.h"
|
#include "GuiInfo.h"
|
||||||
#include "GuiHSpace.h"
|
#include "GuiHSpace.h"
|
||||||
@ -206,6 +207,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
|
|||||||
case FLOAT_CODE:
|
case FLOAT_CODE:
|
||||||
widget = new FloatPlacement(true);
|
widget = new FloatPlacement(true);
|
||||||
break;
|
break;
|
||||||
|
case BIBITEM_CODE:
|
||||||
|
widget = new GuiBibitem;
|
||||||
|
break;
|
||||||
case BRANCH_CODE:
|
case BRANCH_CODE:
|
||||||
widget = new GuiBranch;
|
widget = new GuiBranch;
|
||||||
break;
|
break;
|
||||||
|
@ -1,134 +1,80 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0">
|
||||||
<author></author>
|
|
||||||
<comment></comment>
|
|
||||||
<exportmacro></exportmacro>
|
|
||||||
<class>BibitemUi</class>
|
<class>BibitemUi</class>
|
||||||
<widget class="QDialog" name="BibitemUi" >
|
<widget class="QWidget" name="BibitemUi">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>197</width>
|
<width>211</width>
|
||||||
<height>134</height>
|
<height>74</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeGripEnabled" >
|
<layout class="QGridLayout">
|
||||||
<bool>true</bool>
|
<property name="margin">
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" >
|
|
||||||
<property name="margin" >
|
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing" >
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="keyED" >
|
<widget class="QLineEdit" name="keyED">
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy">
|
||||||
<sizepolicy>
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<hsizetype>7</hsizetype>
|
|
||||||
<vsizetype>0</vsizetype>
|
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip">
|
||||||
<string>The bibliography key</string>
|
<string>The bibliography key</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="labelED" >
|
<widget class="QLineEdit" name="labelED">
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy">
|
||||||
<sizepolicy>
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<hsizetype>7</hsizetype>
|
|
||||||
<vsizetype>0</vsizetype>
|
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip" >
|
<property name="toolTip">
|
||||||
<string>The label as it appears in the document</string>
|
<string>The label as it appears in the document</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelLA" >
|
<widget class="QLabel" name="labelLA">
|
||||||
<property name="toolTip" >
|
<property name="toolTip">
|
||||||
<string>The label as it appears in the document</string>
|
<string>The label as it appears in the document</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Label:</string>
|
<string>&Label:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>labelED</cstring>
|
<cstring>labelED</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="keyLA" >
|
<widget class="QLabel" name="keyLA">
|
||||||
<property name="toolTip" >
|
<property name="toolTip">
|
||||||
<string>The bibliography key</string>
|
<string>The bibliography key</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Key:</string>
|
<string>&Key:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>keyED</cstring>
|
<cstring>keyED</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" 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="default" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="closePB" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Close</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<includes>
|
<includes>
|
||||||
<include location="local" >qt_i18n.h</include>
|
<include location="local">qt_i18n.h</include>
|
||||||
</includes>
|
</includes>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -80,7 +80,7 @@ static void build_translator()
|
|||||||
insetnames[NOMENCL_CODE] = InsetName("nomenclature");
|
insetnames[NOMENCL_CODE] = InsetName("nomenclature");
|
||||||
insetnames[INCLUDE_CODE] = InsetName("include");
|
insetnames[INCLUDE_CODE] = InsetName("include");
|
||||||
insetnames[GRAPHICS_CODE] = InsetName("graphics");
|
insetnames[GRAPHICS_CODE] = InsetName("graphics");
|
||||||
insetnames[BIBITEM_CODE] = InsetName("bibitem");
|
insetnames[BIBITEM_CODE] = InsetName("bibitem", _("Bibliography Entry"));
|
||||||
insetnames[BIBTEX_CODE] = InsetName("bibtex");
|
insetnames[BIBTEX_CODE] = InsetName("bibtex");
|
||||||
insetnames[TEXT_CODE] = InsetName("text");
|
insetnames[TEXT_CODE] = InsetName("text");
|
||||||
insetnames[ERT_CODE] = InsetName("ert", _("TeX Code"));
|
insetnames[ERT_CODE] = InsetName("ert", _("TeX Code"));
|
||||||
@ -296,6 +296,7 @@ bool Inset::showInsetDialog(BufferView * bv) const
|
|||||||
case ERT_CODE:
|
case ERT_CODE:
|
||||||
case FLOAT_CODE:
|
case FLOAT_CODE:
|
||||||
case BOX_CODE:
|
case BOX_CODE:
|
||||||
|
case BIBITEM_CODE:
|
||||||
case BRANCH_CODE:
|
case BRANCH_CODE:
|
||||||
case INFO_CODE:
|
case INFO_CODE:
|
||||||
case MATH_SPACE_CODE:
|
case MATH_SPACE_CODE:
|
||||||
|
Loading…
Reference in New Issue
Block a user