+<<<<<<< ChangeLog
+2005-05-10 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * buffer_funcs.C (setCounter): fix test for numbering of
+ environments.
+
+ * toc.C (getTocList): use LyXTextClass:min_toclevel to set toc
+ depth correctly; use optional argument when it exists
+
+ * lyxtextclass.C: remove unused MaxCounterTags enum
+ (Read): compute min_toclevel_ and max_toclevel_ after reading class.
+ (max_toclevel, min_toclevel): new methods.
+
+ * MenuBackend.C (expandToc2): fix case where depth is smaller than
+ the smallest depth in toc.
+
+ * lyxlayout.[Ch]: add special NOT_IN_TOC toclevel value for
+ layouts that should not appear in a table of contents.
+
+=======
2005-05-11 Lars Gullik Bjonnes <larsbj@gullik.net>
* buffer.C (save): check if destination is writable before trying
to copy a file
+>>>>>>> 1.2180
2005-05-11 Martin Vermeer <martin.vermeer@hut.fi>
* BufferView_pimpl.C (update): fix processEvents -caused update
lyx::toc::Toc::size_type to, int depth)
{
int shortcut_count = 0;
+
+ // check whether depth is smaller than the smallest depth in toc.
+ int min_depth = 1000;
+ for (lyx::toc::Toc::size_type i = from; i < to; ++i)
+ min_depth = std::min(min_depth, toc_list[i].depth);
+ if (min_depth > depth)
+ depth = min_depth;
+
+
if (to - from <= max_number_of_items) {
for (lyx::toc::Toc::size_type i = from; i < to; ++i) {
string label(4 * max(0, toc_list[i].depth - depth),' ');
// is it a layout that has an automatic label?
if (layout->labeltype == LABEL_COUNTER) {
if (layout->toclevel <= buf.params().secnumdepth
- && (!layout->isEnvironment()
+ && (layout->latextype != LATEX_ENVIRONMENT
|| isFirstInSequence(it.pit(), it.plist()))) {
counters.step(layout->counter);
string label = expandLabel(textclass, layout,
* QMathDialog.C (resizeEvent): use lyx_gui::sync_events instead of
the event loop.
+2005-05-11 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * QDocument.C (update_contents): set the limits of the numbering
+ sliders depending on the class; disable the numbering module when
+ the class does not have a sectioning structure.
+
+ * QDocumentDialog.h: remove the numberlevel* listviewitems.
+
+ * QDocumentDialog.C (QDocumentDialog): no need to populate
+ numbering listview here.
+ (classChanged): always invoke QDocument::update_content().
+ (updateNumbering): populate the listview directly from the
+ textclass information;
+
2005-05-11 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lyx_gui.C (sync_events):
#include <qcheckbox.h>
#include <qslider.h>
#include <qlineedit.h>
+#include <qlistview.h>
#include "lengthcombo.h"
}
// numbering
- dialog_->numberingModule->tocSL->setValue(params.tocdepth);
+ int const min_toclevel = controller().textClass().min_toclevel();
+ int const max_toclevel = controller().textClass().max_toclevel();
+ if (min_toclevel != LyXLayout::NOT_IN_TOC)
+ dialog_->numberingModule->setEnabled(true);
+ else {
+ dialog_->numberingModule->setEnabled(false);
+ dialog_->numberingModule->tocLV->clear();
+ }
+ dialog_->numberingModule->depthSL->setMinValue(min_toclevel - 1);
+ dialog_->numberingModule->depthSL->setMaxValue(max_toclevel);
dialog_->numberingModule->depthSL->setValue(params.secnumdepth);
+ dialog_->numberingModule->tocSL->setMinValue(min_toclevel - 1);
+ dialog_->numberingModule->tocSL->setMaxValue(max_toclevel);
+ dialog_->numberingModule->tocSL->setValue(params.tocdepth);
dialog_->updateNumbering();
// bullets
marginsModule->headheightLE));
marginsModule->footskipLE->setValidator(unsignedLengthValidator(
marginsModule->footskipLE));
-
- // create the numbering items, in reverse order
- numberlevel7 =
- new QListViewItem(numberingModule->tocLV, qt_("Subparagraph"));
- numberlevel6 =
- new QListViewItem(numberingModule->tocLV, qt_("Paragraph"));
- numberlevel5 =
- new QListViewItem(numberingModule->tocLV, qt_("Subsubsection"));
- numberlevel4 =
- new QListViewItem(numberingModule->tocLV, qt_("Subsection"));
- numberlevel3 =
- new QListViewItem(numberingModule->tocLV, qt_("Section"));
- numberlevel2 =
- new QListViewItem(numberingModule->tocLV, qt_("Chapter"));
- numberlevel1 =
- new QListViewItem(numberingModule->tocLV, qt_("Part"));
}
if (form_->controller().loadTextclass(tc)) {
params.textclass = tc;
-
- if (lyxrc.auto_reset_options) {
+ if (lyxrc.auto_reset_options)
params.useClassDefaults();
- form_->update_contents();
- } else {
- updateFontsize(cntrl.textClass().opt_fontsize(),
- params.fontsize);
- updatePagestyle(cntrl.textClass().opt_pagestyle(),
- params.pagestyle);
- updateNumbering();
- }
+ form_->update_contents();
} else {
latexModule->classCO->setCurrentItem(params.textclass);
}
void QDocumentDialog::updateNumbering()
{
- int const depth = numberingModule->depthSL->value();
- int const toc = numberingModule->tocSL->value();
-
- // check if the document class features chapter
LyXTextClass const & tclass =
form_->controller().params().getLyXTextClass();
- bool const hasChapter = tclass.hasLayout("Chapter");
-
- QString const no = qt_("No");
- QString const yes = qt_("Yes");
//numberingModule->tocLV->setUpdatesEnabled(false);
- numberlevel1->setText(1, yes);
- numberlevel2->setText(1, yes);
- numberlevel3->setText(1, yes);
- numberlevel4->setText(1, yes);
- numberlevel5->setText(1, yes);
- numberlevel6->setText(1, yes);
- numberlevel7->setText(1, yes);
-
- numberlevel1->setText(2, yes);
- numberlevel2->setText(2, yes);
- numberlevel3->setText(2, yes);
- numberlevel4->setText(2, yes);
- numberlevel5->setText(2, yes);
- numberlevel6->setText(2, yes);
- numberlevel7->setText(2, yes);
-
- // numbering
- if (depth < -1) numberlevel1->setText(1, no);
- if (depth < 0) numberlevel2->setText(1, no);
- if (depth < 1) numberlevel3->setText(1, no);
- if (depth < 2) numberlevel4->setText(1, no);
- if (depth < 3) numberlevel5->setText(1, no);
- if (depth < 4) numberlevel6->setText(1, no);
- if (depth < 5) numberlevel7->setText(1, no);
-
- // in toc
- if (toc < 0 && hasChapter) numberlevel2->setText(2, no);
- if (toc < 1) numberlevel3->setText(2, no);
- if (toc < 2) numberlevel4->setText(2, no);
- if (toc < 3) numberlevel5->setText(2, no);
- if (toc < 4) numberlevel6->setText(2, no);
- if (toc < 5) numberlevel7->setText(2, no);
-
- // in article style classes, the part number is shifted by 1
- if (!hasChapter) {
- numberlevel1->setText(0, qt_(""));
- numberlevel1->setText(1, qt_(""));
- numberlevel1->setText(2, qt_(""));
- numberlevel2->setText(0, qt_("Part"));
- } else {
- numberlevel1->setText(0, qt_("Part"));
- numberlevel2->setText(0, qt_("Chapter"));
+ // Update the example QListView
+ int const depth = numberingModule->depthSL->value();
+ int const toc = numberingModule->tocSL->value();
+ QString const no = qt_("No");
+ QString const yes = qt_("Yes");
+ LyXTextClass::const_iterator end = tclass.end();
+ LyXTextClass::const_iterator cit = tclass.begin();
+ numberingModule->tocLV->clear();
+ QListViewItem * item = 0;
+ for ( ; cit != end ; ++cit) {
+ int const toclevel = (*cit)->toclevel;
+ if (toclevel != LyXLayout::NOT_IN_TOC) {
+ item = new QListViewItem(numberingModule->tocLV,
+ item, qt_((*cit)->name()));
+ item->setText(1, (toclevel <= depth) ? yes : no);
+ item->setText(2, (toclevel <= toc) ? yes : no);
+ }
}
//numberingModule->tocLV->setUpdatesEnabled(true);
FloatPlacement * floatModule;
BranchesModuleBase * branchesModule;
- QListViewItem * numberlevel7;
- QListViewItem * numberlevel6;
- QListViewItem * numberlevel5;
- QListViewItem * numberlevel4;
- QListViewItem * numberlevel3;
- QListViewItem * numberlevel2;
- QListViewItem * numberlevel1;
-
QDocument * form_;
};
using std::endl;
using std::string;
+/// Special value of toclevel for layouts that to not belong in a TOC
+const int LyXLayout::NOT_IN_TOC = -1000;
// The order of the LayoutTags enum is no more important. [asierra300396]
// Tags indexes.
free_spacing = false;
pass_thru = false;
is_environment = false;
- toclevel = -2;
+ toclevel = NOT_IN_TOC;
commanddepth = 0;
}
bool is_environment;
/// show this in toc
int toclevel;
+ /// special value of toclevel for non-section layouts
+ static const int NOT_IN_TOC;
/// for new environment insets
std::string latexheader;
/// for new environment insets
<< "' is missing a defaultstyle." << endl;
error = true;
}
+
+ min_toclevel_ = LyXLayout::NOT_IN_TOC;
+ max_toclevel_ = LyXLayout::NOT_IN_TOC;
+ const_iterator cit = begin();
+ const_iterator the_end = end();
+ for ( ; cit != the_end ; ++cit) {
+ int const toclevel = (*cit)->toclevel;
+ if (toclevel != LyXLayout::NOT_IN_TOC) {
+ if (min_toclevel_ == LyXLayout::NOT_IN_TOC)
+ min_toclevel_ = toclevel;
+ else
+ min_toclevel_ = std::min(min_toclevel_,
+ toclevel);
+ max_toclevel_ = std::max(max_toclevel_,
+ toclevel);
+ }
+ }
+ lyxerr[Debug::TCLASS]
+ << "Minimum TocLevel is " << min_toclevel_
+ << ", maximum is " << max_toclevel_ <<endl;
+
} else
lyxerr[Debug::TCLASS] << "Finished reading input file "
<< MakeDisplayPath(filename)
}
-enum MaxCounterTags {
- MC_COUNTER_CHAPTER = 1,
- MC_COUNTER_SECTION,
- MC_COUNTER_SUBSECTION,
- MC_COUNTER_SUBSUBSECTION,
- MC_COUNTER_PARAGRAPH,
- MC_COUNTER_SUBPARAGRAPH,
- MC_COUNTER_ENUMI,
- MC_COUNTER_ENUMII,
- MC_COUNTER_ENUMIII,
- MC_COUNTER_ENUMIV
-};
-
-
enum ClassOptionsTags {
CO_FONTSIZE = 1,
CO_PAGESTYLE,
}
+int LyXTextClass::min_toclevel() const
+{
+ return min_toclevel_;
+}
+
+
+int LyXTextClass::max_toclevel() const
+{
+ return max_toclevel_;
+}
+
+
ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
{
switch (p) {
///
int size() const;
+ /// The minimal TocLevel of sectioning layouts
+ int min_toclevel() const;
+ /// The maximal TocLevel of sectioning layouts
+ int max_toclevel() const;
private:
///
bool delete_layout(std::string const &);
/// Is the TeX class available?
bool texClassAvail_;
+
+ /// The minimal TocLevel of sectioning layouts
+ int min_toclevel_;
+ /// The maximal TocLevel of sectioning layouts
+ int max_toclevel_;
};
#include "frontends/LyXView.h"
#include "insets/insetfloat.h"
+#include "insets/insetoptarg.h"
#include "insets/insetwrap.h"
#include "support/convert.h"
TocList toclist;
BufferParams const & bufparams = buf.params();
+ const int min_toclevel = bufparams.getLyXTextClass().min_toclevel();
ParConstIterator pit = buf.par_iterator_begin();
ParConstIterator end = buf.par_iterator_end();
for (; pit != end; ++pit) {
- int const toclevel = pit->layout()->toclevel;
- if (toclevel > 0 && toclevel <= bufparams.tocdepth) {
- // insert this into the table of contents
- TocItem const item(pit->id(), toclevel - 1, pit->asString(buf, true));
- toclist["TOC"].push_back(item);
- }
+ // the string that goes to the toc (could be the optarg)
+ string tocstring;
// For each paragraph, traverse its insets and look for
// FLOAT_CODE or WRAP_CODE
InsetList::const_iterator it = pit->insetlist.begin();
InsetList::const_iterator end = pit->insetlist.end();
for (; it != end; ++it) {
- if (it->inset->lyxCode() == InsetBase::FLOAT_CODE) {
+ switch (it->inset->lyxCode()) {
+ case InsetBase::FLOAT_CODE:
static_cast<InsetFloat*>(it->inset)
->addToToc(toclist, buf);
- } else if (it->inset->lyxCode() == InsetBase::WRAP_CODE) {
+ break;
+ case InsetBase::WRAP_CODE:
static_cast<InsetWrap*>(it->inset)
->addToToc(toclist, buf);
+ break;
+ case InsetBase::OPTARG_CODE: {
+ if (!tocstring.empty())
+ break;
+ Paragraph const & par = *static_cast<InsetOptArg*>(it->inset)->paragraphs().begin();
+ if (!pit->getLabelstring().empty())
+ tocstring = pit->getLabelstring()
+ + ' ';
+ tocstring += par.asString(buf, false);
+ break;
+ }
+ default:
+ break;
}
}
+
+ /// now the toc entry for the paragraph
+ int const toclevel = pit->layout()->toclevel;
+ if (toclevel >= min_toclevel
+ && toclevel <= bufparams.tocdepth) {
+ // insert this into the table of contents
+ if (tocstring.empty())
+ tocstring = pit->asString(buf, true);
+ TocItem const item(pit->id(), toclevel - min_toclevel,
+ tocstring);
+ toclist["TOC"].push_back(item);
+ }
}
return toclist;
}