]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Dialogs.cpp
Transfer some code from GuiView to TabWorkArea.
[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 #include "GuiDialog.h"
15
16 #include "ButtonController.h"
17 #include "DialogView.h"
18 #include "DockView.h"
19 #include "GuiBibitem.h"
20 #include "GuiDelimiter.h"
21 #include "GuiExternal.h"
22 #include "GuiIndex.h"
23 #include "GuiMathMatrix.h"
24 #include "GuiNomencl.h"
25 #include "GuiParagraph.h"
26 #include "GuiPrefs.h"
27 #include "GuiView.h"
28 #include "GuiURL.h"
29
30 // Uncomment this if you prefer dock widget
31 //#define USE_DOCK_WIDGET
32
33 #include "qt_helpers.h"
34
35 #include <boost/assert.hpp>
36
37 using std::string;
38
39 namespace lyx {
40 namespace frontend {
41
42 namespace {
43
44 // This list should be kept in sync with the list of insets in
45 // src/insets/Inset.cpp.  I.e., if a dialog goes with an inset, the
46 // dialog should have the same name as the inset.
47
48 char const * const dialognames[] = {
49 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
50 "citation", "document", "embedding", "errorlist", "ert", "external", "file",
51 "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
52 "mathdelimiter", "mathmatrix", "note", "paragraph",
53 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
54
55 #ifdef HAVE_LIBAIKSAURUS
56 "thesaurus",
57 #endif
58
59 "texinfo", "toc", "url", "view-source", "vspace", "wrap", "listings" };
60
61 char const * const * const end_dialognames =
62         dialognames + (sizeof(dialognames) / sizeof(char *));
63
64 class cmpCStr {
65 public:
66         cmpCStr(char const * name) : name_(name) {}
67         bool operator()(char const * other) {
68                 return strcmp(other, name_) == 0;
69         }
70 private:
71         char const * name_;
72 };
73
74
75 } // namespace anon
76
77 // will be replaced by a proper factory...
78 Dialog * createGuiAbout(LyXView & lv);
79 Dialog * createGuiBibitem(LyXView & lv);
80 Dialog * createGuiBibtex(LyXView & lv);
81 Dialog * createGuiBox(LyXView & lv);
82 Dialog * createGuiBranch(LyXView & lv);
83 Dialog * createGuiChanges(LyXView & lv);
84 Dialog * createGuiCharacter(LyXView & lv);
85 Dialog * createGuiCitation(LyXView & lv);
86 Dialog * createGuiDelimiter(LyXView & lv);
87 Dialog * createGuiDocument(LyXView & lv);
88 Dialog * createGuiEmbeddedFiles(LyXView & lv);
89 Dialog * createGuiErrorList(LyXView & lv);
90 Dialog * createGuiERT(LyXView & lv);
91 Dialog * createGuiExternal(LyXView & lv);
92 Dialog * createGuiFloat(LyXView & lv);
93 Dialog * createGuiGraphics(LyXView & lv);
94 Dialog * createGuiInclude(LyXView & lv);
95 Dialog * createGuiIndex(LyXView & lv);
96 Dialog * createGuiLabel(LyXView & lv);
97 Dialog * createGuiListings(LyXView & lv);
98 Dialog * createGuiLog(LyXView & lv);
99 Dialog * createGuiMathMatrix(LyXView & lv);
100 Dialog * createGuiNomencl(LyXView & lv);
101 Dialog * createGuiNote(LyXView & lv);
102 Dialog * createGuiPrefs(LyXView & lv);
103 Dialog * createGuiPrint(LyXView & lv);
104 Dialog * createGuiRef(LyXView & lv);
105 Dialog * createGuiSearch(LyXView & lv);
106 Dialog * createGuiSendTo(LyXView & lv);
107 Dialog * createGuiShowFile(LyXView & lv);
108 Dialog * createGuiSpellchecker(LyXView & lv);
109 Dialog * createGuiTabularCreate(LyXView & lv);
110 Dialog * createGuiTabular(LyXView & lv);
111 Dialog * createGuiTexInfo(LyXView & lv);
112 Dialog * createGuiToc(LyXView & lv);
113 Dialog * createGuiThesaurus(LyXView & lv);
114 Dialog * createGuiURL(LyXView & lv);
115 Dialog * createGuiVSpace(LyXView & lv);
116 Dialog * createGuiViewSource(LyXView & lv);
117 Dialog * createGuiWrap(LyXView & lv);
118
119
120 bool Dialogs::isValidName(string const & name) const
121 {
122         return std::find_if(dialognames, end_dialognames,
123                             cmpCStr(name.c_str())) != end_dialognames;
124 }
125
126
127 Dialog * Dialogs::build(string const & name)
128 {
129         BOOST_ASSERT(isValidName(name));
130
131         GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
132
133         if (name == "aboutlyx")
134                 return createGuiAbout(lyxview_);
135         if (name == "bibitem")
136                 return new GuiBibitemDialog(lyxview_);
137         if (name == "bibtex")
138                 return createGuiBibtex(lyxview_);
139         if (name == "box")
140                 return createGuiBox(lyxview_);
141         if (name == "branch")
142                 return createGuiBranch(lyxview_);
143         if (name == "changes")
144                 return createGuiChanges(lyxview_);
145         if (name == "character")
146                 return createGuiCharacter(lyxview_);
147         if (name == "citation")
148                 return createGuiCitation(lyxview_);
149         if (name == "document")
150                 return createGuiDocument(lyxview_);
151         if (name == "embedding")
152                 return createGuiEmbeddedFiles(lyxview_);
153         if (name == "errorlist")
154                 return createGuiErrorList(lyxview_);
155         if (name == "ert")
156                 return createGuiERT(lyxview_);
157         if (name == "external")
158                 return new GuiExternalDialog(lyxview_);
159         if (name == "file")
160                 return createGuiShowFile(lyxview_);
161         if (name == "findreplace")
162                 return createGuiSearch(lyxview_);
163         if (name == "float")
164                 return createGuiFloat(lyxview_);
165         if (name == "graphics")
166                 return createGuiGraphics(lyxview_);
167         if (name == "include")
168                 return createGuiInclude(lyxview_);
169         if (name == "index")
170                 return new GuiIndexDialog(lyxview_);
171         if (name == "nomenclature")
172                 return new GuiNomenclDialog(lyxview_);
173         if (name == "label")
174                 return new GuiLabelDialog(lyxview_);
175         if (name == "log")
176                 return createGuiLog(lyxview_);
177         if (name == "view-source")
178                 return createGuiViewSource(lyxview_);
179         if (name == "mathdelimiter")
180                 return new GuiDelimiterDialog(lyxview_);
181         if (name == "mathmatrix")
182                 return new GuiMathMatrixDialog(lyxview_);
183         if (name == "note")
184                 return createGuiNote(lyxview_);
185         if (name == "paragraph") {
186 #ifdef USE_DOCK_WIDGET
187                 return new DockView<ControlParagraph, GuiParagraph>(guiview, name,
188                         Qt::TopDockWidgetArea);
189 #else
190                 return new DialogView<ControlParagraph, GuiParagraph>(guiview, name);
191 #endif
192         }
193         if (name == "prefs")
194                 return new GuiPrefsDialog(lyxview_);
195         if (name == "print")
196                 return createGuiPrint(lyxview_);
197         if (name == "ref")
198                 return createGuiRef(lyxview_);
199         if (name == "sendto")
200                 return createGuiSendTo(lyxview_);
201         if (name == "spellchecker")
202                 return createGuiSpellchecker(lyxview_);
203         if (name == "tabular")
204                 return createGuiTabular(lyxview_);
205         if (name == "tabularcreate")
206                 return createGuiTabularCreate(lyxview_);
207         if (name == "texinfo")
208                 return createGuiTexInfo(lyxview_);
209 #ifdef HAVE_LIBAIKSAURUS
210         if (name == "thesaurus")
211                 return createGuiThesaurus(lyxview_);
212 #endif
213         if (name == "toc")
214                 return createGuiToc(lyxview_);
215         if (name == "url")
216                 return new GuiURLDialog(lyxview_);
217         if (name == "vspace")
218                 return createGuiVSpace(lyxview_);
219         if (name == "wrap")
220                 return createGuiWrap(lyxview_);
221         if (name == "listings")
222                 return createGuiListings(lyxview_);
223
224         return 0;
225 }
226
227
228 /// Are the tooltips on or off?
229 bool Dialogs::tooltipsEnabled()
230 {
231         return false;
232 }
233
234 } // namespace frontend
235 } // namespace lyx