** fix bug 2114. Fileformat change.

** fix bug 5343 (patch from Richard, prerequisite for the other fix)

* Buffer.cpp:
	- increment format to 343
* src/BufferParams.{cpp,h}:
	- new param \use_default_options that allows to select/deselect
	  the "Other" class options defined in the layout file.
* src/frontends/qt4/GuiDocument.cpp:
* src/frontends/qt4/ui/LaTeXUi.ui:
	- add GUI to set \use_default_options, display predefined options in the dialog
	- update dialog correctly on class change.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26860 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-10-12 09:36:00 +00:00
parent 41c028cce5
commit d45ca67d1d
7 changed files with 204 additions and 96 deletions

View File

@ -1,6 +1,10 @@
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.

View File

@ -2955,6 +2955,22 @@ def revert_mongolian(document):
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
#
@ -3025,10 +3041,12 @@ convert = [[277, [fix_wrong_tables]],
[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]],

View File

@ -115,7 +115,7 @@ namespace os = support::os;
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;

View File

@ -335,6 +335,7 @@ BufferParams::BufferParams()
use_bibtopic = false;
trackChanges = false;
outputChanges = false;
use_default_options = true;
secnumdepth = 3;
tocdepth = 3;
language = default_language;
@ -495,6 +496,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
} 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();
@ -692,6 +695,10 @@ void BufferParams::writeFile(ostream & os) const
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';
@ -1073,6 +1080,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
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 << ',';
@ -1444,7 +1455,7 @@ void BufferParams::useClassDefaults()
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();
@ -1460,7 +1471,7 @@ bool BufferParams::hasClassDefaults() const
return sides == tclass.sides()
&& columns == tclass.columns()
&& pagestyle == tclass.pagestyle()
&& options == tclass.options()
&& use_default_options
&& secnumdepth == tclass.secnumdepth()
&& tocdepth == tclass.tocdepth();
}
@ -1499,7 +1510,7 @@ bool BufferParams::setBaseClass(string const & classname)
}
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));
@ -1516,14 +1527,14 @@ bool BufferParams::setBaseClass(string const & 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.");

View File

@ -236,6 +236,8 @@ public:
std::string local_layout;
///
std::string options;
/// use the class options defined in the layout?
bool use_default_options;
///
std::string master;
///

View File

@ -896,6 +896,8 @@ GuiDocument::GuiDocument(GuiView & lv)
// 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)),
@ -913,7 +915,7 @@ GuiDocument::GuiDocument(GuiView & lv)
connect(latexModule->childDocPB, SIGNAL(clicked()),
this, SLOT(browseMaster()));
selectionManager =
selectionManager =
new ModuleSelectionManager(latexModule->availableLV,
latexModule->selectedLV,
latexModule->addPB, latexModule->deletePB,
@ -1348,13 +1350,14 @@ void GuiDocument::classChanged()
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_);
}
@ -1700,6 +1703,9 @@ void GuiDocument::apply(BufferParams & params)
params.options =
fromqstr(latexModule->optionsLE->text());
params.use_default_options =
latexModule->defaultOptionsCB->isChecked();
if (latexModule->childDocGB->isChecked())
params.master =
fromqstr(latexModule->childDocLE->text());
@ -1995,6 +2001,24 @@ void GuiDocument::paramsToDialog(BufferParams const & params)
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(

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>413</height>
<height>449</height>
</rect>
</property>
<property name="windowTitle" >
@ -19,54 +19,6 @@
<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&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="4" column="0" colspan="4" >
<widget class="QGroupBox" name="modulesGB" >
<property name="title" >
@ -160,18 +112,53 @@
</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&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="2" column="1" >
<widget class="QComboBox" name="psdriverCO" >
@ -190,16 +177,23 @@
</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>&amp;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>
@ -231,26 +225,64 @@
</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&amp;redefined:</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="optionsL" >
<property name="text" >
<string>Cust&amp;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>
@ -269,5 +301,22 @@
<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>