]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Dialogs.cpp
e7788db147a0cd7f8b3b846352848334601b3407
[lyx.git] / src / frontends / qt4 / Dialogs.cpp
1 /**
2  * \file qt4/Dialogs.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Dialogs.h"
14
15 #include <boost/assert.hpp>
16
17 using std::string;
18
19 namespace lyx {
20 namespace frontend {
21
22 namespace {
23
24 // This list should be kept in sync with the list of insets in
25 // src/insets/Inset.cpp.  I.e., if a dialog goes with an inset, the
26 // dialog should have the same name as the inset.
27
28 char const * const dialognames[] = {
29 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
30 "citation", "document", "embedding", "errorlist", "ert", "external", "file",
31 "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
32 "mathdelimiter", "mathmatrix", "note", "paragraph",
33 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
34
35 #ifdef HAVE_LIBAIKSAURUS
36 "thesaurus",
37 #endif
38
39 "texinfo", "toc", "href", "view-source", "vspace", "wrap", "listings" };
40
41 char const * const * const end_dialognames =
42         dialognames + (sizeof(dialognames) / sizeof(char *));
43
44 class cmpCStr {
45 public:
46         cmpCStr(char const * name) : name_(name) {}
47         bool operator()(char const * other) {
48                 return strcmp(other, name_) == 0;
49         }
50 private:
51         char const * name_;
52 };
53
54
55 } // namespace anon
56
57 // will be replaced by a proper factory...
58 Dialog * createGuiAbout(LyXView & lv);
59 Dialog * createGuiBibitem(LyXView & lv);
60 Dialog * createGuiBibtex(LyXView & lv);
61 Dialog * createGuiBox(LyXView & lv);
62 Dialog * createGuiBranch(LyXView & lv);
63 Dialog * createGuiChanges(LyXView & lv);
64 Dialog * createGuiCharacter(LyXView & lv);
65 Dialog * createGuiCitation(LyXView & lv);
66 Dialog * createGuiDelimiter(LyXView & lv);
67 Dialog * createGuiDocument(LyXView & lv);
68 Dialog * createGuiErrorList(LyXView & lv);
69 Dialog * createGuiERT(LyXView & lv);
70 Dialog * createGuiExternal(LyXView & lv);
71 Dialog * createGuiFloat(LyXView & lv);
72 Dialog * createGuiGraphics(LyXView & lv);
73 Dialog * createGuiInclude(LyXView & lv);
74 Dialog * createGuiIndex(LyXView & lv);
75 Dialog * createGuiLabel(LyXView & lv);
76 Dialog * createGuiListings(LyXView & lv);
77 Dialog * createGuiLog(LyXView & lv);
78 Dialog * createGuiMathMatrix(LyXView & lv);
79 Dialog * createGuiNomenclature(LyXView & lv);
80 Dialog * createGuiNote(LyXView & lv);
81 Dialog * createGuiParagraph(LyXView & lv);
82 Dialog * createGuiPreferences(LyXView & lv);
83 Dialog * createGuiPrint(LyXView & lv);
84 Dialog * createGuiRef(LyXView & lv);
85 Dialog * createGuiSearch(LyXView & lv);
86 Dialog * createGuiSendTo(LyXView & lv);
87 Dialog * createGuiShowFile(LyXView & lv);
88 Dialog * createGuiSpellchecker(LyXView & lv);
89 Dialog * createGuiTabularCreate(LyXView & lv);
90 Dialog * createGuiTabular(LyXView & lv);
91 Dialog * createGuiTexInfo(LyXView & lv);
92 Dialog * createGuiToc(LyXView & lv);
93 Dialog * createGuiThesaurus(LyXView & lv);
94 Dialog * createGuiHyperlink(LyXView & lv);
95 Dialog * createGuiVSpace(LyXView & lv);
96 Dialog * createGuiViewSource(LyXView & lv);
97 Dialog * createGuiWrap(LyXView & lv);
98
99
100 bool Dialogs::isValidName(string const & name) const
101 {
102         return std::find_if(dialognames, end_dialognames,
103                             cmpCStr(name.c_str())) != end_dialognames;
104 }
105
106
107 Dialog * Dialogs::build(string const & name)
108 {
109         BOOST_ASSERT(isValidName(name));
110
111         if (name == "aboutlyx")
112                 return createGuiAbout(lyxview_);
113         if (name == "bibitem")
114                 return createGuiBibitem(lyxview_);
115         if (name == "bibtex")
116                 return createGuiBibtex(lyxview_);
117         if (name == "box")
118                 return createGuiBox(lyxview_);
119         if (name == "branch")
120                 return createGuiBranch(lyxview_);
121         if (name == "changes")
122                 return createGuiChanges(lyxview_);
123         if (name == "character")
124                 return createGuiCharacter(lyxview_);
125         if (name == "citation")
126                 return createGuiCitation(lyxview_);
127         if (name == "document")
128                 return createGuiDocument(lyxview_);
129         if (name == "errorlist")
130                 return createGuiErrorList(lyxview_);
131         if (name == "ert")
132                 return createGuiERT(lyxview_);
133         if (name == "external")
134                 return createGuiExternal(lyxview_);
135         if (name == "file")
136                 return createGuiShowFile(lyxview_);
137         if (name == "findreplace")
138                 return createGuiSearch(lyxview_);
139         if (name == "float")
140                 return createGuiFloat(lyxview_);
141         if (name == "graphics")
142                 return createGuiGraphics(lyxview_);
143         if (name == "include")
144                 return createGuiInclude(lyxview_);
145         if (name == "index")
146                 return createGuiIndex(lyxview_);
147         if (name == "nomenclature")
148                 return createGuiNomenclature(lyxview_);
149         if (name == "label")
150                 return createGuiLabel(lyxview_);
151         if (name == "log")
152                 return createGuiLog(lyxview_);
153         if (name == "view-source")
154                 return createGuiViewSource(lyxview_);
155         if (name == "mathdelimiter")
156                 return createGuiDelimiter(lyxview_);
157         if (name == "mathmatrix")
158                 return createGuiMathMatrix(lyxview_);
159         if (name == "note")
160                 return createGuiNote(lyxview_);
161         if (name == "paragraph")
162                 return createGuiParagraph(lyxview_);
163         if (name == "prefs")
164                 return createGuiPreferences(lyxview_);
165         if (name == "print")
166                 return createGuiPrint(lyxview_);
167         if (name == "ref")
168                 return createGuiRef(lyxview_);
169         if (name == "sendto")
170                 return createGuiSendTo(lyxview_);
171         if (name == "spellchecker")
172                 return createGuiSpellchecker(lyxview_);
173         if (name == "tabular")
174                 return createGuiTabular(lyxview_);
175         if (name == "tabularcreate")
176                 return createGuiTabularCreate(lyxview_);
177         if (name == "texinfo")
178                 return createGuiTexInfo(lyxview_);
179 #ifdef HAVE_LIBAIKSAURUS
180         if (name == "thesaurus")
181                 return createGuiThesaurus(lyxview_);
182 #endif
183         if (name == "toc")
184                 return createGuiToc(lyxview_);
185         if (name == "href")
186                 return createGuiHyperlink(lyxview_);
187         if (name == "vspace")
188                 return createGuiVSpace(lyxview_);
189         if (name == "wrap")
190                 return createGuiWrap(lyxview_);
191         if (name == "listings")
192                 return createGuiListings(lyxview_);
193
194         return 0;
195 }
196
197
198 /// Are the tooltips on or off?
199 bool Dialogs::tooltipsEnabled()
200 {
201         return false;
202 }
203
204 } // namespace frontend
205 } // namespace lyx