]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
Remove the .aux and .bbl files and update the citation labels
[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 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 setIndent(int);
101         void enableIndent(bool);
102         void setSkip(int);
103         void enableSkip(bool);
104         void browseLayout();
105         void browseMaster();
106         void classChanged();
107         void languagePackageChanged(int);
108         void biblioChanged();
109         void bibtexChanged(int);
110         void updateModuleInfo();
111         void modulesChanged();
112         void changeBackgroundColor();
113         void deleteBackgroundColor();
114         void changeFontColor();
115         void deleteFontColor();
116         void changeNoteFontColor();
117         void deleteNoteFontColor();
118         void changeBoxBackgroundColor();
119         void deleteBoxBackgroundColor();
120         void osFontsChanged(bool);
121         void branchesRename(docstring const &, docstring const &);
122 private:
123         /// validate listings parameters and return an error message, if any
124         QString validateListingsParameters();
125
126         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
127         UiWidget<Ui::MasterChildUi> *masterChildModule;
128         UiWidget<Ui::FontUi> *fontModule;
129         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
130         UiWidget<Ui::MarginsUi> *marginsModule;
131         UiWidget<Ui::LanguageUi> *langModule;
132         UiWidget<Ui::ColorUi> *colorModule;
133         UiWidget<Ui::NumberingUi> *numberingModule;
134         UiWidget<Ui::BiblioUi> *biblioModule;
135         UiWidget<Ui::MathsUi> *mathsModule;
136         UiWidget<Ui::LaTeXUi> *latexModule;
137         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
138         UiWidget<Ui::ModulesUi> *modulesModule;
139         UiWidget<Ui::OutputUi> *outputModule;
140         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
141         PreambleModule * preambleModule;
142         LocalLayout * localLayout;
143
144         GuiBranches * branchesModule;
145         GuiIndices * indicesModule;
146
147         BulletsModule * bulletsModule;
148         FloatPlacement * floatModule;
149
150         ModuleSelectionManager * selectionManager;
151
152         /// Available modules
153         GuiIdListModel * availableModel() { return &modules_av_model_; }
154         /// Selected modules
155         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
156
157         /// Apply changes
158         void applyView();
159         /// update
160         void updateContents();
161         ///
162         void updateAvailableModules();
163         ///
164         void updateSelectedModules();
165         ///
166         void updateIncludeonlys();
167         /// save as default template
168         void saveDocDefault();
169         /// reset to default params
170         void useClassDefaults();
171         ///
172         void setLayoutComboByIDString(std::string const & idString);
173
174         /// available classes
175         GuiIdListModel classes_model_;
176         /// available modules
177         GuiIdListModel modules_av_model_;
178         /// selected modules
179         GuiIdListModel modules_sel_model_;
180         /// current buffer
181         BufferId current_id_;
182
183         /// return false if validate_listings_params returns error
184         bool isValid();
185
186         /// font family names for BufferParams::fonts_default_family
187         static char const * const fontfamilies[5];
188         /// GUI names corresponding fontfamilies
189         static char const * fontfamilies_gui[5];
190         ///
191         bool initialiseParams(std::string const & data);
192         ///
193         void clearParams();
194         ///
195         void dispatchParams();
196         ///
197         void modulesToParams(BufferParams &);
198         ///
199         bool isBufferDependent() const { return true; }
200         /// always true since we don't manipulate document contents
201         bool canApply() const { return true; }
202         ///
203         DocumentClass const & documentClass() const;
204         ///
205         BufferParams & params() { return bp_; }
206         ///
207         BufferId id() const;
208         ///
209         struct modInfoStruct {
210                 QString name;
211                 std::string id;
212                 QString description;
213         };
214         /// List of available modules
215         std::list<modInfoStruct> const & getModuleInfo();
216         /// Modules in use in current buffer
217         std::list<modInfoStruct> const getSelectedModules();
218         ///
219         std::list<modInfoStruct> const getProvidedModules();
220         ///
221         std::list<modInfoStruct> const
222                         makeModuleInfo(LayoutModuleList const & mods);
223         ///
224         void setLanguage() const;
225         ///
226         void saveAsDefault() const;
227         ///
228         bool isFontAvailable(std::string const & font) const;
229         /// does this font provide Old Style figures?
230         bool providesOSF(std::string const & font) const;
231         /// does this font provide true Small Caps?
232         bool providesSC(std::string const & font) const;
233         /// does this font provide size adjustment?
234         bool providesScale(std::string const & font) const;
235         ///
236         void executeBranchRenaming() const;
237         ///
238         void setCustomPapersize(bool custom);
239 private:
240         ///
241         void loadModuleInfo();
242         ///
243         void updateUnknownBranches();
244         ///
245         BufferParams bp_;
246         /// List of names of available modules
247         std::list<modInfoStruct> moduleNames_;
248         ///
249         std::map<docstring, docstring> changedBranches_;
250         ///
251         std::list<std::string> includeonlys_;
252 };
253
254
255 class PreambleModule : public UiWidget<Ui::PreambleUi>
256 {
257         Q_OBJECT
258 public:
259         PreambleModule();
260         void update(BufferParams const & params, BufferId id);
261         void apply(BufferParams & params);
262
263 Q_SIGNALS:
264         /// signal that something's changed in the Widget.
265         void changed();
266
267 private:
268         void closeEvent(QCloseEvent *);
269         void on_preambleTE_textChanged() { changed(); }
270
271 private:
272         typedef std::map<BufferId, std::pair<int,int> > Coords;
273         Coords preamble_coords_;
274         BufferId current_id_;
275 };
276
277
278 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
279 {
280         Q_OBJECT
281 public:
282         LocalLayout();
283         void update(BufferParams const & params, BufferId id);
284         void apply(BufferParams & params);
285         bool isValid() const { return is_valid_; }
286
287 Q_SIGNALS:
288         /// signal that something's changed in the Widget.
289         void changed();
290
291 private:
292         void validate();
293         void convert();
294 private Q_SLOTS:
295         void textChanged();
296         void validatePressed();
297         void convertPressed();
298
299 private:
300         BufferId current_id_;
301         bool is_valid_;
302 };
303
304
305 } // namespace frontend
306 } // namespace lyx
307
308 #endif // GUIDOCUMENT_H