]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QNomencl.C
renaming in frontends/qt4/ui: s/Q//g
[lyx.git] / src / frontends / qt4 / QNomencl.C
1 /**
2  * \file QNomencl.C
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  * \author O. U. Baran
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "debug.h"
15 #include "ControlCommand.h"
16 #include "qt_helpers.h"
17
18 #include "QNomenclDialog.h"
19 #include "QNomencl.h"
20 #include "Qt2BC.h"
21 #include "ButtonController.h"
22 #include <QLabel>
23 #include <QLineEdit>
24 #include <QPushButton>
25 #include <QTextEdit>
26
27 using std::string;
28
29 namespace lyx {
30 namespace frontend {
31
32 typedef QController<ControlCommand, QView<QNomenclDialog> > nomencl_base_class;
33
34
35 QNomencl::QNomencl(Dialog & parent, docstring const & title)
36         : nomencl_base_class(parent, title)
37 {
38 }
39
40
41 void QNomencl::build_dialog()
42 {
43         dialog_.reset(new QNomenclDialog(this));
44
45         bcview().setOK(dialog_->okPB);
46         bcview().setCancel(dialog_->closePB);
47         bcview().addReadOnly(dialog_->symbolED);
48         bcview().addReadOnly(dialog_->descriptionTE);
49         bcview().addReadOnly(dialog_->prefixED);
50 }
51
52
53 void QNomencl::update_contents()
54 {
55         dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
56         dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
57         QString description = toqstr(controller().params()["description"]);
58         description.replace("\\\\","\n");
59         dialog_->descriptionTE->setPlainText(description);
60
61         bc().valid(isValid());
62 }
63
64
65 void QNomencl::apply()
66 {
67         controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
68         controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
69         QString description = dialog_->descriptionTE->toPlainText();
70         description.replace('\n',"\\\\");
71         controller().params()["description"] = qstring_to_ucs4(description);
72 }
73
74
75 bool QNomencl::isValid()
76 {
77         QString const description = dialog_->descriptionTE->toPlainText();
78         return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
79 }
80
81 } // namespace frontend
82 } // namespace lyx