]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
7f49de22b4a67e4aeeb289f1616910caaf33e06d
[lyx.git] / src / frontends / qt4 / GuiBibitem.cpp
1 /**
2  * \file GuiBibitem.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiBibitem.h"
14 #include "ControlCommand.h"
15 #include "qt_helpers.h"
16 #include "FuncRequest.h"
17
18 #include "insets/InsetCommand.h"
19
20 #include <QCloseEvent>
21 #include <QLineEdit>
22 #include <QPushButton>
23
24
25 namespace lyx {
26 namespace frontend {
27
28
29 GuiBibitem::GuiBibitem(LyXView & lv)
30         : GuiDialog(lv, "bibitem"), Controller(this), params_("bibitem")
31 {
32         setupUi(this);
33         setViewTitle(_("Bibliography Entry Settings"));
34         setController(this, false);
35
36         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
37         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
38
39         connect(keyED, SIGNAL(textChanged(QString)),
40                 this, SLOT(change_adaptor()));
41         connect(labelED, SIGNAL(textChanged(QString)),
42                 this, SLOT(change_adaptor()));
43
44         bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
45         bc().setOK(okPB);
46         bc().setCancel(closePB);
47         bc().addReadOnly(keyED);
48         bc().addReadOnly(labelED);
49 }
50
51
52 void GuiBibitem::change_adaptor()
53 {
54         changed();
55 }
56
57
58 void GuiBibitem::closeEvent(QCloseEvent *e)
59 {
60         slotClose();
61         e->accept();
62 }
63
64
65 void GuiBibitem::updateContents()
66 {
67         keyED->setText(toqstr(params_["key"]));
68         labelED->setText(toqstr(params_["label"]));
69 }
70
71
72 void GuiBibitem::applyView()
73 {
74         params_["key"] = qstring_to_ucs4(keyED->text());
75         params_["label"] = qstring_to_ucs4(labelED->text());
76 }
77
78
79 bool GuiBibitem::isValid()
80 {
81         return !keyED->text().isEmpty();
82 }
83
84
85 bool GuiBibitem::initialiseParams(std::string const & data)
86 {
87         // The name passed with LFUN_INSET_APPLY is also the name
88         // used to identify the mailer.
89         InsetCommandMailer::string2params("bibitem", data, params_);
90         return true;
91 }
92
93
94 void GuiBibitem::dispatchParams()
95 {
96         std::string const lfun = InsetCommandMailer::params2string("bibitem", params_);
97         dispatch(FuncRequest(getLfun(), lfun));
98 }
99
100
101 Dialog * createGuiBibitem(LyXView & lv) { return new GuiBibitem(lv); }
102
103
104 } // namespace frontend
105 } // namespace lyx
106
107 #include "GuiBibitem_moc.cpp"