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