]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
Factorize out the way window titles are handled.
[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 <QCloseEvent>
18 #include <QLineEdit>
19 #include <QPushButton>
20
21
22 namespace lyx {
23 namespace frontend {
24
25
26 GuiBibitem::GuiBibitem(GuiView & lv)
27         : GuiCommand(lv, "bibitem", qt_("Bibliography Entry Settings"))
28 {
29         setupUi(this);
30
31         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
32         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
33
34         connect(keyED, SIGNAL(textChanged(QString)),
35                 this, SLOT(change_adaptor()));
36         connect(labelED, SIGNAL(textChanged(QString)),
37                 this, SLOT(change_adaptor()));
38
39         bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
40         bc().setOK(okPB);
41         bc().setCancel(closePB);
42         bc().addReadOnly(keyED);
43         bc().addReadOnly(labelED);
44 }
45
46
47 void GuiBibitem::change_adaptor()
48 {
49         changed();
50 }
51
52
53 void GuiBibitem::closeEvent(QCloseEvent *e)
54 {
55         slotClose();
56         e->accept();
57 }
58
59
60 void GuiBibitem::updateContents()
61 {
62         keyED->setText(toqstr(params_["key"]));
63         labelED->setText(toqstr(params_["label"]));
64 }
65
66
67 void GuiBibitem::applyView()
68 {
69         params_["key"] = qstring_to_ucs4(keyED->text());
70         params_["label"] = qstring_to_ucs4(labelED->text());
71 }
72
73
74 bool GuiBibitem::isValid()
75 {
76         return !keyED->text().isEmpty();
77 }
78
79
80 Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
81
82
83 } // namespace frontend
84 } // namespace lyx
85
86 #include "GuiBibitem_moc.cpp"