2 * \file QDocumentDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
14 #include "QDocument.h"
15 #include "QDocumentDialog.h"
17 #include <QCloseEvent>
19 #include "floatplacement.h"
20 #include "lengthcombo.h"
21 #include "validators.h"
22 #include "panelstack.h"
24 #include "checkedwidgets.h"
25 #include "qt_helpers.h"
27 #include "bufferparams.h"
28 #include "floatplacement.h"
30 #include "helper_funcs.h" // getSecond()
32 #include "lyxrc.h" // defaultUnit
33 #include "lyxtextclasslist.h"
34 #include "tex-strings.h" // tex_graphics
37 #include "controllers/ControlDocument.h"
38 #include "controllers/frnt_lang.h"
40 #include "support/lstrings.h"
42 #include "controllers/ControlDocument.h"
43 #include "controllers/frnt_lang.h"
48 #include <QPushButton>
49 #include <QRadioButton>
54 #include <QColorDialog>
57 using lyx::support::token;
58 using lyx::support::bformat;
59 using lyx::support::getVectorFromString;
75 char const * encodings[] = { "LaTeX default", "latin1", "latin2",
76 "latin3", "latin4", "latin5", "latin9",
77 "koi8-r", "koi8-u", "cp866", "cp1251",
78 "iso88595", "pt154", 0
84 QDocumentDialog::getTextClass()
86 return latexModule->classCO->currentItem();
90 QDocumentDialog::QDocumentDialog(QDocument * form)
92 lang_(getSecond(getLanguageData(false)))
96 connect(okPB, SIGNAL(clicked()),
97 form, SLOT(slotOK()));
98 connect(applyPB, SIGNAL(clicked()),
99 form, SLOT(slotApply()));
100 connect(closePB, SIGNAL(clicked()),
101 form, SLOT(slotClose()));
102 connect(restorePB, SIGNAL(clicked()),
103 form, SLOT(slotRestore()));
106 connect( savePB, SIGNAL( clicked() ), this, SLOT( saveDefaultClicked() ) );
107 connect( defaultPB, SIGNAL( clicked() ), this, SLOT( useDefaultsClicked() ) );
109 // Manage the restore, ok, apply, restore and cancel/close buttons
110 form_->bcview().setOK(okPB);
111 form_->bcview().setApply(applyPB);
112 form_->bcview().setCancel(closePB);
113 form_->bcview().setRestore(restorePB);
116 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
118 connect(textLayoutModule->fontsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
119 connect(textLayoutModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
120 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
121 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int)));
122 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
123 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
124 connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
125 connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
126 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
127 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
128 connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int)));
129 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool)));
130 connect(textLayoutModule->twoColumnCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
131 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
132 textLayoutModule->lspacingLE));
133 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
134 textLayoutModule->skipLE));
136 for (int n = 0; tex_fonts[n][0]; ++n) {
137 QString font = tex_fonts[n];
138 textLayoutModule->fontsCO->insertItem(font);
141 textLayoutModule->fontsizeCO->insertItem(qt_("default"));
142 textLayoutModule->fontsizeCO->insertItem(qt_("10"));
143 textLayoutModule->fontsizeCO->insertItem(qt_("11"));
144 textLayoutModule->fontsizeCO->insertItem(qt_("12"));
146 textLayoutModule->skipCO->insertItem(qt_("SmallSkip"));
147 textLayoutModule->skipCO->insertItem(qt_("MedSkip"));
148 textLayoutModule->skipCO->insertItem(qt_("BigSkip"));
149 textLayoutModule->skipCO->insertItem(qt_("Length"));
150 // remove the %-items from the unit choice
151 textLayoutModule->skipLengthCO->noPercents();
152 textLayoutModule->lspacingCO->insertItem(
153 qt_("Single"), Spacing::Single);
154 textLayoutModule->lspacingCO->insertItem(
155 qt_("OneHalf"), Spacing::Onehalf);
156 textLayoutModule->lspacingCO->insertItem(
157 qt_("Double"), Spacing::Double);
158 textLayoutModule->lspacingCO->insertItem(
159 qt_("Custom"), Spacing::Other);
161 // initialize the length validator
162 addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE);
167 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
169 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
170 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int)));
171 connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(portraitChanged()));
172 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
173 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
174 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
175 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
176 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
177 connect(pageLayoutModule->portraitRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
178 connect(pageLayoutModule->landscapeRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
179 connect(pageLayoutModule->facingPagesCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
180 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
181 pageLayoutModule->pagestyleCO->insertItem(qt_("default"));
182 pageLayoutModule->pagestyleCO->insertItem(qt_("empty"));
183 pageLayoutModule->pagestyleCO->insertItem(qt_("plain"));
184 pageLayoutModule->pagestyleCO->insertItem(qt_("headings"));
185 pageLayoutModule->pagestyleCO->insertItem(qt_("fancy"));
186 addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE,
187 pageLayoutModule->paperheightL);
188 addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE,
189 pageLayoutModule->paperwidthL);
192 QComboBox * cb = pageLayoutModule->papersizeCO;
193 cb->insertItem(qt_("Default"));
194 cb->insertItem(qt_("Custom"));
195 cb->insertItem(qt_("US letter"));
196 cb->insertItem(qt_("US legal"));
197 cb->insertItem(qt_("US executive"));
198 cb->insertItem(qt_("A3"));
199 cb->insertItem(qt_("A4"));
200 cb->insertItem(qt_("A5"));
201 cb->insertItem(qt_("B3"));
202 cb->insertItem(qt_("B4"));
203 cb->insertItem(qt_("B5"));
204 // remove the %-items from the unit choice
205 pageLayoutModule->paperwidthUnitCO->noPercents();
206 pageLayoutModule->paperheightUnitCO->noPercents();
207 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
208 pageLayoutModule->paperheightLE));
209 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
210 pageLayoutModule->paperwidthLE));
215 marginsModule = new UiWidget<Ui::MarginsUi>;
217 connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(setCustomMargins(bool)));
218 connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
219 connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
220 connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
221 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
222 connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
223 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
224 connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
225 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
226 connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
227 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
228 connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
229 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
230 connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
231 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
232 connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
233 marginsModule->topLE->setValidator(unsignedLengthValidator(
234 marginsModule->topLE));
235 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
236 marginsModule->bottomLE));
237 marginsModule->innerLE->setValidator(unsignedLengthValidator(
238 marginsModule->innerLE));
239 marginsModule->outerLE->setValidator(unsignedLengthValidator(
240 marginsModule->outerLE));
241 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
242 marginsModule->headsepLE));
243 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
244 marginsModule->headheightLE));
245 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
246 marginsModule->footskipLE));
248 addCheckedLineEdit(form_->bcview(), marginsModule->topLE,
249 marginsModule->topL);
250 addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE,
251 marginsModule->bottomL);
252 addCheckedLineEdit(form_->bcview(), marginsModule->innerLE,
253 marginsModule->innerL);
254 addCheckedLineEdit(form_->bcview(), marginsModule->outerLE,
255 marginsModule->outerL);
256 addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE,
257 marginsModule->headsepL);
258 addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE,
259 marginsModule->headheightL);
260 addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE,
261 marginsModule->footskipL);
267 langModule = new UiWidget<Ui::LanguageUi>;
268 connect( langModule->defaultencodingCB, SIGNAL( toggled(bool) ), langModule->encodingL, SLOT( setDisabled(bool) ) );
269 connect( langModule->defaultencodingCB, SIGNAL( toggled(bool) ), langModule->encodingCO, SLOT( setDisabled(bool) ) );
271 connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
272 connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
273 connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
274 connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
276 vector<LanguagePair> const langs = getLanguageData(false);
277 vector<LanguagePair>::const_iterator lit = langs.begin();
278 vector<LanguagePair>::const_iterator lend = langs.end();
279 for (; lit != lend; ++lit) {
280 langModule->languageCO->insertItem(
285 while (encodings[k]) {
286 langModule->encodingCO->insertItem(qt_(encodings[k++]));
289 langModule->quoteStyleCO->insertItem(qt_("``text''"));
290 langModule->quoteStyleCO->insertItem(qt_("''text''"));
291 langModule->quoteStyleCO->insertItem(qt_(",,text``"));
292 langModule->quoteStyleCO->insertItem(qt_(",,text''"));
293 langModule->quoteStyleCO->insertItem(qt_("<<text>>"));
294 langModule->quoteStyleCO->insertItem(qt_(">>text<<"));
298 numberingModule = new UiWidget<Ui::NumberingUi>;
300 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
301 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor()));
302 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
303 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering()));
304 numberingModule->tocLV->setSorting(-1);
308 biblioModule = new UiWidget<Ui::BiblioUi>;
309 connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) );
310 connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) );
312 connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
313 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
314 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
315 connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
316 connect(biblioModule->bibtopicCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
318 biblioModule->citeStyleCO->insertItem(qt_("Author-year"));
319 biblioModule->citeStyleCO->insertItem(qt_("Numerical"));
320 biblioModule->citeStyleCO->setCurrentItem(0);
324 mathsModule = new UiWidget<Ui::MathsUi>;
325 connect( mathsModule->amsautoCB, SIGNAL( toggled(bool) ), mathsModule->amsCB, SLOT( setDisabled(bool) ) );
327 connect(mathsModule->amsCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
328 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
331 latexModule = new UiWidget<Ui::LaTeXUi>;
333 connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
334 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
335 connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
336 connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged()));
338 for (int n = 0; tex_graphics[n][0]; ++n) {
339 QString enc = tex_graphics[n];
340 latexModule->psdriverCO->insertItem(enc);
343 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
344 cit != textclasslist.end(); ++cit) {
345 if (cit->isTeXClassAvailable()) {
346 latexModule->classCO->insertItem(toqstr(cit->description()));
349 bformat(_("Unavailable: %1$s"), cit->description());
350 latexModule->classCO->insertItem(toqstr(item));
356 branchesModule = new QBranches;
357 connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
360 preambleModule = new UiWidget<Ui::PreambleUi>;
362 connect(preambleModule->preambleMLE, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
365 bulletsModule = new BulletsModule;
367 connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
370 floatModule = new FloatPlacement(this);
372 connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor()));
374 docPS->addPanel(latexModule, _("Document Class"));
375 docPS->addPanel(textLayoutModule, _("Text Layout"));
376 docPS->addPanel(pageLayoutModule, _("Page Layout"));
377 docPS->addPanel(marginsModule, _("Page Margins"));
378 docPS->addPanel(langModule, _("Language"));
379 docPS->addPanel(numberingModule, _("Numbering & TOC"));
380 docPS->addPanel(biblioModule, _("Bibliography"));
381 docPS->addPanel(mathsModule, _("Math Options"));
382 docPS->addPanel(floatModule, _("Float Placement"));
383 docPS->addPanel(bulletsModule, _("Bullets"));
384 docPS->addPanel(branchesModule, _("Branches"));
385 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
386 docPS->setCurrentPanel(_("Document Class"));
390 QDocumentDialog::~QDocumentDialog()
395 void QDocumentDialog::showPreamble()
397 docPS->setCurrentPanel(_("LaTeX Preamble"));
401 void QDocumentDialog::saveDefaultClicked()
403 form_->saveDocDefault();
407 void QDocumentDialog::useDefaultsClicked()
409 form_->useClassDefaults();
413 void QDocumentDialog::change_adaptor()
419 void QDocumentDialog::closeEvent(QCloseEvent * e)
426 void QDocumentDialog::setLSpacing(int item)
428 textLayoutModule->lspacingLE->setEnabled(item == 3);
432 void QDocumentDialog::setSkip(int item)
434 bool const enable = (item == 3);
435 textLayoutModule->skipLE->setEnabled(enable);
436 textLayoutModule->skipLengthCO->setEnabled(enable);
440 void QDocumentDialog::enableSkip(bool skip)
442 textLayoutModule->skipCO->setEnabled(skip);
443 textLayoutModule->skipLE->setEnabled(skip);
444 textLayoutModule->skipLengthCO->setEnabled(skip);
446 setSkip(textLayoutModule->skipCO->currentItem());
449 void QDocumentDialog::portraitChanged()
451 setMargins(pageLayoutModule->papersizeCO->currentItem());
454 void QDocumentDialog::setMargins(bool custom)
456 marginsModule->marginCB->setChecked(custom);
457 setCustomMargins(custom);
461 void QDocumentDialog::setCustomPapersize(int papersize)
463 bool const custom = (papersize == 1);
465 pageLayoutModule->paperwidthL->setEnabled(custom);
466 pageLayoutModule->paperwidthLE->setEnabled(custom);
467 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
468 pageLayoutModule->paperheightL->setEnabled(custom);
469 pageLayoutModule->paperheightLE->setEnabled(custom);
470 pageLayoutModule->paperheightLE->setFocus();
471 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
475 void QDocumentDialog::setCustomMargins(bool custom)
477 marginsModule->topL->setEnabled(!custom);
478 marginsModule->topLE->setEnabled(!custom);
479 marginsModule->topUnit->setEnabled(!custom);
481 marginsModule->bottomL->setEnabled(!custom);
482 marginsModule->bottomLE->setEnabled(!custom);
483 marginsModule->bottomUnit->setEnabled(!custom);
485 marginsModule->innerL->setEnabled(!custom);
486 marginsModule->innerLE->setEnabled(!custom);
487 marginsModule->innerUnit->setEnabled(!custom);
489 marginsModule->outerL->setEnabled(!custom);
490 marginsModule->outerLE->setEnabled(!custom);
491 marginsModule->outerUnit->setEnabled(!custom);
493 marginsModule->headheightL->setEnabled(!custom);
494 marginsModule->headheightLE->setEnabled(!custom);
495 marginsModule->headheightUnit->setEnabled(!custom);
497 marginsModule->headsepL->setEnabled(!custom);
498 marginsModule->headsepLE->setEnabled(!custom);
499 marginsModule->headsepUnit->setEnabled(!custom);
501 marginsModule->footskipL->setEnabled(!custom);
502 marginsModule->footskipLE->setEnabled(!custom);
503 marginsModule->footskipUnit->setEnabled(!custom);
507 void QDocumentDialog::updateFontsize(string const & items, string const & sel)
509 textLayoutModule->fontsizeCO->clear();
510 textLayoutModule->fontsizeCO->insertItem("default");
512 for (int n = 0; !token(items,'|',n).empty(); ++n)
513 textLayoutModule->fontsizeCO->
514 insertItem(toqstr(token(items,'|',n)));
516 for (int n = 0; n<textLayoutModule->fontsizeCO->count(); ++n) {
517 if (fromqstr(textLayoutModule->fontsizeCO->text(n)) == sel) {
518 textLayoutModule->fontsizeCO->setCurrentItem(n);
525 void QDocumentDialog::updatePagestyle(string const & items, string const & sel)
527 pageLayoutModule->pagestyleCO->clear();
528 pageLayoutModule->pagestyleCO->insertItem("default");
530 for (int n=0; !token(items,'|',n).empty(); ++n)
531 pageLayoutModule->pagestyleCO->
532 insertItem(toqstr(token(items,'|',n)));
534 for (int n = 0; n<pageLayoutModule->pagestyleCO->count(); ++n) {
535 if (fromqstr(pageLayoutModule->pagestyleCO->text(n))==sel) {
536 pageLayoutModule->pagestyleCO->setCurrentItem(n);
543 void QDocumentDialog::classChanged()
545 ControlDocument & cntrl = form_->controller();
546 BufferParams & params = cntrl.params();
548 lyx::textclass_type const tc = latexModule->classCO->currentItem();
550 if (form_->controller().loadTextclass(tc)) {
551 params.textclass = tc;
552 if (lyxrc.auto_reset_options)
553 params.useClassDefaults();
554 form_->update_contents();
556 latexModule->classCO->setCurrentItem(params.textclass);
561 void QDocumentDialog::updateNumbering()
563 LyXTextClass const & tclass =
564 form_->controller().params().getLyXTextClass();
566 //numberingModule->tocLV->setUpdatesEnabled(false);
568 // Update the example QListView
569 int const depth = numberingModule->depthSL->value();
570 int const toc = numberingModule->tocSL->value();
571 QString const no = qt_("No");
572 QString const yes = qt_("Yes");
573 LyXTextClass::const_iterator end = tclass.end();
574 LyXTextClass::const_iterator cit = tclass.begin();
575 numberingModule->tocLV->clear();
576 Q3ListViewItem * item = 0;
577 for ( ; cit != end ; ++cit) {
578 int const toclevel = (*cit)->toclevel;
579 if (toclevel != LyXLayout::NOT_IN_TOC) {
580 item = new Q3ListViewItem(numberingModule->tocLV,
581 item, qt_((*cit)->name()));
582 item->setText(1, (toclevel <= depth) ? yes : no);
583 item->setText(2, (toclevel <= toc) ? yes : no);
587 //numberingModule->tocLV->setUpdatesEnabled(true);
588 //numberingModule->tocLV->update();
591 void QDocumentDialog::apply(BufferParams & params)
595 fromqstr(preambleModule->preambleMLE->text());
598 params.cite_engine = biblio::ENGINE_BASIC;
600 if (biblioModule->citeNatbibRB->isChecked()) {
601 bool const use_numerical_citations =
602 biblioModule->citeStyleCO->currentItem();
603 if (use_numerical_citations)
604 params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
606 params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
608 } else if (biblioModule->citeJurabibRB->isChecked())
609 params.cite_engine = biblio::ENGINE_JURABIB;
611 params.use_bibtopic =
612 biblioModule->bibtopicCB->isChecked();
615 if (langModule->defaultencodingCB->isChecked()) {
616 params.inputenc = "auto";
618 int i = langModule->encodingCO->currentItem();
620 params.inputenc = "default";
622 params.inputenc = encodings[i];
626 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
627 switch (langModule->quoteStyleCO->currentItem()) {
629 lga = InsetQuotes::EnglishQ;
632 lga = InsetQuotes::SwedishQ;
635 lga = InsetQuotes::GermanQ;
638 lga = InsetQuotes::PolishQ;
641 lga = InsetQuotes::FrenchQ;
644 lga = InsetQuotes::DanishQ;
647 params.quotes_language = lga;
649 int const pos = langModule->languageCO->currentItem();
650 params.language = languages.getLanguage(lang_[pos]);
653 params.tocdepth = numberingModule->tocSL->value();
654 params.secnumdepth = numberingModule->depthSL->value();
657 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
658 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
659 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
660 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
663 params.graphicsDriver =
664 fromqstr(latexModule->psdriverCO->currentText());
666 if (mathsModule->amsautoCB->isChecked()) {
667 params.use_amsmath = BufferParams::AMS_AUTO;
669 if (mathsModule->amsCB->isChecked())
670 params.use_amsmath = BufferParams::AMS_ON;
672 params.use_amsmath = BufferParams::AMS_OFF;
677 latexModule->classCO->currentItem();
680 fromqstr(textLayoutModule->fontsCO->currentText());
683 fromqstr(textLayoutModule->fontsizeCO->currentText());
686 fromqstr(pageLayoutModule->pagestyleCO->currentText());
688 switch (textLayoutModule->lspacingCO->currentItem()) {
690 params.spacing().set(Spacing::Single);
693 params.spacing().set(Spacing::Onehalf);
696 params.spacing().set(Spacing::Double);
699 params.spacing().set(Spacing::Other,
700 fromqstr(textLayoutModule->lspacingLE->text()));
704 if (textLayoutModule->twoColumnCB->isChecked())
709 if (textLayoutModule->indentRB->isChecked())
710 params.paragraph_separation = BufferParams::PARSEP_INDENT;
712 params.paragraph_separation = BufferParams::PARSEP_SKIP;
714 switch (textLayoutModule->skipCO->currentItem()) {
716 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
719 params.setDefSkip(VSpace(VSpace::MEDSKIP));
722 params.setDefSkip(VSpace(VSpace::BIGSKIP));
727 widgetsToLength(textLayoutModule->skipLE,
728 textLayoutModule->skipLengthCO)
730 params.setDefSkip(vs);
734 // DocumentDefskipCB assures that this never happens
735 // so Assert then !!! - jbl
736 params.setDefSkip(VSpace(VSpace::MEDSKIP));
741 fromqstr(latexModule->optionsLE->text());
743 params.float_placement = floatModule->get();
746 params.papersize = PAPER_SIZE(
747 pageLayoutModule->papersizeCO->currentItem());
749 // custom, A3, B3 and B4 paper sizes need geometry
750 int psize = pageLayoutModule->papersizeCO->currentItem();
751 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
753 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
754 pageLayoutModule->paperwidthUnitCO);
756 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
757 pageLayoutModule->paperheightUnitCO);
759 if (pageLayoutModule->facingPagesCB->isChecked())
760 params.sides = LyXTextClass::TwoSides;
762 params.sides = LyXTextClass::OneSide;
764 if (pageLayoutModule->landscapeRB->isChecked())
765 params.orientation = ORIENTATION_LANDSCAPE;
767 params.orientation = ORIENTATION_PORTRAIT;
770 params.use_geometry =
771 (!marginsModule->marginCB->isChecked()
774 Ui::MarginsUi const * m(marginsModule);
776 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
778 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
780 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
782 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
784 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
786 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
788 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
790 branchesModule->apply(params);
795 /** Return the position of val in the vector if found.
796 If not found, return 0.
799 typename std::vector<A>::size_type
800 findPos(std::vector<A> const & vec, A const & val)
802 typename std::vector<A>::const_iterator it =
803 std::find(vec.begin(), vec.end(), val);
806 return distance(vec.begin(), it);
812 void QDocumentDialog::update(BufferParams const & params)
814 // set the default unit
815 // FIXME: move to controller
816 LyXLength::UNIT defaultUnit = LyXLength::CM;
817 switch (lyxrc.default_papersize) {
818 case PAPER_DEFAULT: break;
822 case PAPER_USEXECUTIVE:
823 defaultUnit = LyXLength::IN;
832 defaultUnit = LyXLength::CM;
839 QString preamble = toqstr(params.preamble);
840 preambleModule->preambleMLE->setText(preamble);
843 biblioModule->citeDefaultRB->setChecked(
844 params.cite_engine == biblio::ENGINE_BASIC);
846 biblioModule->citeNatbibRB->setChecked(
847 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
848 params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
850 biblioModule->citeStyleCO->setCurrentItem(
851 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
853 biblioModule->citeJurabibRB->setChecked(
854 params.cite_engine == biblio::ENGINE_JURABIB);
856 biblioModule->bibtopicCB->setChecked(
857 params.use_bibtopic);
860 int const pos = int(findPos(lang_,
861 params.language->lang()));
862 langModule->languageCO->setCurrentItem(pos);
864 langModule->quoteStyleCO->setCurrentItem(
865 params.quotes_language);
867 langModule->defaultencodingCB->setChecked(true);
869 if (params.inputenc != "auto") {
870 langModule->defaultencodingCB->setChecked(false);
871 if (params.inputenc == "default") {
872 langModule->encodingCO->setCurrentItem(0);
875 while (encodings[i]) {
876 if (encodings[i] == params.inputenc)
877 langModule->encodingCO->setCurrentItem(i);
884 int const min_toclevel = form_->controller().textClass().min_toclevel();
885 int const max_toclevel = form_->controller().textClass().max_toclevel();
886 if (min_toclevel != LyXLayout::NOT_IN_TOC)
887 numberingModule->setEnabled(true);
889 numberingModule->setEnabled(false);
890 numberingModule->tocLV->clear();
892 numberingModule->depthSL->setMinValue(min_toclevel - 1);
893 numberingModule->depthSL->setMaxValue(max_toclevel);
894 numberingModule->depthSL->setValue(params.secnumdepth);
895 numberingModule->tocSL->setMinValue(min_toclevel - 1);
896 numberingModule->tocSL->setMaxValue(max_toclevel);
897 numberingModule->tocSL->setValue(params.tocdepth);
901 bulletsModule->setBullet(0,params.user_defined_bullet(0));
902 bulletsModule->setBullet(1,params.user_defined_bullet(1));
903 bulletsModule->setBullet(2,params.user_defined_bullet(2));
904 bulletsModule->setBullet(3,params.user_defined_bullet(3));
907 QString text = toqstr(params.graphicsDriver);
908 int nitem = latexModule->psdriverCO->count();
909 for (int n = 0; n < nitem ; ++n) {
910 QString enc = tex_graphics[n];
912 latexModule->psdriverCO->setCurrentItem(n);
917 mathsModule->amsCB->setChecked(
918 params.use_amsmath == BufferParams::AMS_ON);
919 mathsModule->amsautoCB->setChecked(
920 params.use_amsmath == BufferParams::AMS_AUTO);
922 switch (params.spacing().getSpace()) {
923 case Spacing::Other: nitem = 3; break;
924 case Spacing::Double: nitem = 2; break;
925 case Spacing::Onehalf: nitem = 1; break;
926 case Spacing::Default: case Spacing::Single: nitem = 0; break;
930 latexModule->classCO->setCurrentItem(params.textclass);
932 updateFontsize(form_->controller().textClass().opt_fontsize(),
935 updatePagestyle(form_->controller().textClass().opt_pagestyle(),
938 for (int n = 0; tex_fonts[n][0]; ++n) {
939 if (tex_fonts[n] == params.fonts) {
940 textLayoutModule->fontsCO->setCurrentItem(n);
945 textLayoutModule->lspacingCO->setCurrentItem(nitem);
946 if (params.spacing().getSpace() == Spacing::Other) {
947 textLayoutModule->lspacingLE->setText(
948 toqstr(params.spacing().getValueAsString()));
952 if (params.paragraph_separation
953 == BufferParams::PARSEP_INDENT) {
954 textLayoutModule->indentRB->setChecked(true);
956 textLayoutModule->skipRB->setChecked(true);
960 switch (params.getDefSkip().kind()) {
961 case VSpace::SMALLSKIP:
964 case VSpace::MEDSKIP:
967 case VSpace::BIGSKIP:
973 string const length = params.getDefSkip().asLyXCommand();
974 lengthToWidgets(textLayoutModule->skipLE,
975 textLayoutModule->skipLengthCO,
976 length, defaultUnit);
983 textLayoutModule->skipCO->setCurrentItem(skip);
986 textLayoutModule->twoColumnCB->setChecked(
987 params.columns == 2);
989 if (!params.options.empty()) {
990 latexModule->optionsLE->setText(
991 toqstr(params.options));
993 latexModule->optionsLE->setText("");
996 floatModule->set(params.float_placement);
999 int const psize = params.papersize;
1000 pageLayoutModule->papersizeCO->setCurrentItem(psize);
1001 setCustomPapersize(psize);
1003 bool const landscape =
1004 params.orientation == ORIENTATION_LANDSCAPE;
1005 pageLayoutModule->landscapeRB->setChecked(landscape);
1006 pageLayoutModule->portraitRB->setChecked(!landscape);
1008 pageLayoutModule->facingPagesCB->setChecked(
1009 params.sides == LyXTextClass::TwoSides);
1012 lengthToWidgets(pageLayoutModule->paperwidthLE,
1013 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1015 lengthToWidgets(pageLayoutModule->paperheightLE,
1016 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1019 Ui::MarginsUi * m = marginsModule;
1021 setMargins(!params.use_geometry);
1023 lengthToWidgets(m->topLE, m->topUnit,
1024 params.topmargin, defaultUnit);
1026 lengthToWidgets(m->bottomLE, m->bottomUnit,
1027 params.bottommargin, defaultUnit);
1029 lengthToWidgets(m->innerLE, m->innerUnit,
1030 params.leftmargin, defaultUnit);
1032 lengthToWidgets(m->outerLE, m->outerUnit,
1033 params.rightmargin, defaultUnit);
1035 lengthToWidgets(m->headheightLE, m->headheightUnit,
1036 params.headheight, defaultUnit);
1038 lengthToWidgets(m->headsepLE, m->headsepUnit,
1039 params.headsep, defaultUnit);
1041 lengthToWidgets(m->footskipLE, m->footskipUnit,
1042 params.footskip, defaultUnit);
1044 branchesModule->update(params);
1050 } // namespace frontend