]> git.lyx.org Git - features.git/commitdiff
support for default master document.
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 28 Apr 2008 16:38:56 +0000 (16:38 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 28 Apr 2008 16:38:56 +0000 (16:38 +0000)
file format change.

This is the last feature for today. Promised.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24540 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/ui/LaTeXUi.ui

index 3e4676186d4d306150f2accd1dffeef16bd0847a..3dda47ea9a49c95144dce78ec4e8c628378050f7 100644 (file)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2008-04-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+       * Format incremented to 329: new param \master.
+
 2008-04-18 Bo Peng <ben.bob@gmail.com>
        * Format incremented to 328: Revert the support for embedding
 
index cae99b7e5254342c541eaca5495b0e71f55969f0..b4b9648a72280770c95695c549397f70daa83e90 100644 (file)
@@ -80,7 +80,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_3",     [221], minor_versions("1.3" , 7)),
                    ("1_4", range(222,246), minor_versions("1.4" , 5)),
                    ("1_5", range(246,277), minor_versions("1.5" , 2)),
-                   ("1_6", range(277,329), minor_versions("1.6" , 0))] # Uwe: support for Spanish(Mexico)
+                   ("1_6", range(277,330), minor_versions("1.6" , 0))]
 
 
 def formats_list():
index 4eee35daf2b8577db28696a3e6ab6363013f39a9..60b1e31be1a9acdc8011dc7f9a00d389f0a59c36 100644 (file)
@@ -1977,7 +1977,7 @@ def revert_pdfpages(document):
 
 
 def revert_mexican(document):
-    "Set language Spanish(Mexico) to Spanish"
+    ' Set language Spanish(Mexico) to Spanish '
     i = 0
     if document.language == "spanish-mexico":
         document.language = "spanish"
@@ -1994,13 +1994,20 @@ def revert_mexican(document):
 
 
 def remove_embedding(document):
-    ' Remove embed tag from all insets'
+    ' Remove embed tag from all insets '
     revert_inset_embedding(document, 'Graphics')
     revert_inset_embedding(document, 'External')
     revert_inset_embedding(document, 'CommandInset include')
     revert_inset_embedding(document, 'CommandInset bibtex')
 
 
+def revert_master(document):
+    ' Remove master param '
+    i = find_token(document.header, "\\master", 0)
+    if i != -1:
+        del document.header[i]
+
+
 ##
 # Conversion hub
 #
@@ -2058,9 +2065,11 @@ convert = [[277, [fix_wrong_tables]],
            [326, []],
            [327, []],
            [328, [remove_embedding, remove_extra_embedded_files, remove_inzip_options]],
+           [329, []],
           ]
 
-revert =  [[327, []],
+revert =  [[328, [revert_master]],
+           [327, []],
            [326, [revert_mexican]],
            [325, [revert_pdfpages]],
            [324, []],
index 2caf701774cb5387551f997ec1e8da9c3a84e940..686fee33c4cb43158ad7d7e8a8372ccc5ddfe9f5 100644 (file)
@@ -115,7 +115,7 @@ namespace os = support::os;
 
 namespace {
 
-int const LYX_FORMAT = 328;
+int const LYX_FORMAT = 329;
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -441,6 +441,7 @@ int Buffer::readHeader(Lexer & lex)
        params().branchlist().clear();
        params().preamble.erase();
        params().options.erase();
+       params().master.erase();
        params().float_placement.erase();
        params().paperwidth.erase();
        params().paperheight.erase();
@@ -550,6 +551,15 @@ bool Buffer::readDocument(Lexer & lex)
                }
        }
 
+       if (!params().master.empty()) {
+               FileName const master_file = makeAbsPath(params().master,
+                          onlyPath(absFileName()));
+               if (isLyXFilename(master_file.absFilename())) {
+                       Buffer * master = checkAndLoadLyXFile(master_file);
+                       d->parent_buffer = master;
+               }
+       }
+
        // read main text
        bool const res = text().read(*this, lex, errorList, &(d->inset));
 
index 7477a9ac5123b3fdca4957de15b869e2e4fd4512..3f52f99702c0db6175f900fe5b62662ef5335e54 100644 (file)
@@ -497,6 +497,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\options") {
                lex.eatLine();
                options = lex.getString();
+       } else if (token == "\\master") {
+               lex.eatLine();
+               master = lex.getString();
        } else if (token == "\\language") {
                readLanguage(lex);
        } else if (token == "\\inputencoding") {
@@ -688,6 +691,11 @@ void BufferParams::writeFile(ostream & os) const
        if (!options.empty()) {
                os << "\\options " << options << '\n';
        }
+
+       // the master document
+       if (!master.empty()) {
+               os << "\\master " << master << '\n';
+       }
        
        //the modules
        if (!layoutModules_.empty()) {
index b622e443b172a8260ffb8bb462d60e88cd309146..46c02433408bd064f34123f4615c8ab7e5967937 100644 (file)
@@ -223,6 +223,8 @@ public:
        ///
        std::string options;
        ///
+       std::string master;
+       ///
        std::string float_placement;
        ///
        unsigned int columns;
index 0ce3284cf50e468641c2590205c63338138f65b6..2ba63bacbf160ca44b800f1c41ccf879b7c29598 100644 (file)
@@ -876,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, 
@@ -1262,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();
@@ -1610,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
@@ -1901,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
@@ -2201,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()) {
index 92965adea2fa63b77abd660bbe1ba6e58fa335e6..fa0ac26a81fc9917909d3fc00140b0c6b435464f 100644 (file)
@@ -135,6 +135,7 @@ private Q_SLOTS:
        void enableSkip(bool);
        void portraitChanged();
        void browseLayout();
+       void browseMaster();
        void classChanged();
        void updateModuleInfo();
 
index c3b663d559101a30ad592af452bc80a3df48ecb2..7d4903376b3a0636d1be35591e3735c37526a526 100644 (file)
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>381</width>
-    <height>375</height>
+    <height>413</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item row="4" column="2" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
+   <item row="3" column="0" colspan="4" >
+    <widget class="QGroupBox" name="childDocGB" >
+     <property name="toolTip" >
+      <string>Select if the current document is included to a master file</string>
      </property>
-     <property name="sizeHint" >
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
+     <property name="statusTip" >
+      <string/>
      </property>
-    </spacer>
+     <property name="title" >
+      <string>Select de&amp;fault master document</string>
+     </property>
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="childDocLA" >
+        <property name="text" >
+         <string>&amp;Master:</string>
+        </property>
+        <property name="buddy" >
+         <cstring>childDocLE</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" >
+       <widget class="QPushButton" name="childDocPB" >
+        <property name="text" >
+         <string>&amp;Browse...</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QLineEdit" name="childDocLE" >
+        <property name="toolTip" >
+         <string>Enter the name of the default master document</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
    </item>
-   <item row="3" column="0" colspan="4" >
+   <item row="4" column="0" colspan="4" >
     <widget class="QGroupBox" name="modulesGB" >
      <property name="title" >
       <string>Modules</string>
      </property>
     </widget>
    </item>
+   <item row="5" column="1" colspan="2" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <tabstops>