3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "ControlAboutlyx.h"
16 #include "ControlBibtex.h"
17 #include "ControlBox.h"
18 #include "ControlBranch.h"
19 #include "ControlChanges.h"
20 #include "ControlCharacter.h"
21 #include "ControlDocument.h"
22 #include "ControlErrorList.h"
23 #include "ControlERT.h"
24 #include "ControlExternal.h"
25 #include "ControlFloat.h"
26 #include "ControlGraphics.h"
27 #include "ControlInclude.h"
28 #include "ControlLog.h"
29 #include "ControlViewSource.h"
30 #include "ControlMath.h"
31 #include "ControlNote.h"
32 #include "ControlParagraph.h"
33 #include "ControlPrefs.h"
34 #include "ControlPrint.h"
35 #include "ControlRef.h"
36 #include "ControlSearch.h"
37 #include "ControlSendto.h"
38 #include "ControlShowFile.h"
39 #include "ControlSpellchecker.h"
40 #include "ControlTabular.h"
41 #include "ControlTabularCreate.h"
42 #include "ControlVSpace.h"
43 #include "ControlWrap.h"
46 #include "ButtonController.h"
55 #include "QCharacter.h"
56 #include "QCitation.h"
57 #include "QCitationDialog.h"
58 #include "QDocument.h"
59 #include "QErrorList.h"
61 #include "QExternal.h"
63 #include "QGraphics.h"
68 #include "QViewSource.h"
69 #include "QViewSourceDialog.h"
72 #include "QParagraph.h"
78 #include "QShowFile.h"
79 #include "QSpellchecker.h"
81 #include "QTabularCreate.h"
84 #include "TocWidget.h"
89 #ifdef HAVE_LIBAIKSAURUS
90 #include "ControlThesaurus.h"
91 #include "QThesaurus.h"
94 #include "qt_helpers.h"
96 #include <boost/assert.hpp>
100 using namespace lyx::frontend;
104 char const * const dialognames[] = {
105 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
106 "citation", "document", "errorlist", "ert", "external", "file",
107 "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
108 "mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph",
109 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
111 #ifdef HAVE_LIBAIKSAURUS
115 "texinfo", "toc", "url", "view-source", "vspace", "wrap" };
117 char const * const * const end_dialognames =
118 dialognames + (sizeof(dialognames) / sizeof(char *));
122 cmpCStr(char const * name) : name_(name) {}
123 bool operator()(char const * other) {
124 return strcmp(other, name_) == 0;
137 bool Dialogs::isValidName(string const & name) const
139 return std::find_if(dialognames, end_dialognames,
140 cmpCStr(name.c_str())) != end_dialognames;
144 Dialogs::DialogPtr Dialogs::build(string const & name)
146 BOOST_ASSERT(isValidName(name));
148 DialogPtr dialog(new Dialog(lyxview_, name));
149 dialog->bc().view(new Qt2BC(dialog->bc()));
151 if (name == "aboutlyx") {
152 dialog->setController(new ControlAboutlyx(*dialog));
153 dialog->setView(new QAbout(*dialog));
154 dialog->bc().bp(new OkCancelPolicy);
155 } else if (name == "bibitem") {
156 dialog->setController(new ControlCommand(*dialog, name, name));
157 dialog->setView(new QBibitem(*dialog));
158 dialog->bc().bp(new OkCancelReadOnlyPolicy);
159 } else if (name == "bibtex") {
160 dialog->setController(new ControlBibtex(*dialog));
161 dialog->setView(new QBibtex(*dialog));
162 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
163 } else if (name == "box") {
164 dialog->setController(new ControlBox(*dialog));
165 dialog->setView(new QBox(*dialog));
166 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
167 } else if (name == "branch") {
168 dialog->setController(new ControlBranch(*dialog));
169 dialog->setView(new QBranch(*dialog));
170 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
171 } else if (name == "changes") {
172 dialog->setController(new ControlChanges(*dialog));
173 dialog->setView(new QChanges(*dialog));
174 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
175 } else if (name == "character") {
176 dialog->setController(new ControlCharacter(*dialog));
177 dialog->setView(new QCharacter(*dialog));
178 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
179 } else if (name == "citation") {
180 QCitation * ci = new QCitation(*dialog);
181 dialog->setController(ci);
182 dialog->setView(new QCitationDialog(*dialog, ci));
183 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
184 } else if (name == "document") {
185 dialog->setController(new ControlDocument(*dialog));
186 dialog->setView(new QDocument(*dialog));
187 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
188 } else if (name == "errorlist") {
189 dialog->setController(new ControlErrorList(*dialog));
190 dialog->setView(new QErrorList(*dialog));
191 dialog->bc().bp(new OkCancelPolicy);
192 } else if (name == "ert") {
193 dialog->setController(new ControlERT(*dialog));
194 dialog->setView(new QERT(*dialog));
195 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
196 } else if (name == "external") {
197 dialog->setController(new ControlExternal(*dialog));
198 dialog->setView(new QExternal(*dialog));
199 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
200 } else if (name == "file") {
201 dialog->setController(new ControlShowFile(*dialog));
202 dialog->setView(new QShowFile(*dialog));
203 dialog->bc().bp(new OkCancelPolicy);
204 } else if (name == "findreplace") {
205 dialog->setController(new ControlSearch(*dialog));
206 dialog->setView(new QSearch(*dialog));
207 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
208 } else if (name == "float") {
209 dialog->setController(new ControlFloat(*dialog));
210 dialog->setView(new QFloat(*dialog));
211 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
212 } else if (name == "graphics") {
213 dialog->setController(new ControlGraphics(*dialog));
214 dialog->setView(new QGraphics(*dialog));
215 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
216 } else if (name == "include") {
217 dialog->setController(new ControlInclude(*dialog));
218 dialog->setView(new QInclude(*dialog));
219 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
220 } else if (name == "index") {
221 dialog->setController(new ControlCommand(*dialog, name, name));
222 dialog->setView(new QIndex(*dialog,
225 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
226 } else if (name == "nomenclature") {
227 dialog->setController(new ControlCommand(*dialog, name, name));
228 dialog->setView(new QNomencl(*dialog, _("Glossary Entry")));
229 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
230 } else if (name == "label") {
231 dialog->setController(new ControlCommand(*dialog, name, name));
232 dialog->setView(new QIndex(*dialog,
235 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
236 } else if (name == "log") {
237 dialog->setController(new ControlLog(*dialog));
238 dialog->setView(new QLog(*dialog));
239 dialog->bc().bp(new OkCancelPolicy);
240 } else if (name == "view-source") {
241 QViewSource * qvs = new QViewSource(*dialog);
242 dialog->setController(qvs);
243 GuiView & gui_view = static_cast<GuiView &>(lyxview_);
244 dialog->setView(new DockView<QViewSource, QViewSourceDialog>(
245 *dialog, qvs, &gui_view, _("LateX Source"), Qt::BottomDockWidgetArea));
246 dialog->bc().bp(new OkCancelPolicy);
247 } else if (name == "mathpanel") {
248 dialog->setController(new ControlMath(*dialog));
249 dialog->setView(new QMath(*dialog));
250 dialog->bc().bp(new IgnorantPolicy);
251 } else if (name == "mathdelimiter") {
252 dialog->setController(new ControlMath(*dialog));
253 dialog->setView(new QMathDelimiter(*dialog));
254 dialog->bc().bp(new IgnorantPolicy);
255 } else if (name == "mathmatrix") {
256 dialog->setController(new ControlMath(*dialog));
257 dialog->setView(new QMathMatrix(*dialog));
258 dialog->bc().bp(new IgnorantPolicy);
259 } else if (name == "note") {
260 dialog->setController(new ControlNote(*dialog));
261 dialog->setView(new QNote(*dialog));
262 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
263 } else if (name == "paragraph") {
264 dialog->setController(new ControlParagraph(*dialog));
265 dialog->setView(new QParagraph(*dialog));
266 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
267 } else if (name == "prefs") {
268 dialog->setController(new ControlPrefs(*dialog));
269 dialog->setView(new QPrefs(*dialog));
270 dialog->bc().bp(new PreferencesPolicy);
271 } else if (name == "print") {
272 dialog->setController(new ControlPrint(*dialog));
273 dialog->setView(new QPrint(*dialog));
274 dialog->bc().bp(new OkApplyCancelPolicy);
275 } else if (name == "ref") {
276 // full qualification because qt4 has also a ControlRef type
277 dialog->setController(new lyx::frontend::ControlRef(*dialog));
278 dialog->setView(new QRef(*dialog));
279 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
280 } else if (name == "sendto") {
281 dialog->setController(new ControlSendto(*dialog));
282 dialog->setView(new QSendto(*dialog));
283 dialog->bc().bp(new OkApplyCancelPolicy);
284 } else if (name == "spellchecker") {
285 dialog->setController(new ControlSpellchecker(*dialog));
286 dialog->setView(new QSpellchecker(*dialog));
287 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
288 } else if (name == "tabular") {
289 dialog->setController(new ControlTabular(*dialog));
290 dialog->setView(new QTabular(*dialog));
291 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
292 } else if (name == "tabularcreate") {
293 dialog->setController(new ControlTabularCreate(*dialog));
294 dialog->setView(new QTabularCreate(*dialog));
295 dialog->bc().bp(new IgnorantPolicy);
296 } else if (name == "texinfo") {
297 dialog->setController(new ControlTexinfo(*dialog));
298 dialog->setView(new QTexinfo(*dialog));
299 dialog->bc().bp(new OkCancelPolicy);
300 #ifdef HAVE_LIBAIKSAURUS
301 } else if (name == "thesaurus") {
302 dialog->setController(new ControlThesaurus(*dialog));
303 dialog->setView(new QThesaurus(*dialog));
304 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
306 } else if (name == "toc") {
307 QToc * qtoc = new QToc(*dialog);
308 dialog->setController(qtoc);
309 GuiView & gui_view = static_cast<GuiView &>(lyxview_);
310 dialog->setView(new DockView<QToc, TocWidget>(
311 *dialog, qtoc, &gui_view, _("Toc")));
312 dialog->bc().bp(new OkCancelPolicy);
313 } else if (name == "url") {
314 dialog->setController(new ControlCommand(*dialog, name, name));
315 dialog->setView(new UrlView(*dialog));
316 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
317 } else if (name == "vspace") {
318 dialog->setController(new ControlVSpace(*dialog));
319 dialog->setView(new QVSpace(*dialog));
320 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
321 } else if (name == "wrap") {
322 dialog->setController(new ControlWrap(*dialog));
323 dialog->setView(new QWrap(*dialog));
324 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
331 /// Are the tooltips on or off?
332 bool Dialogs::tooltipsEnabled()