#include "GuiDocument.h"
+#include "GuiApplication.h"
+#include "GuiBranches.h"
+#include "LaTeXHighlighter.h"
+#include "LengthCombo.h"
+#include "PanelStack.h"
+#include "Validator.h"
+
#include "LayoutFile.h"
#include "BranchList.h"
#include "buffer_funcs.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "FuncRequest.h"
-#include "support/gettext.h"
-#include "GuiBranches.h"
#include "Language.h"
#include "LaTeXFeatures.h"
-#include "LaTeXHighlighter.h"
#include "Layout.h"
-#include "LengthCombo.h"
#include "LyXRC.h" // defaultUnit
#include "ModuleList.h"
#include "OutputParams.h"
-#include "PanelStack.h"
#include "PDFOptions.h"
#include "qt_helpers.h"
#include "Spacing.h"
-#include "Validator.h"
#include "insets/InsetListingsParams.h"
#include "support/debug.h"
#include "support/FileName.h"
-#include "support/FileFilterList.h"
#include "support/filetools.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include "frontends/alert.h"
+#include <QAbstractItemModel>
#include <QCloseEvent>
#include <QScrollBar>
#include <QTextCursor>
GuiDocument::GuiDocument(GuiView & lv)
- : GuiDialog(lv, "document", qt_("Document Settings")), current_id_(0)
+ : GuiDialog(lv, "document", qt_("Document Settings"))
{
setupUi(this);
- QList<LanguagePair> langs = languageData(false);
- for (int i = 0; i != langs.size(); ++i)
- lang_.append(langs[i].second);
-
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
this, SLOT(change_adaptor()));
connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
// language & quotes
-
- QList<LanguagePair>::const_iterator lit = langs.begin();
- QList<LanguagePair>::const_iterator lend = langs.end();
- for (; lit != lend; ++lit)
- langModule->languageCO->addItem(lit->first);
+ QAbstractItemModel * language_model = guiApp->languageModel();
+ // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
+ language_model->sort(0);
+ langModule->languageCO->setModel(language_model);
// Always put the default encoding in the first position.
// It is special because the displayed text is translated.
this, SLOT(change_adaptor()));
connect(latexModule->layoutPB, SIGNAL(clicked()),
this, SLOT(browseLayout()));
+ connect(latexModule->childDocGB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(latexModule->childDocLE, SIGNAL(textChanged(const QString &)),
+ this, SLOT(change_adaptor()));
+ connect(latexModule->childDocPB, SIGNAL(clicked()),
+ this, SLOT(browseMaster()));
selectionManager =
new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
{
QString const label1 = qt_("Layouts|#o#O");
QString const dir1 = toqstr(lyxrc.document_path);
- FileFilterList const filter(_("LyX Layout (*.layout)"));
+ QStringList const filter(qt_("LyX Layout (*.layout)"));
QString file = browseRelFile(QString(), bufferFilepath(),
qt_("Local layout file"), filter, false,
label1, dir1);
- if (!suffixIs(fromqstr(file), ".layout"))
+ if (!file.endsWith(".layout"))
return;
- FileName layoutFile = makeAbsPath(fromqstr(file),
+ FileName layoutFile = support::makeAbsPath(fromqstr(file),
fromqstr(bufferFilepath()));
// load the layout file
}
+void GuiDocument::browseMaster()
+{
+ QString const title = qt_("Select master document");
+ QString const dir1 = toqstr(lyxrc.document_path);
+ QString const old = latexModule->childDocLE->text();
+ QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
+ QStringList const filter(qt_("LyX Files (*.lyx)"));
+ QString file = browseRelFile(old, docpath, title, filter, false,
+ qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
+
+ latexModule->childDocLE->setText(file);
+}
+
+
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
setLayoutComboByIDString(bp_.baseClassID());
return;
}
- } else if (prefixIs(classname, LayoutFileList::embeddedPrefix)) {
- int const ret = Alert::prompt(_("Embedded layout"),
- _("The layout file you have selected is an embedded layout that\n"
- "is embedded to a buffer. You cannot make use of it unless\n"
- "it is already embedded to this buffer.\n"),
- 1, 1, _("&Set Layout"), _("&Cancel"));
- if (ret == 1) {
- setLayoutComboByIDString(bp_.baseClassID());
- return;
- }
}
// FIXME Note that by doing things this way, we load the TextClass
// as soon as it is selected. So, if you use the scroll wheel when
applyView();
}
bp_.useClassDefaults();
- forceUpdate();
+ paramsToDialog(bp_);
}
}
preambleModule->apply(params);
// biblio
- params.setCiteEngine(biblio::ENGINE_BASIC);
+ params.setCiteEngine(ENGINE_BASIC);
if (biblioModule->citeNatbibRB->isChecked()) {
bool const use_numerical_citations =
biblioModule->citeStyleCO->currentIndex();
if (use_numerical_citations)
- params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
+ params.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
else
- params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
+ params.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
} else if (biblioModule->citeJurabibRB->isChecked())
- params.setCiteEngine(biblio::ENGINE_JURABIB);
+ params.setCiteEngine(ENGINE_JURABIB);
params.use_bibtopic =
biblioModule->bibtopicCB->isChecked();
}
params.quotes_language = lga;
- int const pos = langModule->languageCO->currentIndex();
- params.language = lyx::languages.getLanguage(fromqstr(lang_[pos]));
+ QString const lang = langModule->languageCO->itemData(
+ langModule->languageCO->currentIndex()).toString();
+ params.language = lyx::languages.getLanguage(fromqstr(lang));
// numbering
if (params.documentClass().hasTocLevels()) {
params.options =
fromqstr(latexModule->optionsLE->text());
+ if (latexModule->childDocGB->isChecked())
+ params.master =
+ fromqstr(latexModule->childDocLE->text());
+ else
+ params.master = string();
+
params.float_placement = floatModule->get();
// fonts
params.fontsTypewriter =
tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+ params.fontsCJK =
+ fromqstr(fontModule->cjkFontLE->text());
+
params.fontsSansScale = fontModule->scaleSansSB->value();
params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
}
-static int findPos(QStringList const & vec, QString const & val)
-{
- for (int i = 0; i != vec.size(); ++i)
- if (vec[i] == val)
- return i;
- return 0;
-}
-
-
-void GuiDocument::updateParams()
-{
- updateParams(bp_);
-}
-
-
-void GuiDocument::updateParams(BufferParams const & params)
+void GuiDocument::paramsToDialog(BufferParams const & params)
{
// set the default unit
Length::UNIT defaultUnit = Length::CM;
// biblio
biblioModule->citeDefaultRB->setChecked(
- params.citeEngine() == biblio::ENGINE_BASIC);
+ params.citeEngine() == ENGINE_BASIC);
biblioModule->citeNatbibRB->setChecked(
- params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
- params.citeEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
+ params.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
+ params.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
biblioModule->citeStyleCO->setCurrentIndex(
- params.citeEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
+ params.citeEngine() == ENGINE_NATBIB_NUMERICAL);
biblioModule->citeJurabibRB->setChecked(
- params.citeEngine() == biblio::ENGINE_JURABIB);
+ params.citeEngine() == ENGINE_JURABIB);
biblioModule->bibtopicCB->setChecked(
params.use_bibtopic);
// language & quotes
- int const pos = findPos(lang_, toqstr(params.language->lang()));
+ int const pos = langModule->languageCO->findData(toqstr(
+ params.language->lang()));
langModule->languageCO->setCurrentIndex(pos);
langModule->quoteStyleCO->setCurrentIndex(
latexModule->optionsLE->setText(QString());
}
+ if (!params.master.empty()) {
+ latexModule->childDocGB->setChecked(true);
+ latexModule->childDocLE->setText(
+ toqstr(params.master));
+ } else {
+ latexModule->childDocLE->setText(QString());
+ latexModule->childDocGB->setChecked(false);
+ }
+
floatModule->set(params.float_placement);
// Fonts
ttChanged(n);
}
+ if (!params.fontsCJK.empty())
+ fontModule->cjkFontLE->setText(
+ toqstr(params.fontsCJK));
+ else
+ fontModule->cjkFontLE->setText(QString());
+
fontModule->fontScCB->setChecked(params.fontsSC);
fontModule->fontOsfCB->setChecked(params.fontsOSF);
fontModule->scaleSansSB->setValue(params.fontsSansScale);
void GuiDocument::updateContents()
{
- if (id() == current_id_)
- return;
-
- updateAvailableModules();
- updateSelectedModules();
-
- //FIXME It'd be nice to make sure here that the selected
- //modules are consistent: That required modules are actually
- //selected, and that we don't have conflicts. If so, we could
- //at least pop up a warning.
- updateParams(bp_);
- current_id_ = id();
-}
-
-
-void GuiDocument::forceUpdate()
-{
- // reset to force dialog update
- current_id_ = 0;
- updateContents();
+ // Nothing to do here as the document settings is not cursor dependant.
+ return;
}
return;
}
bp_.useClassDefaults();
- forceUpdate();
+ paramsToDialog(bp_);
}
bool GuiDocument::initialiseParams(string const &)
{
- bp_ = buffer().params();
+ BufferView * view = bufferview();
+ if (!view) {
+ bp_ = BufferParams();
+ paramsToDialog(bp_);
+ return true;
+ }
+ bp_ = view->buffer().params();
loadModuleInfo();
+ updateAvailableModules();
+ updateSelectedModules();
+ //FIXME It'd be nice to make sure here that the selected
+ //modules are consistent: That required modules are actually
+ //selected, and that we don't have conflicts. If so, we could
+ //at least pop up a warning.
+ paramsToDialog(bp_);
return true;
}
BufferId GuiDocument::id() const
{
- return &buffer();
+ BufferView const * const view = bufferview();
+ return view? &view->buffer() : 0;
}
// and then update the buffer's layout.
dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
+ if (!params().master.empty()) {
+ FileName const master_file = support::makeAbsPath(params().master,
+ support::onlyPath(buffer().absFileName()));
+ if (isLyXFilename(master_file.absFilename())) {
+ Buffer * master = checkAndLoadLyXFile(master_file);
+ buffer().setParent(master);
+ }
+ }
+
// Generate the colours requested by each new branch.
BranchList & branchlist = params().branchlist();
if (!branchlist.empty()) {