]> git.lyx.org Git - features.git/blob - src/frontends/qt/GuiDocument.h
Remove unused forward declarations
[features.git] / src / frontends / qt / 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_ChangeTrackingUi.h"
24 #include "ui_DocumentUi.h"
25 #include "ui_FontUi.h"
26 #include "ui_LanguageUi.h"
27 #include "ui_LaTeXUi.h"
28 #include "ui_ListingsSettingsUi.h"
29 #include "ui_LocalLayoutUi.h"
30 #include "ui_MarginsUi.h"
31 #include "ui_MasterChildUi.h"
32 #include "ui_MathsUi.h"
33 #include "ui_ModulesUi.h"
34 #include "ui_NumberingUi.h"
35 #include "ui_OutputUi.h"
36 #include "ui_PageLayoutUi.h"
37 #include "ui_PDFSupportUi.h"
38 #include "ui_PreambleUi.h"
39 #include "ui_TextLayoutUi.h"
40
41 #include <QStandardItemModel>
42
43 namespace lyx {
44
45 class LayoutModuleList;
46 class LyXModule;
47
48 namespace support {
49         class TempFile;
50 }
51
52 namespace frontend {
53
54 class FloatPlacement;
55 class GuiBranches;
56 class GuiIndices;
57 class ModuleSelectionManager;
58 class PreambleModule;
59 class LocalLayout;
60 class FontModule;
61
62 ///
63 typedef Buffer const * BufferId;
64
65 template<class UI>
66 class UiWidget : public QWidget, public UI
67 {
68 public:
69         UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
70 };
71
72
73 class GuiDocument : public GuiDialog, public Ui::DocumentUi
74 {
75         Q_OBJECT
76 public:
77         GuiDocument(GuiView & lv);
78
79         void paramsToDialog();
80         void updateFontsize(std::string const &, std::string const &);
81         void updateFontlist();
82         void updateDefaultFormat();
83         void updateCiteStyles(std::vector<std::string> const &,
84                               CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
85         void updateEngineType(std::string const &, CiteEngineType const &);
86         void updatePagestyle(std::string const &, std::string const &);
87         bool isChildIncluded(std::string const &);
88
89         ///
90         BufferParams const & params() const { return bp_; }
91
92 public Q_SLOTS:
93         void onBufferViewChanged() override;
94         // OK button clicked
95         void slotOK();
96         // Apply button clicked
97         void slotApply();
98         void slotButtonBox(QAbstractButton *);
99
100 private Q_SLOTS:
101         void updateNumbering();
102         void change_adaptor();
103         void shellescapeChanged();
104         void includeonlyClicked(QTreeWidgetItem * item, int);
105         void setListingsMessage();
106         void listingsPackageChanged(int);
107         void saveDefaultClicked();
108         void useDefaultsClicked();
109         void setLSpacing(int);
110         void setMargins();
111         void papersizeChanged(int);
112         void setColSep();
113         void setCustomMargins(bool);
114         void fontencChanged(int);
115         void romanChanged(int);
116         void sansChanged(int);
117         void ttChanged(int);
118         void fontOsfToggled(bool state);
119         void fontScToggled(bool state);
120         void setIndent(int);
121         void enableIndent(bool);
122         void setSkip(int);
123         void enableSkip(bool);
124         void allowMathIndent();
125         void enableMathIndent(int);
126         void browseLayout();
127         void browseMaster();
128         void classChanged();
129         void classChanged_adaptor();
130         void languagePackageChanged(int);
131         void biblioChanged();
132         void rescanBibFiles();
133         void resetDefaultBibfile(std::string const & which = std::string());
134         void resetDefaultBbxBibfile();
135         void resetDefaultCbxBibfile();
136         void citeEngineChanged(int);
137         void citeStyleChanged();
138         void bibtexChanged(int);
139         void updateResetDefaultBiblio();
140         void matchBiblatexStyles();
141         void updateEngineDependends();
142         void updateModuleInfo();
143         void modulesChanged();
144         void changeBackgroundColor();
145         void deleteBackgroundColor();
146         void changeFontColor();
147         void deleteFontColor();
148         void changeNoteFontColor();
149         void deleteNoteFontColor();
150         void changeBoxBackgroundColor();
151         void deleteBoxBackgroundColor();
152         void languageChanged(int);
153         void osFontsChanged(bool);
154         void encodingSwitched(int);
155         void inputencodingToDialog();
156         void mathFontChanged(int);
157         void branchesRename(docstring const &, docstring const &);
158         void allPackagesAuto();
159         void allPackagesAlways();
160         void allPackagesNot();
161         void moduleFilterPressed();
162         void moduleFilterChanged(const QString & text);
163         void resetModuleFilter();
164         void linenoToggled(bool);
165         void outputChangesToggled(bool);
166         void setOutputSync(bool);
167         void bookmarksopenChanged(bool);
168 private:
169         /// validate listings parameters and return an error message, if any
170         QString validateListingsParameters();
171
172         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
173         UiWidget<Ui::MasterChildUi> *masterChildModule;
174         FontModule *fontModule;
175         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
176         UiWidget<Ui::MarginsUi> *marginsModule;
177         UiWidget<Ui::LanguageUi> *langModule;
178         UiWidget<Ui::ColorUi> *colorModule;
179         UiWidget<Ui::ChangeTrackingUi> *changesModule;
180         UiWidget<Ui::NumberingUi> *numberingModule;
181         UiWidget<Ui::BiblioUi> *biblioModule;
182         UiWidget<Ui::MathsUi> *mathsModule;
183         UiWidget<Ui::LaTeXUi> *latexModule;
184         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
185         UiWidget<Ui::ModulesUi> *modulesModule;
186         UiWidget<Ui::OutputUi> *outputModule;
187         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
188         PreambleModule * preambleModule;
189         LocalLayout * localLayout;
190
191         GuiBranches * branchesModule;
192         GuiIndices * indicesModule;
193
194         BulletsModule * bulletsModule;
195         FloatPlacement * floatModule;
196
197         ModuleSelectionManager * selectionManager;
198
199         /// Available modules
200         QStandardItemModel * availableModel() { return &modules_av_model_; }
201         /// Selected modules
202         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
203
204         /// Apply changes
205         void applyView() override;
206         /// update
207         void updateContents() override;
208         ///
209         void updateAvailableModules();
210         ///
211         void updateSelectedModules();
212         ///
213         void updateIncludeonlyDisplay();
214         ///
215         void updateIncludeonlys();
216         ///
217         void updateDefaultBiblio(std::string const & style,
218                                  std::string const & which = std::string());
219         /// save as default template
220         void saveDocDefault();
221         /// reset to default params
222         void useClassDefaults();
223         ///
224         void setLayoutComboByIDString(std::string const & idString);
225         /// Update quotes styles combo, indicating the current language's default
226         void updateQuoteStyles(bool const set = false);
227         ///
228         void getTableStyles();
229
230         /// available modules
231         QStandardItemModel modules_av_model_;
232         /// selected modules
233         GuiIdListModel modules_sel_model_;
234
235         /// Module filter
236         FancyLineEdit * filter_;
237
238         /// return false if validate_listings_params returns error
239         bool isValid() override;
240
241         /// font family names for BufferParams::fonts_default_family
242         static char const * const fontfamilies[5];
243         /// GUI names corresponding fontfamilies
244         static char const * fontfamilies_gui[5];
245         ///
246         bool initialiseParams(std::string const & data) override;
247         ///
248         void clearParams() override;
249         ///
250         void dispatchParams() override;
251         ///
252         void modulesToParams(BufferParams &);
253         ///
254         bool isBufferDependent() const override { return true; }
255         /// always true since we don't manipulate document contents
256         bool canApply() const override { return true; }
257         ///
258         DocumentClass const & documentClass() const;
259         ///
260         BufferParams & params() { return bp_; }
261         ///
262         BufferId id() const;
263         ///
264         struct modInfoStruct {
265                 QString name;
266                 std::string id;
267                 QString description;
268                 QString category;
269                 bool local;
270                 bool missingreqs;
271         };
272         ///
273         static modInfoStruct modInfo(LyXModule const & mod);
274         /// List of available modules
275         std::list<modInfoStruct> const & getModuleInfo();
276         /// Modules in use in current buffer
277         std::list<modInfoStruct> const getSelectedModules();
278         ///
279         std::list<modInfoStruct> const getProvidedModules();
280         ///
281         std::list<modInfoStruct> const
282                         makeModuleInfo(LayoutModuleList const & mods);
283         ///
284         void setLanguage() const;
285         ///
286         void saveAsDefault() const;
287         /// does this font provide Old Style figures?
288         bool providesOSF(QString const & font) const;
289         /// does this font provide true Small Caps?
290         bool providesSC(QString const & font) const;
291         /** does this font provide OSF and Small Caps only via
292          * a single, undifferentiated expert option?
293          */
294         bool hasMonolithicExpertSet(QString const & font) const;
295         /// does this font provide size adjustment?
296         bool providesScale(QString const & font) const;
297         /// does this font provide extra options?
298         bool providesExtraOpts(QString const & font) const;
299         /// does this font provide an alternative without math?
300         bool providesNoMath(QString const & font) const;
301         ///
302         void executeBranchRenaming() const;
303         ///
304         void setCustomPapersize(bool custom);
305 private:
306         ///
307         void loadModuleInfo();
308         ///
309         void updateUnknownBranches();
310         ///
311         void updateTexFonts();
312         ///
313         void updateMathFonts(QString const & rm);
314         ///
315         void updateExtraOpts();
316         ///
317         void updateFontOptions();
318         ///
319         bool ot1() const;
320         ///
321         bool completeFontset() const;
322         ///
323         bool noMathFont() const;
324         ///
325         void allPackages(int);
326         ///
327         bool isBiblatex() const;
328         ///
329         void checkPossibleCiteEngines();
330         ///
331         void filterModules(QString const & string);
332         ///
333         BufferParams bp_;
334         /// List of names of available modules
335         std::list<modInfoStruct> moduleNames_;
336         ///
337         std::map<docstring, docstring> changedBranches_;
338         ///
339         std::list<std::string> includeonlys_;
340         ///
341         bool biblioChanged_;
342         /// Track if a non-module document param changed
343         bool nonModuleChanged_;
344         /// Track if used modules changed
345         bool modulesChanged_;
346         /// Track if the shellescape param changed
347         bool shellescapeChanged_;
348 };
349
350
351 class PreambleModule : public UiWidget<Ui::PreambleUi>
352 {
353         Q_OBJECT
354 public:
355         PreambleModule(QWidget * parent);
356         void update(BufferParams const & params, BufferId id);
357         void apply(BufferParams & params);
358         bool editing() const { return (bool)tempfile_; }
359
360 Q_SIGNALS:
361         /// signal that something's changed in the Widget.
362         void changed();
363
364 private:
365         void closeEvent(QCloseEvent *) override;
366         void on_preambleTE_textChanged() { changed(); }
367
368         typedef std::map<BufferId, std::pair<int,int> > Coords;
369         Coords preamble_coords_;
370         BufferId current_id_;
371         unique_ptr<support::TempFile> tempfile_;
372
373 private Q_SLOTS:
374         ///
375         void checkFindButton();
376         void findText();
377         void editExternal();
378 };
379
380
381 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
382 {
383         Q_OBJECT
384 public:
385         LocalLayout(QWidget * parent);
386         void update(BufferParams const & params, BufferId id);
387         void apply(BufferParams & params);
388         bool isValid() const { return validated_; }
389         bool editing() const { return (bool)tempfile_; }
390
391 Q_SIGNALS:
392         /// signal that something's changed in the Widget.
393         void changed();
394
395 private:
396         void validate();
397         void convert();
398         void hideConvert();
399 private Q_SLOTS:
400         void textChanged();
401         void validatePressed();
402         void convertPressed();
403         void editExternal();
404
405 private:
406         BufferId current_id_;
407         bool validated_;
408         unique_ptr<support::TempFile> tempfile_;
409 };
410
411
412 class FontModule : public UiWidget<Ui::FontUi>
413 {
414         Q_OBJECT
415 public:
416         FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
417            font_sf_scale(100), font_tt_scale(100) {}
418         /// The roman font currently not selected by osFontsCB->isChecked()
419         QString font_roman;
420         /// The sans font currently not selected by osFontsCB->isChecked()
421         QString font_sans;
422         /// The typewriter font currently not selected by osFontsCB->isChecked()
423         QString font_typewriter;
424         /// The math font currently not selected by osFontsCB->isChecked()
425         QString font_math;
426         /// The sans font scale currently not selected by osFontsCB->isChecked()
427         int font_sf_scale;
428         /// The typewriter font scale currently not selected by osFontsCB->isChecked()
429         int font_tt_scale;
430 };
431
432
433 } // namespace frontend
434 } // namespace lyx
435
436 #endif // GUIDOCUMENT_H