2 * \file GuiDocument.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Richard Heck (modules)
9 * Full author contact details are available in file CREDITS.
14 #include "GuiDocument.h"
16 #include "BranchList.h"
17 #include "buffer_funcs.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
22 #include "EmbeddedFiles.h"
24 #include "FloatPlacement.h"
25 #include "FuncRequest.h"
26 #include "support/gettext.h"
27 #include "GuiBranches.h"
29 #include "LaTeXFeatures.h"
30 #include "LaTeXHighlighter.h"
32 #include "LengthCombo.h"
33 #include "LyXRC.h" // defaultUnit
34 #include "ModuleList.h"
35 #include "OutputParams.h"
36 #include "PanelStack.h"
37 #include "PDFOptions.h"
38 #include "qt_helpers.h"
40 #include "TextClassList.h"
41 #include "Validator.h"
43 #include "insets/InsetListingsParams.h"
45 //#include "support/debug.h"
46 #include "support/FileName.h"
47 #include "support/filetools.h"
48 #include "support/lstrings.h"
50 #include "frontends/alert.h"
52 #include <boost/bind.hpp>
54 #include <QCloseEvent>
56 #include <QTextCursor>
62 using namespace lyx::support;
67 vector<typename Pair::second_type> const
68 getSecond(vector<Pair> const & pr)
70 vector<typename Pair::second_type> tmp(pr.size());
71 transform(pr.begin(), pr.end(), tmp.begin(),
72 boost::bind(&Pair::second, _1));
77 char const * const tex_graphics[] =
79 "default", "dvips", "dvitops", "emtex",
80 "ln", "oztex", "textures", "none", ""
84 char const * const tex_graphics_gui[] =
86 N_("Default"), "Dvips", "DVItoPS", "EmTeX",
87 "LN", "OzTeX", "Textures", N_("None"), ""
91 char const * const tex_fonts_roman[] =
93 "default", "cmr", "lmodern", "ae", "times", "palatino",
94 "charter", "newcent", "bookman", "utopia", "beraserif",
95 "ccfonts", "chancery", ""
99 char const * tex_fonts_roman_gui[] =
101 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
102 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
103 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
104 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
109 char const * const tex_fonts_sans[] =
111 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
115 char const * tex_fonts_sans_gui[] =
117 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
118 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
122 char const * const tex_fonts_monospaced[] =
124 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
128 char const * tex_fonts_monospaced_gui[] =
130 N_("Default"), N_("Computer Modern Typewriter"),
131 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
132 N_("LuxiMono"), N_("CM Typewriter Light"), ""
136 vector<pair<string, lyx::docstring> > pagestyles;
144 QModelIndex getSelectedIndex(QListView * lv)
146 QModelIndex retval = QModelIndex();
147 QModelIndexList selIdx =
148 lv->selectionModel()->selectedIndexes();
150 retval = selIdx.first();
156 vector<string> getRequiredList(string const & modName)
158 LyXModule const * const mod = moduleList[modName];
160 return vector<string>(); //empty such thing
161 return mod->getRequiredModules();
165 vector<string> getExcludedList(string const & modName)
167 LyXModule const * const mod = moduleList[modName];
169 return vector<string>(); //empty such thing
170 return mod->getExcludedModules();
174 docstring getModuleDescription(string const & modName)
176 LyXModule const * const mod = moduleList[modName];
178 return _("Module not found!");
179 return _(mod->getDescription());
183 vector<string> getPackageList(string const & modName)
185 LyXModule const * const mod = moduleList[modName];
187 return vector<string>(); //empty such thing
188 return mod->getPackageList();
192 bool isModuleAvailable(string const & modName)
194 LyXModule * mod = moduleList[modName];
197 return mod->isAvailable();
199 } //anonymous namespace
202 ModuleSelMan::ModuleSelMan(
203 QListView * availableLV,
204 QListView * selectedLV,
208 QPushButton * downPB,
209 GuiIdListModel * availableModel,
210 GuiIdListModel * selectedModel) :
211 GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
212 upPB, downPB, availableModel, selectedModel)
216 void ModuleSelMan::updateAddPB()
218 int const arows = availableModel->rowCount();
219 QModelIndexList const availSels =
220 availableLV->selectionModel()->selectedIndexes();
221 if (arows == 0 || availSels.isEmpty() || isSelected(availSels.first())) {
222 addPB->setEnabled(false);
226 QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
227 string const modName = getAvailableModel()->getIDString(idx.row());
228 vector<string> reqs = getRequiredList(modName);
229 vector<string> excl = getExcludedList(modName);
231 if (reqs.empty() && excl.empty()) {
232 addPB->setEnabled(true);
236 int const srows = selectedModel->rowCount();
237 vector<string> selModList;
238 for (int i = 0; i < srows; ++i)
239 selModList.push_back(getSelectedModel()->getIDString(i));
241 vector<string>::const_iterator selModStart = selModList.begin();
242 vector<string>::const_iterator selModEnd = selModList.end();
244 //Check whether some required module is available
246 bool foundOne = false;
247 vector<string>::const_iterator it = reqs.begin();
248 vector<string>::const_iterator end = reqs.end();
249 for (; it != end; ++it) {
250 if (find(selModStart, selModEnd, *it) != selModEnd) {
256 addPB->setEnabled(false);
261 //Check whether any excluded module is being used
263 vector<string>::const_iterator it = excl.begin();
264 vector<string>::const_iterator end = excl.end();
265 for (; it != end; ++it) {
266 if (find(selModStart, selModEnd, *it) != selModEnd) {
267 addPB->setEnabled(false);
273 addPB->setEnabled(true);
277 void ModuleSelMan::updateDownPB()
279 int const srows = selectedModel->rowCount();
281 downPB->setEnabled(false);
284 QModelIndexList const selSels =
285 selectedLV->selectionModel()->selectedIndexes();
286 //disable if empty or last item is selected
287 if (selSels.empty() || selSels.first().row() == srows - 1) {
288 downPB->setEnabled(false);
291 //determine whether immediately succeding element requires this one
292 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
293 int curRow = curIdx.row();
294 if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
295 downPB->setEnabled(false);
298 string const curModName = getSelectedModel()->getIDString(curRow);
299 string const nextModName = getSelectedModel()->getIDString(curRow + 1);
301 vector<string> reqs = getRequiredList(nextModName);
303 //if it doesn't require anything....
305 downPB->setEnabled(true);
309 //FIXME This should perhaps be more flexible and check whether, even
310 //if this one is required, there is also an earlier one that is required.
311 //enable it if this module isn't required
313 find(reqs.begin(), reqs.end(), curModName) == reqs.end());
316 void ModuleSelMan::updateUpPB()
318 int const srows = selectedModel->rowCount();
320 upPB->setEnabled(false);
323 QModelIndexList const selSels =
324 selectedLV->selectionModel()->selectedIndexes();
325 //disable if empty or first item is selected
326 if (selSels.empty() || selSels.first().row() == 0) {
327 upPB->setEnabled(false);
331 //determine whether immediately preceding element is required by this one
332 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
333 int curRow = curIdx.row();
334 if (curRow <= -1 || curRow > srows - 1) { //sanity check
335 downPB->setEnabled(false);
338 string const curModName = getSelectedModel()->getIDString(curRow);
339 vector<string> reqs = getRequiredList(curModName);
341 //if this one doesn't require anything....
343 upPB->setEnabled(true);
347 string preModName = getSelectedModel()->getIDString(curRow - 1);
349 //NOTE This is less flexible than it might be. You could check whether, even
350 //if this one is required, there is also an earlier one that is required.
351 //enable it if the preceding module isn't required
352 upPB->setEnabled(find(reqs.begin(), reqs.end(), preModName) == reqs.end());
355 void ModuleSelMan::updateDelPB()
357 int const srows = selectedModel->rowCount();
359 deletePB->setEnabled(false);
362 QModelIndexList const selSels =
363 selectedLV->selectionModel()->selectedIndexes();
364 if (selSels.empty() || selSels.first().row() < 0) {
365 deletePB->setEnabled(false);
369 //determine whether some LATER module requires this one
370 //NOTE Things are arranged so that this is the only way there
371 //can be a problem. At least, we hope so.
372 QModelIndex const & curIdx =
373 selectedLV->selectionModel()->currentIndex();
374 int const curRow = curIdx.row();
375 if (curRow < 0 || curRow >= srows) { //this shouldn't happen
376 deletePB->setEnabled(false);
380 QString const curModName = curIdx.data().toString();
382 //We're looking here for a reason NOT to enable the button. If we
383 //find one, we disable it and return. If we don't, we'll end up at
384 //the end of the function, and then we enable it.
385 for (int i = curRow + 1; i < srows; ++i) {
386 string const thisMod = getSelectedModel()->getIDString(i);
387 vector<string> reqs = getRequiredList(thisMod);
388 //does this one require us?
389 if (find(reqs.begin(), reqs.end(), fromqstr(curModName)) == reqs.end())
393 //OK, so this module requires us
394 //is there an EARLIER module that also satisfies the require?
395 //NOTE We demand that it be earlier to keep the list of modules
396 //consistent with the rule that a module must be proceeded by a
397 //required module. There would be more flexible ways to proceed,
398 //but that would be a lot more complicated, and the logic here is
399 //already complicated. (That's why I've left the debugging code.)
400 //lyxerr << "Testing " << thisMod << std::endl;
401 bool foundOne = false;
402 for (int j = 0; j < curRow; ++j) {
403 string const mod = getSelectedModel()->getIDString(j);
404 //lyxerr << "In loop: Testing " << mod << std::endl;
405 //do we satisfy the require?
406 if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
407 //lyxerr << mod << " does the trick." << std::endl;
412 //did we find a module to satisfy the require?
414 //lyxerr << "No matching module found." << std::endl;
415 deletePB->setEnabled(false);
419 //lyxerr << "All's well that ends well." << std::endl;
420 deletePB->setEnabled(true);
424 /////////////////////////////////////////////////////////////////////
428 /////////////////////////////////////////////////////////////////////
430 PreambleModule::PreambleModule(): current_id_(0)
432 // This is not a memory leak. The object will be destroyed
434 (void) new LaTeXHighlighter(preambleTE->document());
435 setFocusProxy(preambleTE);
436 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
440 void PreambleModule::update(BufferParams const & params, BufferId id)
442 QString preamble = toqstr(params.preamble);
443 // Nothing to do if the params and preamble are unchanged.
444 if (id == current_id_
445 && preamble == preambleTE->document()->toPlainText())
448 QTextCursor cur = preambleTE->textCursor();
449 // Save the coords before switching to the new one.
450 preamble_coords_[current_id_] =
451 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
453 // Save the params address for further use.
455 preambleTE->document()->setPlainText(preamble);
456 Coords::const_iterator it = preamble_coords_.find(current_id_);
457 if (it == preamble_coords_.end())
458 // First time we open this one.
459 preamble_coords_[current_id_] = make_pair(0,0);
461 // Restore saved coords.
462 QTextCursor cur = preambleTE->textCursor();
463 cur.setPosition(it->second.first);
464 preambleTE->setTextCursor(cur);
465 preambleTE->verticalScrollBar()->setValue(it->second.second);
470 void PreambleModule::apply(BufferParams & params)
472 params.preamble = fromqstr(preambleTE->document()->toPlainText());
476 void PreambleModule::closeEvent(QCloseEvent * e)
478 // Save the coords before closing.
479 QTextCursor cur = preambleTE->textCursor();
480 preamble_coords_[current_id_] =
481 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
486 /////////////////////////////////////////////////////////////////////
490 /////////////////////////////////////////////////////////////////////
494 GuiDocument::GuiDocument(GuiView & lv)
495 : GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
499 lang_ = getSecond(getLanguageData(false));
501 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
502 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
503 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
504 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
506 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
507 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
509 // Manage the restore, ok, apply, restore and cancel/close buttons
510 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
512 bc().setApply(applyPB);
513 bc().setCancel(closePB);
514 bc().setRestore(restorePB);
516 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
518 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
519 this, SLOT(change_adaptor()));
520 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
521 this, SLOT(setLSpacing(int)));
522 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
523 this, SLOT(change_adaptor()));
524 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
525 this, SLOT(change_adaptor()));
526 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
527 this, SLOT(change_adaptor()));
528 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
529 this, SLOT(change_adaptor()));
530 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
531 this, SLOT(change_adaptor()));
532 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
533 this, SLOT(change_adaptor()));
534 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
535 this, SLOT(setSkip(int)));
536 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
537 this, SLOT(enableSkip(bool)));
538 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
539 this, SLOT(change_adaptor()));
540 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
541 this, SLOT(change_adaptor()));
542 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
543 this, SLOT(change_adaptor()));
544 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
545 this, SLOT(set_listings_msg()));
546 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
547 this, SLOT(set_listings_msg()));
548 textLayoutModule->listingsTB->setPlainText(
549 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
550 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
551 textLayoutModule->lspacingLE));
552 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
553 textLayoutModule->skipLE));
555 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
556 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
557 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
558 textLayoutModule->skipCO->addItem(qt_("Length"));
559 // remove the %-items from the unit choice
560 textLayoutModule->skipLengthCO->noPercents();
561 textLayoutModule->lspacingCO->insertItem(
562 Spacing::Single, qt_("Single"));
563 textLayoutModule->lspacingCO->insertItem(
564 Spacing::Onehalf, qt_("OneHalf"));
565 textLayoutModule->lspacingCO->insertItem(
566 Spacing::Double, qt_("Double"));
567 textLayoutModule->lspacingCO->insertItem(
568 Spacing::Other, qt_("Custom"));
570 // initialize the length validator
571 bc().addCheckedLineEdit(textLayoutModule->skipLE);
573 fontModule = new UiWidget<Ui::FontUi>;
575 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
576 this, SLOT(change_adaptor()));
577 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
578 this, SLOT(romanChanged(int)));
579 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
580 this, SLOT(change_adaptor()));
581 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
582 this, SLOT(sansChanged(int)));
583 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
584 this, SLOT(change_adaptor()));
585 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
586 this, SLOT(ttChanged(int)));
587 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
588 this, SLOT(change_adaptor()));
589 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
590 this, SLOT(change_adaptor()));
591 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
592 this, SLOT(change_adaptor()));
593 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
594 this, SLOT(change_adaptor()));
595 connect(fontModule->fontScCB, SIGNAL(clicked()),
596 this, SLOT(change_adaptor()));
597 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
598 this, SLOT(change_adaptor()));
600 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
601 QString font = qt_(tex_fonts_roman_gui[n]);
602 if (!isFontAvailable(tex_fonts_roman[n]))
603 font += qt_(" (not installed)");
604 fontModule->fontsRomanCO->addItem(font);
606 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
607 QString font = qt_(tex_fonts_sans_gui[n]);
608 if (!isFontAvailable(tex_fonts_sans[n]))
609 font += qt_(" (not installed)");
610 fontModule->fontsSansCO->addItem(font);
612 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
613 QString font = qt_(tex_fonts_monospaced_gui[n]);
614 if (!isFontAvailable(tex_fonts_monospaced[n]))
615 font += qt_(" (not installed)");
616 fontModule->fontsTypewriterCO->addItem(font);
619 fontModule->fontsizeCO->addItem(qt_("Default"));
620 fontModule->fontsizeCO->addItem(qt_("10"));
621 fontModule->fontsizeCO->addItem(qt_("11"));
622 fontModule->fontsizeCO->addItem(qt_("12"));
624 for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
625 fontModule->fontsDefaultCO->addItem(
626 qt_(GuiDocument::fontfamilies_gui[n]));
629 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
631 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
632 this, SLOT(setCustomPapersize(int)));
633 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
634 this, SLOT(setCustomPapersize(int)));
635 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
636 this, SLOT(portraitChanged()));
637 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
638 this, SLOT(change_adaptor()));
639 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
640 this, SLOT(change_adaptor()));
641 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
642 this, SLOT(change_adaptor()));
643 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
644 this, SLOT(change_adaptor()));
645 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
646 this, SLOT(change_adaptor()));
647 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
648 this, SLOT(change_adaptor()));
649 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
650 this, SLOT(change_adaptor()));
651 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
652 this, SLOT(change_adaptor()));
653 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
654 this, SLOT(change_adaptor()));
656 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
657 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
658 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
659 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
660 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
661 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
662 pageLayoutModule->paperheightL);
663 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
664 pageLayoutModule->paperwidthL);
667 QComboBox * cb = pageLayoutModule->papersizeCO;
668 cb->addItem(qt_("Default"));
669 cb->addItem(qt_("Custom"));
670 cb->addItem(qt_("US letter"));
671 cb->addItem(qt_("US legal"));
672 cb->addItem(qt_("US executive"));
673 cb->addItem(qt_("A3"));
674 cb->addItem(qt_("A4"));
675 cb->addItem(qt_("A5"));
676 cb->addItem(qt_("B3"));
677 cb->addItem(qt_("B4"));
678 cb->addItem(qt_("B5"));
679 // remove the %-items from the unit choice
680 pageLayoutModule->paperwidthUnitCO->noPercents();
681 pageLayoutModule->paperheightUnitCO->noPercents();
682 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
683 pageLayoutModule->paperheightLE));
684 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
685 pageLayoutModule->paperwidthLE));
688 marginsModule = new UiWidget<Ui::MarginsUi>;
690 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
691 this, SLOT(setCustomMargins(bool)));
692 connect(marginsModule->marginCB, SIGNAL(clicked()),
693 this, SLOT(change_adaptor()));
694 connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
695 this, SLOT(change_adaptor()));
696 connect(marginsModule->topUnit, SIGNAL(activated(int)),
697 this, SLOT(change_adaptor()));
698 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
699 this, SLOT(change_adaptor()));
700 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
701 this, SLOT(change_adaptor()));
702 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
703 this, SLOT(change_adaptor()));
704 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
705 this, SLOT(change_adaptor()));
706 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
707 this, SLOT(change_adaptor()));
708 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
709 this, SLOT(change_adaptor()));
710 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
711 this, SLOT(change_adaptor()));
712 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
713 this, SLOT(change_adaptor()));
714 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
715 this, SLOT(change_adaptor()));
716 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
717 this, SLOT(change_adaptor()));
718 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
719 this, SLOT(change_adaptor()));
720 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
721 this, SLOT(change_adaptor()));
722 marginsModule->topLE->setValidator(unsignedLengthValidator(
723 marginsModule->topLE));
724 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
725 marginsModule->bottomLE));
726 marginsModule->innerLE->setValidator(unsignedLengthValidator(
727 marginsModule->innerLE));
728 marginsModule->outerLE->setValidator(unsignedLengthValidator(
729 marginsModule->outerLE));
730 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
731 marginsModule->headsepLE));
732 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
733 marginsModule->headheightLE));
734 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
735 marginsModule->footskipLE));
737 bc().addCheckedLineEdit(marginsModule->topLE,
738 marginsModule->topL);
739 bc().addCheckedLineEdit(marginsModule->bottomLE,
740 marginsModule->bottomL);
741 bc().addCheckedLineEdit(marginsModule->innerLE,
742 marginsModule->innerL);
743 bc().addCheckedLineEdit(marginsModule->outerLE,
744 marginsModule->outerL);
745 bc().addCheckedLineEdit(marginsModule->headsepLE,
746 marginsModule->headsepL);
747 bc().addCheckedLineEdit(marginsModule->headheightLE,
748 marginsModule->headheightL);
749 bc().addCheckedLineEdit(marginsModule->footskipLE,
750 marginsModule->footskipL);
753 langModule = new UiWidget<Ui::LanguageUi>;
755 connect(langModule->languageCO, SIGNAL(activated(int)),
756 this, SLOT(change_adaptor()));
757 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
758 this, SLOT(change_adaptor()));
759 connect(langModule->otherencodingRB, SIGNAL(clicked()),
760 this, SLOT(change_adaptor()));
761 connect(langModule->encodingCO, SIGNAL(activated(int)),
762 this, SLOT(change_adaptor()));
763 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
764 this, SLOT(change_adaptor()));
766 vector<LanguagePair> const langs = getLanguageData(false);
767 vector<LanguagePair>::const_iterator lit = langs.begin();
768 vector<LanguagePair>::const_iterator lend = langs.end();
769 for (; lit != lend; ++lit) {
770 langModule->languageCO->addItem(toqstr(lit->first));
773 // Always put the default encoding in the first position.
774 // It is special because the displayed text is translated.
775 langModule->encodingCO->addItem(qt_("LaTeX default"));
776 Encodings::const_iterator it = encodings.begin();
777 Encodings::const_iterator const end = encodings.end();
778 for (; it != end; ++it)
779 langModule->encodingCO->addItem(toqstr(it->latexName()));
781 langModule->quoteStyleCO->addItem(qt_("``text''"));
782 langModule->quoteStyleCO->addItem(qt_("''text''"));
783 langModule->quoteStyleCO->addItem(qt_(",,text``"));
784 langModule->quoteStyleCO->addItem(qt_(",,text''"));
785 langModule->quoteStyleCO->addItem(qt_("<<text>>"));
786 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
790 numberingModule = new UiWidget<Ui::NumberingUi>;
792 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
793 this, SLOT(change_adaptor()));
794 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
795 this, SLOT(change_adaptor()));
796 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
797 this, SLOT(updateNumbering()));
798 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
799 this, SLOT(updateNumbering()));
800 numberingModule->tocTW->setColumnCount(3);
801 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
802 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
803 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
806 biblioModule = new UiWidget<Ui::BiblioUi>;
807 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
808 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
809 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
810 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
812 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
813 this, SLOT(change_adaptor()));
814 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
815 this, SLOT(change_adaptor()));
816 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
817 this, SLOT(change_adaptor()));
818 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
819 this, SLOT(change_adaptor()));
820 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
821 this, SLOT(change_adaptor()));
823 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
824 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
825 biblioModule->citeStyleCO->setCurrentIndex(0);
828 mathsModule = new UiWidget<Ui::MathsUi>;
829 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
830 mathsModule->amsCB, SLOT(setDisabled(bool)));
831 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
832 mathsModule->esintCB, SLOT(setDisabled(bool)));
834 connect(mathsModule->amsCB, SIGNAL(clicked()),
835 this, SLOT(change_adaptor()));
836 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
837 this, SLOT(change_adaptor()));
838 connect(mathsModule->esintCB, SIGNAL(clicked()),
839 this, SLOT(change_adaptor()));
840 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
841 this, SLOT(change_adaptor()));
843 latexModule = new UiWidget<Ui::LaTeXUi>;
845 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
846 this, SLOT(change_adaptor()));
847 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
848 this, SLOT(change_adaptor()));
849 connect(latexModule->classCO, SIGNAL(activated(int)),
850 this, SLOT(classChanged()));
851 connect(latexModule->classCO, SIGNAL(activated(int)),
852 this, SLOT(change_adaptor()));
855 new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
856 latexModule->addPB, latexModule->deletePB,
857 latexModule->upPB, latexModule->downPB,
858 availableModel(), selectedModel());
859 connect(selectionManager, SIGNAL(updateHook()),
860 this, SLOT(updateModuleInfo()));
861 connect(selectionManager, SIGNAL(updateHook()),
862 this, SLOT(change_adaptor()));
864 // postscript drivers
865 for (int n = 0; tex_graphics[n][0]; ++n) {
866 QString enc = qt_(tex_graphics_gui[n]);
867 latexModule->psdriverCO->addItem(enc);
870 //FIXME This seems too involved with the kernel. Some of this
871 //should be moved to the kernel---which should perhaps just
872 //give us a list of entries or something of the sort.
873 for (TextClassList::const_iterator cit = textclasslist.begin();
874 cit != textclasslist.end(); ++cit) {
875 if (cit->isTeXClassAvailable()) {
876 latexModule->classCO->addItem(toqstr(cit->description()));
879 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
880 latexModule->classCO->addItem(toqstr(item));
885 branchesModule = new GuiBranches;
886 connect(branchesModule, SIGNAL(changed()),
887 this, SLOT(change_adaptor()));
890 preambleModule = new PreambleModule;
891 connect(preambleModule, SIGNAL(changed()),
892 this, SLOT(change_adaptor()));
895 bulletsModule = new BulletsModule;
896 connect(bulletsModule, SIGNAL(changed()),
897 this, SLOT(change_adaptor()));
900 embeddedFilesModule = new UiWidget<Ui::EmbeddedFilesUi>;
901 connect(embeddedFilesModule->bundleCB, SIGNAL(toggled(bool)),
902 this, SLOT(change_adaptor()));
903 connect(embeddedFilesModule->addPB, SIGNAL(clicked()),
904 this, SLOT(change_adaptor()));
905 connect(embeddedFilesModule->removePB, SIGNAL(clicked()),
906 this, SLOT(change_adaptor()));
909 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
911 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
912 this, SLOT(change_adaptor()));
913 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
914 this, SLOT(change_adaptor()));
915 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
916 this, SLOT(change_adaptor()));
917 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
918 this, SLOT(change_adaptor()));
919 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
920 this, SLOT(change_adaptor()));
921 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
922 this, SLOT(change_adaptor()));
923 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
924 this, SLOT(change_adaptor()));
925 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
926 this, SLOT(change_adaptor()));
927 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
928 this, SLOT(change_adaptor()));
929 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
930 this, SLOT(change_adaptor()));
931 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
932 this, SLOT(change_adaptor()));
933 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
934 this, SLOT(change_adaptor()));
935 connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
936 this, SLOT(change_adaptor()));
937 connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
938 this, SLOT(change_adaptor()));
939 connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
940 this, SLOT(change_adaptor()));
941 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
942 this, SLOT(change_adaptor()));
943 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
944 this, SLOT(change_adaptor()));
947 floatModule = new FloatPlacement;
948 connect(floatModule, SIGNAL(changed()),
949 this, SLOT(change_adaptor()));
951 docPS->addPanel(latexModule, _("Document Class"));
952 docPS->addPanel(fontModule, _("Fonts"));
953 docPS->addPanel(textLayoutModule, _("Text Layout"));
954 docPS->addPanel(pageLayoutModule, _("Page Layout"));
955 docPS->addPanel(marginsModule, _("Page Margins"));
956 docPS->addPanel(langModule, _("Language"));
957 docPS->addPanel(numberingModule, _("Numbering & TOC"));
958 docPS->addPanel(biblioModule, _("Bibliography"));
959 docPS->addPanel(pdfSupportModule, _("PDF Properties"));
960 docPS->addPanel(mathsModule, _("Math Options"));
961 docPS->addPanel(floatModule, _("Float Placement"));
962 docPS->addPanel(bulletsModule, _("Bullets"));
963 docPS->addPanel(branchesModule, _("Branches"));
964 docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
965 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
966 docPS->setCurrentPanel(_("Document Class"));
967 // FIXME: hack to work around resizing bug in Qt >= 4.2
968 // bug verified with Qt 4.2.{0-3} (JSpitzm)
969 #if QT_VERSION >= 0x040200
970 docPS->updateGeometry();
975 void GuiDocument::showPreamble()
977 docPS->setCurrentPanel(_("LaTeX Preamble"));
981 void GuiDocument::saveDefaultClicked()
987 void GuiDocument::useDefaultsClicked()
993 void GuiDocument::change_adaptor()
999 docstring GuiDocument::validate_listings_params()
1001 // use a cache here to avoid repeated validation
1002 // of the same parameters
1003 static string param_cache = string();
1004 static docstring msg_cache = docstring();
1006 if (textLayoutModule->bypassCB->isChecked())
1009 string params = fromqstr(textLayoutModule->listingsED->toPlainText());
1010 if (params != param_cache) {
1011 param_cache = params;
1012 msg_cache = InsetListingsParams(params).validate();
1018 void GuiDocument::set_listings_msg()
1020 static bool isOK = true;
1021 docstring msg = validate_listings_params();
1026 // listingsTB->setTextColor("black");
1027 textLayoutModule->listingsTB->setPlainText(
1028 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
1031 // listingsTB->setTextColor("red");
1032 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
1037 void GuiDocument::closeEvent(QCloseEvent * e)
1044 void GuiDocument::setLSpacing(int item)
1046 textLayoutModule->lspacingLE->setEnabled(item == 3);
1050 void GuiDocument::setSkip(int item)
1052 bool const enable = (item == 3);
1053 textLayoutModule->skipLE->setEnabled(enable);
1054 textLayoutModule->skipLengthCO->setEnabled(enable);
1058 void GuiDocument::enableSkip(bool skip)
1060 textLayoutModule->skipCO->setEnabled(skip);
1061 textLayoutModule->skipLE->setEnabled(skip);
1062 textLayoutModule->skipLengthCO->setEnabled(skip);
1064 setSkip(textLayoutModule->skipCO->currentIndex());
1067 void GuiDocument::portraitChanged()
1069 setMargins(pageLayoutModule->papersizeCO->currentIndex());
1072 void GuiDocument::setMargins(bool custom)
1074 marginsModule->marginCB->setChecked(custom);
1075 setCustomMargins(custom);
1079 void GuiDocument::setCustomPapersize(int papersize)
1081 bool const custom = (papersize == 1);
1083 pageLayoutModule->paperwidthL->setEnabled(custom);
1084 pageLayoutModule->paperwidthLE->setEnabled(custom);
1085 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
1086 pageLayoutModule->paperheightL->setEnabled(custom);
1087 pageLayoutModule->paperheightLE->setEnabled(custom);
1088 pageLayoutModule->paperheightLE->setFocus();
1089 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
1093 void GuiDocument::setCustomMargins(bool custom)
1095 marginsModule->topL->setEnabled(!custom);
1096 marginsModule->topLE->setEnabled(!custom);
1097 marginsModule->topUnit->setEnabled(!custom);
1099 marginsModule->bottomL->setEnabled(!custom);
1100 marginsModule->bottomLE->setEnabled(!custom);
1101 marginsModule->bottomUnit->setEnabled(!custom);
1103 marginsModule->innerL->setEnabled(!custom);
1104 marginsModule->innerLE->setEnabled(!custom);
1105 marginsModule->innerUnit->setEnabled(!custom);
1107 marginsModule->outerL->setEnabled(!custom);
1108 marginsModule->outerLE->setEnabled(!custom);
1109 marginsModule->outerUnit->setEnabled(!custom);
1111 marginsModule->headheightL->setEnabled(!custom);
1112 marginsModule->headheightLE->setEnabled(!custom);
1113 marginsModule->headheightUnit->setEnabled(!custom);
1115 marginsModule->headsepL->setEnabled(!custom);
1116 marginsModule->headsepLE->setEnabled(!custom);
1117 marginsModule->headsepUnit->setEnabled(!custom);
1119 marginsModule->footskipL->setEnabled(!custom);
1120 marginsModule->footskipLE->setEnabled(!custom);
1121 marginsModule->footskipUnit->setEnabled(!custom);
1125 void GuiDocument::updateFontsize(string const & items, string const & sel)
1127 fontModule->fontsizeCO->clear();
1128 fontModule->fontsizeCO->addItem(qt_("Default"));
1130 for (int n = 0; !token(items,'|',n).empty(); ++n)
1131 fontModule->fontsizeCO->
1132 addItem(toqstr(token(items,'|',n)));
1134 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
1135 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
1136 fontModule->fontsizeCO->setCurrentIndex(n);
1143 void GuiDocument::romanChanged(int item)
1145 string const font = tex_fonts_roman[item];
1146 fontModule->fontScCB->setEnabled(providesSC(font));
1147 fontModule->fontOsfCB->setEnabled(providesOSF(font));
1151 void GuiDocument::sansChanged(int item)
1153 string const font = tex_fonts_sans[item];
1154 bool scaleable = providesScale(font);
1155 fontModule->scaleSansSB->setEnabled(scaleable);
1156 fontModule->scaleSansLA->setEnabled(scaleable);
1160 void GuiDocument::ttChanged(int item)
1162 string const font = tex_fonts_monospaced[item];
1163 bool scaleable = providesScale(font);
1164 fontModule->scaleTypewriterSB->setEnabled(scaleable);
1165 fontModule->scaleTypewriterLA->setEnabled(scaleable);
1169 void GuiDocument::updatePagestyle(string const & items, string const & sel)
1172 pageLayoutModule->pagestyleCO->clear();
1173 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
1175 for (int n = 0; !token(items,'|',n).empty(); ++n) {
1176 string style = token(items, '|', n);
1177 docstring style_gui = _(style);
1178 pagestyles.push_back(pair<string, docstring>(style, style_gui));
1179 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
1182 if (sel == "default") {
1183 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
1189 for (size_t i = 0; i < pagestyles.size(); ++i)
1190 if (pagestyles[i].first == sel)
1191 nn = pageLayoutModule->pagestyleCO->findText(
1192 toqstr(pagestyles[i].second));
1195 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
1199 void GuiDocument::classChanged()
1201 textclass_type const tc = latexModule->classCO->currentIndex();
1202 bp_.setBaseClass(tc);
1203 if (lyxrc.auto_reset_options) {
1204 if (applyPB->isEnabled()) {
1205 int const ret = Alert::prompt(_("Unapplied changes"),
1206 _("Some changes in the dialog were not yet applied."
1207 "If you do not apply now, they will be lost after this action."),
1208 1, 1, _("&Apply"), _("&Dismiss"));
1212 bp_.useClassDefaults();
1219 //This is an insanely complicated attempt to make this sort of thing
1220 //work with RTL languages.
1221 docstring formatStrVec(vector<string> const & v, docstring const & s)
1223 //this mess formats the list as "v[0], v[1], ..., [s] v[n]"
1224 int const vSize = v.size();
1227 else if (v.size() == 1)
1228 return from_ascii(v[0]);
1229 else if (v.size() == 2) {
1230 docstring retval = _("%1$s and %2$s");
1231 retval = subst(retval, _("and"), s);
1232 return bformat(retval, from_ascii(v[0]), from_ascii(v[1]));
1234 //The idea here is to format all but the last two items...
1235 docstring t2 = _("%1$s, %2$s");
1236 docstring retval = from_ascii(v[0]);
1237 for (int i = 1; i < vSize - 2; ++i)
1238 retval = bformat(t2, retval, from_ascii(v[i]));
1239 //...and then to plug them, and the last two, into this schema
1240 docstring t = _("%1$s, %2$s, and %3$s");
1241 t = subst(t, _("and"), s);
1242 return bformat(t, retval, from_ascii(v[vSize - 2]), from_ascii(v[vSize - 1]));
1245 vector<string> idsToNames(vector<string> const & idList)
1247 vector<string> retval;
1248 vector<string>::const_iterator it = idList.begin();
1249 vector<string>::const_iterator end = idList.end();
1250 for (; it != end; ++it) {
1251 LyXModule const * const mod = moduleList[*it];
1253 retval.push_back(*it + " (Unavailable)");
1255 retval.push_back(mod->getName());
1262 void GuiDocument::updateModuleInfo()
1264 selectionManager->update();
1266 //Module description
1267 bool const focusOnSelected = selectionManager->selectedFocused();
1268 QListView const * const lv =
1269 focusOnSelected ? latexModule->selectedLV : latexModule->availableLV;
1270 if (lv->selectionModel()->selectedIndexes().isEmpty()) {
1271 latexModule->infoML->document()->clear();
1274 QModelIndex const & idx = lv->selectionModel()->currentIndex();
1275 GuiIdListModel const & idModel =
1276 focusOnSelected ? selected_model_ : available_model_;
1277 string const modName = idModel.getIDString(idx.row());
1278 docstring desc = getModuleDescription(modName);
1280 vector<string> pkgList = getPackageList(modName);
1281 docstring pkgdesc = formatStrVec(pkgList, _("and"));
1282 if (!pkgdesc.empty()) {
1285 desc += bformat(_("Package(s) required: %1$s."), pkgdesc);
1288 pkgList = getRequiredList(modName);
1289 if (!pkgList.empty()) {
1290 vector<string> const reqDescs = idsToNames(pkgList);
1291 pkgdesc = formatStrVec(reqDescs, _("or"));
1294 desc += bformat(_("Module required: %1$s."), pkgdesc);
1297 pkgList = getExcludedList(modName);
1298 if (!pkgList.empty()) {
1299 vector<string> const reqDescs = idsToNames(pkgList);
1300 pkgdesc = formatStrVec(reqDescs, _( "and"));
1303 desc += bformat(_("Modules excluded: %1$s."), pkgdesc);
1306 if (!isModuleAvailable(modName)) {
1309 desc += _("WARNING: Some packages are unavailable!");
1312 latexModule->infoML->document()->setPlainText(toqstr(desc));
1316 void GuiDocument::updateEmbeddedFileList()
1318 embeddedFilesModule->filesLW->clear();
1319 // add current embedded files
1320 EmbeddedFileList & files = buffer().embeddedFiles();
1321 files.update(buffer());
1322 EmbeddedFileList::iterator fit = files.begin();
1323 EmbeddedFileList::iterator fit_end = files.end();
1324 for (; fit != fit_end; ++fit) {
1325 QString label = toqstr(fit->relFilename(buffer().filePath()));
1326 if (fit->refCount() > 1)
1327 label += " (" + QString::number(fit->refCount()) + ")";
1328 QListWidgetItem * item = new QListWidgetItem(label);
1329 item->setFlags(item->flags() | Qt::ItemIsSelectable
1330 | Qt::ItemIsUserCheckable);
1332 item->setCheckState(Qt::Checked);
1334 item->setCheckState(Qt::Unchecked);
1335 // index of the currently used ParConstIterator
1336 embeddedFilesModule->filesLW->addItem(item);
1341 void GuiDocument::updateNumbering()
1343 TextClass const & tclass = bp_.getTextClass();
1345 numberingModule->tocTW->setUpdatesEnabled(false);
1346 numberingModule->tocTW->clear();
1348 int const depth = numberingModule->depthSL->value();
1349 int const toc = numberingModule->tocSL->value();
1350 QString const no = qt_("No");
1351 QString const yes = qt_("Yes");
1352 TextClass::const_iterator end = tclass.end();
1353 TextClass::const_iterator cit = tclass.begin();
1354 QTreeWidgetItem * item = 0;
1355 for ( ; cit != end ; ++cit) {
1356 int const toclevel = (*cit)->toclevel;
1357 if (toclevel != Layout::NOT_IN_TOC
1358 && (*cit)->labeltype == LABEL_COUNTER) {
1359 item = new QTreeWidgetItem(numberingModule->tocTW);
1360 item->setText(0, toqstr(translateIfPossible((*cit)->name())));
1361 item->setText(1, (toclevel <= depth) ? yes : no);
1362 item->setText(2, (toclevel <= toc) ? yes : no);
1366 numberingModule->tocTW->setUpdatesEnabled(true);
1367 numberingModule->tocTW->update();
1371 void GuiDocument::apply(BufferParams & params)
1374 preambleModule->apply(params);
1377 params.setCiteEngine(biblio::ENGINE_BASIC);
1379 if (biblioModule->citeNatbibRB->isChecked()) {
1380 bool const use_numerical_citations =
1381 biblioModule->citeStyleCO->currentIndex();
1382 if (use_numerical_citations)
1383 params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1385 params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1387 } else if (biblioModule->citeJurabibRB->isChecked())
1388 params.setCiteEngine(biblio::ENGINE_JURABIB);
1390 params.use_bibtopic =
1391 biblioModule->bibtopicCB->isChecked();
1393 // language & quotes
1394 if (langModule->defaultencodingRB->isChecked()) {
1395 params.inputenc = "auto";
1397 int i = langModule->encodingCO->currentIndex();
1399 params.inputenc = "default";
1402 fromqstr(langModule->encodingCO->currentText());
1405 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1406 switch (langModule->quoteStyleCO->currentIndex()) {
1408 lga = InsetQuotes::EnglishQ;
1411 lga = InsetQuotes::SwedishQ;
1414 lga = InsetQuotes::GermanQ;
1417 lga = InsetQuotes::PolishQ;
1420 lga = InsetQuotes::FrenchQ;
1423 lga = InsetQuotes::DanishQ;
1426 params.quotes_language = lga;
1428 int const pos = langModule->languageCO->currentIndex();
1429 params.language = lyx::languages.getLanguage(lang_[pos]);
1432 if (params.getTextClass().hasTocLevels()) {
1433 params.tocdepth = numberingModule->tocSL->value();
1434 params.secnumdepth = numberingModule->depthSL->value();
1438 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1439 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1440 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1441 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1444 params.graphicsDriver =
1445 tex_graphics[latexModule->psdriverCO->currentIndex()];
1448 params.setBaseClass(latexModule->classCO->currentIndex());
1451 params.clearLayoutModules();
1452 int const srows = selected_model_.rowCount();
1453 vector<string> selModList;
1454 for (int i = 0; i < srows; ++i)
1455 params.addLayoutModule(selected_model_.getIDString(i));
1457 if (mathsModule->amsautoCB->isChecked()) {
1458 params.use_amsmath = BufferParams::package_auto;
1460 if (mathsModule->amsCB->isChecked())
1461 params.use_amsmath = BufferParams::package_on;
1463 params.use_amsmath = BufferParams::package_off;
1466 if (mathsModule->esintautoCB->isChecked())
1467 params.use_esint = BufferParams::package_auto;
1469 if (mathsModule->esintCB->isChecked())
1470 params.use_esint = BufferParams::package_on;
1472 params.use_esint = BufferParams::package_off;
1475 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1476 params.pagestyle = "default";
1478 docstring style_gui =
1479 qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1480 for (size_t i = 0; i < pagestyles.size(); ++i)
1481 if (pagestyles[i].second == style_gui)
1482 params.pagestyle = pagestyles[i].first;
1485 switch (textLayoutModule->lspacingCO->currentIndex()) {
1487 params.spacing().set(Spacing::Single);
1490 params.spacing().set(Spacing::Onehalf);
1493 params.spacing().set(Spacing::Double);
1496 params.spacing().set(Spacing::Other,
1497 fromqstr(textLayoutModule->lspacingLE->text()));
1501 if (textLayoutModule->twoColumnCB->isChecked())
1506 // text should have passed validation
1507 params.listings_params =
1508 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1510 if (textLayoutModule->indentRB->isChecked())
1511 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1513 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1515 switch (textLayoutModule->skipCO->currentIndex()) {
1517 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1520 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1523 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1528 widgetsToLength(textLayoutModule->skipLE,
1529 textLayoutModule->skipLengthCO)
1531 params.setDefSkip(vs);
1535 // DocumentDefskipCB assures that this never happens
1536 // so Assert then !!! - jbl
1537 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1542 fromqstr(latexModule->optionsLE->text());
1544 params.float_placement = floatModule->get();
1548 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1551 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1553 params.fontsTypewriter =
1554 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1556 params.fontsSansScale = fontModule->scaleSansSB->value();
1558 params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1560 params.fontsSC = fontModule->fontScCB->isChecked();
1562 params.fontsOSF = fontModule->fontOsfCB->isChecked();
1564 params.fontsDefaultFamily = GuiDocument::fontfamilies[
1565 fontModule->fontsDefaultCO->currentIndex()];
1567 if (fontModule->fontsizeCO->currentIndex() == 0)
1568 params.fontsize = "default";
1571 fromqstr(fontModule->fontsizeCO->currentText());
1574 params.papersize = PAPER_SIZE(
1575 pageLayoutModule->papersizeCO->currentIndex());
1577 // custom, A3, B3 and B4 paper sizes need geometry
1578 int psize = pageLayoutModule->papersizeCO->currentIndex();
1579 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1581 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1582 pageLayoutModule->paperwidthUnitCO);
1584 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1585 pageLayoutModule->paperheightUnitCO);
1587 if (pageLayoutModule->facingPagesCB->isChecked())
1588 params.sides = TwoSides;
1590 params.sides = OneSide;
1592 if (pageLayoutModule->landscapeRB->isChecked())
1593 params.orientation = ORIENTATION_LANDSCAPE;
1595 params.orientation = ORIENTATION_PORTRAIT;
1598 params.use_geometry =
1599 (!marginsModule->marginCB->isChecked()
1602 Ui::MarginsUi const * m(marginsModule);
1604 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1605 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1606 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1607 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1608 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1609 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1610 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1612 branchesModule->apply(params);
1615 PDFOptions & pdf = params.pdfoptions();
1616 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
1617 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1618 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1619 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1620 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1622 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1623 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1624 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1625 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
1627 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
1628 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
1629 pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
1630 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
1631 pdf.backref = pdfSupportModule->backrefCB->isChecked();
1632 pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
1633 if (pdfSupportModule->fullscreenCB->isChecked())
1634 pdf.pagemode = pdf.pagemode_fullscreen;
1636 pdf.pagemode.clear();
1637 pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1644 /** Return the position of val in the vector if found.
1645 If not found, return 0.
1648 static size_t findPos(vector<A> const & vec, A const & val)
1650 typename vector<A>::const_iterator it =
1651 find(vec.begin(), vec.end(), val);
1652 if (it == vec.end())
1654 return distance(vec.begin(), it);
1658 void GuiDocument::updateParams()
1664 void GuiDocument::updateParams(BufferParams const & params)
1666 // set the default unit
1667 Length::UNIT defaultUnit = Length::CM;
1668 switch (lyxrc.default_papersize) {
1669 case PAPER_DEFAULT: break;
1671 case PAPER_USLETTER:
1673 case PAPER_USEXECUTIVE:
1674 defaultUnit = Length::IN;
1683 defaultUnit = Length::CM;
1690 preambleModule->update(params, id());
1693 biblioModule->citeDefaultRB->setChecked(
1694 params.getEngine() == biblio::ENGINE_BASIC);
1696 biblioModule->citeNatbibRB->setChecked(
1697 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1698 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1700 biblioModule->citeStyleCO->setCurrentIndex(
1701 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1703 biblioModule->citeJurabibRB->setChecked(
1704 params.getEngine() == biblio::ENGINE_JURABIB);
1706 biblioModule->bibtopicCB->setChecked(
1707 params.use_bibtopic);
1709 // language & quotes
1710 int const pos = int(findPos(lang_,
1711 params.language->lang()));
1712 langModule->languageCO->setCurrentIndex(pos);
1714 langModule->quoteStyleCO->setCurrentIndex(
1715 params.quotes_language);
1717 bool default_enc = true;
1718 if (params.inputenc != "auto") {
1719 default_enc = false;
1720 if (params.inputenc == "default") {
1721 langModule->encodingCO->setCurrentIndex(0);
1723 int const i = langModule->encodingCO->findText(
1724 toqstr(params.inputenc));
1726 langModule->encodingCO->setCurrentIndex(i);
1728 // unknown encoding. Set to default.
1732 langModule->defaultencodingRB->setChecked(default_enc);
1733 langModule->otherencodingRB->setChecked(!default_enc);
1736 int const min_toclevel = textClass().min_toclevel();
1737 int const max_toclevel = textClass().max_toclevel();
1738 if (textClass().hasTocLevels()) {
1739 numberingModule->setEnabled(true);
1740 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1741 numberingModule->depthSL->setMaximum(max_toclevel);
1742 numberingModule->depthSL->setValue(params.secnumdepth);
1743 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1744 numberingModule->tocSL->setMaximum(max_toclevel);
1745 numberingModule->tocSL->setValue(params.tocdepth);
1748 numberingModule->setEnabled(false);
1749 numberingModule->tocTW->clear();
1753 bulletsModule->setBullet(0, params.user_defined_bullet(0));
1754 bulletsModule->setBullet(1, params.user_defined_bullet(1));
1755 bulletsModule->setBullet(2, params.user_defined_bullet(2));
1756 bulletsModule->setBullet(3, params.user_defined_bullet(3));
1757 bulletsModule->init();
1760 int nitem = findToken(tex_graphics, params.graphicsDriver);
1762 latexModule->psdriverCO->setCurrentIndex(nitem);
1765 mathsModule->amsCB->setChecked(
1766 params.use_amsmath == BufferParams::package_on);
1767 mathsModule->amsautoCB->setChecked(
1768 params.use_amsmath == BufferParams::package_auto);
1770 mathsModule->esintCB->setChecked(
1771 params.use_esint == BufferParams::package_on);
1772 mathsModule->esintautoCB->setChecked(
1773 params.use_esint == BufferParams::package_auto);
1775 switch (params.spacing().getSpace()) {
1776 case Spacing::Other: nitem = 3; break;
1777 case Spacing::Double: nitem = 2; break;
1778 case Spacing::Onehalf: nitem = 1; break;
1779 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1783 latexModule->classCO->setCurrentIndex(params.getBaseClass());
1785 updatePagestyle(textClass().opt_pagestyle(),
1788 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1789 if (params.spacing().getSpace() == Spacing::Other) {
1790 textLayoutModule->lspacingLE->setText(
1791 toqstr(params.spacing().getValueAsString()));
1795 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1796 textLayoutModule->indentRB->setChecked(true);
1798 textLayoutModule->skipRB->setChecked(true);
1801 switch (params.getDefSkip().kind()) {
1802 case VSpace::SMALLSKIP:
1805 case VSpace::MEDSKIP:
1808 case VSpace::BIGSKIP:
1811 case VSpace::LENGTH:
1814 string const length = params.getDefSkip().asLyXCommand();
1815 lengthToWidgets(textLayoutModule->skipLE,
1816 textLayoutModule->skipLengthCO,
1817 length, defaultUnit);
1824 textLayoutModule->skipCO->setCurrentIndex(skip);
1827 textLayoutModule->twoColumnCB->setChecked(
1828 params.columns == 2);
1830 // break listings_params to multiple lines
1832 InsetListingsParams(params.listings_params).separatedParams();
1833 textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1835 if (!params.options.empty()) {
1836 latexModule->optionsLE->setText(
1837 toqstr(params.options));
1839 latexModule->optionsLE->setText(QString());
1842 floatModule->set(params.float_placement);
1845 updateFontsize(textClass().opt_fontsize(),
1848 int n = findToken(tex_fonts_roman, params.fontsRoman);
1850 fontModule->fontsRomanCO->setCurrentIndex(n);
1854 n = findToken(tex_fonts_sans, params.fontsSans);
1856 fontModule->fontsSansCO->setCurrentIndex(n);
1860 n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1862 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1866 fontModule->fontScCB->setChecked(params.fontsSC);
1867 fontModule->fontOsfCB->setChecked(params.fontsOSF);
1868 fontModule->scaleSansSB->setValue(params.fontsSansScale);
1869 fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1870 n = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
1872 fontModule->fontsDefaultCO->setCurrentIndex(n);
1875 int const psize = params.papersize;
1876 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1877 setCustomPapersize(psize);
1879 bool const landscape =
1880 params.orientation == ORIENTATION_LANDSCAPE;
1881 pageLayoutModule->landscapeRB->setChecked(landscape);
1882 pageLayoutModule->portraitRB->setChecked(!landscape);
1884 pageLayoutModule->facingPagesCB->setChecked(
1885 params.sides == TwoSides);
1888 lengthToWidgets(pageLayoutModule->paperwidthLE,
1889 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1891 lengthToWidgets(pageLayoutModule->paperheightLE,
1892 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1895 Ui::MarginsUi * m = marginsModule;
1897 setMargins(!params.use_geometry);
1899 lengthToWidgets(m->topLE, m->topUnit,
1900 params.topmargin, defaultUnit);
1902 lengthToWidgets(m->bottomLE, m->bottomUnit,
1903 params.bottommargin, defaultUnit);
1905 lengthToWidgets(m->innerLE, m->innerUnit,
1906 params.leftmargin, defaultUnit);
1908 lengthToWidgets(m->outerLE, m->outerUnit,
1909 params.rightmargin, defaultUnit);
1911 lengthToWidgets(m->headheightLE, m->headheightUnit,
1912 params.headheight, defaultUnit);
1914 lengthToWidgets(m->headsepLE, m->headsepUnit,
1915 params.headsep, defaultUnit);
1917 lengthToWidgets(m->footskipLE, m->footskipUnit,
1918 params.footskip, defaultUnit);
1920 branchesModule->update(params);
1923 PDFOptions const & pdf = params.pdfoptions();
1924 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
1925 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1926 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1927 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1928 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1930 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1931 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1932 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1934 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
1936 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1937 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1938 pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
1939 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1940 pdfSupportModule->backrefCB->setChecked(pdf.backref);
1941 pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1942 pdfSupportModule->fullscreenCB->setChecked
1943 (pdf.pagemode == pdf.pagemode_fullscreen);
1945 pdfSupportModule->optionsLE->setText(
1946 toqstr(pdf.quoted_options));
1949 updateEmbeddedFileList();
1953 void GuiDocument::applyView()
1959 void GuiDocument::saveDocDefault()
1961 // we have to apply the params first
1967 void GuiDocument::updateAvailableModules()
1969 available_model_.clear();
1970 vector<modInfoStruct> const modInfoList = getModuleInfo();
1971 int const mSize = modInfoList.size();
1972 for (int i = 0; i < mSize; ++i) {
1973 modInfoStruct const & modInfo = modInfoList[i];
1974 available_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
1979 void GuiDocument::updateSelectedModules()
1981 //and selected ones, too
1982 selected_model_.clear();
1983 vector<modInfoStruct> const selModList = getSelectedModules();
1984 int const sSize = selModList.size();
1985 for (int i = 0; i < sSize; ++i) {
1986 modInfoStruct const & modInfo = selModList[i];
1987 selected_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
1992 void GuiDocument::updateContents()
1994 if (id() == current_id_)
1997 updateAvailableModules();
1998 updateSelectedModules();
2000 //FIXME It'd be nice to make sure here that the selected
2001 //modules are consistent: That required modules are actually
2002 //selected, and that we don't have conflicts. If so, we could
2003 //at least pop up a warning.
2009 void GuiDocument::forceUpdate()
2011 // reset to force dialog update
2017 void GuiDocument::useClassDefaults()
2019 if (applyPB->isEnabled()) {
2020 int const ret = Alert::prompt(_("Unapplied changes"),
2021 _("Some changes in the dialog were not yet applied."
2022 "If you do not apply now, they will be lost after this action."),
2023 1, 1, _("&Apply"), _("&Dismiss"));
2028 bp_.setBaseClass(latexModule->classCO->currentIndex());
2029 bp_.useClassDefaults();
2034 bool GuiDocument::isValid()
2036 return validate_listings_params().empty();
2040 char const * const GuiDocument::fontfamilies[5] = {
2041 "default", "rmdefault", "sfdefault", "ttdefault", ""
2045 char const * GuiDocument::fontfamilies_gui[5] = {
2046 N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
2050 bool GuiDocument::initialiseParams(string const &)
2052 bp_ = buffer().params();
2058 void GuiDocument::clearParams()
2060 bp_ = BufferParams();
2064 BufferId GuiDocument::id() const
2070 vector<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
2072 return moduleNames_;
2076 vector<GuiDocument::modInfoStruct> const GuiDocument::getSelectedModules()
2078 vector<string> const & mods = params().getModules();
2079 vector<string>::const_iterator it = mods.begin();
2080 vector<string>::const_iterator end = mods.end();
2081 vector<modInfoStruct> mInfo;
2082 for (; it != end; ++it) {
2085 LyXModule * mod = moduleList[*it];
2087 m.name = mod->getName();
2089 m.name = *it + " (Not Found)";
2096 TextClass const & GuiDocument::textClass() const
2098 return textclasslist[bp_.getBaseClass()];
2102 static void dispatch_bufferparams(Dialog const & dialog,
2103 BufferParams const & bp, kb_action lfun)
2106 ss << "\\begin_header\n";
2108 ss << "\\end_header\n";
2109 dialog.dispatch(FuncRequest(lfun, ss.str()));
2113 void GuiDocument::dispatchParams()
2115 // This must come first so that a language change is correctly noticed
2118 // Apply the BufferParams. Note that this will set the base class
2119 // and then update the buffer's layout.
2120 dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
2122 // Generate the colours requested by each new branch.
2123 BranchList & branchlist = params().branchlist();
2124 if (!branchlist.empty()) {
2125 BranchList::const_iterator it = branchlist.begin();
2126 BranchList::const_iterator const end = branchlist.end();
2127 for (; it != end; ++it) {
2128 docstring const & current_branch = it->getBranch();
2129 Branch const * branch = branchlist.find(current_branch);
2130 string const x11hexname = X11hexname(branch->getColor());
2131 // display the new color
2132 docstring const str = current_branch + ' ' + from_ascii(x11hexname);
2133 dispatch(FuncRequest(LFUN_SET_COLOR, str));
2136 // Open insets of selected branches, close deselected ones
2137 dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
2140 // FIXME: If we used an LFUN, we would not need those two lines:
2141 bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
2145 void GuiDocument::setLanguage() const
2147 Language const * const newL = bp_.language;
2148 if (buffer().params().language == newL)
2151 string const & lang_name = newL->lang();
2152 dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
2156 void GuiDocument::saveAsDefault() const
2158 dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
2162 bool GuiDocument::isFontAvailable(string const & font) const
2164 if (font == "default" || font == "cmr"
2165 || font == "cmss" || font == "cmtt")
2166 // these are standard
2168 if (font == "lmodern" || font == "lmss" || font == "lmtt")
2169 return LaTeXFeatures::isAvailable("lmodern");
2170 if (font == "times" || font == "palatino"
2171 || font == "helvet" || font == "courier")
2172 return LaTeXFeatures::isAvailable("psnfss");
2173 if (font == "cmbr" || font == "cmtl")
2174 return LaTeXFeatures::isAvailable("cmbright");
2175 if (font == "utopia")
2176 return LaTeXFeatures::isAvailable("utopia")
2177 || LaTeXFeatures::isAvailable("fourier");
2178 if (font == "beraserif" || font == "berasans"
2179 || font == "beramono")
2180 return LaTeXFeatures::isAvailable("bera");
2181 return LaTeXFeatures::isAvailable(font);
2185 bool GuiDocument::providesOSF(string const & font) const
2188 return isFontAvailable("eco");
2189 if (font == "palatino")
2190 return isFontAvailable("mathpazo");
2195 bool GuiDocument::providesSC(string const & font) const
2197 if (font == "palatino")
2198 return isFontAvailable("mathpazo");
2199 if (font == "utopia")
2200 return isFontAvailable("fourier");
2205 bool GuiDocument::providesScale(string const & font) const
2207 return font == "helvet" || font == "luximono"
2208 || font == "berasans" || font == "beramono";
2212 void GuiDocument::loadModuleInfo()
2214 moduleNames_.clear();
2215 LyXModuleList::const_iterator it = moduleList.begin();
2216 LyXModuleList::const_iterator end = moduleList.end();
2217 for (; it != end; ++it) {
2220 m.name = it->getName();
2221 moduleNames_.push_back(m);
2226 Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
2229 } // namespace frontend
2232 #include "GuiDocument_moc.cpp"