]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiIndex.cpp
move our stuff off the Q* namespace
[lyx.git] / src / frontends / qt4 / GuiIndex.cpp
1 /**
2  * \file GuiIndex.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 "debug.h"
14 #include "ControlCommand.h"
15 #include "qt_helpers.h"
16
17 #include "GuiIndex.h"
18 #include "Qt2BC.h"
19 #include "ButtonController.h"
20
21 #include <QLabel>
22 #include <QPushButton>
23 #include <QLineEdit>
24 #include <QWhatsThis>
25 #include <QCloseEvent>
26
27
28 using std::string;
29
30 /////////////////////////////////////////////////////////////////////
31 //
32 // GuiIndexDialog
33 //
34 /////////////////////////////////////////////////////////////////////
35
36 namespace lyx {
37 namespace frontend {
38
39 GuiIndexDialog::GuiIndexDialog(GuiIndex * form)
40         : form_(form)
41 {
42         setupUi(this);
43
44         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
45         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
46         connect( keywordED, SIGNAL(textChanged(const QString &)),
47                 this, SLOT(change_adaptor()));
48
49         setFocusProxy(keywordED);
50
51         keywordED->setWhatsThis( qt_(
52                 "The format of the entry in the index.\n"
53                 "\n"
54                 "An entry can be specified as a sub-entry of\n"
55                 "another with \"!\":\n"
56                 "\n"
57                 "cars!mileage\n"
58                 "\n"
59                 "You can cross-refer to another entry like so:\n"
60                 "\n"
61                 "cars!mileage|see{economy}\n"
62                 "\n"
63                 "For further details refer to the local LaTeX\n"
64                 "documentation.\n")
65         );
66 }
67
68
69 void GuiIndexDialog::change_adaptor()
70 {
71         form_->changed();
72 }
73
74
75 void GuiIndexDialog::reject()
76 {
77         form_->slotClose();
78 }
79
80
81 void GuiIndexDialog::closeEvent(QCloseEvent * e)
82 {
83         form_->slotWMHide();
84         e->accept();
85 }
86
87
88 /////////////////////////////////////////////////////////////////////
89 //
90 // GuiIndex
91 //
92 /////////////////////////////////////////////////////////////////////
93
94
95 typedef QController<ControlCommand, GuiView<GuiIndexDialog> > IndexBase;
96
97 GuiIndex::GuiIndex(Dialog & parent, docstring const & title, QString const & label)
98         : IndexBase(parent, title), label_(label)
99 {
100 }
101
102
103 void GuiIndex::build_dialog()
104 {
105         dialog_.reset(new GuiIndexDialog(this));
106
107         dialog_->keywordLA->setText(label_);
108
109         bcview().setOK(dialog_->okPB);
110         bcview().setCancel(dialog_->closePB);
111         bcview().addReadOnly(dialog_->keywordED);
112 }
113
114
115 void GuiIndex::update_contents()
116 {
117         docstring const contents = controller().params()["name"];
118         dialog_->keywordED->setText(toqstr(contents));
119
120         bc().valid(!contents.empty());
121 }
122
123
124 void GuiIndex::apply()
125 {
126         controller().params()["name"] = qstring_to_ucs4(dialog_->keywordED->text());
127 }
128
129
130 bool GuiIndex::isValid()
131 {
132         return !dialog_->keywordED->text().isEmpty();
133 }
134
135 } // namespace frontend
136 } // namespace lyx
137
138 #include "GuiIndex_moc.cpp"