]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
the fun begins....
[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
17 #include <QCloseEvent>
18 #include <QLineEdit>
19 #include <QPushButton>
20
21
22 namespace lyx {
23 namespace frontend {
24
25
26 GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
27         : GuiDialog(lv, "bibitem")
28 {
29         setupUi(this);
30         setViewTitle(_("Bibliography Entry Settings"));
31         setController(new ControlCommand(*this, "bibitem", "bibitem"));
32
33         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
34         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
35
36         connect(keyED, SIGNAL(textChanged(const QString &)),
37                 this, SLOT(change_adaptor()));
38         connect(labelED, SIGNAL(textChanged(const 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 ControlCommand & GuiBibitemDialog::controller() const
50 {
51         return static_cast<ControlCommand &>(Dialog::controller());
52 }
53
54
55 void GuiBibitemDialog::change_adaptor()
56 {
57         changed();
58 }
59
60
61 void GuiBibitemDialog::closeEvent(QCloseEvent *e)
62 {
63         slotWMHide();
64         e->accept();
65 }
66
67
68 void GuiBibitemDialog::update_contents()
69 {
70         keyED->setText(toqstr(controller().params()["key"]));
71         labelED->setText(toqstr(controller().params()["label"]));
72 }
73
74
75 void GuiBibitemDialog::applyView()
76 {
77         controller().params()["key"] = qstring_to_ucs4(keyED->text());
78         controller().params()["label"] = qstring_to_ucs4(labelED->text());
79 }
80
81
82 bool GuiBibitemDialog::isValid()
83 {
84         return !keyED->text().isEmpty();
85 }
86
87 } // namespace frontend
88 } // namespace lyx
89
90 #include "GuiBibitem_moc.cpp"