git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20813 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-07 10:31:37 +00:00
parent 9358073e14
commit 09013cf1af
4 changed files with 64 additions and 29 deletions

View File

@ -16,7 +16,6 @@
#include "ButtonController.h" #include "ButtonController.h"
#include "DialogView.h" #include "DialogView.h"
#include "DockView.h" #include "DockView.h"
#include "GuiBibitem.h"
#include "GuiDelimiter.h" #include "GuiDelimiter.h"
#include "GuiIndex.h" #include "GuiIndex.h"
#include "GuiMathMatrix.h" #include "GuiMathMatrix.h"
@ -96,7 +95,7 @@ Dialog * createGuiLog(LyXView & lv);
Dialog * createGuiMath(LyXView & lv); Dialog * createGuiMath(LyXView & lv);
Dialog * createGuiNomencl(LyXView & lv); Dialog * createGuiNomencl(LyXView & lv);
Dialog * createGuiNote(LyXView & lv); Dialog * createGuiNote(LyXView & lv);
Dialog * createGuiParagraph(LyXView & lv) Dialog * createGuiParagraph(LyXView & lv);
Dialog * createGuiPreferences(LyXView & lv); Dialog * createGuiPreferences(LyXView & lv);
Dialog * createGuiPrint(LyXView & lv); Dialog * createGuiPrint(LyXView & lv);
Dialog * createGuiRef(LyXView & lv); Dialog * createGuiRef(LyXView & lv);
@ -129,7 +128,7 @@ Dialog * Dialogs::build(string const & name)
if (name == "aboutlyx") if (name == "aboutlyx")
return createGuiAbout(lyxview_); return createGuiAbout(lyxview_);
if (name == "bibitem") if (name == "bibitem")
return new GuiBibitemDialog(lyxview_); return createGuiBibitem(lyxview_);
if (name == "bibtex") if (name == "bibtex")
return createGuiBibtex(lyxview_); return createGuiBibtex(lyxview_);
if (name == "box") if (name == "box")

View File

@ -13,6 +13,9 @@
#include "GuiBibitem.h" #include "GuiBibitem.h"
#include "ControlCommand.h" #include "ControlCommand.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "FuncRequest.h"
#include "insets/InsetCommand.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QLineEdit> #include <QLineEdit>
@ -23,19 +26,19 @@ namespace lyx {
namespace frontend { namespace frontend {
GuiBibitemDialog::GuiBibitemDialog(LyXView & lv) GuiBibitem::GuiBibitem(LyXView & lv)
: GuiDialog(lv, "bibitem") : GuiDialog(lv, "bibitem"), Controller(this), params_("bibitem")
{ {
setupUi(this); setupUi(this);
setViewTitle(_("Bibliography Entry Settings")); setViewTitle(_("Bibliography Entry Settings"));
setController(new ControlCommand(*this, "bibitem")); setController(this, false);
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
connect(keyED, SIGNAL(textChanged(const QString &)), connect(keyED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(labelED, SIGNAL(textChanged(const QString &)), connect(labelED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy); bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
@ -46,44 +49,58 @@ GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
} }
ControlCommand & GuiBibitemDialog::controller() void GuiBibitem::change_adaptor()
{
return static_cast<ControlCommand &>(GuiDialog::controller());
}
void GuiBibitemDialog::change_adaptor()
{ {
changed(); changed();
} }
void GuiBibitemDialog::closeEvent(QCloseEvent *e) void GuiBibitem::closeEvent(QCloseEvent *e)
{ {
slotClose(); slotClose();
e->accept(); e->accept();
} }
void GuiBibitemDialog::updateContents() void GuiBibitem::updateContents()
{ {
keyED->setText(toqstr(controller().params()["key"])); keyED->setText(toqstr(params_["key"]));
labelED->setText(toqstr(controller().params()["label"])); labelED->setText(toqstr(params_["label"]));
} }
void GuiBibitemDialog::applyView() void GuiBibitem::applyView()
{ {
controller().params()["key"] = qstring_to_ucs4(keyED->text()); params_["key"] = qstring_to_ucs4(keyED->text());
controller().params()["label"] = qstring_to_ucs4(labelED->text()); params_["label"] = qstring_to_ucs4(labelED->text());
} }
bool GuiBibitemDialog::isValid() bool GuiBibitem::isValid()
{ {
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.
InsetCommandMailer::string2params("bibitem", data, params_);
return true;
}
void GuiBibitem::dispatchParams()
{
std::string const lfun = InsetCommandMailer::params2string("bibitem", params_);
dispatch(FuncRequest(getLfun(), lfun));
}
Dialog * createGuiBibitem(LyXView & lv) { return new GuiBibitem(lv); }
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -4,6 +4,7 @@
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
* \author Angus Leeming
* \author John Levon * \author John Levon
* *
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
@ -13,18 +14,21 @@
#define GUIBIBITEM_H #define GUIBIBITEM_H
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ControlCommand.h"
#include "ui_BibitemUi.h" #include "ui_BibitemUi.h"
#include "frontends/Dialog.h"
#include "insets/InsetCommandParams.h"
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class GuiBibitemDialog : public GuiDialog, public Ui::BibitemUi class GuiBibitem : public GuiDialog, public Ui::BibitemUi, public Controller
{ {
Q_OBJECT Q_OBJECT
public: public:
GuiBibitemDialog(LyXView & lv); GuiBibitem(LyXView & lv);
private Q_SLOTS: private Q_SLOTS:
void change_adaptor(); void change_adaptor();
@ -33,7 +37,7 @@ private:
/// ///
void closeEvent(QCloseEvent * e); void closeEvent(QCloseEvent * e);
/// parent controller /// parent controller
ControlCommand & controller(); Controller & controller() { return *this; }
private: private:
/// ///
@ -42,6 +46,18 @@ private:
void applyView(); void applyView();
/// update /// update
void updateContents(); 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_;
}; };
} // namespace frontend } // namespace frontend

View File

@ -22,6 +22,9 @@
#include "gettext.h" #include "gettext.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "Spacing.h" #include "Spacing.h"
#include "GuiView.h"
#include "DialogView.h"
#include "DockView.h"
#include <QCheckBox> #include <QCheckBox>
#include <QCloseEvent> #include <QCloseEvent>
@ -251,10 +254,10 @@ Dialog * createGuiParagraph(LyXView & lv)
{ {
GuiViewBase & guiview = static_cast<GuiViewBase &>(lv); GuiViewBase & guiview = static_cast<GuiViewBase &>(lv);
#ifdef USE_DOCK_WIDGET #ifdef USE_DOCK_WIDGET
return new DockView<ControlParagraph, GuiParagraph>(guiview, name, return new DockView<ControlParagraph, GuiParagraph>(guiview, "paragraph",
Qt::TopDockWidgetArea); Qt::TopDockWidgetArea);
#else #else
return new DialogView<ControlParagraph, GuiParagraph>(guiview, name); return new DialogView<ControlParagraph, GuiParagraph>(guiview, "paragraph");
#endif #endif
} }