]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
Fix forward search with okular
[lyx.git] / src / frontends / qt4 / GuiDocument.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDocument.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author Richard Heck (modules)
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUIDOCUMENT_H
14 #define GUIDOCUMENT_H
15
16 #include <QDialog>
17
18 #include "BufferParams.h"
19 #include "BulletsModule.h"
20 #include "GuiDialog.h"
21 #include "GuiIdListModel.h"
22
23 #include "ui_BiblioUi.h"
24 #include "ui_ColorUi.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_LanguageUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_ListingsSettingsUi.h"
30 #include "ui_LocalLayoutUi.h"
31 #include "ui_MarginsUi.h"
32 #include "ui_MasterChildUi.h"
33 #include "ui_MathsUi.h"
34 #include "ui_ModulesUi.h"
35 #include "ui_NumberingUi.h"
36 #include "ui_OutputUi.h"
37 #include "ui_PageLayoutUi.h"
38 #include "ui_PDFSupportUi.h"
39 #include "ui_PreambleUi.h"
40 #include "ui_TextLayoutUi.h"
41
42 namespace lyx {
43
44 class BufferParams;
45 class LayoutModuleList;
46 class TextClass;
47
48 namespace frontend {
49
50 class FloatPlacement;
51 class GuiBranches;
52 class GuiIndices;
53 class ModuleSelectionManager;
54 class PreambleModule;
55 class LocalLayout;
56
57 ///
58 typedef void const * BufferId;
59
60 template<class UI>
61 class UiWidget : public QWidget, public UI
62 {
63 public:
64         UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
65 };
66
67
68 class GuiDocument : public GuiDialog, public Ui::DocumentUi
69 {
70         Q_OBJECT
71 public:
72         GuiDocument(GuiView & lv);
73
74         void paramsToDialog();
75         void updateFontsize(std::string const &, std::string const &);
76         void updateFontlist();
77         void updateDefaultFormat();
78         void updateEngineType(std::string const &, CiteEngineType const &);
79         void updatePagestyle(std::string const &, std::string const &);
80         bool isChildIncluded(std::string const &);
81
82         ///
83         BufferParams const & params() const { return bp_; }
84
85 private Q_SLOTS:
86         void updateNumbering();
87         void change_adaptor();
88         void includeonlyClicked(QTreeWidgetItem * item, int);
89         void setListingsMessage();
90         void saveDefaultClicked();
91         void useDefaultsClicked();
92         void setLSpacing(int);
93         void setMargins();
94         void papersizeChanged(int);
95         void setColSep();
96         void setCustomMargins(bool);
97         void fontencChanged(int);
98         void romanChanged(int);
99         void sansChanged(int);
100         void ttChanged(int);
101         void setIndent(int);
102         void enableIndent(bool);
103         void setSkip(int);
104         void enableSkip(bool);
105         void browseLayout();
106         void browseMaster();
107         void classChanged();
108         void languagePackageChanged(int);
109         void biblioChanged();
110         void bibtexChanged(int);
111         void setAuthorYear(bool);
112         void setNumerical(bool);
113         void updateModuleInfo();
114         void modulesChanged();
115         void changeBackgroundColor();
116         void deleteBackgroundColor();
117         void changeFontColor();
118         void deleteFontColor();
119         void changeNoteFontColor();
120         void deleteNoteFontColor();
121         void changeBoxBackgroundColor();
122         void deleteBoxBackgroundColor();
123         void languageChanged(int);
124         void osFontsChanged(bool);
125         void branchesRename(docstring const &, docstring const &);
126 private:
127         /// validate listings parameters and return an error message, if any
128         QString validateListingsParameters();
129
130         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
131         UiWidget<Ui::MasterChildUi> *masterChildModule;
132         UiWidget<Ui::FontUi> *fontModule;
133         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
134         UiWidget<Ui::MarginsUi> *marginsModule;
135         UiWidget<Ui::LanguageUi> *langModule;
136         UiWidget<Ui::ColorUi> *colorModule;
137         UiWidget<Ui::NumberingUi> *numberingModule;
138         UiWidget<Ui::BiblioUi> *biblioModule;
139         UiWidget<Ui::MathsUi> *mathsModule;
140         UiWidget<Ui::LaTeXUi> *latexModule;
141         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
142         UiWidget<Ui::ModulesUi> *modulesModule;
143         UiWidget<Ui::OutputUi> *outputModule;
144         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
145         PreambleModule * preambleModule;
146         LocalLayout * localLayout;
147
148         GuiBranches * branchesModule;
149         GuiIndices * indicesModule;
150
151         BulletsModule * bulletsModule;
152         FloatPlacement * floatModule;
153
154         ModuleSelectionManager * selectionManager;
155
156         /// Available modules
157         GuiIdListModel * availableModel() { return &modules_av_model_; }
158         /// Selected modules
159         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
160
161         /// Apply changes
162         void applyView();
163         /// update
164         void updateContents();
165         ///
166         void updateAvailableModules();
167         ///
168         void updateSelectedModules();
169         ///
170         void updateIncludeonlys();
171         /// save as default template
172         void saveDocDefault();
173         /// reset to default params
174         void useClassDefaults();
175         ///
176         void setLayoutComboByIDString(std::string const & idString);
177
178         /// available classes
179         GuiIdListModel classes_model_;
180         /// available modules
181         GuiIdListModel modules_av_model_;
182         /// selected modules
183         GuiIdListModel modules_sel_model_;
184         /// current buffer
185         BufferId current_id_;
186
187         /// return false if validate_listings_params returns error
188         bool isValid();
189
190         /// font family names for BufferParams::fonts_default_family
191         static char const * const fontfamilies[5];
192         /// GUI names corresponding fontfamilies
193         static char const * fontfamilies_gui[5];
194         ///
195         bool initialiseParams(std::string const & data);
196         ///
197         void clearParams();
198         ///
199         void dispatchParams();
200         ///
201         void modulesToParams(BufferParams &);
202         ///
203         bool isBufferDependent() const { return true; }
204         /// always true since we don't manipulate document contents
205         bool canApply() const { return true; }
206         ///
207         DocumentClass const & documentClass() const;
208         ///
209         BufferParams & params() { return bp_; }
210         ///
211         BufferId id() const;
212         ///
213         struct modInfoStruct {
214                 QString name;
215                 std::string id;
216                 QString description;
217         };
218         /// List of available modules
219         std::list<modInfoStruct> const & getModuleInfo();
220         /// Modules in use in current buffer
221         std::list<modInfoStruct> const getSelectedModules();
222         ///
223         std::list<modInfoStruct> const getProvidedModules();
224         ///
225         std::list<modInfoStruct> const
226                         makeModuleInfo(LayoutModuleList const & mods);
227         ///
228         void setLanguage() const;
229         ///
230         void saveAsDefault() const;
231         /// does this font provide Old Style figures?
232         bool providesOSF(QString const & font) const;
233         /// does this font provide true Small Caps?
234         bool providesSC(QString const & font) const;
235         /// does this font provide size adjustment?
236         bool providesScale(QString const & font) const;
237         ///
238         void executeBranchRenaming() const;
239         ///
240         void setCustomPapersize(bool custom);
241 private:
242         ///
243         void loadModuleInfo();
244         ///
245         void updateUnknownBranches();
246         ///
247         void updateTexFonts();
248         ///
249         void updateFontOptions();
250         ///
251         bool ot1() const;
252         ///
253         BufferParams bp_;
254         /// List of names of available modules
255         std::list<modInfoStruct> moduleNames_;
256         ///
257         std::map<docstring, docstring> changedBranches_;
258         ///
259         std::list<std::string> includeonlys_;
260         ///
261         bool biblioChanged_;
262 };
263
264
265 class PreambleModule : public UiWidget<Ui::PreambleUi>
266 {
267         Q_OBJECT
268 public:
269         PreambleModule();
270         void update(BufferParams const & params, BufferId id);
271         void apply(BufferParams & params);
272
273 Q_SIGNALS:
274         /// signal that something's changed in the Widget.
275         void changed();
276
277 private:
278         void closeEvent(QCloseEvent *);
279         void on_preambleTE_textChanged() { changed(); }
280
281 private:
282         typedef std::map<BufferId, std::pair<int,int> > Coords;
283         Coords preamble_coords_;
284         BufferId current_id_;
285 };
286
287
288 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
289 {
290         Q_OBJECT
291 public:
292         LocalLayout();
293         void update(BufferParams const & params, BufferId id);
294         void apply(BufferParams & params);
295         bool isValid() const { return validated_; }
296
297 Q_SIGNALS:
298         /// signal that something's changed in the Widget.
299         void changed();
300
301 private:
302         void validate();
303         void convert();
304 private Q_SLOTS:
305         void textChanged();
306         void validatePressed();
307         void convertPressed();
308
309 private:
310         BufferId current_id_;
311         bool validated_;
312 };
313
314
315 } // namespace frontend
316 } // namespace lyx
317
318 #endif // GUIDOCUMENT_H