]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
3f9412640ac8e070751623b6402deb7489645455
[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
16 #include <QCloseEvent>
17 #include <QLineEdit>
18 #include <QPushButton>
19
20
21 namespace lyx {
22 namespace frontend {
23
24 /////////////////////////////////////////////////////////////////////
25 //
26 // GuiBibItemDialog
27 //
28 /////////////////////////////////////////////////////////////////////
29
30 GuiBibitemDialog::GuiBibitemDialog(GuiBibitem * form)
31         : form_(form)
32 {
33         setupUi(this);
34         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
35         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
36
37         connect(keyED, SIGNAL(textChanged(const QString &)),
38                 this, SLOT(change_adaptor()));
39         connect(labelED, SIGNAL(textChanged(const QString &)),
40                 this, SLOT(change_adaptor()));
41 }
42
43
44 void GuiBibitemDialog::change_adaptor()
45 {
46         form_->changed();
47 }
48
49
50 void GuiBibitemDialog::closeEvent(QCloseEvent *e)
51 {
52         form_->slotWMHide();
53         e->accept();
54 }
55
56
57 /////////////////////////////////////////////////////////////////////
58 //
59 // GuiBibItem
60 //
61 /////////////////////////////////////////////////////////////////////
62
63
64 GuiBibitem::GuiBibitem(GuiDialog & parent)
65         : GuiView<GuiBibitemDialog>(parent, _("Bibliography Entry Settings"))
66 {
67 }
68
69
70 void GuiBibitem::build_dialog()
71 {
72         dialog_.reset(new GuiBibitemDialog(this));
73
74         bc().setOK(dialog_->okPB);
75         bc().setCancel(dialog_->closePB);
76         bc().addReadOnly(dialog_->keyED);
77         bc().addReadOnly(dialog_->labelED);
78 }
79
80
81 void GuiBibitem::update_contents()
82 {
83         dialog_->keyED->setText(toqstr(controller().params()["key"]));
84         dialog_->labelED->setText(toqstr(controller().params()["label"]));
85 }
86
87
88 void GuiBibitem::apply()
89 {
90         controller().params()["key"] = qstring_to_ucs4(dialog_->keyED->text());
91         controller().params()["label"] = qstring_to_ucs4(dialog_->labelED->text());
92 }
93
94
95 bool GuiBibitem::isValid()
96 {
97         return !dialog_->keyED->text().isEmpty();
98 }
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #include "GuiBibitem_moc.cpp"