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