mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Enhancements and bugfixes to the TOCs
* New TOC "math-macro". This means that math macros can now be accessed in the
outline pane in their order of appearance or in alphabetical order, and can be
searched using the filter.
* Lists of floats now show subfloats deeper in the navigation menu
* The arbitrary 30 element cut-off after which nothing is shown except "Open
Navigator..." is removed. Menus now have no limit in size, so Qt may display
them scrollable. In exchange, we always show "Open outliner..." at the
beginning. I tested for performance issues with a rather complex document and
it is fine; but this does not exclude corner cases with lots of TOC entries of
a certain kind. If necessary, populating the navigation sub-menu should be
delayed like the main menu.
* Elements that do not contribute to the output (e.g. in a note, a disabled
branch) are now preceded with a symbol indicating this status. (The machinery
was already there; I wonder why it was not implemented already.) I have chosen
U+274E NEGATIVE SQUARED CROSS MARK.
* Fix the contextual menus in the outliner (bug introduced at 94e992c5
).
* Toc item now move to the caption when present, but first center on the float,
to prevent the situation where the caption is at the top of the screen and the
contents of the float is off-screen above the caption.
(Internally, the action of the toc items can now be customised)
* Fix the LyXHTML output. Disabled captions no longer appear in the list of
figures.
This commit is contained in:
parent
89342f2946
commit
d5a5fbb8ee
@ -4462,7 +4462,7 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
|
|||||||
d->bibinfo_cache_valid_ = true;
|
d->bibinfo_cache_valid_ = true;
|
||||||
d->cite_labels_valid_ = true;
|
d->cite_labels_valid_ = true;
|
||||||
/// FIXME: Perf
|
/// FIXME: Perf
|
||||||
cbuf.tocBackend().update(utype == OutputUpdate);
|
cbuf.tocBackend().update(true, utype);
|
||||||
if (scope == UpdateMaster)
|
if (scope == UpdateMaster)
|
||||||
cbuf.structureChanged();
|
cbuf.structureChanged();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ using namespace std;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// TocItem implementation
|
// TocItem implementation
|
||||||
@ -46,8 +47,9 @@ namespace lyx {
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
|
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
|
||||||
bool output_active, docstring const & t) :
|
bool output_active, docstring const & t, FuncRequest action) :
|
||||||
dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active)
|
dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active),
|
||||||
|
action_(action)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,15 +68,32 @@ docstring const & TocItem::tooltip() const
|
|||||||
|
|
||||||
docstring const TocItem::asString() const
|
docstring const TocItem::asString() const
|
||||||
{
|
{
|
||||||
return docstring(4 * depth_, ' ') + str_;
|
// U+2327 X IN A RECTANGLE BOX
|
||||||
|
// char_type const cross = 0x2327;
|
||||||
|
// U+274E NEGATIVE SQUARED CROSS MARK
|
||||||
|
char_type const cross = 0x274e;
|
||||||
|
docstring prefix;
|
||||||
|
if (!output_) {
|
||||||
|
prefix += cross;
|
||||||
|
prefix += " ";
|
||||||
|
}
|
||||||
|
return prefix + str_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO
|
||||||
|
docstring paragraph_goto_arg(DocIterator const & dit)
|
||||||
|
{
|
||||||
|
CursorSlice const & s = dit.innerTextSlice();
|
||||||
|
return convert<docstring>(s.paragraph().id()) + ' ' +
|
||||||
|
convert<docstring>(s.pos());
|
||||||
|
}
|
||||||
|
|
||||||
FuncRequest TocItem::action() const
|
FuncRequest TocItem::action() const
|
||||||
{
|
{
|
||||||
string const arg = convert<string>(dit_.paragraph().id())
|
if (action_.action() == LFUN_UNKNOWN_ACTION) {
|
||||||
+ ' ' + convert<string>(dit_.pos());
|
return FuncRequest(LFUN_PARAGRAPH_GOTO, paragraph_goto_arg(dit_));
|
||||||
return FuncRequest(LFUN_PARAGRAPH_GOTO, arg);
|
} else
|
||||||
|
return action_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -156,15 +175,29 @@ void TocBuilder::pushItem(DocIterator const & dit, docstring const & s,
|
|||||||
void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
|
void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
|
||||||
bool output_active)
|
bool output_active)
|
||||||
{
|
{
|
||||||
|
// first show the float before moving to the caption
|
||||||
|
docstring arg = "paragraph-goto " + paragraph_goto_arg(dit);
|
||||||
|
if (!stack_.empty())
|
||||||
|
arg = "paragraph-goto " +
|
||||||
|
paragraph_goto_arg((*toc_)[stack_.top().pos].dit_) + ";" + arg;
|
||||||
|
FuncRequest func(LFUN_COMMAND_SEQUENCE, arg);
|
||||||
|
|
||||||
if (!stack_.empty() && !stack_.top().is_captioned) {
|
if (!stack_.empty() && !stack_.top().is_captioned) {
|
||||||
// The float we entered has not yet been assigned a caption.
|
// The float we entered has not yet been assigned a caption.
|
||||||
// Assign the caption string to it.
|
// Assign the caption string to it.
|
||||||
(*toc_)[stack_.top().pos].str(s);
|
TocItem & captionable = (*toc_)[stack_.top().pos];
|
||||||
|
captionable.str(s);
|
||||||
|
captionable.setAction(func);
|
||||||
stack_.top().is_captioned = true;
|
stack_.top().is_captioned = true;
|
||||||
} else {
|
} else {
|
||||||
// This is a new entry.
|
// This is a new entry.
|
||||||
pop();
|
pop();
|
||||||
pushItem(dit, s, output_active, true);
|
// the dit is at the float's level, e.g. for the contextual menu of
|
||||||
|
// outliner entries
|
||||||
|
DocIterator captionable_dit = dit;
|
||||||
|
captionable_dit.pop_back();
|
||||||
|
pushItem(captionable_dit, s, output_active, true);
|
||||||
|
(*toc_)[stack_.top().pos].setAction(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,14 +302,14 @@ bool TocBackend::updateItem(DocIterator const & dit)
|
|||||||
&& tocstring.empty())
|
&& tocstring.empty())
|
||||||
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
|
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
|
||||||
|
|
||||||
const_cast<TocItem &>(*toc_item).str_ = tocstring;
|
const_cast<TocItem &>(*toc_item).str(tocstring);
|
||||||
|
|
||||||
buffer_->updateTocItem("tableofcontents", dit);
|
buffer_->updateTocItem("tableofcontents", dit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TocBackend::update(bool output_active)
|
void TocBackend::update(bool output_active, UpdateType utype)
|
||||||
{
|
{
|
||||||
for (TocList::iterator it = tocs_.begin(); it != tocs_.end(); ++it)
|
for (TocList::iterator it = tocs_.begin(); it != tocs_.end(); ++it)
|
||||||
it->second->clear();
|
it->second->clear();
|
||||||
@ -284,7 +317,7 @@ void TocBackend::update(bool output_active)
|
|||||||
builders_.clear();
|
builders_.clear();
|
||||||
if (!buffer_->isInternal()) {
|
if (!buffer_->isInternal()) {
|
||||||
DocIterator dit;
|
DocIterator dit;
|
||||||
buffer_->inset().addToToc(dit, output_active);
|
buffer_->inset().addToToc(dit, output_active, utype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#define TOC_BACKEND_H
|
#define TOC_BACKEND_H
|
||||||
|
|
||||||
#include "DocIterator.h"
|
#include "DocIterator.h"
|
||||||
|
#include "FuncRequest.h"
|
||||||
|
#include "OutputEnums.h"
|
||||||
|
|
||||||
#include "support/shared_ptr.h"
|
#include "support/shared_ptr.h"
|
||||||
#include "support/strfwd.h"
|
#include "support/strfwd.h"
|
||||||
@ -29,7 +31,6 @@
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class FuncRequest;
|
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: toc types are currently identified by strings. It cannot be converted
|
/* FIXME: toc types are currently identified by strings. It cannot be converted
|
||||||
@ -66,6 +67,7 @@ class TocItem
|
|||||||
{
|
{
|
||||||
friend class Toc;
|
friend class Toc;
|
||||||
friend class TocBackend;
|
friend class TocBackend;
|
||||||
|
friend class TocBuilder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Default constructor for STL containers.
|
/// Default constructor for STL containers.
|
||||||
@ -75,7 +77,8 @@ public:
|
|||||||
int depth,
|
int depth,
|
||||||
docstring const & s,
|
docstring const & s,
|
||||||
bool output_active,
|
bool output_active,
|
||||||
docstring const & t = docstring()
|
docstring const & t = docstring(),
|
||||||
|
FuncRequest action = FuncRequest(LFUN_UNKNOWN_ACTION)
|
||||||
);
|
);
|
||||||
///
|
///
|
||||||
~TocItem() {}
|
~TocItem() {}
|
||||||
@ -89,19 +92,22 @@ public:
|
|||||||
void str(docstring const & s) { str_ = s; }
|
void str(docstring const & s) { str_ = s; }
|
||||||
///
|
///
|
||||||
docstring const & tooltip() const;
|
docstring const & tooltip() const;
|
||||||
///
|
/// String for display, e.g. it has a mark if output is inactive
|
||||||
docstring const asString() const;
|
docstring const asString() const;
|
||||||
///
|
///
|
||||||
DocIterator const & dit() const { return dit_; }
|
DocIterator const & dit() const { return dit_; }
|
||||||
///
|
///
|
||||||
bool isOutput() const { return output_; }
|
bool isOutput() const { return output_; }
|
||||||
|
///
|
||||||
/// the action corresponding to the goTo above
|
void setAction(FuncRequest a) { action_ = a; }
|
||||||
|
/// custom action, or the default one (paragraph-goto) if not customised
|
||||||
FuncRequest action() const;
|
FuncRequest action() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Current position of item.
|
/// Current position of item.
|
||||||
DocIterator dit_;
|
DocIterator dit_;
|
||||||
|
|
||||||
|
private:
|
||||||
/// nesting depth
|
/// nesting depth
|
||||||
int depth_;
|
int depth_;
|
||||||
/// Full item string
|
/// Full item string
|
||||||
@ -110,6 +116,8 @@ protected:
|
|||||||
docstring tooltip_;
|
docstring tooltip_;
|
||||||
/// Is this item in a note, inactive branch, etc?
|
/// Is this item in a note, inactive branch, etc?
|
||||||
bool output_;
|
bool output_;
|
||||||
|
/// Custom action
|
||||||
|
FuncRequest action_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -192,7 +200,7 @@ public:
|
|||||||
///
|
///
|
||||||
void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
|
void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
|
||||||
///
|
///
|
||||||
void update(bool output_active);
|
void update(bool output_active, UpdateType utype);
|
||||||
/// \return true if the item was updated.
|
/// \return true if the item was updated.
|
||||||
bool updateItem(DocIterator const & pit);
|
bool updateItem(DocIterator const & pit);
|
||||||
///
|
///
|
||||||
|
@ -1219,7 +1219,7 @@ void MenuDefinition::expandFlexInsert(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t const max_number_of_items = 25;
|
size_t const max_number_of_items = 30;
|
||||||
|
|
||||||
void MenuDefinition::expandToc2(Toc const & toc_list,
|
void MenuDefinition::expandToc2(Toc const & toc_list,
|
||||||
size_t from, size_t to, int depth)
|
size_t from, size_t to, int depth)
|
||||||
@ -1236,7 +1236,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
|
|||||||
if (to - from <= max_number_of_items) {
|
if (to - from <= max_number_of_items) {
|
||||||
for (size_t i = from; i < to; ++i) {
|
for (size_t i = from; i < to; ++i) {
|
||||||
QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
|
QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
|
||||||
label += limitStringLength(toc_list[i].str());
|
label += limitStringLength(toc_list[i].asString());
|
||||||
if (toc_list[i].depth() == depth) {
|
if (toc_list[i].depth() == depth) {
|
||||||
label += '|';
|
label += '|';
|
||||||
if (shortcut_count < 9) {
|
if (shortcut_count < 9) {
|
||||||
@ -1246,6 +1246,9 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
|
|||||||
}
|
}
|
||||||
add(MenuItem(MenuItem::Command, label,
|
add(MenuItem(MenuItem::Command, label,
|
||||||
FuncRequest(toc_list[i].action())));
|
FuncRequest(toc_list[i].action())));
|
||||||
|
// separator after the menu heading
|
||||||
|
if (toc_list[i].depth() < depth)
|
||||||
|
add(MenuItem(MenuItem::Separator));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t pos = from;
|
size_t pos = from;
|
||||||
@ -1255,7 +1258,7 @@ void MenuDefinition::expandToc2(Toc const & toc_list,
|
|||||||
++new_pos;
|
++new_pos;
|
||||||
|
|
||||||
QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
|
QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
|
||||||
label += limitStringLength(toc_list[pos].str());
|
label += limitStringLength(toc_list[pos].asString());
|
||||||
if (toc_list[pos].depth() == depth) {
|
if (toc_list[pos].depth() == depth) {
|
||||||
label += '|';
|
label += '|';
|
||||||
if (shortcut_count < 9) {
|
if (shortcut_count < 9) {
|
||||||
@ -1285,12 +1288,10 @@ void MenuDefinition::expandToc(Buffer const * buf)
|
|||||||
// all MenuItem constructors and to expandToc2. However, we
|
// all MenuItem constructors and to expandToc2. However, we
|
||||||
// know that all the entries in a TOC will be have status_ ==
|
// know that all the entries in a TOC will be have status_ ==
|
||||||
// OK, so we avoid this unnecessary overhead (JMarc)
|
// OK, so we avoid this unnecessary overhead (JMarc)
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
add(MenuItem(MenuItem::Info, qt_("<No Document Open>")));
|
add(MenuItem(MenuItem::Info, qt_("(No Document Open)")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an entry for the master doc if this is a child doc
|
// Add an entry for the master doc if this is a child doc
|
||||||
Buffer const * const master = buf->masterBuffer();
|
Buffer const * const master = buf->masterBuffer();
|
||||||
if (buf != master) {
|
if (buf != master) {
|
||||||
@ -1301,68 +1302,36 @@ void MenuDefinition::expandToc(Buffer const * buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MenuDefinition other_lists;
|
MenuDefinition other_lists;
|
||||||
|
|
||||||
FloatList const & floatlist = buf->params().documentClass().floats();
|
FloatList const & floatlist = buf->params().documentClass().floats();
|
||||||
TocList const & toc_list = buf->tocBackend().tocs();
|
TocList const & toc_list = buf->tocBackend().tocs();
|
||||||
TocList::const_iterator cit = toc_list.begin();
|
TocList::const_iterator cit = toc_list.begin();
|
||||||
TocList::const_iterator end = toc_list.end();
|
TocList::const_iterator end = toc_list.end();
|
||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit) {
|
||||||
// Handle this later
|
// Handle table of contents later
|
||||||
if (cit->first == "tableofcontents")
|
if (cit->first == "tableofcontents" || cit->second->empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MenuDefinition submenu;
|
MenuDefinition submenu;
|
||||||
if (floatlist.typeExist(cit->first)) {
|
// "Open outliner..." entry
|
||||||
TocIterator ccit = cit->second->begin();
|
FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
|
||||||
TocIterator eend = cit->second->end();
|
submenu.add(MenuItem(MenuItem::Command, qt_("Open outliner..."), f));
|
||||||
for (; ccit != eend; ++ccit) {
|
submenu.add(MenuItem(MenuItem::Separator));
|
||||||
if (0 == ccit->depth()) {// omit subfloats
|
// add entries
|
||||||
submenu.add(MenuItem(MenuItem::Command,
|
submenu.expandToc2(* cit->second, 0, cit->second->size(), 0);
|
||||||
limitStringLength(ccit->str()) + '|',
|
MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
|
||||||
FuncRequest(ccit->action())));
|
item.setSubmenu(submenu);
|
||||||
}
|
// deserves to be in the main menu?
|
||||||
}
|
if (floatlist.typeExist(cit->first) || cit->first == "child")
|
||||||
|
|
||||||
FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
|
|
||||||
submenu.add(MenuItem(MenuItem::Separator));
|
|
||||||
submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
|
|
||||||
MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
|
|
||||||
// deserves to be in the main menu.
|
|
||||||
item.setSubmenu(submenu);
|
|
||||||
add(item);
|
add(item);
|
||||||
} else {
|
else
|
||||||
if (cit->second->size() >= 30) {
|
other_lists.add(item);
|
||||||
// FIXME: the behaviour of the interface should not change
|
|
||||||
// arbitrarily. Each type should be audited to see if the list
|
|
||||||
// can be optimised like for floats above.
|
|
||||||
FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
|
|
||||||
submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
|
|
||||||
} else {
|
|
||||||
TocIterator ccit = cit->second->begin();
|
|
||||||
TocIterator eend = cit->second->end();
|
|
||||||
for (; ccit != eend; ++ccit) {
|
|
||||||
submenu.add(MenuItem(MenuItem::Command,
|
|
||||||
limitStringLength(ccit->str()) + '|',
|
|
||||||
FuncRequest(ccit->action())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
|
|
||||||
item.setSubmenu(submenu);
|
|
||||||
if (cit->first == "child") {
|
|
||||||
// deserves to be in the main menu.
|
|
||||||
add(item);
|
|
||||||
} else
|
|
||||||
other_lists.add(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!other_lists.empty()) {
|
if (!other_lists.empty()) {
|
||||||
MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
|
MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
|
||||||
item.setSubmenu(other_lists);
|
item.setSubmenu(other_lists);
|
||||||
add(item);
|
add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle normal TOC
|
// Handle normal TOC
|
||||||
|
add(MenuItem(MenuItem::Separator));
|
||||||
cit = toc_list.find("tableofcontents");
|
cit = toc_list.find("tableofcontents");
|
||||||
if (cit == end)
|
if (cit == end)
|
||||||
LYXERR(Debug::GUI, "No table of contents.");
|
LYXERR(Debug::GUI, "No table of contents.");
|
||||||
@ -1370,7 +1339,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
|
|||||||
if (!cit->second->empty())
|
if (!cit->second->empty())
|
||||||
expandToc2(* cit->second, 0, cit->second->size(), 0);
|
expandToc2(* cit->second, 0, cit->second->size(), 0);
|
||||||
else
|
else
|
||||||
add(MenuItem(MenuItem::Info, qt_("<Empty Table of Contents>")));
|
add(MenuItem(MenuItem::Info, qt_("(Empty Table of Contents)")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ void TocModel::updateItem(DocIterator const & dit)
|
|||||||
{
|
{
|
||||||
QModelIndex index = modelIndex(dit);
|
QModelIndex index = modelIndex(dit);
|
||||||
TocItem const & toc_item = tocItem(index);
|
TocItem const & toc_item = tocItem(index);
|
||||||
model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
|
model_->setData(index, toqstr(toc_item.asString()), Qt::DisplayRole);
|
||||||
model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
|
model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,12 +183,12 @@ void TocModel::reset(shared_ptr<Toc const> toc)
|
|||||||
int current_row = model_->rowCount();
|
int current_row = model_->rowCount();
|
||||||
model_->insertRows(current_row, 1);
|
model_->insertRows(current_row, 1);
|
||||||
QModelIndex top_level_item = model_->index(current_row, 0);
|
QModelIndex top_level_item = model_->index(current_row, 0);
|
||||||
model_->setData(top_level_item, toqstr(item.str()), Qt::DisplayRole);
|
model_->setData(top_level_item, toqstr(item.asString()), Qt::DisplayRole);
|
||||||
model_->setData(top_level_item, index, Qt::UserRole);
|
model_->setData(top_level_item, index, Qt::UserRole);
|
||||||
model_->setData(top_level_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
model_->setData(top_level_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
||||||
|
|
||||||
LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
|
LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
|
||||||
<< ", added item " << item.str());
|
<< ", added item " << item.asString());
|
||||||
|
|
||||||
populate(index, top_level_item);
|
populate(index, top_level_item);
|
||||||
if (index >= end)
|
if (index >= end)
|
||||||
@ -224,7 +224,7 @@ void TocModel::populate(unsigned int & index, QModelIndex const & parent)
|
|||||||
int current_row = model_->rowCount(parent);
|
int current_row = model_->rowCount(parent);
|
||||||
model_->insertRows(current_row, 1, parent);
|
model_->insertRows(current_row, 1, parent);
|
||||||
child_item = model_->index(current_row, 0, parent);
|
child_item = model_->index(current_row, 0, parent);
|
||||||
model_->setData(child_item, toqstr(item.str()), Qt::DisplayRole);
|
model_->setData(child_item, toqstr(item.asString()), Qt::DisplayRole);
|
||||||
model_->setData(child_item, index, Qt::UserRole);
|
model_->setData(child_item, index, Qt::UserRole);
|
||||||
model_->setData(child_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
model_->setData(child_item, toqstr(item.tooltip()), Qt::ToolTipRole);
|
||||||
populate(index, child_item);
|
populate(index, child_item);
|
||||||
@ -315,7 +315,7 @@ void TocModels::goTo(QString const & type, QModelIndex const & index) const
|
|||||||
}
|
}
|
||||||
LASSERT(index.model() == it.value()->model(), return);
|
LASSERT(index.model() == it.value()->model(), return);
|
||||||
TocItem const item = it.value()->tocItem(index);
|
TocItem const item = it.value()->tocItem(index);
|
||||||
LYXERR(Debug::GUI, "TocModels::goTo " << item.str());
|
LYXERR(Debug::GUI, "TocModels::goTo " << item.asString());
|
||||||
dispatch(item.action());
|
dispatch(item.action());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,16 +119,12 @@ Inset * TocWidget::itemInset() const
|
|||||||
|
|
||||||
else if (current_type_ == "branch"
|
else if (current_type_ == "branch"
|
||||||
|| current_type_ == "index"
|
|| current_type_ == "index"
|
||||||
|| current_type_ == "change")
|
|| current_type_ == "change"
|
||||||
|
|| current_type_ == "table"
|
||||||
|
|| current_type_ == "listing"
|
||||||
|
|| current_type_ == "figure")
|
||||||
inset = &dit.inset();
|
inset = &dit.inset();
|
||||||
|
|
||||||
else if (current_type_ == "table"
|
|
||||||
|| current_type_ == "listing"
|
|
||||||
|| current_type_ == "figure") {
|
|
||||||
DocIterator tmp_dit(dit);
|
|
||||||
tmp_dit.pop_back();
|
|
||||||
inset = &tmp_dit.inset();
|
|
||||||
}
|
|
||||||
return inset;
|
return inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +153,7 @@ bool TocWidget::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
|
|
||||||
case LFUN_LABEL_COPY_AS_REFERENCE: {
|
case LFUN_LABEL_COPY_AS_REFERENCE: {
|
||||||
// For labels in math, we need to supply the label as a string
|
// For labels in math, we need to supply the label as a string
|
||||||
FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
|
FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
|
||||||
if (inset)
|
if (inset)
|
||||||
return inset->getStatus(cur, label_copy, status);
|
return inset->getStatus(cur, label_copy, status);
|
||||||
break;
|
break;
|
||||||
@ -202,7 +198,7 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_LABEL_COPY_AS_REFERENCE: {
|
case LFUN_LABEL_COPY_AS_REFERENCE: {
|
||||||
// For labels in math, we need to supply the label as a string
|
// For labels in math, we need to supply the label as a string
|
||||||
FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
|
FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
|
||||||
if (inset)
|
if (inset)
|
||||||
inset->dispatch(cur, label_copy);
|
inset->dispatch(cur, label_copy);
|
||||||
break;
|
break;
|
||||||
|
@ -616,6 +616,8 @@ QString guiName(string const & type, BufferParams const & bp)
|
|||||||
return qt_("Index Entries");
|
return qt_("Index Entries");
|
||||||
if (type == "marginalnote")
|
if (type == "marginalnote")
|
||||||
return qt_("Marginal notes");
|
return qt_("Marginal notes");
|
||||||
|
if (type == "math-macro")
|
||||||
|
return qt_("Math macros");
|
||||||
if (type == "nomencl")
|
if (type == "nomencl")
|
||||||
return qt_("Nomenclature Entries");
|
return qt_("Nomenclature Entries");
|
||||||
if (type == "note")
|
if (type == "note")
|
||||||
|
@ -74,7 +74,7 @@ std::string insetName(InsetCode);
|
|||||||
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
|
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
|
||||||
docstring insetDisplayName(InsetCode);
|
docstring insetDisplayName(InsetCode);
|
||||||
///
|
///
|
||||||
static int const TOC_ENTRY_LENGTH = 40;
|
static int const TOC_ENTRY_LENGTH = 80;
|
||||||
|
|
||||||
/// Common base class to all insets
|
/// Common base class to all insets
|
||||||
|
|
||||||
@ -493,7 +493,15 @@ public:
|
|||||||
/// Add an entry to the TocList
|
/// Add an entry to the TocList
|
||||||
/// Pass a DocIterator that points at the paragraph containing
|
/// Pass a DocIterator that points at the paragraph containing
|
||||||
/// the inset
|
/// the inset
|
||||||
virtual void addToToc(DocIterator const & /* di */, bool /* output_active */) const {}
|
///
|
||||||
|
/// \param output_active : is the inset active or is it in an inactive
|
||||||
|
/// branch or a note?
|
||||||
|
///
|
||||||
|
/// \param utype : is the toc being generated for use by the output
|
||||||
|
/// routines?
|
||||||
|
virtual void addToToc(DocIterator const & /* di */,
|
||||||
|
bool /* output_active */,
|
||||||
|
UpdateType /* utype*/) const {}
|
||||||
/// Collect BibTeX information
|
/// Collect BibTeX information
|
||||||
virtual void collectBibKeys(InsetIterator const &) const {}
|
virtual void collectBibKeys(InsetIterator const &) const {}
|
||||||
/// Update the counters of this inset and of its contents.
|
/// Update the counters of this inset and of its contents.
|
||||||
|
@ -348,7 +348,8 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
|
||||||
@ -359,7 +360,7 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
bool const doing_output = output_active && isBranchSelected();
|
bool const doing_output = output_active && isBranchSelected();
|
||||||
InsetCollapsable::addToToc(cpit, doing_output);
|
InsetCollapsable::addToToc(cpit, doing_output, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ private:
|
|||||||
///
|
///
|
||||||
std::string contextMenuName() const;
|
std::string contextMenuName() const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
InsetBranchParams const & params() const { return params_; }
|
InsetBranchParams const & params() const { return params_; }
|
||||||
///
|
///
|
||||||
|
@ -90,17 +90,25 @@ void InsetCaption::setCustomLabel(docstring const & label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCaption::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
string const & type = floattype_.empty() ? "senseless" : floattype_;
|
string const & type = floattype_.empty() ? "senseless" : floattype_;
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
|
||||||
docstring str = full_label_;
|
int length = (utype == OutputUpdate) ?
|
||||||
int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
|
// For output (e.g. xhtml) all (bug #8603) or nothing
|
||||||
text().forOutliner(str, length);
|
(output_active ? INT_MAX : 0) :
|
||||||
|
// TOC for LyX interface
|
||||||
|
TOC_ENTRY_LENGTH;
|
||||||
|
docstring str;
|
||||||
|
if (length > 0) {
|
||||||
|
str = full_label_;
|
||||||
|
text().forOutliner(str, length);
|
||||||
|
}
|
||||||
buffer().tocBackend().builder(type)->captionItem(pit, str, output_active);
|
buffer().tocBackend().builder(type)->captionItem(pit, str, output_active);
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
InsetText::addToToc(cpit, output_active);
|
InsetText::addToToc(cpit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,9 +79,8 @@ private:
|
|||||||
docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
|
docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
|
||||||
///
|
///
|
||||||
void setCustomLabel(docstring const & label);
|
void setCustomLabel(docstring const & label);
|
||||||
/// \param output_active : is the toc being generated for use by the
|
///
|
||||||
/// output routines?
|
void addToToc(DocIterator const & di, bool output_active, UpdateType utype) const;
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
|
||||||
///
|
///
|
||||||
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
|
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
|
||||||
/// Captions don't accept alignment, spacing, etc.
|
/// Captions don't accept alignment, spacing, etc.
|
||||||
|
@ -45,17 +45,21 @@ docstring InsetCaptionable::floatName(string const & type) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
|
||||||
docstring str;
|
docstring str;
|
||||||
int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
|
// Leave str empty if we generate for output (e.g. xhtml lists of figures).
|
||||||
text().forOutliner(str, length);
|
// This ensures that there is a caption if and only if the string is
|
||||||
|
// non-empty.
|
||||||
|
if (utype != OutputUpdate)
|
||||||
|
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||||
shared_ptr<TocBuilder> b = buffer().tocBackend().builder(caption_type_);
|
shared_ptr<TocBuilder> b = buffer().tocBackend().builder(caption_type_);
|
||||||
b->pushItem(pit, str, output_active);
|
b->pushItem(pit, str, output_active);
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
InsetCollapsable::addToToc(cpit, output_active);
|
InsetCollapsable::addToToc(cpit, output_active, utype);
|
||||||
b->pop();
|
b->pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ protected:
|
|||||||
/// are our captions subcaptions?
|
/// are our captions subcaptions?
|
||||||
virtual bool hasSubCaptions(ParIterator const &) const { return false; }
|
virtual bool hasSubCaptions(ParIterator const &) const { return false; }
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
/// Update the counters of this inset and of its contents
|
/// Update the counters of this inset and of its contents
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
|
@ -331,7 +331,8 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCitation::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
{
|
{
|
||||||
// NOTE
|
// NOTE
|
||||||
// BiblioInfo::collectCitedEntries() uses the TOC to collect the citations
|
// BiblioInfo::collectCitedEntries() uses the TOC to collect the citations
|
||||||
|
@ -65,7 +65,8 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const & it, UpdateType);
|
void updateBuffer(ParIterator const & it, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
std::string contextMenuName() const;
|
std::string contextMenuName() const;
|
||||||
//@}
|
//@}
|
||||||
|
@ -209,8 +209,6 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
|
|||||||
op.local_font->language()->lang());
|
op.local_font->language()->lang());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME Do we need to check if it exists? If so, we need a new
|
|
||||||
// routine in TocBackend to do that.
|
|
||||||
shared_ptr<Toc const> toc = buffer().tocBackend().toc(toctype);
|
shared_ptr<Toc const> toc = buffer().tocBackend().toc(toctype);
|
||||||
if (toc->empty())
|
if (toc->empty())
|
||||||
return docstring();
|
return docstring();
|
||||||
@ -252,6 +250,8 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
|
|||||||
Toc::const_iterator it = toc->begin();
|
Toc::const_iterator it = toc->begin();
|
||||||
Toc::const_iterator const en = toc->end();
|
Toc::const_iterator const en = toc->end();
|
||||||
for (; it != en; ++it) {
|
for (; it != en; ++it) {
|
||||||
|
if (it->str().empty())
|
||||||
|
continue;
|
||||||
Paragraph const & par = it->dit().innerParagraph();
|
Paragraph const & par = it->dit().innerParagraph();
|
||||||
string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
|
string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
|
||||||
xs << html::StartTag("div", attr);
|
xs << html::StartTag("div", attr);
|
||||||
|
@ -74,7 +74,8 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFoot::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
|
||||||
@ -84,7 +85,7 @@ void InsetFoot::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
InsetFootlike::addToToc(cpit, output_active);
|
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ private:
|
|||||||
/// Update the counters of this inset and of its contents
|
/// Update the counters of this inset and of its contents
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -1027,7 +1027,8 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
{
|
{
|
||||||
//FIXME UNICODE
|
//FIXME UNICODE
|
||||||
docstring const str = from_utf8(params_.filename.onlyFileName());
|
docstring const str = from_utf8(params_.filename.onlyFileName());
|
||||||
|
@ -99,7 +99,8 @@ private:
|
|||||||
///
|
///
|
||||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
std::string contextMenuName() const;
|
std::string contextMenuName() const;
|
||||||
/// Force inset into LTR environment if surroundings are RTL
|
/// Force inset into LTR environment if surroundings are RTL
|
||||||
|
@ -1125,13 +1125,14 @@ void InsetInclude::addPreview(DocIterator const & /*inset_pos*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
TocBackend & backend = buffer().tocBackend();
|
TocBackend & backend = buffer().tocBackend();
|
||||||
|
|
||||||
if (isListings(params())) {
|
if (isListings(params())) {
|
||||||
if (label_)
|
if (label_)
|
||||||
label_->addToToc(cpit, output_active);
|
label_->addToToc(cpit, output_active, utype);
|
||||||
|
|
||||||
InsetListingsParams p(to_utf8(params()["lstparams"]));
|
InsetListingsParams p(to_utf8(params()["lstparams"]));
|
||||||
string caption = p.getParamValue("caption");
|
string caption = p.getParamValue("caption");
|
||||||
@ -1151,8 +1152,7 @@ void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
docstring str = childbuffer->fileName().displayName();
|
docstring str = childbuffer->fileName().displayName();
|
||||||
toc->push_back(TocItem(cpit, 0, str, output_active));
|
toc->push_back(TocItem(cpit, 0, str, output_active));
|
||||||
|
|
||||||
//TocList & toclist = backend.tocs();
|
childbuffer->tocBackend().update(output_active, utype);
|
||||||
childbuffer->tocBackend().update(output_active);
|
|
||||||
TocList const & childtoclist = childbuffer->tocBackend().tocs();
|
TocList const & childtoclist = childbuffer->tocBackend().tocs();
|
||||||
TocList::const_iterator it = childtoclist.begin();
|
TocList::const_iterator it = childtoclist.begin();
|
||||||
TocList::const_iterator const end = childtoclist.end();
|
TocList::const_iterator const end = childtoclist.end();
|
||||||
|
@ -104,7 +104,8 @@ public:
|
|||||||
///
|
///
|
||||||
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
|
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
|
@ -348,7 +348,8 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetIndex::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
|
||||||
@ -360,7 +361,7 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
text().forOutliner(str, INT_MAX);
|
text().forOutliner(str, INT_MAX);
|
||||||
buffer().tocBackend().toc(type)->push_back(TocItem(pit, 0, str, output_active));
|
buffer().tocBackend().toc(type)->push_back(TocItem(pit, 0, str, output_active));
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
InsetCollapsable::addToToc(cpit, output_active);
|
InsetCollapsable::addToToc(cpit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ private:
|
|||||||
/// should paragraph indendation be omitted in any case?
|
/// should paragraph indendation be omitted in any case?
|
||||||
bool neverIndent() const { return true; }
|
bool neverIndent() const { return true; }
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -169,7 +169,8 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetLabel::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetLabel::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
{
|
{
|
||||||
docstring const & label = getParam("name");
|
docstring const & label = getParam("name");
|
||||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
|
shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
|
||||||
|
@ -57,7 +57,8 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const & it, UpdateType);
|
void updateBuffer(ParIterator const & it, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name Static public methods obligated for InsetCommand derived classes
|
/// \name Static public methods obligated for InsetCommand derived classes
|
||||||
|
@ -51,7 +51,8 @@ int InsetMarginal::docbook(odocstream & os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
|
||||||
@ -61,7 +62,7 @@ void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||||
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
InsetFootlike::addToToc(cpit, output_active);
|
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -36,7 +36,8 @@ public:
|
|||||||
///
|
///
|
||||||
int docbook(odocstream &, OutputParams const & runparams) const;
|
int docbook(odocstream &, OutputParams const & runparams) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
Inset * clone() const { return new InsetMarginal(*this); }
|
Inset * clone() const { return new InsetMarginal(*this); }
|
||||||
|
@ -132,7 +132,8 @@ void InsetNomencl::validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
{
|
{
|
||||||
docstring const str = getParam("symbol");
|
docstring const str = getParam("symbol");
|
||||||
buffer().tocBackend().toc("nomencl")->push_back(TocItem(cpit, 0, str, output_active));
|
buffer().tocBackend().toc("nomencl")->push_back(TocItem(cpit, 0, str, output_active));
|
||||||
|
@ -40,7 +40,8 @@ public:
|
|||||||
/// Updates needed features for this inset.
|
/// Updates needed features for this inset.
|
||||||
void validate(LaTeXFeatures & features) const;
|
void validate(LaTeXFeatures & features) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return NOMENCL_CODE; }
|
InsetCode lyxCode() const { return NOMENCL_CODE; }
|
||||||
///
|
///
|
||||||
|
@ -207,7 +207,8 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetNote::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator pit = cpit;
|
DocIterator pit = cpit;
|
||||||
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
|
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
|
||||||
@ -220,7 +221,7 @@ void InsetNote::addToToc(DocIterator const & cpit, bool output_active) const
|
|||||||
|
|
||||||
// Proceed with the rest of the inset.
|
// Proceed with the rest of the inset.
|
||||||
bool doing_output = output_active && producesOutput();
|
bool doing_output = output_active && producesOutput();
|
||||||
InsetCollapsable::addToToc(cpit, doing_output);
|
InsetCollapsable::addToToc(cpit, doing_output, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +96,8 @@ private:
|
|||||||
///
|
///
|
||||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
|
@ -303,7 +303,8 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetRef::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
{
|
{
|
||||||
docstring const & label = getParam("reference");
|
docstring const & label = getParam("reference");
|
||||||
if (buffer().insetLabel(label))
|
if (buffer().insetLabel(label))
|
||||||
|
@ -70,7 +70,8 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const & it, UpdateType);
|
void updateBuffer(ParIterator const & it, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
bool forceLTR() const { return true; }
|
bool forceLTR() const { return true; }
|
||||||
//@}
|
//@}
|
||||||
|
@ -3439,9 +3439,10 @@ docstring InsetTableCell::asString(bool intoInsets)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
|
void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
InsetText::iterateForToc(di, output_active);
|
InsetText::iterateForToc(di, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3927,13 +3928,14 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::addToToc(DocIterator const & cpit, bool output_active) const
|
void InsetTabular::addToToc(DocIterator const & cpit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator dit = cpit;
|
DocIterator dit = cpit;
|
||||||
dit.forwardPos();
|
dit.forwardPos();
|
||||||
size_t const end = dit.nargs();
|
size_t const end = dit.nargs();
|
||||||
for ( ; dit.idx() < end; dit.top().forwardIdx())
|
for ( ; dit.idx() < end; dit.top().forwardIdx())
|
||||||
cell(dit.idx())->addToToc(dit, output_active);
|
cell(dit.idx())->addToToc(dit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ public:
|
|||||||
///
|
///
|
||||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
private:
|
private:
|
||||||
/// unimplemented
|
/// unimplemented
|
||||||
InsetTableCell();
|
InsetTableCell();
|
||||||
@ -942,7 +943,8 @@ public:
|
|||||||
/// Update the counters of this inset and of its contents
|
/// Update the counters of this inset and of its contents
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
bool completionSupported(Cursor const &) const;
|
bool completionSupported(Cursor const &) const;
|
||||||
|
@ -797,18 +797,20 @@ void InsetText::forOutliner(docstring & os, size_t maxlen) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
|
void InsetText::addToToc(DocIterator const & cdit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator dit = cdit;
|
DocIterator dit = cdit;
|
||||||
dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
|
dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
|
||||||
iterateForToc(dit, output_active);
|
iterateForToc(dit, output_active, utype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) const
|
void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
DocIterator dit = cdit;
|
DocIterator dit = cdit;
|
||||||
// Ensure that any document has a table of contents
|
// This also ensures that any document has a table of contents
|
||||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("tableofcontents");
|
shared_ptr<Toc> toc = buffer().tocBackend().toc("tableofcontents");
|
||||||
|
|
||||||
BufferParams const & bufparams = buffer_->params();
|
BufferParams const & bufparams = buffer_->params();
|
||||||
@ -832,7 +834,7 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) cons
|
|||||||
Inset & inset = *it->inset;
|
Inset & inset = *it->inset;
|
||||||
dit.pos() = it->pos;
|
dit.pos() = it->pos;
|
||||||
//lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
|
//lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
|
||||||
inset.addToToc(dit, doing_output);
|
inset.addToToc(dit, doing_output, utype);
|
||||||
if (inset.lyxCode() == ARG_CODE)
|
if (inset.lyxCode() == ARG_CODE)
|
||||||
arginset = inset.asInsetText();
|
arginset = inset.asInsetText();
|
||||||
}
|
}
|
||||||
@ -841,7 +843,8 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) cons
|
|||||||
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
|
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
|
||||||
// insert this into the table of contents
|
// insert this into the table of contents
|
||||||
docstring tocstring;
|
docstring tocstring;
|
||||||
int const length = doing_output ? INT_MAX : TOC_ENTRY_LENGTH;
|
int const length = (doing_output && utype == OutputUpdate) ?
|
||||||
|
INT_MAX : TOC_ENTRY_LENGTH;
|
||||||
if (arginset) {
|
if (arginset) {
|
||||||
tocstring = par.labelString();
|
tocstring = par.labelString();
|
||||||
if (!tocstring.empty())
|
if (!tocstring.empty())
|
||||||
|
@ -171,7 +171,8 @@ public:
|
|||||||
///
|
///
|
||||||
void forOutliner(docstring &, size_t) const;
|
void forOutliner(docstring &, size_t) const;
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
Inset * clone() const { return new InsetText(*this); }
|
Inset * clone() const { return new InsetText(*this); }
|
||||||
///
|
///
|
||||||
@ -217,7 +218,8 @@ protected:
|
|||||||
///
|
///
|
||||||
docstring getCaptionHTML(OutputParams const &) const;
|
docstring getCaptionHTML(OutputParams const &) const;
|
||||||
///
|
///
|
||||||
void iterateForToc(DocIterator const & cdit, bool output_active) const;
|
void iterateForToc(DocIterator const & cdit, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
bool drawFrame_;
|
bool drawFrame_;
|
||||||
|
@ -292,7 +292,8 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
|
void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
|
||||||
|
UpdateType utype) const
|
||||||
{
|
{
|
||||||
if (!buffer_) {
|
if (!buffer_) {
|
||||||
//FIXME: buffer_ should be set at creation for this inset! Problem is
|
//FIXME: buffer_ should be set at creation for this inset! Problem is
|
||||||
@ -307,7 +308,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
|
|||||||
if (!numbered(row))
|
if (!numbered(row))
|
||||||
continue;
|
continue;
|
||||||
if (label_[row])
|
if (label_[row])
|
||||||
label_[row]->addToToc(pit, output_active);
|
label_[row]->addToToc(pit, output_active, utype);
|
||||||
toc->push_back(TocItem(pit, 0, nicelabel(row), output_active));
|
toc->push_back(TocItem(pit, 0, nicelabel(row), output_active));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ public:
|
|||||||
///
|
///
|
||||||
void updateBuffer(ParIterator const &, UpdateType);
|
void updateBuffer(ParIterator const &, UpdateType);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active) const;
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
///
|
///
|
||||||
InsetMathHull & operator=(InsetMathHull const &);
|
InsetMathHull & operator=(InsetMathHull const &);
|
||||||
///
|
///
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
|
#include "TocBackend.h"
|
||||||
|
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
@ -1383,4 +1384,17 @@ string MathMacroTemplate::contextMenuName() const
|
|||||||
return "context-math-macro-definition";
|
return "context-math-macro-definition";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MathMacroTemplate::addToToc(DocIterator const & pit, bool output_active,
|
||||||
|
UpdateType) const
|
||||||
|
{
|
||||||
|
shared_ptr<Toc> toc = buffer().tocBackend().toc("math-macro");
|
||||||
|
docstring str;
|
||||||
|
if (!validMacro())
|
||||||
|
str = bformat(_("Invalid macro! \\%1$s"), name());
|
||||||
|
else
|
||||||
|
str = "\\" + name();
|
||||||
|
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -103,6 +103,9 @@ public:
|
|||||||
void infoize(odocstream & os) const;
|
void infoize(odocstream & os) const;
|
||||||
///
|
///
|
||||||
std::string contextMenuName() const;
|
std::string contextMenuName() const;
|
||||||
|
///
|
||||||
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
|
UpdateType utype) const;
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user