]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiBibitem.cpp
Do not compute caret geometry when we are not ready to do so.
[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
15 #include "qt_helpers.h"
16
17 #include "insets/InsetCommand.h"
18
19 #include <QLineEdit>
20 #include <QPushButton>
21
22
23 namespace lyx {
24 namespace frontend {
25
26
27 GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
28 {
29         setupUi(this);
30
31         connect(keyED, SIGNAL(textChanged(QString)),
32                 this, SIGNAL(changed()));
33         connect(labelED, SIGNAL(textChanged(QString)),
34                 this, SIGNAL(changed()));
35         connect(literalCB, SIGNAL(clicked()),
36                 this, SIGNAL(changed()));
37 }
38
39
40 void GuiBibitem::paramsToDialog(Inset const * inset)
41 {
42         InsetCommand const * ic = static_cast<InsetCommand const *>(inset);
43         InsetCommandParams const & params = ic->params();
44         keyED->setText(toqstr(params["key"]));
45         labelED->setText(toqstr(params["label"]));
46         literalCB->setChecked(params["literal"] == "true");
47 }
48
49
50 docstring GuiBibitem::dialogToParams() const
51 {
52         InsetCommandParams params(insetCode());
53         params["key"] = qstring_to_ucs4(keyED->text());
54         params["label"] = qstring_to_ucs4(labelED->text());
55         params["literal"] = literalCB->isChecked()
56                         ? from_ascii("true") : from_ascii("false");
57         return from_utf8(InsetCommand::params2string(params));
58 }
59
60
61 bool GuiBibitem::checkWidgets(bool readonly) const
62 {
63         keyED->setReadOnly(readonly);
64         labelED->setReadOnly(readonly);
65         if (!InsetParamsWidget::checkWidgets())
66                 return false;
67         return !keyED->text().isEmpty();
68 }
69
70 } // namespace frontend
71 } // namespace lyx
72
73 #include "moc_GuiBibitem.cpp"