mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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 "GuiBibitem.h"
|
||||
|
||||
#include "qt_helpers.h"
|
||||
#include "FuncRequest.h"
|
||||
|
||||
#include "insets/InsetCommand.h"
|
||||
|
||||
@ -24,73 +24,42 @@ namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
GuiBibitem::GuiBibitem(GuiView & lv)
|
||||
: GuiDialog(lv, "bibitem", qt_("Bibliography Entry Settings")),
|
||||
params_(insetCode("bibitem"))
|
||||
GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
|
||||
connect(keyED, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
this, SIGNAL(changed()));
|
||||
connect(labelED, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
|
||||
bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
|
||||
bc().setOK(okPB);
|
||||
bc().setCancel(closePB);
|
||||
bc().addReadOnly(keyED);
|
||||
bc().addReadOnly(labelED);
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
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"]));
|
||||
labelED->setText(toqstr(params_["label"]));
|
||||
InsetCommandParams params(insetCode());
|
||||
params["key"] = qstring_to_ucs4(keyED->text());
|
||||
params["label"] = qstring_to_ucs4(labelED->text());
|
||||
return from_utf8(InsetCommand::params2string("bibitem", params));
|
||||
}
|
||||
|
||||
|
||||
void GuiBibitem::applyView()
|
||||
{
|
||||
params_["key"] = qstring_to_ucs4(keyED->text());
|
||||
params_["label"] = qstring_to_ucs4(labelED->text());
|
||||
}
|
||||
|
||||
|
||||
bool GuiBibitem::isValid()
|
||||
bool GuiBibitem::checkWidgets() const
|
||||
{
|
||||
if (!InsetParamsWidget::checkWidgets())
|
||||
return false;
|
||||
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 lyx
|
||||
|
||||
|
@ -13,44 +13,30 @@
|
||||
#ifndef GUIBIBITEM_H
|
||||
#define GUIBIBITEM_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "InsetParamsWidget.h"
|
||||
#include "ui_BibitemUi.h"
|
||||
|
||||
#include "insets/InsetCommandParams.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiBibitem : public GuiDialog, public Ui::BibitemUi
|
||||
class GuiBibitem : public InsetParamsWidget, public Ui::BibitemUi
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
GuiBibitem(GuiView & lv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void change_adaptor();
|
||||
GuiBibitem(QWidget * parent = 0);
|
||||
|
||||
private:
|
||||
///
|
||||
bool isValid();
|
||||
/// Apply changes
|
||||
void applyView();
|
||||
/// update
|
||||
void updateContents();
|
||||
///
|
||||
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_;
|
||||
/// \name DialogView inherited methods
|
||||
//@{
|
||||
InsetCode insetCode() const { return BIBITEM_CODE; }
|
||||
FuncCode creationCode() const { return LFUN_INSET_INSERT; }
|
||||
void paramsToDialog(Inset const *);
|
||||
docstring dialogToParams() const;
|
||||
bool checkWidgets() const;
|
||||
//@}
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -3452,7 +3452,6 @@ Dialog * createDialog(GuiView & lv, string const & name);
|
||||
|
||||
// will be replaced by a proper factory...
|
||||
Dialog * createGuiAbout(GuiView & lv);
|
||||
Dialog * createGuiBibitem(GuiView & lv);
|
||||
Dialog * createGuiBibtex(GuiView & lv);
|
||||
Dialog * createGuiChanges(GuiView & lv);
|
||||
Dialog * createGuiCharacter(GuiView & lv);
|
||||
@ -3505,8 +3504,6 @@ Dialog * GuiView::build(string const & name)
|
||||
|
||||
if (name == "aboutlyx")
|
||||
return createGuiAbout(*this);
|
||||
if (name == "bibitem")
|
||||
return createGuiBibitem(*this);
|
||||
if (name == "bibtex")
|
||||
return createGuiBibtex(*this);
|
||||
if (name == "changes")
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "GuiBox.h"
|
||||
#include "GuiBranch.h"
|
||||
#include "GuiBibitem.h"
|
||||
#include "GuiERT.h"
|
||||
#include "GuiInfo.h"
|
||||
#include "GuiHSpace.h"
|
||||
@ -206,6 +207,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
|
||||
case FLOAT_CODE:
|
||||
widget = new FloatPlacement(true);
|
||||
break;
|
||||
case BIBITEM_CODE:
|
||||
widget = new GuiBibitem;
|
||||
break;
|
||||
case BRANCH_CODE:
|
||||
widget = new GuiBranch;
|
||||
break;
|
||||
|
@ -1,134 +1,80 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<ui version="4.0">
|
||||
<class>BibitemUi</class>
|
||||
<widget class="QDialog" name="BibitemUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="BibitemUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>197</width>
|
||||
<height>134</height>
|
||||
<width>211</width>
|
||||
<height>74</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<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="0" column="1" >
|
||||
<widget class="QLineEdit" name="keyED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="keyED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="labelED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="labelED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="labelLA" >
|
||||
<property name="toolTip" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLA">
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>labelED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="keyLA" >
|
||||
<property name="toolTip" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="keyLA">
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>&Key:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>keyED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -80,7 +80,7 @@ static void build_translator()
|
||||
insetnames[NOMENCL_CODE] = InsetName("nomenclature");
|
||||
insetnames[INCLUDE_CODE] = InsetName("include");
|
||||
insetnames[GRAPHICS_CODE] = InsetName("graphics");
|
||||
insetnames[BIBITEM_CODE] = InsetName("bibitem");
|
||||
insetnames[BIBITEM_CODE] = InsetName("bibitem", _("Bibliography Entry"));
|
||||
insetnames[BIBTEX_CODE] = InsetName("bibtex");
|
||||
insetnames[TEXT_CODE] = InsetName("text");
|
||||
insetnames[ERT_CODE] = InsetName("ert", _("TeX Code"));
|
||||
@ -296,6 +296,7 @@ bool Inset::showInsetDialog(BufferView * bv) const
|
||||
case ERT_CODE:
|
||||
case FLOAT_CODE:
|
||||
case BOX_CODE:
|
||||
case BIBITEM_CODE:
|
||||
case BRANCH_CODE:
|
||||
case INFO_CODE:
|
||||
case MATH_SPACE_CODE:
|
||||
|
Loading…
Reference in New Issue
Block a user