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/FileName.h"
46 #include "support/filetools.h"
47 #include "support/lstrings.h"
49 #include "frontends/alert.h"
51 #include <boost/bind.hpp>
53 #include <QCloseEvent>
55 #include <QTextCursor>
61 using namespace lyx::support;
66 vector<typename Pair::second_type> const
67 getSecond(vector<Pair> const & pr)
69 vector<typename Pair::second_type> tmp(pr.size());
70 transform(pr.begin(), pr.end(), tmp.begin(),
71 boost::bind(&Pair::second, _1));
76 char const * const tex_graphics[] =
78 "default", "dvips", "dvitops", "emtex",
79 "ln", "oztex", "textures", "none", ""
83 char const * const tex_graphics_gui[] =
85 N_("Default"), "Dvips", "DVItoPS", "EmTeX",
86 "LN", "OzTeX", "Textures", N_("None"), ""
90 char const * const tex_fonts_roman[] =
92 "default", "cmr", "lmodern", "ae", "times", "palatino",
93 "charter", "newcent", "bookman", "utopia", "beraserif",
94 "ccfonts", "chancery", ""
98 char const * tex_fonts_roman_gui[] =
100 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
101 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
102 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
103 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
108 char const * const tex_fonts_sans[] =
110 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
114 char const * tex_fonts_sans_gui[] =
116 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
117 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
121 char const * const tex_fonts_monospaced[] =
123 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
127 char const * tex_fonts_monospaced_gui[] =
129 N_("Default"), N_("Computer Modern Typewriter"),
130 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
131 N_("LuxiMono"), N_("CM Typewriter Light"), ""
135 vector<pair<string, lyx::docstring> > pagestyles;
143 QModelIndex getSelectedIndex(QListView * lv)
145 QModelIndex retval = QModelIndex();
146 QModelIndexList selIdx =
147 lv->selectionModel()->selectedIndexes();
149 retval = selIdx.first();
155 vector<string> getRequiredList(string const & modName)
157 LyXModule const * const mod = moduleList[modName];
159 return vector<string>(); //empty such thing
160 return mod->getRequiredModules();
164 vector<string> getExcludedList(string const & modName)
166 LyXModule const * const mod = moduleList[modName];
168 return vector<string>(); //empty such thing
169 return mod->getExcludedModules();
173 docstring getModuleDescription(string const & modName)
175 LyXModule const * const mod = moduleList[modName];
177 return _("Module not found!");
178 return _(mod->getDescription());
182 vector<string> getPackageList(string const & modName)
184 LyXModule const * const mod = moduleList[modName];
186 return vector<string>(); //empty such thing
187 return mod->getPackageList();
191 bool isModuleAvailable(string const & modName)
193 LyXModule * mod = moduleList[modName];
196 return mod->isAvailable();
198 } //anonymous namespace
201 ModuleSelMan::ModuleSelMan(
202 QListView * availableLV,
203 QListView * selectedLV,
207 QPushButton * downPB,
208 GuiIdListModel * availableModel,
209 GuiIdListModel * selectedModel) :
210 GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
211 upPB, downPB, availableModel, selectedModel)
215 void ModuleSelMan::updateAddPB()
217 int const arows = availableModel->rowCount();
218 QModelIndexList const availSels =
219 availableLV->selectionModel()->selectedIndexes();
220 if (arows == 0 || availSels.isEmpty() || isSelected(availSels.first())) {
221 addPB->setEnabled(false);
225 QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
226 string const modName = getAvailableModel()->getIDString(idx.row());
227 vector<string> reqs = getRequiredList(modName);
228 vector<string> excl = getExcludedList(modName);
230 if (reqs.empty() && excl.empty()) {
231 addPB->setEnabled(true);
235 int const srows = selectedModel->rowCount();
236 vector<string> selModList;
237 for (int i = 0; i < srows; ++i)
238 selModList.push_back(getSelectedModel()->getIDString(i));
240 vector<string>::const_iterator selModStart = selModList.begin();
241 vector<string>::const_iterator selModEnd = selModList.end();
243 //Check whether some required module is available
245 bool foundOne = false;
246 vector<string>::const_iterator it = reqs.begin();
247 vector<string>::const_iterator end = reqs.end();
248 for (; it != end; ++it) {
249 if (find(selModStart, selModEnd, *it) != selModEnd) {
255 addPB->setEnabled(false);
260 //Check whether any excluded module is being used
262 vector<string>::const_iterator it = excl.begin();
263 vector<string>::const_iterator end = excl.end();
264 for (; it != end; ++it) {
265 if (find(selModStart, selModEnd, *it) != selModEnd) {
266 addPB->setEnabled(false);
272 addPB->setEnabled(true);
276 void ModuleSelMan::updateDownPB()
278 int const srows = selectedModel->rowCount();
280 downPB->setEnabled(false);
283 QModelIndexList const selSels =
284 selectedLV->selectionModel()->selectedIndexes();
285 //disable if empty or last item is selected
286 if (selSels.empty() || selSels.first().row() == srows - 1) {
287 downPB->setEnabled(false);
290 //determine whether immediately succeding element requires this one
291 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
292 int curRow = curIdx.row();
293 if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
294 downPB->setEnabled(false);
297 string const curModName = getSelectedModel()->getIDString(curRow);
298 string const nextModName = getSelectedModel()->getIDString(curRow + 1);
300 vector<string> reqs = getRequiredList(nextModName);
302 //if it doesn't require anything....
304 downPB->setEnabled(true);
308 //FIXME This should perhaps be more flexible and check whether, even
309 //if this one is required, there is also an earlier one that is required.
310 //enable it if this module isn't required
312 find(reqs.begin(), reqs.end(), curModName) == reqs.end());
315 void ModuleSelMan::updateUpPB()
317 int const srows = selectedModel->rowCount();
319 upPB->setEnabled(false);
322 QModelIndexList const selSels =
323 selectedLV->selectionModel()->selectedIndexes();
324 //disable if empty or first item is selected
325 if (selSels.empty() || selSels.first().row() == 0) {
326 upPB->setEnabled(false);
330 //determine whether immediately preceding element is required by this one
331 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
332 int curRow = curIdx.row();
333 if (curRow <= -1 || curRow > srows - 1) { //sanity check
334 downPB->setEnabled(false);
337 string const curModName = getSelectedModel()->getIDString(curRow);
338 vector<string> reqs = getRequiredList(curModName);
340 //if this one doesn't require anything....
342 upPB->setEnabled(true);
346 string preModName = getSelectedModel()->getIDString(curRow - 1);
348 //NOTE This is less flexible than it might be. You could check whether, even
349 //if this one is required, there is also an earlier one that is required.
350 //enable it if the preceding module isn't required
351 upPB->setEnabled(find(reqs.begin(), reqs.end(), preModName) == reqs.end());
354 void ModuleSelMan::updateDelPB()
356 int const srows = selectedModel->rowCount();
358 deletePB->setEnabled(false);
361 QModelIndexList const selSels =
362 selectedLV->selectionModel()->selectedIndexes();
363 if (selSels.empty() || selSels.first().row() < 0) {
364 deletePB->setEnabled(false);
368 //determine whether some LATER module requires this one
369 //NOTE Things are arranged so that this is the only way there
370 //can be a problem. At least, we hope so.
371 QModelIndex const & curIdx =
372 selectedLV->selectionModel()->currentIndex();
373 int const curRow = curIdx.row();
374 if (curRow < 0 || curRow >= srows) { //this shouldn't happen
375 deletePB->setEnabled(false);
379 QString const curModName = curIdx.data().toString();
381 //We're looking here for a reason NOT to enable the button. If we
382 //find one, we disable it and return. If we don't, we'll end up at
383 //the end of the function, and then we enable it.
384 for (int i = curRow + 1; i < srows; ++i) {
385 string const thisMod = getSelectedModel()->getIDString(i);
386 vector<string> reqs = getRequiredList(thisMod);
387 //does this one require us?
388 if (find(reqs.begin(), reqs.end(), fromqstr(curModName)) == reqs.end())
392 //OK, so this module requires us
393 //is there an EARLIER module that also satisfies the require?
394 //NOTE We demand that it be earlier to keep the list of modules
395 //consistent with the rule that a module must be proceeded by a
396 //required module. There would be more flexible ways to proceed,
397 //but that would be a lot more complicated, and the logic here is
398 //already complicated. (That's why I've left the debugging code.)
399 //lyxerr << "Testing " << thisMod << std::endl;
400 bool foundOne = false;
401 for (int j = 0; j < curRow; ++j) {
402 string const mod = getSelectedModel()->getIDString(j);
403 //lyxerr << "In loop: Testing " << mod << std::endl;
404 //do we satisfy the require?
405 if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
406 //lyxerr << mod << " does the trick." << std::endl;
411 //did we find a module to satisfy the require?
413 //lyxerr << "No matching module found." << std::endl;
414 deletePB->setEnabled(false);
418 //lyxerr << "All's well that ends well." << std::endl;
419 deletePB->setEnabled(true);
423 /////////////////////////////////////////////////////////////////////
427 /////////////////////////////////////////////////////////////////////
429 PreambleModule::PreambleModule(): current_id_(0)
431 // This is not a memory leak. The object will be destroyed
433 (void) new LaTeXHighlighter(preambleTE->document());
434 setFocusProxy(preambleTE);
435 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
439 void PreambleModule::update(BufferParams const & params, BufferId id)
441 QString preamble = toqstr(params.preamble);
442 // Nothing to do if the params and preamble are unchanged.
443 if (id == current_id_
444 && preamble == preambleTE->document()->toPlainText())
447 QTextCursor cur = preambleTE->textCursor();
448 // Save the coords before switching to the new one.
449 preamble_coords_[current_id_] =
450 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
452 // Save the params address for further use.
454 preambleTE->document()->setPlainText(preamble);
455 Coords::const_iterator it = preamble_coords_.find(current_id_);
456 if (it == preamble_coords_.end())
457 // First time we open this one.
458 preamble_coords_[current_id_] = make_pair(0,0);
460 // Restore saved coords.
461 QTextCursor cur = preambleTE->textCursor();
462 cur.setPosition(it->second.first);
463 preambleTE->setTextCursor(cur);
464 preambleTE->verticalScrollBar()->setValue(it->second.second);
469 void PreambleModule::apply(BufferParams & params)
471 params.preamble = fromqstr(preambleTE->document()->toPlainText());
475 void PreambleModule::closeEvent(QCloseEvent * e)
477 // Save the coords before closing.
478 QTextCursor cur = preambleTE->textCursor();
479 preamble_coords_[current_id_] =
480 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
485 /////////////////////////////////////////////////////////////////////
489 /////////////////////////////////////////////////////////////////////
493 GuiDocument::GuiDocument(GuiView & lv)
494 : GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
498 lang_ = getSecond(getLanguageData(false));
500 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
501 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
502 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
503 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
505 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
506 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
508 // Manage the restore, ok, apply, restore and cancel/close buttons
509 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
511 bc().setApply(applyPB);
512 bc().setCancel(closePB);
513 bc().setRestore(restorePB);
515 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
517 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
518 this, SLOT(change_adaptor()));
519 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
520 this, SLOT(setLSpacing(int)));
521 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
522 this, SLOT(change_adaptor()));
523 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
524 this, SLOT(change_adaptor()));
525 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
526 this, SLOT(change_adaptor()));
527 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
528 this, SLOT(change_adaptor()));
529 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
530 this, SLOT(change_adaptor()));
531 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
532 this, SLOT(change_adaptor()));
533 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
534 this, SLOT(setSkip(int)));
535 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
536 this, SLOT(enableSkip(bool)));
537 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
538 this, SLOT(change_adaptor()));
539 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
540 this, SLOT(change_adaptor()));
541 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
542 this, SLOT(change_adaptor()));
543 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
544 this, SLOT(set_listings_msg()));
545 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
546 this, SLOT(set_listings_msg()));
547 textLayoutModule->listingsTB->setPlainText(
548 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
549 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
550 textLayoutModule->lspacingLE));
551 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
552 textLayoutModule->skipLE));
554 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
555 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
556 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
557 textLayoutModule->skipCO->addItem(qt_("Length"));
558 // remove the %-items from the unit choice
559 textLayoutModule->skipLengthCO->noPercents();
560 textLayoutModule->lspacingCO->insertItem(
561 Spacing::Single, qt_("Single"));
562 textLayoutModule->lspacingCO->insertItem(
563 Spacing::Onehalf, qt_("OneHalf"));
564 textLayoutModule->lspacingCO->insertItem(
565 Spacing::Double, qt_("Double"));
566 textLayoutModule->lspacingCO->insertItem(
567 Spacing::Other, qt_("Custom"));
569 // initialize the length validator
570 bc().addCheckedLineEdit(textLayoutModule->skipLE);
572 fontModule = new UiWidget<Ui::FontUi>;
574 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
575 this, SLOT(change_adaptor()));
576 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
577 this, SLOT(romanChanged(int)));
578 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
579 this, SLOT(change_adaptor()));
580 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
581 this, SLOT(sansChanged(int)));
582 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
583 this, SLOT(change_adaptor()));
584 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
585 this, SLOT(ttChanged(int)));
586 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
587 this, SLOT(change_adaptor()));
588 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
589 this, SLOT(change_adaptor()));
590 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
591 this, SLOT(change_adaptor()));
592 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
593 this, SLOT(change_adaptor()));
594 connect(fontModule->fontScCB, SIGNAL(clicked()),
595 this, SLOT(change_adaptor()));
596 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
597 this, SLOT(change_adaptor()));
599 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
600 QString font = qt_(tex_fonts_roman_gui[n]);
601 if (!isFontAvailable(tex_fonts_roman[n]))
602 font += qt_(" (not installed)");
603 fontModule->fontsRomanCO->addItem(font);
605 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
606 QString font = qt_(tex_fonts_sans_gui[n]);
607 if (!isFontAvailable(tex_fonts_sans[n]))
608 font += qt_(" (not installed)");
609 fontModule->fontsSansCO->addItem(font);
611 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
612 QString font = qt_(tex_fonts_monospaced_gui[n]);
613 if (!isFontAvailable(tex_fonts_monospaced[n]))
614 font += qt_(" (not installed)");
615 fontModule->fontsTypewriterCO->addItem(font);
618 fontModule->fontsizeCO->addItem(qt_("Default"));
619 fontModule->fontsizeCO->addItem(qt_("10"));
620 fontModule->fontsizeCO->addItem(qt_("11"));
621 fontModule->fontsizeCO->addItem(qt_("12"));
623 for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
624 fontModule->fontsDefaultCO->addItem(
625 qt_(GuiDocument::fontfamilies_gui[n]));
628 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
630 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
631 this, SLOT(setCustomPapersize(int)));
632 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
633 this, SLOT(setCustomPapersize(int)));
634 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
635 this, SLOT(portraitChanged()));
636 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
637 this, SLOT(change_adaptor()));
638 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
639 this, SLOT(change_adaptor()));
640 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
641 this, SLOT(change_adaptor()));
642 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
643 this, SLOT(change_adaptor()));
644 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
645 this, SLOT(change_adaptor()));
646 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
647 this, SLOT(change_adaptor()));
648 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
649 this, SLOT(change_adaptor()));
650 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
651 this, SLOT(change_adaptor()));
652 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
653 this, SLOT(change_adaptor()));
655 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
656 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
657 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
658 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
659 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
660 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
661 pageLayoutModule->paperheightL);
662 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
663 pageLayoutModule->paperwidthL);
666 QComboBox * cb = pageLayoutModule->papersizeCO;
667 cb->addItem(qt_("Default"));
668 cb->addItem(qt_("Custom"));
669 cb->addItem(qt_("US letter"));
670 cb->addItem(qt_("US legal"));
671 cb->addItem(qt_("US executive"));
672 cb->addItem(qt_("A3"));
673 cb->addItem(qt_("A4"));
674 cb->addItem(qt_("A5"));
675 cb->addItem(qt_("B3"));
676 cb->addItem(qt_("B4"));
677 cb->addItem(qt_("B5"));
678 // remove the %-items from the unit choice
679 pageLayoutModule->paperwidthUnitCO->noPercents();
680 pageLayoutModule->paperheightUnitCO->noPercents();
681 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
682 pageLayoutModule->paperheightLE));
683 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
684 pageLayoutModule->paperwidthLE));
687 marginsModule = new UiWidget<Ui::MarginsUi>;
689 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
690 this, SLOT(setCustomMargins(bool)));
691 connect(marginsModule->marginCB, SIGNAL(clicked()),
692 this, SLOT(change_adaptor()));
693 connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
694 this, SLOT(change_adaptor()));
695 connect(marginsModule->topUnit, SIGNAL(activated(int)),
696 this, SLOT(change_adaptor()));
697 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
698 this, SLOT(change_adaptor()));
699 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
700 this, SLOT(change_adaptor()));
701 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
702 this, SLOT(change_adaptor()));
703 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
704 this, SLOT(change_adaptor()));
705 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
706 this, SLOT(change_adaptor()));
707 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
708 this, SLOT(change_adaptor()));
709 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
710 this, SLOT(change_adaptor()));
711 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
712 this, SLOT(change_adaptor()));
713 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
714 this, SLOT(change_adaptor()));
715 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
716 this, SLOT(change_adaptor()));
717 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
718 this, SLOT(change_adaptor()));
719 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
720 this, SLOT(change_adaptor()));
721 connect(marginsModule->columnsepLE, SIGNAL(textChanged(const QString&)),
722 this, SLOT(change_adaptor()));
723 connect(marginsModule->columnsepUnit, SIGNAL(activated(int)),
724 this, SLOT(change_adaptor()));
725 marginsModule->topLE->setValidator(unsignedLengthValidator(
726 marginsModule->topLE));
727 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
728 marginsModule->bottomLE));
729 marginsModule->innerLE->setValidator(unsignedLengthValidator(
730 marginsModule->innerLE));
731 marginsModule->outerLE->setValidator(unsignedLengthValidator(
732 marginsModule->outerLE));
733 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
734 marginsModule->headsepLE));
735 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
736 marginsModule->headheightLE));
737 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
738 marginsModule->footskipLE));
739 marginsModule->columnsepLE->setValidator(unsignedLengthValidator(
740 marginsModule->columnsepLE));
742 bc().addCheckedLineEdit(marginsModule->topLE,
743 marginsModule->topL);
744 bc().addCheckedLineEdit(marginsModule->bottomLE,
745 marginsModule->bottomL);
746 bc().addCheckedLineEdit(marginsModule->innerLE,
747 marginsModule->innerL);
748 bc().addCheckedLineEdit(marginsModule->outerLE,
749 marginsModule->outerL);
750 bc().addCheckedLineEdit(marginsModule->headsepLE,
751 marginsModule->headsepL);
752 bc().addCheckedLineEdit(marginsModule->headheightLE,
753 marginsModule->headheightL);
754 bc().addCheckedLineEdit(marginsModule->footskipLE,
755 marginsModule->footskipL);
756 bc().addCheckedLineEdit(marginsModule->columnsepLE,
757 marginsModule->columnsepL);
760 langModule = new UiWidget<Ui::LanguageUi>;
762 connect(langModule->languageCO, SIGNAL(activated(int)),
763 this, SLOT(change_adaptor()));
764 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
765 this, SLOT(change_adaptor()));
766 connect(langModule->otherencodingRB, SIGNAL(clicked()),
767 this, SLOT(change_adaptor()));
768 connect(langModule->encodingCO, SIGNAL(activated(int)),
769 this, SLOT(change_adaptor()));
770 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
771 this, SLOT(change_adaptor()));
773 vector<LanguagePair> const langs = getLanguageData(false);
774 vector<LanguagePair>::const_iterator lit = langs.begin();
775 vector<LanguagePair>::const_iterator lend = langs.end();
776 for (; lit != lend; ++lit) {
777 langModule->languageCO->addItem(toqstr(lit->first));
780 // Always put the default encoding in the first position.
781 // It is special because the displayed text is translated.
782 langModule->encodingCO->addItem(qt_("LaTeX default"));
783 Encodings::const_iterator it = encodings.begin();
784 Encodings::const_iterator const end = encodings.end();
785 for (; it != end; ++it)
786 langModule->encodingCO->addItem(toqstr(it->latexName()));
788 langModule->quoteStyleCO->addItem(qt_("``text''"));
789 langModule->quoteStyleCO->addItem(qt_("''text''"));
790 langModule->quoteStyleCO->addItem(qt_(",,text``"));
791 langModule->quoteStyleCO->addItem(qt_(",,text''"));
792 langModule->quoteStyleCO->addItem(qt_("<<text>>"));
793 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
797 numberingModule = new UiWidget<Ui::NumberingUi>;
799 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
800 this, SLOT(change_adaptor()));
801 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
802 this, SLOT(change_adaptor()));
803 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
804 this, SLOT(updateNumbering()));
805 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
806 this, SLOT(updateNumbering()));
807 numberingModule->tocTW->setColumnCount(3);
808 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
809 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
810 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
813 biblioModule = new UiWidget<Ui::BiblioUi>;
814 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
815 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
816 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
817 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
819 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
820 this, SLOT(change_adaptor()));
821 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
822 this, SLOT(change_adaptor()));
823 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
824 this, SLOT(change_adaptor()));
825 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
826 this, SLOT(change_adaptor()));
827 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
828 this, SLOT(change_adaptor()));
830 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
831 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
832 biblioModule->citeStyleCO->setCurrentIndex(0);
835 mathsModule = new UiWidget<Ui::MathsUi>;
836 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
837 mathsModule->amsCB, SLOT(setDisabled(bool)));
838 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
839 mathsModule->esintCB, SLOT(setDisabled(bool)));
841 connect(mathsModule->amsCB, SIGNAL(clicked()),
842 this, SLOT(change_adaptor()));
843 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
844 this, SLOT(change_adaptor()));
845 connect(mathsModule->esintCB, SIGNAL(clicked()),
846 this, SLOT(change_adaptor()));
847 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
848 this, SLOT(change_adaptor()));
850 latexModule = new UiWidget<Ui::LaTeXUi>;
852 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
853 this, SLOT(change_adaptor()));
854 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
855 this, SLOT(change_adaptor()));
856 connect(latexModule->classCO, SIGNAL(activated(int)),
857 this, SLOT(classChanged()));
858 connect(latexModule->classCO, SIGNAL(activated(int)),
859 this, SLOT(change_adaptor()));
862 new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
863 latexModule->addPB, latexModule->deletePB,
864 latexModule->upPB, latexModule->downPB,
865 availableModel(), selectedModel());
866 connect(selectionManager, SIGNAL(updateHook()),
867 this, SLOT(updateModuleInfo()));
868 connect(selectionManager, SIGNAL(updateHook()),
869 this, SLOT(change_adaptor()));
871 // postscript drivers
872 for (int n = 0; tex_graphics[n][0]; ++n) {
873 QString enc = qt_(tex_graphics_gui[n]);
874 latexModule->psdriverCO->addItem(enc);
877 //FIXME This seems too involved with the kernel. Some of this
878 //should be moved to the kernel---which should perhaps just
879 //give us a list of entries or something of the sort.
880 for (TextClassList::const_iterator cit = textclasslist.begin();
881 cit != textclasslist.end(); ++cit) {
882 if (cit->isTeXClassAvailable()) {
883 latexModule->classCO->addItem(toqstr(cit->description()));
886 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
887 latexModule->classCO->addItem(toqstr(item));
892 branchesModule = new GuiBranches;
893 connect(branchesModule, SIGNAL(changed()),
894 this, SLOT(change_adaptor()));
897 preambleModule = new PreambleModule;
898 connect(preambleModule, SIGNAL(changed()),
899 this, SLOT(change_adaptor()));
902 bulletsModule = new BulletsModule;
903 connect(bulletsModule, SIGNAL(changed()),
904 this, SLOT(change_adaptor()));
907 embeddedFilesModule = new UiWidget<Ui::EmbeddedFilesUi>;
908 connect(embeddedFilesModule->bundleCB, SIGNAL(toggled(bool)),
909 this, SLOT(change_adaptor()));
910 connect(embeddedFilesModule->addPB, SIGNAL(clicked()),
911 this, SLOT(change_adaptor()));
912 connect(embeddedFilesModule->removePB, SIGNAL(clicked()),
913 this, SLOT(change_adaptor()));
916 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
918 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
919 this, SLOT(change_adaptor()));
920 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
921 this, SLOT(change_adaptor()));
922 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
923 this, SLOT(change_adaptor()));
924 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
925 this, SLOT(change_adaptor()));
926 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
927 this, SLOT(change_adaptor()));
928 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
929 this, SLOT(change_adaptor()));
930 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
931 this, SLOT(change_adaptor()));
932 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
933 this, SLOT(change_adaptor()));
934 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
935 this, SLOT(change_adaptor()));
936 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
937 this, SLOT(change_adaptor()));
938 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
939 this, SLOT(change_adaptor()));
940 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
941 this, SLOT(change_adaptor()));
942 connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
943 this, SLOT(change_adaptor()));
944 connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
945 this, SLOT(change_adaptor()));
946 connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
947 this, SLOT(change_adaptor()));
948 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
949 this, SLOT(change_adaptor()));
950 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
951 this, SLOT(change_adaptor()));
954 floatModule = new FloatPlacement;
955 connect(floatModule, SIGNAL(changed()),
956 this, SLOT(change_adaptor()));
958 docPS->addPanel(latexModule, _("Document Class"));
959 docPS->addPanel(fontModule, _("Fonts"));
960 docPS->addPanel(textLayoutModule, _("Text Layout"));
961 docPS->addPanel(pageLayoutModule, _("Page Layout"));
962 docPS->addPanel(marginsModule, _("Page Margins"));
963 docPS->addPanel(langModule, _("Language"));
964 docPS->addPanel(numberingModule, _("Numbering & TOC"));
965 docPS->addPanel(biblioModule, _("Bibliography"));
966 docPS->addPanel(pdfSupportModule, _("PDF Properties"));
967 docPS->addPanel(mathsModule, _("Math Options"));
968 docPS->addPanel(floatModule, _("Float Placement"));
969 docPS->addPanel(bulletsModule, _("Bullets"));
970 docPS->addPanel(branchesModule, _("Branches"));
971 docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
972 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
973 docPS->setCurrentPanel(_("Document Class"));
974 // FIXME: hack to work around resizing bug in Qt >= 4.2
975 // bug verified with Qt 4.2.{0-3} (JSpitzm)
976 #if QT_VERSION >= 0x040200
977 docPS->updateGeometry();
982 void GuiDocument::showPreamble()
984 docPS->setCurrentPanel(_("LaTeX Preamble"));
988 void GuiDocument::saveDefaultClicked()
994 void GuiDocument::useDefaultsClicked()
1000 void GuiDocument::change_adaptor()
1006 docstring GuiDocument::validate_listings_params()
1008 // use a cache here to avoid repeated validation
1009 // of the same parameters
1010 static string param_cache = string();
1011 static docstring msg_cache = docstring();
1013 if (textLayoutModule->bypassCB->isChecked())
1016 string params = fromqstr(textLayoutModule->listingsED->toPlainText());
1017 if (params != param_cache) {
1018 param_cache = params;
1019 msg_cache = InsetListingsParams(params).validate();
1025 void GuiDocument::set_listings_msg()
1027 static bool isOK = true;
1028 docstring msg = validate_listings_params();
1033 // listingsTB->setTextColor("black");
1034 textLayoutModule->listingsTB->setPlainText(
1035 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
1038 // listingsTB->setTextColor("red");
1039 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
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);
1123 marginsModule->columnsepL->setEnabled(!custom);
1124 marginsModule->columnsepLE->setEnabled(!custom);
1125 marginsModule->columnsepUnit->setEnabled(!custom);
1129 void GuiDocument::updateFontsize(string const & items, string const & sel)
1131 fontModule->fontsizeCO->clear();
1132 fontModule->fontsizeCO->addItem(qt_("Default"));
1134 for (int n = 0; !token(items,'|',n).empty(); ++n)
1135 fontModule->fontsizeCO->
1136 addItem(toqstr(token(items,'|',n)));
1138 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
1139 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
1140 fontModule->fontsizeCO->setCurrentIndex(n);
1147 void GuiDocument::romanChanged(int item)
1149 string const font = tex_fonts_roman[item];
1150 fontModule->fontScCB->setEnabled(providesSC(font));
1151 fontModule->fontOsfCB->setEnabled(providesOSF(font));
1155 void GuiDocument::sansChanged(int item)
1157 string const font = tex_fonts_sans[item];
1158 bool scaleable = providesScale(font);
1159 fontModule->scaleSansSB->setEnabled(scaleable);
1160 fontModule->scaleSansLA->setEnabled(scaleable);
1164 void GuiDocument::ttChanged(int item)
1166 string const font = tex_fonts_monospaced[item];
1167 bool scaleable = providesScale(font);
1168 fontModule->scaleTypewriterSB->setEnabled(scaleable);
1169 fontModule->scaleTypewriterLA->setEnabled(scaleable);
1173 void GuiDocument::updatePagestyle(string const & items, string const & sel)
1176 pageLayoutModule->pagestyleCO->clear();
1177 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
1179 for (int n = 0; !token(items,'|',n).empty(); ++n) {
1180 string style = token(items, '|', n);
1181 docstring style_gui = _(style);
1182 pagestyles.push_back(pair<string, docstring>(style, style_gui));
1183 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
1186 if (sel == "default") {
1187 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
1193 for (size_t i = 0; i < pagestyles.size(); ++i)
1194 if (pagestyles[i].first == sel)
1195 nn = pageLayoutModule->pagestyleCO->findText(
1196 toqstr(pagestyles[i].second));
1199 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
1203 void GuiDocument::classChanged()
1205 textclass_type const tc = latexModule->classCO->currentIndex();
1206 bp_.setBaseClass(tc);
1207 if (lyxrc.auto_reset_options) {
1208 if (applyPB->isEnabled()) {
1209 int const ret = Alert::prompt(_("Unapplied changes"),
1210 _("Some changes in the dialog were not yet applied."
1211 "If you do not apply now, they will be lost after this action."),
1212 1, 1, _("&Apply"), _("&Dismiss"));
1216 bp_.useClassDefaults();
1223 //This is an insanely complicated attempt to make this sort of thing
1224 //work with RTL languages.
1225 docstring formatStrVec(vector<string> const & v, docstring const & s)
1227 //this mess formats the list as "v[0], v[1], ..., [s] v[n]"
1228 int const vSize = v.size();
1231 else if (v.size() == 1)
1232 return from_ascii(v[0]);
1233 else if (v.size() == 2) {
1234 docstring retval = _("%1$s and %2$s");
1235 retval = subst(retval, _("and"), s);
1236 return bformat(retval, from_ascii(v[0]), from_ascii(v[1]));
1238 //The idea here is to format all but the last two items...
1239 docstring t2 = _("%1$s, %2$s");
1240 docstring retval = from_ascii(v[0]);
1241 for (int i = 1; i < vSize - 2; ++i)
1242 retval = bformat(t2, retval, from_ascii(v[i]));
1243 //...and then to plug them, and the last two, into this schema
1244 docstring t = _("%1$s, %2$s, and %3$s");
1245 t = subst(t, _("and"), s);
1246 return bformat(t, retval, from_ascii(v[vSize - 2]), from_ascii(v[vSize - 1]));
1249 vector<string> idsToNames(vector<string> const & idList)
1251 vector<string> retval;
1252 vector<string>::const_iterator it = idList.begin();
1253 vector<string>::const_iterator end = idList.end();
1254 for (; it != end; ++it) {
1255 LyXModule const * const mod = moduleList[*it];
1257 retval.push_back(*it + " (Unavailable)");
1259 retval.push_back(mod->getName());
1266 void GuiDocument::updateModuleInfo()
1268 selectionManager->update();
1270 //Module description
1271 bool const focusOnSelected = selectionManager->selectedFocused();
1272 QListView const * const lv =
1273 focusOnSelected ? latexModule->selectedLV : latexModule->availableLV;
1274 if (lv->selectionModel()->selectedIndexes().isEmpty()) {
1275 latexModule->infoML->document()->clear();
1278 QModelIndex const & idx = lv->selectionModel()->currentIndex();
1279 GuiIdListModel const & idModel =
1280 focusOnSelected ? selected_model_ : available_model_;
1281 string const modName = idModel.getIDString(idx.row());
1282 docstring desc = getModuleDescription(modName);
1284 vector<string> pkgList = getPackageList(modName);
1285 docstring pkgdesc = formatStrVec(pkgList, _("and"));
1286 if (!pkgdesc.empty()) {
1289 desc += bformat(_("Package(s) required: %1$s."), pkgdesc);
1292 pkgList = getRequiredList(modName);
1293 if (!pkgList.empty()) {
1294 vector<string> const reqDescs = idsToNames(pkgList);
1295 pkgdesc = formatStrVec(reqDescs, _("or"));
1298 desc += bformat(_("Module required: %1$s."), pkgdesc);
1301 pkgList = getExcludedList(modName);
1302 if (!pkgList.empty()) {
1303 vector<string> const reqDescs = idsToNames(pkgList);
1304 pkgdesc = formatStrVec(reqDescs, _( "and"));
1307 desc += bformat(_("Modules excluded: %1$s."), pkgdesc);
1310 if (!isModuleAvailable(modName)) {
1313 desc += _("WARNING: Some packages are unavailable!");
1316 latexModule->infoML->document()->setPlainText(toqstr(desc));
1320 void GuiDocument::updateEmbeddedFileList()
1322 embeddedFilesModule->filesLW->clear();
1323 // add current embedded files
1324 EmbeddedFileList & files = buffer().embeddedFiles();
1325 files.update(buffer());
1326 EmbeddedFileList::iterator fit = files.begin();
1327 EmbeddedFileList::iterator fit_end = files.end();
1328 for (; fit != fit_end; ++fit) {
1329 QString label = toqstr(fit->relFilename(buffer().filePath()));
1330 if (fit->refCount() > 1)
1331 label += " (" + QString::number(fit->refCount()) + ")";
1332 QListWidgetItem * item = new QListWidgetItem(label);
1333 item->setFlags(item->flags() | Qt::ItemIsSelectable
1334 | Qt::ItemIsUserCheckable);
1336 item->setCheckState(Qt::Checked);
1338 item->setCheckState(Qt::Unchecked);
1339 // index of the currently used ParConstIterator
1340 embeddedFilesModule->filesLW->addItem(item);
1345 void GuiDocument::updateNumbering()
1347 TextClass const & tclass = bp_.getTextClass();
1349 numberingModule->tocTW->setUpdatesEnabled(false);
1350 numberingModule->tocTW->clear();
1352 int const depth = numberingModule->depthSL->value();
1353 int const toc = numberingModule->tocSL->value();
1354 QString const no = qt_("No");
1355 QString const yes = qt_("Yes");
1356 TextClass::const_iterator end = tclass.end();
1357 TextClass::const_iterator cit = tclass.begin();
1358 QTreeWidgetItem * item = 0;
1359 for ( ; cit != end ; ++cit) {
1360 int const toclevel = (*cit)->toclevel;
1361 if (toclevel != Layout::NOT_IN_TOC
1362 && (*cit)->labeltype == LABEL_COUNTER) {
1363 item = new QTreeWidgetItem(numberingModule->tocTW);
1364 item->setText(0, toqstr(translateIfPossible((*cit)->name())));
1365 item->setText(1, (toclevel <= depth) ? yes : no);
1366 item->setText(2, (toclevel <= toc) ? yes : no);
1370 numberingModule->tocTW->setUpdatesEnabled(true);
1371 numberingModule->tocTW->update();
1375 void GuiDocument::apply(BufferParams & params)
1378 preambleModule->apply(params);
1381 params.setCiteEngine(biblio::ENGINE_BASIC);
1383 if (biblioModule->citeNatbibRB->isChecked()) {
1384 bool const use_numerical_citations =
1385 biblioModule->citeStyleCO->currentIndex();
1386 if (use_numerical_citations)
1387 params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1389 params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1391 } else if (biblioModule->citeJurabibRB->isChecked())
1392 params.setCiteEngine(biblio::ENGINE_JURABIB);
1394 params.use_bibtopic =
1395 biblioModule->bibtopicCB->isChecked();
1397 // language & quotes
1398 if (langModule->defaultencodingRB->isChecked()) {
1399 params.inputenc = "auto";
1401 int i = langModule->encodingCO->currentIndex();
1403 params.inputenc = "default";
1406 fromqstr(langModule->encodingCO->currentText());
1409 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1410 switch (langModule->quoteStyleCO->currentIndex()) {
1412 lga = InsetQuotes::EnglishQ;
1415 lga = InsetQuotes::SwedishQ;
1418 lga = InsetQuotes::GermanQ;
1421 lga = InsetQuotes::PolishQ;
1424 lga = InsetQuotes::FrenchQ;
1427 lga = InsetQuotes::DanishQ;
1430 params.quotes_language = lga;
1432 int const pos = langModule->languageCO->currentIndex();
1433 params.language = lyx::languages.getLanguage(lang_[pos]);
1436 if (params.getTextClass().hasTocLevels()) {
1437 params.tocdepth = numberingModule->tocSL->value();
1438 params.secnumdepth = numberingModule->depthSL->value();
1442 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1443 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1444 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1445 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1448 params.graphicsDriver =
1449 tex_graphics[latexModule->psdriverCO->currentIndex()];
1452 params.setBaseClass(latexModule->classCO->currentIndex());
1455 params.clearLayoutModules();
1456 int const srows = selected_model_.rowCount();
1457 vector<string> selModList;
1458 for (int i = 0; i < srows; ++i)
1459 params.addLayoutModule(selected_model_.getIDString(i));
1461 if (mathsModule->amsautoCB->isChecked()) {
1462 params.use_amsmath = BufferParams::package_auto;
1464 if (mathsModule->amsCB->isChecked())
1465 params.use_amsmath = BufferParams::package_on;
1467 params.use_amsmath = BufferParams::package_off;
1470 if (mathsModule->esintautoCB->isChecked())
1471 params.use_esint = BufferParams::package_auto;
1473 if (mathsModule->esintCB->isChecked())
1474 params.use_esint = BufferParams::package_on;
1476 params.use_esint = BufferParams::package_off;
1479 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1480 params.pagestyle = "default";
1482 docstring style_gui =
1483 qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1484 for (size_t i = 0; i < pagestyles.size(); ++i)
1485 if (pagestyles[i].second == style_gui)
1486 params.pagestyle = pagestyles[i].first;
1489 switch (textLayoutModule->lspacingCO->currentIndex()) {
1491 params.spacing().set(Spacing::Single);
1494 params.spacing().set(Spacing::Onehalf);
1497 params.spacing().set(Spacing::Double);
1500 params.spacing().set(Spacing::Other,
1501 fromqstr(textLayoutModule->lspacingLE->text()));
1505 if (textLayoutModule->twoColumnCB->isChecked())
1510 // text should have passed validation
1511 params.listings_params =
1512 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1514 if (textLayoutModule->indentRB->isChecked())
1515 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1517 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1519 switch (textLayoutModule->skipCO->currentIndex()) {
1521 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1524 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1527 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1532 widgetsToLength(textLayoutModule->skipLE,
1533 textLayoutModule->skipLengthCO)
1535 params.setDefSkip(vs);
1539 // DocumentDefskipCB assures that this never happens
1540 // so Assert then !!! - jbl
1541 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1546 fromqstr(latexModule->optionsLE->text());
1548 params.float_placement = floatModule->get();
1552 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1555 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1557 params.fontsTypewriter =
1558 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1560 params.fontsSansScale = fontModule->scaleSansSB->value();
1562 params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1564 params.fontsSC = fontModule->fontScCB->isChecked();
1566 params.fontsOSF = fontModule->fontOsfCB->isChecked();
1568 params.fontsDefaultFamily = GuiDocument::fontfamilies[
1569 fontModule->fontsDefaultCO->currentIndex()];
1571 if (fontModule->fontsizeCO->currentIndex() == 0)
1572 params.fontsize = "default";
1575 fromqstr(fontModule->fontsizeCO->currentText());
1578 params.papersize = PAPER_SIZE(
1579 pageLayoutModule->papersizeCO->currentIndex());
1581 // custom, A3, B3 and B4 paper sizes need geometry
1582 int psize = pageLayoutModule->papersizeCO->currentIndex();
1583 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1585 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1586 pageLayoutModule->paperwidthUnitCO);
1588 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1589 pageLayoutModule->paperheightUnitCO);
1591 if (pageLayoutModule->facingPagesCB->isChecked())
1592 params.sides = TwoSides;
1594 params.sides = OneSide;
1596 if (pageLayoutModule->landscapeRB->isChecked())
1597 params.orientation = ORIENTATION_LANDSCAPE;
1599 params.orientation = ORIENTATION_PORTRAIT;
1602 params.use_geometry =
1603 (!marginsModule->marginCB->isChecked()
1606 Ui::MarginsUi const * m(marginsModule);
1608 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1609 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1610 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1611 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1612 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1613 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1614 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1615 params.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit);
1617 branchesModule->apply(params);
1620 PDFOptions & pdf = params.pdfoptions();
1621 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
1622 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1623 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1624 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1625 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1627 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1628 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1629 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1630 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
1632 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
1633 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
1634 pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
1635 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
1636 pdf.backref = pdfSupportModule->backrefCB->isChecked();
1637 pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
1638 if (pdfSupportModule->fullscreenCB->isChecked())
1639 pdf.pagemode = pdf.pagemode_fullscreen;
1641 pdf.pagemode.clear();
1642 pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1649 /** Return the position of val in the vector if found.
1650 If not found, return 0.
1653 static size_t findPos(vector<A> const & vec, A const & val)
1655 typename vector<A>::const_iterator it =
1656 find(vec.begin(), vec.end(), val);
1657 if (it == vec.end())
1659 return distance(vec.begin(), it);
1663 void GuiDocument::updateParams()
1669 void GuiDocument::updateParams(BufferParams const & params)
1671 // set the default unit
1672 Length::UNIT defaultUnit = Length::CM;
1673 switch (lyxrc.default_papersize) {
1674 case PAPER_DEFAULT: break;
1676 case PAPER_USLETTER:
1678 case PAPER_USEXECUTIVE:
1679 defaultUnit = Length::IN;
1688 defaultUnit = Length::CM;
1695 preambleModule->update(params, id());
1698 biblioModule->citeDefaultRB->setChecked(
1699 params.getEngine() == biblio::ENGINE_BASIC);
1701 biblioModule->citeNatbibRB->setChecked(
1702 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1703 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1705 biblioModule->citeStyleCO->setCurrentIndex(
1706 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1708 biblioModule->citeJurabibRB->setChecked(
1709 params.getEngine() == biblio::ENGINE_JURABIB);
1711 biblioModule->bibtopicCB->setChecked(
1712 params.use_bibtopic);
1714 // language & quotes
1715 int const pos = int(findPos(lang_,
1716 params.language->lang()));
1717 langModule->languageCO->setCurrentIndex(pos);
1719 langModule->quoteStyleCO->setCurrentIndex(
1720 params.quotes_language);
1722 bool default_enc = true;
1723 if (params.inputenc != "auto") {
1724 default_enc = false;
1725 if (params.inputenc == "default") {
1726 langModule->encodingCO->setCurrentIndex(0);
1728 int const i = langModule->encodingCO->findText(
1729 toqstr(params.inputenc));
1731 langModule->encodingCO->setCurrentIndex(i);
1733 // unknown encoding. Set to default.
1737 langModule->defaultencodingRB->setChecked(default_enc);
1738 langModule->otherencodingRB->setChecked(!default_enc);
1741 int const min_toclevel = textClass().min_toclevel();
1742 int const max_toclevel = textClass().max_toclevel();
1743 if (textClass().hasTocLevels()) {
1744 numberingModule->setEnabled(true);
1745 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1746 numberingModule->depthSL->setMaximum(max_toclevel);
1747 numberingModule->depthSL->setValue(params.secnumdepth);
1748 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1749 numberingModule->tocSL->setMaximum(max_toclevel);
1750 numberingModule->tocSL->setValue(params.tocdepth);
1753 numberingModule->setEnabled(false);
1754 numberingModule->tocTW->clear();
1758 bulletsModule->setBullet(0, params.user_defined_bullet(0));
1759 bulletsModule->setBullet(1, params.user_defined_bullet(1));
1760 bulletsModule->setBullet(2, params.user_defined_bullet(2));
1761 bulletsModule->setBullet(3, params.user_defined_bullet(3));
1762 bulletsModule->init();
1765 int nitem = findToken(tex_graphics, params.graphicsDriver);
1767 latexModule->psdriverCO->setCurrentIndex(nitem);
1770 mathsModule->amsCB->setChecked(
1771 params.use_amsmath == BufferParams::package_on);
1772 mathsModule->amsautoCB->setChecked(
1773 params.use_amsmath == BufferParams::package_auto);
1775 mathsModule->esintCB->setChecked(
1776 params.use_esint == BufferParams::package_on);
1777 mathsModule->esintautoCB->setChecked(
1778 params.use_esint == BufferParams::package_auto);
1780 switch (params.spacing().getSpace()) {
1781 case Spacing::Other: nitem = 3; break;
1782 case Spacing::Double: nitem = 2; break;
1783 case Spacing::Onehalf: nitem = 1; break;
1784 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1788 latexModule->classCO->setCurrentIndex(params.getBaseClass());
1790 updatePagestyle(textClass().opt_pagestyle(),
1793 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1794 if (params.spacing().getSpace() == Spacing::Other) {
1795 textLayoutModule->lspacingLE->setText(
1796 toqstr(params.spacing().getValueAsString()));
1800 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1801 textLayoutModule->indentRB->setChecked(true);
1803 textLayoutModule->skipRB->setChecked(true);
1806 switch (params.getDefSkip().kind()) {
1807 case VSpace::SMALLSKIP:
1810 case VSpace::MEDSKIP:
1813 case VSpace::BIGSKIP:
1816 case VSpace::LENGTH:
1819 string const length = params.getDefSkip().asLyXCommand();
1820 lengthToWidgets(textLayoutModule->skipLE,
1821 textLayoutModule->skipLengthCO,
1822 length, defaultUnit);
1829 textLayoutModule->skipCO->setCurrentIndex(skip);
1832 textLayoutModule->twoColumnCB->setChecked(
1833 params.columns == 2);
1835 // break listings_params to multiple lines
1837 InsetListingsParams(params.listings_params).separatedParams();
1838 textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1840 if (!params.options.empty()) {
1841 latexModule->optionsLE->setText(
1842 toqstr(params.options));
1844 latexModule->optionsLE->setText(QString());
1847 floatModule->set(params.float_placement);
1850 updateFontsize(textClass().opt_fontsize(),
1853 int n = findToken(tex_fonts_roman, params.fontsRoman);
1855 fontModule->fontsRomanCO->setCurrentIndex(n);
1859 n = findToken(tex_fonts_sans, params.fontsSans);
1861 fontModule->fontsSansCO->setCurrentIndex(n);
1865 n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1867 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1871 fontModule->fontScCB->setChecked(params.fontsSC);
1872 fontModule->fontOsfCB->setChecked(params.fontsOSF);
1873 fontModule->scaleSansSB->setValue(params.fontsSansScale);
1874 fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1875 n = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
1877 fontModule->fontsDefaultCO->setCurrentIndex(n);
1880 int const psize = params.papersize;
1881 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1882 setCustomPapersize(psize);
1884 bool const landscape =
1885 params.orientation == ORIENTATION_LANDSCAPE;
1886 pageLayoutModule->landscapeRB->setChecked(landscape);
1887 pageLayoutModule->portraitRB->setChecked(!landscape);
1889 pageLayoutModule->facingPagesCB->setChecked(
1890 params.sides == TwoSides);
1893 lengthToWidgets(pageLayoutModule->paperwidthLE,
1894 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1896 lengthToWidgets(pageLayoutModule->paperheightLE,
1897 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1900 Ui::MarginsUi * m = marginsModule;
1902 setMargins(!params.use_geometry);
1904 lengthToWidgets(m->topLE, m->topUnit,
1905 params.topmargin, defaultUnit);
1907 lengthToWidgets(m->bottomLE, m->bottomUnit,
1908 params.bottommargin, defaultUnit);
1910 lengthToWidgets(m->innerLE, m->innerUnit,
1911 params.leftmargin, defaultUnit);
1913 lengthToWidgets(m->outerLE, m->outerUnit,
1914 params.rightmargin, defaultUnit);
1916 lengthToWidgets(m->headheightLE, m->headheightUnit,
1917 params.headheight, defaultUnit);
1919 lengthToWidgets(m->headsepLE, m->headsepUnit,
1920 params.headsep, defaultUnit);
1922 lengthToWidgets(m->footskipLE, m->footskipUnit,
1923 params.footskip, defaultUnit);
1925 lengthToWidgets(m->columnsepLE, m->columnsepUnit,
1926 params.columnsep, defaultUnit);
1928 branchesModule->update(params);
1931 PDFOptions const & pdf = params.pdfoptions();
1932 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
1933 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1934 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1935 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1936 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1938 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1939 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1940 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1942 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
1944 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1945 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1946 pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
1947 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1948 pdfSupportModule->backrefCB->setChecked(pdf.backref);
1949 pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1950 pdfSupportModule->fullscreenCB->setChecked
1951 (pdf.pagemode == pdf.pagemode_fullscreen);
1953 pdfSupportModule->optionsLE->setText(
1954 toqstr(pdf.quoted_options));
1957 updateEmbeddedFileList();
1961 void GuiDocument::applyView()
1967 void GuiDocument::saveDocDefault()
1969 // we have to apply the params first
1975 void GuiDocument::updateAvailableModules()
1977 available_model_.clear();
1978 vector<modInfoStruct> const modInfoList = getModuleInfo();
1979 int const mSize = modInfoList.size();
1980 for (int i = 0; i < mSize; ++i) {
1981 modInfoStruct const & modInfo = modInfoList[i];
1982 available_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
1987 void GuiDocument::updateSelectedModules()
1989 //and selected ones, too
1990 selected_model_.clear();
1991 vector<modInfoStruct> const selModList = getSelectedModules();
1992 int const sSize = selModList.size();
1993 for (int i = 0; i < sSize; ++i) {
1994 modInfoStruct const & modInfo = selModList[i];
1995 selected_model_.insertRow(i, qt_(modInfo.name), modInfo.id);
2000 void GuiDocument::updateContents()
2002 if (id() == current_id_)
2005 updateAvailableModules();
2006 updateSelectedModules();
2008 //FIXME It'd be nice to make sure here that the selected
2009 //modules are consistent: That required modules are actually
2010 //selected, and that we don't have conflicts. If so, we could
2011 //at least pop up a warning.
2017 void GuiDocument::forceUpdate()
2019 // reset to force dialog update
2025 void GuiDocument::useClassDefaults()
2027 if (applyPB->isEnabled()) {
2028 int const ret = Alert::prompt(_("Unapplied changes"),
2029 _("Some changes in the dialog were not yet applied."
2030 "If you do not apply now, they will be lost after this action."),
2031 1, 1, _("&Apply"), _("&Dismiss"));
2036 bp_.setBaseClass(latexModule->classCO->currentIndex());
2037 bp_.useClassDefaults();
2042 bool GuiDocument::isValid()
2044 return (validate_listings_params().empty() &&
2045 (textLayoutModule->skipCO->currentIndex() != 3 ||
2046 !textLayoutModule->skipLE->text().isEmpty()));
2050 char const * const GuiDocument::fontfamilies[5] = {
2051 "default", "rmdefault", "sfdefault", "ttdefault", ""
2055 char const * GuiDocument::fontfamilies_gui[5] = {
2056 N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
2060 bool GuiDocument::initialiseParams(string const &)
2062 bp_ = buffer().params();
2068 void GuiDocument::clearParams()
2070 bp_ = BufferParams();
2074 BufferId GuiDocument::id() const
2080 vector<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
2082 return moduleNames_;
2086 vector<GuiDocument::modInfoStruct> const GuiDocument::getSelectedModules()
2088 vector<string> const & mods = params().getModules();
2089 vector<string>::const_iterator it = mods.begin();
2090 vector<string>::const_iterator end = mods.end();
2091 vector<modInfoStruct> mInfo;
2092 for (; it != end; ++it) {
2095 LyXModule * mod = moduleList[*it];
2097 m.name = mod->getName();
2099 m.name = *it + " (Not Found)";
2106 TextClass const & GuiDocument::textClass() const
2108 return textclasslist[bp_.getBaseClass()];
2112 static void dispatch_bufferparams(Dialog const & dialog,
2113 BufferParams const & bp, kb_action lfun)
2116 ss << "\\begin_header\n";
2118 ss << "\\end_header\n";
2119 dialog.dispatch(FuncRequest(lfun, ss.str()));
2123 void GuiDocument::dispatchParams()
2125 // This must come first so that a language change is correctly noticed
2128 // Apply the BufferParams. Note that this will set the base class
2129 // and then update the buffer's layout.
2130 dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
2132 // Generate the colours requested by each new branch.
2133 BranchList & branchlist = params().branchlist();
2134 if (!branchlist.empty()) {
2135 BranchList::const_iterator it = branchlist.begin();
2136 BranchList::const_iterator const end = branchlist.end();
2137 for (; it != end; ++it) {
2138 docstring const & current_branch = it->getBranch();
2139 Branch const * branch = branchlist.find(current_branch);
2140 string const x11hexname = X11hexname(branch->getColor());
2141 // display the new color
2142 docstring const str = current_branch + ' ' + from_ascii(x11hexname);
2143 dispatch(FuncRequest(LFUN_SET_COLOR, str));
2146 // Open insets of selected branches, close deselected ones
2147 dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
2150 // FIXME: If we used an LFUN, we would not need those two lines:
2151 bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
2155 void GuiDocument::setLanguage() const
2157 Language const * const newL = bp_.language;
2158 if (buffer().params().language == newL)
2161 string const & lang_name = newL->lang();
2162 dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
2166 void GuiDocument::saveAsDefault() const
2168 dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
2172 bool GuiDocument::isFontAvailable(string const & font) const
2174 if (font == "default" || font == "cmr"
2175 || font == "cmss" || font == "cmtt")
2176 // these are standard
2178 if (font == "lmodern" || font == "lmss" || font == "lmtt")
2179 return LaTeXFeatures::isAvailable("lmodern");
2180 if (font == "times" || font == "palatino"
2181 || font == "helvet" || font == "courier")
2182 return LaTeXFeatures::isAvailable("psnfss");
2183 if (font == "cmbr" || font == "cmtl")
2184 return LaTeXFeatures::isAvailable("cmbright");
2185 if (font == "utopia")
2186 return LaTeXFeatures::isAvailable("utopia")
2187 || LaTeXFeatures::isAvailable("fourier");
2188 if (font == "beraserif" || font == "berasans"
2189 || font == "beramono")
2190 return LaTeXFeatures::isAvailable("bera");
2191 return LaTeXFeatures::isAvailable(font);
2195 bool GuiDocument::providesOSF(string const & font) const
2198 return isFontAvailable("eco");
2199 if (font == "palatino")
2200 return isFontAvailable("mathpazo");
2205 bool GuiDocument::providesSC(string const & font) const
2207 if (font == "palatino")
2208 return isFontAvailable("mathpazo");
2209 if (font == "utopia")
2210 return isFontAvailable("fourier");
2215 bool GuiDocument::providesScale(string const & font) const
2217 return font == "helvet" || font == "luximono"
2218 || font == "berasans" || font == "beramono";
2222 void GuiDocument::loadModuleInfo()
2224 moduleNames_.clear();
2225 LyXModuleList::const_iterator it = moduleList.begin();
2226 LyXModuleList::const_iterator end = moduleList.end();
2227 for (; it != end; ++it) {
2230 m.name = it->getName();
2231 moduleNames_.push_back(m);
2236 Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
2239 } // namespace frontend
2242 #include "GuiDocument_moc.cpp"