]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
Correctly enable/disable the filter label and textfield in the TocWidget. Also, short...
[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_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 namespace lyx {
42
43 class BufferParams;
44 class LayoutModuleList;
45 class TextClass;
46
47 namespace frontend {
48
49 class FloatPlacement;
50 class GuiBranches;
51 class GuiIndices;
52 class ModuleSelectionManager;
53 class PreambleModule;
54
55 ///
56 typedef void const * BufferId;
57
58 template<class UI>
59 class UiWidget : public QWidget, public UI
60 {
61 public:
62         UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
63 };
64
65
66 class GuiDocument : public GuiDialog, public Ui::DocumentUi
67 {
68         Q_OBJECT
69 public:
70         GuiDocument(GuiView & lv);
71
72         void paramsToDialog();
73         void updateFontsize(std::string const &, std::string const &);
74         void updateFontlist();
75         void updateDefaultFormat();
76         void updatePagestyle(std::string const &, std::string const &);
77         bool isChildIncluded(std::string const &);
78
79         void showPreamble();
80         ///
81         BufferParams const & params() const { return bp_; }
82
83 private Q_SLOTS:
84         void updateNumbering();
85         void change_adaptor();
86         void includeonlyClicked(QTreeWidgetItem * item, int);
87         void setListingsMessage();
88         void saveDefaultClicked();
89         void useDefaultsClicked();
90         void setLSpacing(int);
91         void setMargins(bool);
92         void papersizeChanged(int);
93         void setColSep();
94         void setCustomMargins(bool);
95         void fontencChanged(int);
96         void romanChanged(int);
97         void sansChanged(int);
98         void ttChanged(int);
99         void setIndent(int);
100         void enableIndent(bool);
101         void setSkip(int);
102         void enableSkip(bool);
103         void portraitChanged();
104         void browseLayout();
105         void browseMaster();
106         void classChanged();
107         void bibtexChanged(int);
108         void updateModuleInfo();
109         void modulesChanged();
110         void changeBackgroundColor();
111         void deleteBackgroundColor();
112         void changeFontColor();
113         void deleteFontColor();
114         void changeNoteFontColor();
115         void deleteNoteFontColor();
116         void changeBoxBackgroundColor();
117         void deleteBoxBackgroundColor();
118         void xetexChanged(bool);
119         void branchesRename(docstring const &, docstring const &);
120 private:
121         /// validate listings parameters and return an error message, if any
122         QString validateListingsParameters();
123
124         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
125         UiWidget<Ui::MasterChildUi> *masterChildModule;
126         UiWidget<Ui::FontUi> *fontModule;
127         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
128         UiWidget<Ui::MarginsUi> *marginsModule;
129         UiWidget<Ui::LanguageUi> *langModule;
130         UiWidget<Ui::ColorUi> *colorModule;
131         UiWidget<Ui::NumberingUi> *numberingModule;
132         UiWidget<Ui::BiblioUi> *biblioModule;
133         UiWidget<Ui::MathsUi> *mathsModule;
134         UiWidget<Ui::LaTeXUi> *latexModule;
135         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
136         UiWidget<Ui::ModulesUi> *modulesModule;
137         UiWidget<Ui::OutputUi> *outputModule;
138         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
139         PreambleModule * preambleModule;
140         
141         GuiBranches * branchesModule;
142         GuiIndices * indicesModule;
143
144         BulletsModule * bulletsModule;
145         FloatPlacement * floatModule;
146
147         ModuleSelectionManager * selectionManager;
148
149         /// Available modules
150         GuiIdListModel * availableModel() { return &modules_av_model_; }
151         /// Selected modules
152         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
153
154         /// Apply changes
155         void applyView();
156         /// update
157         void updateContents();
158         ///
159         void updateAvailableModules();
160         ///
161         void updateSelectedModules();
162         ///
163         void updateIncludeonlys();
164         /// save as default template
165         void saveDocDefault();
166         /// reset to default params
167         void useClassDefaults();
168         ///
169         void setLayoutComboByIDString(std::string const & idString);
170
171         /// available classes
172         GuiIdListModel classes_model_;
173         /// available modules
174         GuiIdListModel modules_av_model_;
175         /// selected modules
176         GuiIdListModel modules_sel_model_;
177         /// current buffer
178         BufferId current_id_;
179
180         /// return false if validate_listings_params returns error
181         bool isValid();
182
183         /// font family names for BufferParams::fontsDefaultFamily
184         static char const * const fontfamilies[5];
185         /// GUI names corresponding fontfamilies
186         static char const * fontfamilies_gui[5];
187         ///
188         bool initialiseParams(std::string const & data);
189         ///
190         void clearParams();
191         ///
192         void dispatchParams();
193         ///
194         void modulesToParams(BufferParams &);
195         ///
196         bool isBufferDependent() const { return true; }
197         /// always true since we don't manipulate document contents
198         bool canApply() const { return true; }
199         ///
200         DocumentClass const & documentClass() const;
201         ///
202         BufferParams & params() { return bp_; }
203         ///
204         BufferId id() const;
205         ///
206         struct modInfoStruct {
207                 QString name;
208                 std::string id;
209                 QString description;
210         };
211         /// List of available modules
212         std::list<modInfoStruct> const & getModuleInfo();
213         /// Modules in use in current buffer
214         std::list<modInfoStruct> const getSelectedModules();
215         ///
216         std::list<modInfoStruct> const getProvidedModules();
217         ///
218         std::list<modInfoStruct> const 
219                         makeModuleInfo(LayoutModuleList const & mods);
220         ///
221         void setLanguage() const;
222         ///
223         void saveAsDefault() const;
224         ///
225         bool isFontAvailable(std::string const & font) const;
226         /// does this font provide Old Style figures?
227         bool providesOSF(std::string const & font) const;
228         /// does this font provide true Small Caps?
229         bool providesSC(std::string const & font) const;
230         /// does this font provide size adjustment?
231         bool providesScale(std::string const & font) const;
232         ///
233         void executeBranchRenaming() const;
234         ///
235         void setCustomPapersize(bool custom);
236 private:
237         ///
238         void loadModuleInfo();
239         ///
240         void updateUnknownBranches();
241         ///
242         BufferParams bp_;
243         /// List of names of available modules
244         std::list<modInfoStruct> moduleNames_;
245         ///
246         std::map<docstring, docstring> changedBranches_;
247         ///
248         std::list<std::string> includeonlys_;
249 };
250
251
252 class PreambleModule : public UiWidget<Ui::PreambleUi>
253 {
254         Q_OBJECT
255 public:
256         PreambleModule();
257         void update(BufferParams const & params, BufferId id);
258         void apply(BufferParams & params);
259
260 Q_SIGNALS:
261         /// signal that something's changed in the Widget.
262         void changed();
263
264 private:
265         void closeEvent(QCloseEvent *);
266         void on_preambleTE_textChanged() { changed(); }
267
268 private:
269         typedef std::map<BufferId, std::pair<int,int> > Coords;
270         Coords preamble_coords_;
271         BufferId current_id_;
272 };
273
274
275 } // namespace frontend
276 } // namespace lyx
277
278 #endif // GUIDOCUMENT_H