]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/guiapi.C
Yet more (minor) compilation fixes.
[lyx.git] / src / frontends / qt2 / guiapi.C
1 /**
2  * \file guiapi.C
3  * Copyright 2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10
11 #include "guiapi.h"
12
13 #include "QAbout.h"
14 #include "QAboutDialog.h"
15 #include "QBibitem.h"
16 #include "QBibitemDialog.h"
17 #include "QBibtex.h"
18 #include "QBibtexDialog.h"
19 #include "QCharacter.h"
20 #include "QCharacterDialog.h"
21 #include "QCitation.h"
22 #include "QCitationDialog.h"
23 //#include "QDocument.h"
24 #include "QError.h"
25 #include "QErrorDialog.h"
26 #include "QERT.h"
27 #include "QERTDialog.h"
28 #include "QExternal.h"
29 #include "QExternalDialog.h"
30 #include "QFloat.h"
31 #include "QFloatDialog.h"
32 //#include "QForks.h"
33 // Here would be an appropriate point to lecture on the evils
34 // of the Qt headers, those most fucked up of disgusting ratholes.
35 // But I won't.
36 #undef signals
37 #include "QGraphics.h"
38 #include "QGraphicsDialog.h"
39 #include "QInclude.h"
40 #include "QIncludeDialog.h"
41 #include "QIndex.h"
42 #include "QIndexDialog.h"
43 #include "QLog.h"
44 #include "QLogDialog.h"
45 #include "QMinipage.h"
46 #include "QMinipageDialog.h"
47 //#include "QParagraph.h"
48 #include "QPreamble.h"
49 #include "QPreambleDialog.h"
50 //#include "QPreferences.h"
51 #include "QPrint.h"
52 #include "QPrintDialog.h"
53 #include "QRef.h"
54 #include "QRefDialog.h"
55 #include "QSearch.h"
56 #include "QSearchDialog.h"
57 //#include "QSendto.h"
58 #include "QShowFile.h"
59 #include "QShowFileDialog.h"
60 #include "QSpellchecker.h"
61 #include "QSpellcheckerDialog.h"
62 //#include "QTabular.h"
63 #include "QTabularCreate.h"
64 #include "QTabularCreateDialog.h"
65 #include "QTexinfo.h"
66 #include "QTexinfoDialog.h"
67 #ifdef HAVE_LIBAIKSAURUS
68 #include "QThesaurus.h"
69 #include "QThesaurusDialog.h"
70 #endif
71 #include "QToc.h"
72 #include "QTocDialog.h"
73 #include "QURL.h"
74 #include "QURLDialog.h"
75 #include "QVCLog.h"
76 #include "QVCLogDialog.h"
77
78 #include "Qt2BC.h"
79
80 #include "controllers/GUI.h"
81 #include "insets/inseterror.h"
82
83 #include "LyXView.h"
84
85 #include "ControlAboutlyx.h"
86 #include "ControlBibitem.h"
87 #include "ControlBibtex.h"
88 #include "ControlCharacter.h"
89 #include "ControlCitation.h"
90 #include "ControlError.h"
91 #include "ControlERT.h"
92 #include "ControlExternal.h"
93 #include "ControlFloat.h"
94 #include "ControlForks.h"
95 #include "ControlGraphics.h"
96 #include "insets/insetgraphicsParams.h"
97 #include "ControlInclude.h"
98 #include "ControlIndex.h"
99 #include "ControlLog.h"
100 #include "ControlMinipage.h"
101 #include "ControlParagraph.h"
102 #include "ControlPreamble.h"
103 #include "ControlPrint.h"
104 #include "ControlRef.h"
105 #include "ControlSearch.h"
106 #include "ControlSendto.h"
107 #include "ControlShowFile.h"
108 #include "ControlSpellchecker.h"
109 #include "ControlTabularCreate.h"
110 #include "ControlTexinfo.h"
111 #include "ControlThesaurus.h"
112 #include "ControlToc.h"
113 #include "ControlUrl.h"
114 #include "ControlVCLog.h"
115
116
117 namespace { // anon
118
119 // I belive that this one is buggy (Lgb)
120 // But not if used correctly. (Lgb)
121 template <class T>
122 class GUISingleton {
123 public:
124         static
125         T & get(LyXView & lv, Dialogs & d) {
126                 static T t(lv, d);
127                 return t;
128         }
129 };
130
131
132 GUISingleton<GUI<ControlCharacter, QCharacter,
133                  OkApplyCancelReadOnlyPolicy, Qt2BC> >
134 controlCharacterSingleton;
135
136 GUISingleton<GUI<ControlCitation, QCitation,
137                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
138 controlCitationSingleton;
139
140
141 GUISingleton<GUI<ControlERT, QERT,
142                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
143 controlERTSingleton;
144
145 GUISingleton<GUI<ControlIndex, QIndex,
146                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
147 controlIndexSingleton;
148
149 GUISingleton<GUI<ControlMinipage, QMinipage,
150                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
151 controlMinipageSingleton;
152
153 //GUISingleton<QPreferences> formPreferencesSingleton;
154
155 GUISingleton<GUI<ControlRef, QRef,
156                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
157 controlRefSingleton;
158
159 //GUISingleton<QTabular> formTabularSingleton;
160
161 GUISingleton<GUI<ControlToc, QToc,
162                  OkCancelPolicy, Qt2BC> >
163 controlTocSingleton;
164
165 GUISingleton<GUI<ControlUrl, QURL,
166                  NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
167 controlUrlSingleton;
168
169 } // anon
170
171
172 extern "C" {
173
174         void gui_ShowAboutlyx(LyXView & lv, Dialogs & d)
175         {
176                 static GUI<ControlAboutlyx, QAbout,
177                         OkCancelPolicy, Qt2BC> cal(lv, d);
178                 cal.show();
179         }
180
181
182         void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d)
183         {
184                 static GUI<ControlBibitem, QBibitem,
185                         OkCancelReadOnlyPolicy, Qt2BC> cbi(lv, d);
186                 cbi.showInset(ic);
187         }
188
189
190         void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d)
191         {
192                 static GUI<ControlBibtex, QBibtex,
193                         OkCancelReadOnlyPolicy, Qt2BC> cbt(lv, d);
194                 cbt.showInset(ic);
195         }
196
197
198         void gui_ShowCharacter(LyXView & lv, Dialogs & d)
199         {
200                 controlCharacterSingleton.get(lv, d).show();
201         }
202
203
204         void gui_SetUserFreeFont(LyXView & lv, Dialogs & d)
205         {
206                 controlCharacterSingleton.get(lv, d).apply();
207         }
208
209
210         void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d)
211         {
212                 controlCitationSingleton.get(lv, d).showInset(ic);
213         }
214
215
216         void gui_CreateCitation(string const & s, LyXView & lv, Dialogs & d)
217         {
218                 controlCitationSingleton.get(lv, d).createInset(s);
219         }
220
221
222         void gui_ShowDocument(LyXView & lv, Dialogs & d)
223         {
224                 //static QDocument fd(&lv, &d);
225                 //fd.show();
226         }
227
228
229         void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d)
230         {
231                 static GUI<ControlError, QError,
232                         OkCancelPolicy, Qt2BC> ce(lv, d);
233                 ce.showInset(ie);
234         }
235
236
237         void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d)
238         {
239                 controlERTSingleton.get(lv, d).showInset(ie);
240         }
241
242
243         void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d)
244         {
245                 controlERTSingleton.get(lv, d).showInset(ie);
246         }
247
248
249         void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d)
250         {
251                 static GUI<ControlExternal, QExternal,
252                         OkApplyCancelReadOnlyPolicy, Qt2BC> ce(lv, d);
253                 ce.showInset(ie);
254         }
255
256
257         void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d)
258         {
259                 static GUI<ControlShowFile, QShowFile,
260                         OkCancelPolicy, Qt2BC> csf(lv, d);
261                 csf.showFile(f);
262         }
263
264
265         void gui_ShowFloat(InsetFloat * ifl, LyXView & lv, Dialogs & d)
266         {
267                 static GUI<ControlFloat, QFloat,
268                         NoRepeatedApplyReadOnlyPolicy, Qt2BC> cf(lv, d);
269                 cf.showInset(ifl);
270         }
271
272
273         void gui_ShowForks(LyXView & lv, Dialogs & d)
274         {
275 #if 0
276                 static GUI<ControlForks, QForks,
277                         OkApplyCancelPolicy, Qt2BC> cf(lv, d);
278                 cf.show();
279 #endif 
280         }
281
282
283         void gui_ShowGraphics(InsetGraphics * ig, LyXView & lv, Dialogs & d)
284         {
285                 static GUI<ControlGraphics, QGraphics,
286                         NoRepeatedApplyReadOnlyPolicy, Qt2BC> cg(lv, d);
287                 cg.showInset(ig);
288         }
289
290
291         void gui_ShowInclude(InsetInclude * ii, LyXView & lv, Dialogs & d)
292         {
293                 static GUI<ControlInclude, QInclude,
294                         OkCancelReadOnlyPolicy, Qt2BC> ci(lv, d);
295                 ci.showInset(ii);
296         }
297
298
299         void gui_ShowIndex(InsetCommand * ic, LyXView & lv, Dialogs & d)
300         {
301                 controlIndexSingleton.get(lv, d).showInset(ic);
302         }
303
304
305         void gui_CreateIndex(LyXView & lv, Dialogs & d)
306         {
307                 controlIndexSingleton.get(lv, d).createInset("");
308         }
309
310
311 #if 0
312         void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d)
313         {
314         }
315 #endif
316
317
318         void gui_ShowLogFile(LyXView & lv, Dialogs & d)
319         {
320                 static GUI<ControlLog, QLog,
321                         OkCancelPolicy, Qt2BC> cl(lv, d);
322                 cl.show();
323         }
324
325
326         void gui_ShowMathPanel(LyXView & lv, Dialogs & d)
327         {
328                 //static QMathsPanel fmp(&lv, &d);
329                 //fmp.show();
330         }
331
332
333         void gui_ShowMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
334         {
335                 controlMinipageSingleton.get(lv, d).showInset(im);
336         }
337
338
339         void gui_UpdateMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
340         {
341                 controlMinipageSingleton.get(lv, d).showInset(im);
342         }
343
344
345         void gui_ShowParagraph(LyXView & lv, Dialogs & d)
346         {
347 #if 0
348                 static GUI<ControlParagraph, QParagraph,
349                         OkApplyCancelReadOnlyPolicy, Qt2BC> cp(lv, d);
350                 cp.show();
351 #endif
352         }
353
354
355 #if 0
356         void gui_UpdateParagraph(LyXView & lv, Dialogs & d)
357         {
358 #warning FIXME!
359                 // This should be the same object as in gui_ShowParagraph
360                 static GUI<ControlParagraph, QParagraph,
361                         OkApplyCancelReadOnlyPolicy, Qt2BC> cp(lv, d);
362 #if 0
363                 cp.
364 #endif
365         }
366 #endif
367
368
369         void gui_ShowPreamble(LyXView & lv, Dialogs & d)
370         {
371                 static GUI<ControlPreamble, QPreamble,
372                         NoRepeatedApplyReadOnlyPolicy, Qt2BC> cp(lv, d);
373                 cp.show();
374         }
375
376
377         void gui_ShowPreferences(LyXView & lv, Dialogs & d)
378         {
379                 //formPreferencesSingleton.get(lv, d).show();
380         }
381
382
383         void gui_ShowPrint(LyXView & lv, Dialogs & d)
384         {
385                 static GUI<ControlPrint, QPrint,
386                         OkApplyCancelPolicy, Qt2BC> cp(lv, d);
387                 cp.show();
388         }
389
390
391         void gui_ShowRef(InsetCommand * ic, LyXView & lv, Dialogs & d)
392         {
393                 controlRefSingleton.get(lv, d).showInset(ic);
394         }
395
396
397         void gui_CreateRef(string const & s, LyXView & lv, Dialogs & d)
398         {
399                 controlRefSingleton.get(lv, d).createInset(s);
400         }
401
402
403         void gui_ShowSearch(LyXView & lv, Dialogs & d)
404         {
405                 static GUI<ControlSearch, QSearch,
406                         NoRepeatedApplyReadOnlyPolicy, Qt2BC> cs(lv, d);
407                 cs.show();
408         }
409
410
411         void gui_ShowSendto(LyXView & lv, Dialogs & d)
412         {
413 #if 0
414                 static GUI<ControlSendto, QSendto,
415                         OkApplyCancelPolicy, Qt2BC> cs(lv, d);
416                 cs.show();
417 #endif 
418         }
419
420
421         void gui_ShowSpellchecker(LyXView & lv, Dialogs & d)
422         {
423                 static GUI<ControlSpellchecker, QSpellchecker,
424                         NoRepeatedApplyReadOnlyPolicy, Qt2BC> cp(lv, d);
425                 cp.show();
426         }
427
428
429         void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d)
430         {
431                 //formPreferencesSingleton.get(lv, d).showSpellPref();
432         }
433
434
435         void gui_ShowTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
436         {
437                 //formTabularSingleton.get(lv, d).showInset(it);
438         }
439
440
441         void gui_UpdateTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
442         {
443                 //formTabularSingleton.get(lv, d).updateInset(it);
444         }
445
446
447         void gui_ShowTabularCreate(LyXView & lv, Dialogs & d)
448         {
449                 static GUI<ControlTabularCreate, QTabularCreate,
450                         OkApplyCancelReadOnlyPolicy, Qt2BC> ctc(lv, d);
451                 ctc.show();
452         }
453
454
455         void gui_ShowTexinfo(LyXView & lv, Dialogs & d)
456         {
457                 static GUI<ControlTexinfo, QTexinfo,
458                         OkCancelPolicy, Qt2BC> ct(lv, d);
459                 ct.show();
460         }
461
462
463         void gui_ShowThesaurus(string const & s, LyXView & lv, Dialogs & d)
464         {
465 #ifdef HAVE_LIBAIKSAURUS
466                 static GUI<ControlThesaurus, QThesaurus,
467                         OkApplyCancelReadOnlyPolicy, Qt2BC> ct(lv, d);
468                 ct.showEntry(s);
469 #endif
470         }
471
472
473         void gui_ShowTOC(InsetCommand * ic, LyXView & lv, Dialogs & d)
474         {
475                 controlTocSingleton.get(lv, d).showInset(ic);
476         }
477
478
479         void gui_CreateTOC(string const & s, LyXView & lv, Dialogs & d)
480         {
481                 controlTocSingleton.get(lv, d).createInset(s);
482         }
483
484
485         void gui_ShowUrl(InsetCommand * ic, LyXView & lv, Dialogs & d)
486         {
487                 controlUrlSingleton.get(lv, d).showInset(ic);
488         }
489
490
491         void gui_CreateUrl(string const & s, LyXView & lv, Dialogs & d)
492         {
493                 controlUrlSingleton.get(lv, d).createInset(s);
494         }
495
496
497         void gui_ShowVCLogFile(LyXView & lv, Dialogs & d)
498         {
499                 static GUI<ControlVCLog, QVCLog,
500                         OkCancelPolicy, Qt2BC> cv(lv, d);
501                 cv.show();
502         }
503
504 } // extern "C"