]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
We don't want the document dialog to be reset for each new paragraph.
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index cb9aefaa8f5e4dfce0da85ebd0df3b3330127b14..0e42f8f720690ecbef9a74a2a1b366bfd6447c67 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"
 
@@ -877,6 +876,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 +1228,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 +1268,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();
@@ -1282,16 +1301,6 @@ void GuiDocument::classChanged()
                        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
@@ -1450,18 +1459,18 @@ void GuiDocument::apply(BufferParams & params)
        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();
@@ -1621,6 +1630,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
@@ -1764,17 +1779,17 @@ void GuiDocument::updateParams(BufferParams const & params)
 
        // 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);
@@ -1912,6 +1927,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
@@ -2143,6 +2167,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;
 }
@@ -2212,6 +2238,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()) {