]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
* fix spelling in comments to please John.
[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 "qt_helpers.h"
15 #include "FuncRequest.h"
16
17 #include "insets/InsetCommand.h"
18
19 #include <QLineEdit>
20 #include <QPushButton>
21
22
23 namespace lyx {
24 namespace frontend {
25
26
27 GuiBibitem::GuiBibitem(GuiView & lv)
28         : GuiDialog(lv, "bibitem", qt_("Bibliography Entry Settings")),
29           params_(insetCode("bibitem"))
30 {
31         setupUi(this);
32
33         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
34         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
35
36         connect(keyED, SIGNAL(textChanged(QString)),
37                 this, SLOT(change_adaptor()));
38         connect(labelED, SIGNAL(textChanged(QString)),
39                 this, SLOT(change_adaptor()));
40
41         bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
42         bc().setOK(okPB);
43         bc().setCancel(closePB);
44         bc().addReadOnly(keyED);
45         bc().addReadOnly(labelED);
46 }
47
48
49 void GuiBibitem::change_adaptor()
50 {
51         changed();
52 }
53
54
55 void GuiBibitem::updateContents()
56 {
57         keyED->setText(toqstr(params_["key"]));
58         labelED->setText(toqstr(params_["label"]));
59 }
60
61
62 void GuiBibitem::applyView()
63 {
64         params_["key"] = qstring_to_ucs4(keyED->text());
65         params_["label"] = qstring_to_ucs4(labelED->text());
66 }
67
68
69 bool GuiBibitem::isValid()
70 {
71         return !keyED->text().isEmpty();
72 }
73
74
75 bool GuiBibitem::initialiseParams(std::string const & data)
76 {
77         // The name passed with LFUN_INSET_APPLY is also the name
78         // used to identify the mailer.
79         InsetCommand::string2params("bibitem", data, params_);
80         return true;
81 }
82
83
84 void GuiBibitem::dispatchParams()
85 {
86         std::string const lfun = InsetCommand::params2string("bibitem", params_);
87         dispatch(FuncRequest(getLfun(), lfun));
88 }
89
90
91 Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
92
93
94 } // namespace frontend
95 } // namespace lyx
96
97 #include "moc_GuiBibitem.cpp"