]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
move languageData() out of qt_helpers.cpp
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index bc4864fce3185513e5efe6dace3ab231284787d2..815912207c1079f19ecea0fc9a232ebf0906976f 100644 (file)
@@ -43,7 +43,6 @@
 
 #include "support/debug.h"
 #include "support/FileName.h"
-#include "support/FileFilterList.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
@@ -511,10 +510,6 @@ GuiDocument::GuiDocument(GuiView & lv)
 {
        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()));
@@ -791,10 +786,12 @@ GuiDocument::GuiDocument(GuiView & lv)
                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);
+       Languages::const_iterator lit = languages.begin();
+       Languages::const_iterator lend = languages.end();
+       for (; lit != lend; ++lit) {
+               lang_.append(toqstr(lit->second.lang()));
+               langModule->languageCO->addItem(qt_(lit->second.display()));
+       }
 
        // Always put the default encoding in the first position.
        // It is special because the displayed text is translated.
@@ -877,6 +874,12 @@ GuiDocument::GuiDocument(GuiView & lv)
                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, 
@@ -1223,15 +1226,15 @@ void GuiDocument::browseLayout()
 {
        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
@@ -1263,6 +1266,20 @@ void GuiDocument::browseLayout()
 }
 
 
+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();
@@ -1611,6 +1628,12 @@ void GuiDocument::apply(BufferParams & params)
        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
@@ -1902,6 +1925,15 @@ void GuiDocument::updateParams(BufferParams const & params)
                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
@@ -2133,6 +2165,8 @@ char const * GuiDocument::fontfamilies_gui[5] = {
 bool GuiDocument::initialiseParams(string const &)
 {
        bp_ = buffer().params();
+       // Force update on next updateContent() round.
+       current_id_ = 0;
        loadModuleInfo();
        return true;
 }
@@ -2202,6 +2236,15 @@ void GuiDocument::dispatchParams()
        // 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()) {