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 "ControlCitation.h"
22 #include "ControlDocument.h"
23 #include "ControlErrorList.h"
24 #include "ControlERT.h"
25 #include "ControlExternal.h"
26 #include "ControlFloat.h"
27 #include "ControlGraphics.h"
28 #include "ControlInclude.h"
29 #include "ControlLog.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 "ControlToc.h"
43 #include "ControlVSpace.h"
44 #include "ControlWrap.h"
47 #include "ButtonController.h"
54 #include "QCharacter.h"
55 #include "QCitation.h"
56 #include "QDocument.h"
57 #include "QErrorList.h"
59 #include "QExternal.h"
61 // Here would be an appropriate point to lecture on the evils
62 // of the Qt headers, those most fucked up of disgusting ratholes.
65 #include "QGraphics.h"
71 #include "QParagraph.h"
77 #include "QShowFile.h"
78 #include "QSpellchecker.h"
80 #include "QTabularCreate.h"
87 #ifdef HAVE_LIBAIKSAURUS
88 #include "ControlThesaurus.h"
89 #include "QThesaurus.h"
92 #include "qt_helpers.h"
94 #include <boost/assert.hpp>
98 using namespace lyx::frontend;
102 char const * const dialognames[] = {
103 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
104 "citation", "document", "errorlist", "ert", "external", "file",
105 "findreplace", "float", "graphics", "include", "index", "label", "log",
106 "mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph", "preamble",
107 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
109 #ifdef HAVE_LIBAIKSAURUS
113 "texinfo", "toc", "url", "vspace", "wrap" };
115 char const * const * const end_dialognames =
116 dialognames + (sizeof(dialognames) / sizeof(char *));
120 cmpCStr(char const * name) : name_(name) {}
121 bool operator()(char const * other) {
122 return strcmp(other, name_) == 0;
132 bool Dialogs::isValidName(string const & name) const
134 return std::find_if(dialognames, end_dialognames,
135 cmpCStr(name.c_str())) != end_dialognames;
139 Dialogs::DialogPtr Dialogs::build(string const & name)
141 BOOST_ASSERT(isValidName(name));
143 DialogPtr dialog(new Dialog(lyxview_, name));
144 dialog->bc().view(new Qt2BC(dialog->bc()));
146 if (name == "aboutlyx") {
147 dialog->setController(new ControlAboutlyx(*dialog));
148 dialog->setView(new QAbout(*dialog));
149 dialog->bc().bp(new OkCancelPolicy);
150 } else if (name == "bibitem") {
151 dialog->setController(new ControlCommand(*dialog, name));
152 dialog->setView(new QBibitem(*dialog));
153 dialog->bc().bp(new OkCancelReadOnlyPolicy);
154 } else if (name == "bibtex") {
155 dialog->setController(new ControlBibtex(*dialog));
156 dialog->setView(new QBibtex(*dialog));
157 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
158 } else if (name == "box") {
159 dialog->setController(new ControlBox(*dialog));
160 dialog->setView(new QBox(*dialog));
161 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
162 } else if (name == "branch") {
163 dialog->setController(new ControlBranch(*dialog));
164 dialog->setView(new QBranch(*dialog));
165 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
166 } else if (name == "changes") {
167 dialog->setController(new ControlChanges(*dialog));
168 dialog->setView(new QChanges(*dialog));
169 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
170 } else if (name == "character") {
171 dialog->setController(new ControlCharacter(*dialog));
172 dialog->setView(new QCharacter(*dialog));
173 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
174 } else if (name == "citation") {
175 dialog->setController(new ControlCitation(*dialog));
176 dialog->setView(new QCitation(*dialog));
177 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
178 } else if (name == "document" || name == "preamble") {
180 // This nastiness will exist only as long as xforms
181 // has a separate preamble dialog.
183 string const other = (name == "document") ?
184 "preamble" : "document";
186 std::map<string, DialogPtr>::iterator it =
187 dialogs_.find(other);
189 if (it != dialogs_.end())
192 dialog->setController(new ControlDocument(*dialog));
193 dialog->setView(new QDocument(*dialog));
194 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
197 } else if (name == "errorlist") {
198 dialog->setController(new ControlErrorList(*dialog));
199 dialog->setView(new QErrorList(*dialog));
200 dialog->bc().bp(new OkCancelPolicy);
201 } else if (name == "ert") {
202 dialog->setController(new ControlERT(*dialog));
203 dialog->setView(new QERT(*dialog));
204 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
205 } else if (name == "external") {
206 dialog->setController(new ControlExternal(*dialog));
207 dialog->setView(new QExternal(*dialog));
208 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
209 } else if (name == "file") {
210 dialog->setController(new ControlShowFile(*dialog));
211 dialog->setView(new QShowFile(*dialog));
212 dialog->bc().bp(new OkCancelPolicy);
213 } else if (name == "findreplace") {
214 dialog->setController(new ControlSearch(*dialog));
215 dialog->setView(new QSearch(*dialog));
216 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
217 } else if (name == "float") {
218 dialog->setController(new ControlFloat(*dialog));
219 dialog->setView(new QFloat(*dialog));
220 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
221 } else if (name == "graphics") {
222 dialog->setController(new ControlGraphics(*dialog));
223 dialog->setView(new QGraphics(*dialog));
224 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
225 } else if (name == "include") {
226 dialog->setController(new ControlInclude(*dialog));
227 dialog->setView(new QInclude(*dialog));
228 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
229 } else if (name == "index") {
230 dialog->setController(new ControlCommand(*dialog, name));
231 dialog->setView(new QIndex(*dialog,
234 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
235 } else if (name == "label") {
236 dialog->setController(new ControlCommand(*dialog, name));
237 dialog->setView(new QIndex(*dialog,
240 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
241 } else if (name == "log") {
242 dialog->setController(new ControlLog(*dialog));
243 dialog->setView(new QLog(*dialog));
244 dialog->bc().bp(new OkCancelPolicy);
245 } else if (name == "mathpanel") {
246 dialog->setController(new ControlMath(*dialog));
247 dialog->setView(new QMath(*dialog));
248 dialog->bc().bp(new IgnorantPolicy);
249 } else if (name == "mathdelimiter") {
250 dialog->setController(new ControlMath(*dialog));
251 dialog->setView(new QMathDelimiter(*dialog));
252 dialog->bc().bp(new IgnorantPolicy);
253 } else if (name == "mathmatrix") {
254 dialog->setController(new ControlMath(*dialog));
255 dialog->setView(new QMathMatrix(*dialog));
256 dialog->bc().bp(new IgnorantPolicy);
257 } else if (name == "note") {
258 dialog->setController(new ControlNote(*dialog));
259 dialog->setView(new QNote(*dialog));
260 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
261 } else if (name == "paragraph") {
262 dialog->setController(new ControlParagraph(*dialog));
263 dialog->setView(new QParagraph(*dialog));
264 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
265 } else if (name == "prefs") {
266 dialog->setController(new ControlPrefs(*dialog));
267 dialog->setView(new QPrefs(*dialog));
268 dialog->bc().bp(new PreferencesPolicy);
269 } else if (name == "print") {
270 dialog->setController(new ControlPrint(*dialog));
271 dialog->setView(new QPrint(*dialog));
272 dialog->bc().bp(new OkApplyCancelPolicy);
273 } else if (name == "ref") {
274 dialog->setController(new ControlRef(*dialog));
275 dialog->setView(new QRef(*dialog));
276 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
277 } else if (name == "sendto") {
278 dialog->setController(new ControlSendto(*dialog));
279 dialog->setView(new QSendto(*dialog));
280 dialog->bc().bp(new OkApplyCancelPolicy);
281 } else if (name == "spellchecker") {
282 dialog->setController(new ControlSpellchecker(*dialog));
283 dialog->setView(new QSpellchecker(*dialog));
284 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
285 } else if (name == "tabular") {
286 dialog->setController(new ControlTabular(*dialog));
287 dialog->setView(new QTabular(*dialog));
288 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
289 } else if (name == "tabularcreate") {
290 dialog->setController(new ControlTabularCreate(*dialog));
291 dialog->setView(new QTabularCreate(*dialog));
292 dialog->bc().bp(new IgnorantPolicy);
293 } else if (name == "texinfo") {
294 dialog->setController(new ControlTexinfo(*dialog));
295 dialog->setView(new QTexinfo(*dialog));
296 dialog->bc().bp(new OkCancelPolicy);
297 #ifdef HAVE_LIBAIKSAURUS
298 } else if (name == "thesaurus") {
299 dialog->setController(new ControlThesaurus(*dialog));
300 dialog->setView(new QThesaurus(*dialog));
301 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
303 } else if (name == "toc") {
304 dialog->setController(new ControlToc(*dialog));
305 dialog->setView(new QToc(*dialog));
306 dialog->bc().bp(new OkCancelPolicy);
307 } else if (name == "url") {
308 dialog->setController(new ControlCommand(*dialog, name));
309 dialog->setView(new QURL(*dialog));
310 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
311 } else if (name == "vspace") {
312 dialog->setController(new ControlVSpace(*dialog));
313 dialog->setView(new QVSpace(*dialog));
314 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
315 } else if (name == "wrap") {
316 dialog->setController(new ControlWrap(*dialog));
317 dialog->setView(new QWrap(*dialog));
318 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
325 void Dialogs::toggleTooltips()
329 /// Are the tooltips on or off?
330 bool Dialogs::tooltipsEnabled()