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