]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QDocument.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / QDocument.C
1 /**
2  * \file QDocument.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QDocument.h"
14 #include "QDocumentDialog.h"
15 #include "Qt2BC.h"
16 #include "qt_helpers.h"
17
18 #include "bufferparams.h"
19 #include "FloatPlacement.h"
20 #include "gettext.h"
21 #include "helper_funcs.h" // getSecond()
22 #include "language.h"
23 #include "lyxrc.h" // defaultUnit
24 #include "lyxtextclasslist.h"
25
26 #include "support/lstrings.h"
27
28 #include "controllers/ControlDocument.h"
29 #include "controllers/frnt_lang.h"
30
31 #include "lengthcombo.h"
32
33
34 using lyx::support::bformat;
35 using lyx::support::getVectorFromString;
36
37 using std::distance;
38 using std::vector;
39 using std::string;
40
41 namespace lyx {
42 namespace frontend {
43
44 typedef QController<ControlDocument, QView<QDocumentDialog> > base_class;
45
46
47 QDocument::QDocument(Dialog & parent)
48         : base_class(parent, lyx::to_utf8(_("Document Settings")))
49 {}
50
51
52 void QDocument::build_dialog()
53 {
54         dialog_.reset(new QDocumentDialog(this));
55 }
56
57
58 void QDocument::showPreamble()
59 {
60         dialog_->showPreamble();
61 }
62
63
64 void QDocument::apply()
65 {
66         if (!dialog_.get())
67                 return;
68
69         dialog_->apply(controller().params());
70 }
71
72
73 void QDocument::update_contents()
74 {
75         if (!dialog_.get())
76                 return;
77
78         dialog_->update(controller().params());
79 }
80
81 void QDocument::saveDocDefault()
82 {
83         // we have to apply the params first
84         apply();
85         controller().saveAsDefault();
86 }
87
88
89 void QDocument::useClassDefaults()
90 {
91         BufferParams & params = controller().params();
92
93         ///\todo verify the use of below with lyx-devel:
94         params.textclass = dialog_->latexModule->classCO->currentIndex();
95
96         params.useClassDefaults();
97         update_contents();
98 }
99
100 } // namespace frontend
101 } // namespace lyx