]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Dialogs.cpp
Dock the Embedding dialog (code copied from the ViewSource dialog and I do not really...
[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 "DockView.h"
18 #include "GuiAbout.h"
19 #include "GuiBibitem.h"
20 #include "GuiBibtex.h"
21 #include "GuiBox.h"
22 #include "GuiBranch.h"
23 #include "GuiChanges.h"
24 #include "GuiCharacter.h"
25 #include "GuiCitation.h"
26 #include "GuiDelimiter.h"
27 #include "GuiDocument.h"
28 #include "GuiEmbeddedFiles.h"
29 #include "GuiErrorList.h"
30 #include "GuiERT.h"
31 #include "GuiExternal.h"
32 #include "GuiFloat.h"
33 #include "GuiGraphics.h"
34 #include "GuiInclude.h"
35 #include "GuiIndex.h"
36 #include "GuiMathMatrix.h"
37 #include "GuiNomencl.h"
38 #include "GuiListings.h"
39 #include "GuiLog.h"
40 #include "GuiNote.h"
41 #include "GuiParagraph.h"
42 #include "GuiPrefs.h"
43 #include "GuiPrint.h"
44 #include "GuiRef.h"
45 #include "GuiSearch.h"
46 #include "GuiSendto.h"
47 #include "GuiShowFile.h"
48 #include "GuiSpellchecker.h"
49 #include "GuiTabular.h"
50 #include "GuiTabularCreate.h"
51 #include "GuiTexinfo.h"
52 #include "GuiToc.h"
53 #include "GuiView.h"
54 #include "GuiViewSource.h"
55 #include "TocWidget.h"
56 #include "GuiURL.h"
57 #include "GuiVSpace.h"
58 #include "GuiWrap.h"
59
60 #ifdef HAVE_LIBAIKSAURUS
61 #include "ControlThesaurus.h"
62 #include "GuiThesaurus.h"
63 #endif
64
65 #include "qt_helpers.h"
66
67 #include <boost/assert.hpp>
68
69 using std::string;
70
71 namespace lyx {
72 namespace frontend {
73
74 namespace {
75
76 char const * const dialognames[] = {
77 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
78 "citation", "document", "embedding", "errorlist", "ert", "external", "file",
79 "findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
80 "mathdelimiter", "mathmatrix", "note", "paragraph",
81 "prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
82
83 #ifdef HAVE_LIBAIKSAURUS
84 "thesaurus",
85 #endif
86
87 "texinfo", "toc", "url", "view-source", "vspace", "wrap", "listings" };
88
89 char const * const * const end_dialognames =
90         dialognames + (sizeof(dialognames) / sizeof(char *));
91
92 class cmpCStr {
93 public:
94         cmpCStr(char const * name) : name_(name) {}
95         bool operator()(char const * other) {
96                 return strcmp(other, name_) == 0;
97         }
98 private:
99         char const * name_;
100 };
101
102
103 } // namespace anon
104
105
106 bool Dialogs::isValidName(string const & name) const
107 {
108         return std::find_if(dialognames, end_dialognames,
109                             cmpCStr(name.c_str())) != end_dialognames;
110 }
111
112
113 Dialog * Dialogs::build(string const & name)
114 {
115         BOOST_ASSERT(isValidName(name));
116
117         Dialog * dialog = 0;
118         GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
119
120         if (name == "aboutlyx") {
121                 dialog = new GuiAboutDialog(lyxview_);
122         } else if (name == "bibitem") {
123                 dialog = new GuiBibitemDialog(lyxview_);
124         } else if (name == "bibtex") {
125                 dialog = new GuiBibtexDialog(lyxview_);
126         } else if (name == "box") {
127                 dialog = new GuiBoxDialog(lyxview_);
128         } else if (name == "branch") {
129                 dialog = new GuiBranchDialog(lyxview_);
130         } else if (name == "changes") {
131                 dialog = new GuiChangesDialog(lyxview_);
132         } else if (name == "character") {
133                 dialog = new GuiCharacterDialog(lyxview_);
134         } else if (name == "citation") {
135                 dialog = new GuiCitationDialog(lyxview_);
136         } else if (name == "document") {
137                 dialog = new GuiDocumentDialog(lyxview_);
138         } else if (name == "embedding") {
139                 dialog = new DockView<ControlEmbeddedFiles, GuiEmbeddedFilesDialog>(
140                         guiview, name, Qt::RightDockWidgetArea);
141         } else if (name == "errorlist") {
142                 dialog = new GuiErrorListDialog(lyxview_);
143         } else if (name == "ert") {
144                 dialog = new GuiERTDialog(lyxview_);
145         } else if (name == "external") {
146                 dialog = new GuiExternalDialog(lyxview_);
147         } else if (name == "file") {
148                 dialog = new GuiShowFileDialog(lyxview_);
149         } else if (name == "findreplace") {
150                 dialog = new GuiSearchDialog(lyxview_);
151         } else if (name == "float") {
152                 dialog = new GuiFloatDialog(lyxview_);
153         } else if (name == "graphics") {
154                 dialog = new GuiGraphicsDialog(lyxview_);
155         } else if (name == "include") {
156                 dialog = new GuiIncludeDialog(lyxview_);
157         } else if (name == "index") {
158                 dialog = new GuiIndexDialog(lyxview_);
159         } else if (name == "nomenclature") {
160                 dialog = new GuiNomenclDialog(lyxview_);
161         } else if (name == "label") {
162                 dialog = new GuiLabelDialog(lyxview_);
163         } else if (name == "log") {
164                 dialog = new GuiLogDialog(lyxview_);
165         } else if (name == "view-source") {
166                 dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
167                         guiview, name, Qt::BottomDockWidgetArea);
168         } else if (name == "mathdelimiter") {
169                 dialog = new GuiDelimiterDialog(lyxview_);
170         } else if (name == "mathmatrix") {
171                 dialog = new GuiMathMatrixDialog(lyxview_);
172         } else if (name == "note") {
173                 dialog = new GuiNoteDialog(lyxview_);
174         } else if (name == "paragraph") {
175                 dialog = new GuiParagraphDialog(lyxview_);
176         } else if (name == "prefs") {
177                 dialog = new GuiPrefsDialog(lyxview_);
178         } else if (name == "print") {
179                 dialog = new GuiPrintDialog(lyxview_);
180         } else if (name == "ref") {
181                 dialog = new GuiRefDialog(lyxview_);
182         } else if (name == "sendto") {
183                 dialog = new GuiSendtoDialog(lyxview_);
184         } else if (name == "spellchecker") {
185                 dialog = new GuiSpellcheckerDialog(lyxview_);
186         } else if (name == "tabular") {
187                 dialog = new GuiTabularDialog(lyxview_);
188         } else if (name == "tabularcreate") {
189                 dialog = new GuiTabularCreateDialog(lyxview_);
190         } else if (name == "texinfo") {
191                 dialog = new GuiTexinfoDialog(lyxview_);
192 #ifdef HAVE_LIBAIKSAURUS
193         } else if (name == "thesaurus") {
194                 dialog = new GuiThesaurusDialog(lyxview_);
195 #endif
196         } else if (name == "toc") {
197                 // On Mac show as a drawer at the right
198                 dialog = new DockView<GuiToc, TocWidget>(
199                         guiview, name, Qt::RightDockWidgetArea, Qt::Drawer);
200         } else if (name == "url") {
201                 dialog = new GuiURLDialog(lyxview_);
202         } else if (name == "vspace") {
203                 dialog = new GuiVSpaceDialog(lyxview_);
204         } else if (name == "wrap") {
205                 dialog = new GuiWrapDialog(lyxview_);
206         } else if (name == "listings") {
207                 dialog = new GuiListingsDialog(lyxview_);
208         }
209
210         return dialog;
211 }
212
213
214 /// Are the tooltips on or off?
215 bool Dialogs::tooltipsEnabled()
216 {
217         return false;
218 }
219
220 } // namespace frontend
221 } // namespace lyx