mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Remove some hardcoded addToToc: note, footnote, marginalnote, branch
Define their Toc from the layout instead.
This commit is contained in:
parent
f0663e3ce4
commit
e11a3cb895
@ -6,6 +6,10 @@
|
||||
|
||||
Format 62
|
||||
|
||||
OutlinerName table "Tables" #no AddToToc (built-in)
|
||||
OutlinerName figure "Figures" #no AddToToc (built-in)
|
||||
OutlinerName algorithm "Algorithms" #no AddToToc (built-in)
|
||||
|
||||
Float
|
||||
Type table
|
||||
GuiName Table
|
||||
|
@ -8,6 +8,13 @@ Format 62
|
||||
|
||||
Provides stdinsets 1
|
||||
|
||||
OutlinerName marginalnote "Marginal notes"
|
||||
OutlinerName footnote "Footnotes"
|
||||
OutlinerName note "Notes"
|
||||
OutlinerName branch "Branches"
|
||||
OutlinerName index "Index Entries" #no AddToToc (built-in)
|
||||
OutlinerName listing "Listings" #no AddToToc (built-in)
|
||||
|
||||
InsetLayout Marginal
|
||||
LabelString margin
|
||||
LatexType command
|
||||
@ -35,6 +42,8 @@ InsetLayout Marginal
|
||||
font-style: normal;
|
||||
}
|
||||
EndHTMLStyle
|
||||
AddToToc marginalnote
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
InsetLayout Foot
|
||||
@ -76,6 +85,8 @@ InsetLayout Foot
|
||||
padding: 1em;
|
||||
}
|
||||
EndHTMLStyle
|
||||
AddToToc footnote
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
InsetLayout Foot:InTitle
|
||||
@ -130,6 +141,8 @@ InsetLayout Note:Comment
|
||||
display: none;
|
||||
}
|
||||
EndHTMLStyle
|
||||
AddToToc note
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
|
||||
@ -144,6 +157,8 @@ InsetLayout Note:Note
|
||||
EndFont
|
||||
MultiPar true
|
||||
# Not output for XHTML
|
||||
AddToToc note
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
|
||||
@ -172,6 +187,8 @@ InsetLayout Note:Greyedout
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLIsBlock false
|
||||
AddToToc note
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
InsetLayout ERT
|
||||
@ -338,6 +355,8 @@ InsetLayout Branch
|
||||
MultiPar true
|
||||
InToc true
|
||||
HTMLIsBlock false
|
||||
AddToToc branch
|
||||
IsTocCaption true
|
||||
End
|
||||
|
||||
InsetLayout Index
|
||||
|
@ -38,26 +38,31 @@ class Buffer;
|
||||
* I leave this for documentation purposes for the moment.
|
||||
*
|
||||
enum TocType {
|
||||
// Non-customizable (does not use TocBuilder)
|
||||
//The following is used for XHTML output
|
||||
TABLE_OF_CONTENTS,//"tableofcontents"
|
||||
CHANGE,//"change"
|
||||
//The following is used for XHTML output
|
||||
CITATION,//"citation"
|
||||
LABEL,//"label"
|
||||
SENSELESS,//"senseless"
|
||||
// Built-in but customizable
|
||||
CHILD,//"child"
|
||||
GRAPHICS,//"graphics"
|
||||
NOTE,//"note"
|
||||
BRANCH,//"branch"
|
||||
CHANGE,//"change"
|
||||
LABEL,//"label"
|
||||
CITATION,//"citation"
|
||||
EQUATION,//"equation"
|
||||
FOOTNOTE,//"footnote"
|
||||
MARGINAL_NOTE,//"marginalnote"
|
||||
INDEX,//"index", "index:<user-str>" (from interface)
|
||||
NOMENCL,//"nomencl"
|
||||
LISTING,//"listings"
|
||||
//The following are used for XHTML output
|
||||
FLOAT,//"figure", "table", "algorithm", user-defined (from layout?)
|
||||
MATH_MACRO,//"math-macro"
|
||||
EXTERNAL,//"external"
|
||||
SENSELESS,//"senseless"
|
||||
USER_DEFINED,//any value defined in the layouts
|
||||
TOC_TYPE_COUNT
|
||||
// Defined in layouts
|
||||
NOTE,//"note"
|
||||
FOOTNOTE,//"footnote"
|
||||
MARGINAL_NOTE,//"marginalnote"
|
||||
BRANCH,//"branch"
|
||||
USER_DEFINED //any value defined in the layouts
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -598,9 +598,18 @@ QStringList fileFilters(QString const & desc)
|
||||
|
||||
QString guiName(string const & type, BufferParams const & bp)
|
||||
{
|
||||
// FIXME: hardcoded
|
||||
// Hardcoded types
|
||||
if (type == "tableofcontents")
|
||||
return qt_("Table of Contents");
|
||||
if (type == "change")
|
||||
return qt_("Changes");
|
||||
if (type == "senseless")
|
||||
return qt_("Senseless");
|
||||
if (type == "citation")
|
||||
return qt_("Citations");
|
||||
if (type == "label")
|
||||
return qt_("Labels and References");
|
||||
// Customizable, but the corresponding insets have no layout definition
|
||||
if (type == "child")
|
||||
return qt_("Child Documents");
|
||||
if (type == "graphics")
|
||||
@ -609,30 +618,11 @@ QString guiName(string const & type, BufferParams const & bp)
|
||||
return qt_("Equations");
|
||||
if (type == "external")
|
||||
return qt_("External material");
|
||||
if (type == "footnote")
|
||||
return qt_("Footnotes");
|
||||
if (type == "listing")
|
||||
return qt_("Listings");
|
||||
if (type == "index")
|
||||
return qt_("Index Entries");
|
||||
if (type == "marginalnote")
|
||||
return qt_("Marginal notes");
|
||||
if (type == "math-macro")
|
||||
return qt_("Math macros");
|
||||
if (type == "nomencl")
|
||||
return qt_("Nomenclature Entries");
|
||||
if (type == "note")
|
||||
return qt_("Notes");
|
||||
if (type == "citation")
|
||||
return qt_("Citations");
|
||||
if (type == "label")
|
||||
return qt_("Labels and References");
|
||||
if (type == "branch")
|
||||
return qt_("Branches");
|
||||
if (type == "change")
|
||||
return qt_("Changes");
|
||||
if (type == "senseless")
|
||||
return qt_("Senseless");
|
||||
|
||||
if (prefixIs(type, "index:")) {
|
||||
string const itype = split(type, ':');
|
||||
IndicesList const & indiceslist = bp.indiceslist();
|
||||
@ -643,10 +633,6 @@ QString guiName(string const & type, BufferParams const & bp)
|
||||
return toqstr(bformat(_("Index Entries (%1$s)"), indextype));
|
||||
}
|
||||
|
||||
FloatList const & floats = bp.documentClass().floats();
|
||||
if (floats.typeExist(type))
|
||||
return qt_(floats.getType(type).listName());
|
||||
|
||||
return toqstr(bp.documentClass().outlinerName(type));
|
||||
}
|
||||
|
||||
|
@ -385,22 +385,10 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
|
||||
}
|
||||
|
||||
|
||||
void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
void InsetBranch::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
{
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
|
||||
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
str = params_.branch + (params_.inverted ? " (-):" : ": ") + str;
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("branch");
|
||||
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
bool const doing_output = output_active && producesOutput();
|
||||
InsetCollapsable::addToToc(cpit, doing_output, utype);
|
||||
setLabel(params_.branch + (params_.inverted ? " (-)" : ""));
|
||||
InsetCollapsable::updateBuffer(it, utype);
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,8 +88,7 @@ private:
|
||||
///
|
||||
std::string contextMenuName() const;
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
UpdateType utype) const;
|
||||
void updateBuffer(ParIterator const & it, UpdateType utype);
|
||||
///
|
||||
void setParams(InsetBranchParams const & params) { params_ = params; }
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Lexer.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "OutputParams.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "frontends/FontMetrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
@ -660,4 +661,30 @@ bool InsetCollapsable::canPaintChange(BufferView const & bv) const
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
{
|
||||
bool doing_output = output_active && producesOutput();
|
||||
InsetLayout const & layout = getLayout();
|
||||
if (layout.addToToc()) {
|
||||
TocBuilder & b = buffer().tocBackend().builder(layout.tocType());
|
||||
// Cursor inside the inset
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetCollapsable &>(*this)));
|
||||
docstring const label = getLabel();
|
||||
b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
|
||||
// Proceed with the rest of the inset.
|
||||
InsetText::addToToc(cpit, doing_output, utype);
|
||||
if (layout.isTocCaption()) {
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
b.argumentItem(str);
|
||||
}
|
||||
b.pop();
|
||||
} else
|
||||
InsetText::addToToc(cpit, doing_output, utype);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -150,6 +150,10 @@ public:
|
||||
std::string contextMenu(BufferView const & bv, int x, int y) const;
|
||||
///
|
||||
std::string contextMenuName() const;
|
||||
///
|
||||
void addToToc(DocIterator const & dit, bool output_active,
|
||||
UpdateType utype) const; //override
|
||||
|
||||
protected:
|
||||
///
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "Lexer.h"
|
||||
#include "ParIterator.h"
|
||||
#include "TextClass.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -166,28 +165,4 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
}
|
||||
|
||||
|
||||
void InsetFlex::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
{
|
||||
InsetLayout const & layout = getLayout();
|
||||
if (layout.addToToc()) {
|
||||
TocBuilder & b = buffer().tocBackend().builder(layout.tocType());
|
||||
// Cursor inside the inset
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetFlex &>(*this)));
|
||||
docstring const label = getLabel();
|
||||
b.pushItem(pit, label + (label.empty() ? "" : ": "), output_active);
|
||||
// Proceed with the rest of the inset.
|
||||
InsetCollapsable::addToToc(cpit, output_active, utype);
|
||||
if (layout.isTocCaption()) {
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
b.argumentItem(str);
|
||||
}
|
||||
b.pop();
|
||||
} else
|
||||
InsetCollapsable::addToToc(cpit, output_active, utype);
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -45,9 +45,6 @@ public:
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
void updateBuffer(ParIterator const & it, UpdateType utype);
|
||||
///
|
||||
void addToToc(DocIterator const & dit, bool output_active,
|
||||
UpdateType utype) const; //override
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -75,24 +75,6 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
}
|
||||
|
||||
|
||||
void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
{
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
|
||||
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
str = custom_label_ + ": " + str;
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("footnote");
|
||||
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
|
||||
{
|
||||
if (isOpen(bv))
|
||||
|
@ -39,9 +39,6 @@ private:
|
||||
/// Update the counters of this inset and of its contents
|
||||
void updateBuffer(ParIterator const &, UpdateType);
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
UpdateType utype) const;
|
||||
///
|
||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||
///
|
||||
Inset * clone() const { return new InsetFoot(*this); }
|
||||
|
@ -52,19 +52,4 @@ int InsetMarginal::docbook(odocstream & os,
|
||||
}
|
||||
|
||||
|
||||
void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
{
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
|
||||
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
std::shared_ptr<Toc> toc = buffer().tocBackend().toc("marginalnote");
|
||||
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
InsetFootlike::addToToc(cpit, output_active, utype);
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -35,9 +35,6 @@ public:
|
||||
size_t max_length = INT_MAX) const;
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const & runparams) const;
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
UpdateType utype) const;
|
||||
/// Is the content of this inset part of the immediate (visible) text sequence?
|
||||
bool isPartOfTextSequence() const { return false; }
|
||||
private:
|
||||
|
@ -208,26 +208,6 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType utype) const
|
||||
{
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
|
||||
|
||||
InsetLayout const & il = getLayout();
|
||||
docstring str;
|
||||
text().forOutliner(str, TOC_ENTRY_LENGTH);
|
||||
str = translateIfPossible(il.labelstring()) + ": " + str;
|
||||
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("note");
|
||||
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||
|
||||
// Proceed with the rest of the inset.
|
||||
bool doing_output = output_active && producesOutput();
|
||||
InsetCollapsable::addToToc(cpit, doing_output, utype);
|
||||
}
|
||||
|
||||
|
||||
bool InsetNote::isMacroScope() const
|
||||
{
|
||||
// LyX note has no latex output
|
||||
|
@ -96,9 +96,6 @@ private:
|
||||
///
|
||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
UpdateType utype) const;
|
||||
///
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
Inset * clone() const { return new InsetNote(*this); }
|
||||
|
Loading…
Reference in New Issue
Block a user