]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiLabel.cpp
header cleanup
[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 "support/debug.h"
16 #include "qt_helpers.h"
17
18 #include <QLabel>
19 #include <QPushButton>
20 #include <QLineEdit>
21
22 using namespace std;
23
24 namespace lyx {
25 namespace frontend {
26
27 /////////////////////////////////////////////////////////////////
28 //
29 // Base implementation
30 //
31 /////////////////////////////////////////////////////////////////
32
33 GuiLabel::GuiLabel(GuiView & lv)
34         : GuiCommand(lv, "label", qt_("Label"))
35 {
36         setupUi(this);
37
38         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
39         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
40         connect(keywordED, SIGNAL(textChanged(const QString &)),
41                 this, SLOT(change_adaptor()));
42
43         setFocusProxy(keywordED);
44
45         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
46         bc().setOK(okPB);
47         bc().setCancel(closePB);
48         bc().addReadOnly(keywordED);
49 }
50
51
52 void GuiLabel::change_adaptor()
53 {
54         changed();
55 }
56
57
58 void GuiLabel::reject()
59 {
60         slotClose();
61 }
62
63
64 void GuiLabel::updateContents()
65 {
66         docstring const contents = params_["name"];
67         keywordED->setText(toqstr(contents));
68         bc().setValid(!contents.empty());
69 }
70
71
72 void GuiLabel::applyView()
73 {
74         params_["name"] = qstring_to_ucs4(keywordED->text());
75 }
76
77
78 bool GuiLabel::isValid()
79 {
80         return !keywordED->text().isEmpty();
81 }
82
83
84 Dialog * createGuiLabel(GuiView & lv) { return new GuiLabel(lv); }
85
86
87 } // namespace frontend
88 } // namespace lyx
89
90 #include "GuiLabel_moc.cpp"