]> git.lyx.org Git - features.git/blob - src/frontends/qt4/Dialogs.cpp
4010e47cd522c42614009af451a5f3b39e871d86
[features.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 * createGuiEmbeddedFiles(LyXView & lv);
69 Dialog * createGuiErrorList(LyXView & lv);
70 Dialog * createGuiERT(LyXView & lv);
71 Dialog * createGuiExternal(LyXView & lv);
72 Dialog * createGuiFloat(LyXView & lv);
73 Dialog * createGuiGraphics(LyXView & lv);
74 Dialog * createGuiInclude(LyXView & lv);
75 Dialog * createGuiIndex(LyXView & lv);
76 Dialog * createGuiLabel(LyXView & lv);
77 Dialog * createGuiListings(LyXView & lv);
78 Dialog * createGuiLog(LyXView & lv);
79 Dialog * createGuiMathMatrix(LyXView & lv);
80 Dialog * createGuiNomenclature(LyXView & lv);
81 Dialog * createGuiNote(LyXView & lv);
82 Dialog * createGuiParagraph(LyXView & lv);
83 Dialog * createGuiPreferences(LyXView & lv);
84 Dialog * createGuiPrint(LyXView & lv);
85 Dialog * createGuiRef(LyXView & lv);
86 Dialog * createGuiSearch(LyXView & lv);
87 Dialog * createGuiSendTo(LyXView & lv);
88 Dialog * createGuiShowFile(LyXView & lv);
89 Dialog * createGuiSpellchecker(LyXView & lv);
90 Dialog * createGuiTabularCreate(LyXView & lv);
91 Dialog * createGuiTabular(LyXView & lv);
92 Dialog * createGuiTexInfo(LyXView & lv);
93 Dialog * createGuiToc(LyXView & lv);
94 Dialog * createGuiThesaurus(LyXView & lv);
95 Dialog * createGuiHyperlink(LyXView & lv);
96 Dialog * createGuiVSpace(LyXView & lv);
97 Dialog * createGuiViewSource(LyXView & lv);
98 Dialog * createGuiWrap(LyXView & lv);
99
100
101 bool Dialogs::isValidName(string const & name) const
102 {
103         return std::find_if(dialognames, end_dialognames,
104                             cmpCStr(name.c_str())) != end_dialognames;
105 }
106
107
108 Dialog * Dialogs::build(string const & name)
109 {
110         BOOST_ASSERT(isValidName(name));
111
112         if (name == "aboutlyx")
113                 return createGuiAbout(lyxview_);
114         if (name == "bibitem")
115                 return createGuiBibitem(lyxview_);
116         if (name == "bibtex")
117                 return createGuiBibtex(lyxview_);
118         if (name == "box")
119                 return createGuiBox(lyxview_);
120         if (name == "branch")
121                 return createGuiBranch(lyxview_);
122         if (name == "changes")
123                 return createGuiChanges(lyxview_);
124         if (name == "character")
125                 return createGuiCharacter(lyxview_);
126         if (name == "citation")
127                 return createGuiCitation(lyxview_);
128         if (name == "document")
129                 return createGuiDocument(lyxview_);
130         if (name == "embedding")
131                 return createGuiEmbeddedFiles(lyxview_);
132         if (name == "errorlist")
133                 return createGuiErrorList(lyxview_);
134         if (name == "ert")
135                 return createGuiERT(lyxview_);
136         if (name == "external")
137                 return createGuiExternal(lyxview_);
138         if (name == "file")
139                 return createGuiShowFile(lyxview_);
140         if (name == "findreplace")
141                 return createGuiSearch(lyxview_);
142         if (name == "float")
143                 return createGuiFloat(lyxview_);
144         if (name == "graphics")
145                 return createGuiGraphics(lyxview_);
146         if (name == "include")
147                 return createGuiInclude(lyxview_);
148         if (name == "index")
149                 return createGuiIndex(lyxview_);
150         if (name == "nomenclature")
151                 return createGuiNomenclature(lyxview_);
152         if (name == "label")
153                 return createGuiLabel(lyxview_);
154         if (name == "log")
155                 return createGuiLog(lyxview_);
156         if (name == "view-source")
157                 return createGuiViewSource(lyxview_);
158         if (name == "mathdelimiter")
159                 return createGuiDelimiter(lyxview_);
160         if (name == "mathmatrix")
161                 return createGuiMathMatrix(lyxview_);
162         if (name == "note")
163                 return createGuiNote(lyxview_);
164         if (name == "paragraph")
165                 return createGuiParagraph(lyxview_);
166         if (name == "prefs")
167                 return createGuiPreferences(lyxview_);
168         if (name == "print")
169                 return createGuiPrint(lyxview_);
170         if (name == "ref")
171                 return createGuiRef(lyxview_);
172         if (name == "sendto")
173                 return createGuiSendTo(lyxview_);
174         if (name == "spellchecker")
175                 return createGuiSpellchecker(lyxview_);
176         if (name == "tabular")
177                 return createGuiTabular(lyxview_);
178         if (name == "tabularcreate")
179                 return createGuiTabularCreate(lyxview_);
180         if (name == "texinfo")
181                 return createGuiTexInfo(lyxview_);
182 #ifdef HAVE_LIBAIKSAURUS
183         if (name == "thesaurus")
184                 return createGuiThesaurus(lyxview_);
185 #endif
186         if (name == "toc")
187                 return createGuiToc(lyxview_);
188         if (name == "href")
189                 return createGuiHyperlink(lyxview_);
190         if (name == "vspace")
191                 return createGuiVSpace(lyxview_);
192         if (name == "wrap")
193                 return createGuiWrap(lyxview_);
194         if (name == "listings")
195                 return createGuiListings(lyxview_);
196
197         return 0;
198 }
199
200
201 /// Are the tooltips on or off?
202 bool Dialogs::tooltipsEnabled()
203 {
204         return false;
205 }
206
207 } // namespace frontend
208 } // namespace lyx