]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiLabel.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiLabel.cpp
1 /**
2  * \file GuiLabel.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 "GuiLabel.h"
14
15 #include "FuncRequest.h"
16 #include "qt_helpers.h"
17
18 #include "support/debug.h"
19 #include "insets/InsetCommand.h"
20
21 #include <QLabel>
22 #include <QPushButton>
23 #include <QLineEdit>
24
25 using namespace std;
26
27 namespace lyx {
28 namespace frontend {
29
30 /////////////////////////////////////////////////////////////////
31 //
32 // GuiLabel
33 //
34 /////////////////////////////////////////////////////////////////
35
36 GuiLabel::GuiLabel(GuiView & lv)
37         : GuiDialog(lv, "label", qt_("Label")),
38           params_(insetCode("label"))
39 {
40         setupUi(this);
41
42         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
43         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
44         connect(keywordED, SIGNAL(textChanged(const QString &)),
45                 this, SLOT(change_adaptor()));
46
47         setFocusProxy(keywordED);
48
49         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
50         bc().setOK(okPB);
51         bc().setCancel(closePB);
52         bc().addReadOnly(keywordED);
53 }
54
55
56 void GuiLabel::change_adaptor()
57 {
58         changed();
59 }
60
61
62 void GuiLabel::reject()
63 {
64         slotClose();
65 }
66
67
68 void GuiLabel::updateContents()
69 {
70         docstring const contents = params_["name"];
71         keywordED->setText(toqstr(contents));
72         bc().setValid(!contents.empty());
73 }
74
75
76 void GuiLabel::applyView()
77 {
78         params_["name"] = qstring_to_ucs4(keywordED->text());
79 }
80
81
82
83 void GuiLabel::enableView(bool enable)
84 {
85         keywordED->setEnabled(enable);
86 }
87
88
89 bool GuiLabel::isValid()
90 {
91         return !keywordED->text().isEmpty();
92 }
93
94
95 bool GuiLabel::initialiseParams(std::string const & data)
96 {
97         InsetCommand::string2params("label", data, params_);
98         return true;
99 }
100
101
102 void GuiLabel::dispatchParams()
103 {
104         std::string const lfun = InsetCommand::params2string("label", params_);
105         dispatch(FuncRequest(getLfun(), lfun));
106 }
107
108
109 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
110
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #include "moc_GuiLabel.cpp"