LyX file-format changes
-----------------------
+2008-10-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+ * Format incremented to 343: new param \use_default_options
+ (fix bug 2114).
+
2008-10-12 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 342: support for Mongolian.
j = j + 1
+def revert_default_options(document):
+ ' Remove param use_default_options '
+ i = find_token(document.header, "\\use_default_options", 0)
+ if i != -1:
+ del document.header[i]
+
+
+def convert_default_options(document):
+ ' Add param use_default_options and set it to false '
+ i = find_token(document.header, "\\textclass", 0)
+ if i == -1:
+ document.warning("Malformed LyX document: Missing `\\textclass'.")
+ return
+ document.header.insert(i, '\\use_default_options false')
+
+
##
# Conversion hub
#
[339, []],
[340, [add_plain_layout]],
[341, []],
- [342, []]
+ [342, []],
+ [343, [convert_default_options]]
]
-revert = [[341, [revert_mongolian]],
+revert = [[342, [revert_default_options]],
+ [341, [revert_mongolian]],
[340, [revert_tabulators, revert_tabsize]],
[339, []],
[338, [revert_removed_modules]],
namespace {
-int const LYX_FORMAT = 342; //uwestoehr: support for Mongolian
+int const LYX_FORMAT = 343;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
use_bibtopic = false;
trackChanges = false;
outputChanges = false;
+ use_default_options = true;
secnumdepth = 3;
tocdepth = 3;
language = default_language;
} else if (token == "\\options") {
lex.eatLine();
options = lex.getString();
+ } else if (token == "\\use_default_options") {
+ lex >> use_default_options;
} else if (token == "\\master") {
lex.eatLine();
master = lex.getString();
os << "\\options " << options << '\n';
}
+ // use the class options defined in the layout?
+ os << "\\use_default_options "
+ << convert<string>(use_default_options) << "\n";
+
// the master document
if (!master.empty()) {
os << "\\master " << master << '\n';
clsoptions << language_options.str() << ',';
}
+ // the predefined options from the layout
+ if (use_default_options && !tclass.options().empty())
+ clsoptions << tclass.options() << ',';
+
// the user-defined options
if (!options.empty()) {
clsoptions << options << ',';
sides = tclass.sides();
columns = tclass.columns();
pagestyle = tclass.pagestyle();
- options = tclass.options();
+ use_default_options = true;
// Only if class has a ToC hierarchy
if (tclass.hasTocLevels()) {
secnumdepth = tclass.secnumdepth();
return sides == tclass.sides()
&& columns == tclass.columns()
&& pagestyle == tclass.pagestyle()
- && options == tclass.options()
+ && use_default_options
&& secnumdepth == tclass.secnumdepth()
&& tocdepth == tclass.tocdepth();
}
}
bool const success = bcl[classname].load();
- if (!success) {
+ if (!success) {
docstring s =
bformat(_("The document class %1$s could not be loaded."),
from_utf8(classname));
for (; mit != men; mit++) {
string const & modName = *mit;
// see if we're already in use
- if (find(layoutModules_.begin(), layoutModules_.end(), modName) !=
+ if (find(layoutModules_.begin(), layoutModules_.end(), modName) !=
layoutModules_.end()) {
LYXERR(Debug::TCLASS, "Default module `" << modName <<
"' not added because already used.");
continue;
}
// make sure the user hasn't removed it
- if (find(removedModules_.begin(), removedModules_.end(), modName) !=
+ if (find(removedModules_.begin(), removedModules_.end(), modName) !=
removedModules_.end()) {
LYXERR(Debug::TCLASS, "Default module `" << modName <<
"' not added because removed by user.");
std::string local_layout;
///
std::string options;
+ /// use the class options defined in the layout?
+ bool use_default_options;
///
std::string master;
///
// latex class
connect(latexModule->optionsLE, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
+ connect(latexModule->defaultOptionsCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
connect(latexModule->psdriverCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(latexModule->classCO, SIGNAL(activated(int)),
connect(latexModule->childDocPB, SIGNAL(clicked()),
this, SLOT(browseMaster()));
- selectionManager =
+ selectionManager =
new ModuleSelectionManager(latexModule->availableLV,
latexModule->selectedLV,
latexModule->addPB, latexModule->deletePB,
applyView();
}
bp_.useClassDefaults();
- paramsToDialog(bp_);
}
// FIXME There's a little bug here connected with auto_reset, namely,
// that, if the preceding is skipped and the user has changed the
// modules before changing the class, those changes will be lost on
// update. But maybe that's what we want?
updateSelectedModules();
+ bp_.makeDocumentClass();
+ paramsToDialog(bp_);
}
params.options =
fromqstr(latexModule->optionsLE->text());
+ params.use_default_options =
+ latexModule->defaultOptionsCB->isChecked();
+
if (latexModule->childDocGB->isChecked())
params.master =
fromqstr(latexModule->childDocLE->text());
latexModule->optionsLE->setText(QString());
}
+ latexModule->defaultOptionsCB->setChecked(
+ params.use_default_options);
+
+ if (!documentClass().options().empty()) {
+ latexModule->defaultOptionsLE->setText(
+ toqstr(documentClass().options()));
+ } else {
+ latexModule->defaultOptionsLE->setText(
+ toqstr(_("[No options predefined]")));
+ }
+
+ latexModule->defaultOptionsLE->setEnabled(
+ params.use_default_options
+ && !documentClass().options().empty());
+
+ latexModule->defaultOptionsCB->setEnabled(
+ !documentClass().options().empty());
+
if (!params.master.empty()) {
latexModule->childDocGB->setChecked(true);
latexModule->childDocLE->setText(
<x>0</x>
<y>0</y>
<width>381</width>
- <height>413</height>
+ <height>449</height>
</rect>
</property>
<property name="windowTitle" >
<property name="spacing" >
<number>6</number>
</property>
- <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="statusTip" >
- <string/>
- </property>
- <property name="title" >
- <string>Select de&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>&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>&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="4" column="0" colspan="4" >
<widget class="QGroupBox" name="modulesGB" >
<property name="title" >
</layout>
</widget>
</item>
- <item row="2" column="2" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</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>261</width>
- <height>22</height>
- </size>
+ <property name="statusTip" >
+ <string/>
</property>
- </spacer>
+ <property name="title" >
+ <string>Select de&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>&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>&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="2" column="1" >
<widget class="QComboBox" name="psdriverCO" >
</property>
</widget>
</item>
- <item row="1" column="1" colspan="3" >
- <widget class="QLineEdit" name="optionsLE" />
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="optionsL" >
- <property name="text" >
- <string>&Options:</string>
+ <item row="2" column="2" colspan="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="buddy" >
- <cstring>optionsLE</cstring>
+ <property name="sizeHint" >
+ <size>
+ <width>261</width>
+ <height>22</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QComboBox" name="classCO" >
+ <property name="maxVisibleItems" >
+ <number>20</number>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="0" column="1" colspan="2" >
- <widget class="QComboBox" name="classCO" >
- <property name="maxVisibleItems" >
- <number>20</number>
+ <item row="1" column="0" colspan="4" >
+ <widget class="QGroupBox" name="optionsGB" >
+ <property name="title" >
+ <string>Class options</string>
</property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item rowspan="2" row="0" column="1" >
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="defaultOptionsLE" >
+ <property name="toolTip" >
+ <string>The options that are predefined in the layout file. Click to the left to select/deselect.</string>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="optionsLE" />
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QCheckBox" name="defaultOptionsCB" >
+ <property name="toolTip" >
+ <string>Enable to use the options that are predefined in the layout file</string>
+ </property>
+ <property name="text" >
+ <string>P&redefined:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="optionsL" >
+ <property name="text" >
+ <string>Cust&om:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>optionsLE</cstring>
+ </property>
+ </widget>
+ </item>
+ </layout>
</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>
<include location="local" >qt_i18n.h</include>
</includes>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>defaultOptionsCB</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>defaultOptionsLE</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>63</x>
+ <y>79</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>237</x>
+ <y>82</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>