mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Add TOC of external materials. (#7790, partial)
Known issues (non-regressions): * The TOC is not updated immediately after an external material inset is inserted. See TocBackend::updateItem().
This commit is contained in:
parent
bb344452c8
commit
68be651e89
@ -80,6 +80,8 @@ docstring const TocItem::asString() const
|
||||
return prefix + str_;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO
|
||||
docstring paragraph_goto_arg(DocIterator const & dit)
|
||||
{
|
||||
@ -88,6 +90,8 @@ docstring paragraph_goto_arg(DocIterator const & dit)
|
||||
convert<docstring>(s.pos());
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
FuncRequest TocItem::action() const
|
||||
{
|
||||
if (action_.action() == LFUN_UNKNOWN_ACTION) {
|
||||
|
@ -56,6 +56,7 @@ enum TocType {
|
||||
LISTING,//"listings"
|
||||
FLOAT,//"figure", "table", "algorithm", user-defined (from layout?)
|
||||
MATH_MACRO,//"math-macro"
|
||||
EXTERNAL,//"external"
|
||||
SENSELESS,//"senseless"
|
||||
TOC_TYPE_COUNT
|
||||
}
|
||||
|
@ -608,6 +608,8 @@ QString guiName(string const & type, BufferParams const & bp)
|
||||
return qt_("Graphics");
|
||||
if (type == "equation")
|
||||
return qt_("Equations");
|
||||
if (type == "external")
|
||||
return qt_("External material");
|
||||
if (type == "footnote")
|
||||
return qt_("Footnotes");
|
||||
if (type == "listing")
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "MetricsInfo.h"
|
||||
#include "OutputParams.h"
|
||||
#include "output_latex.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
#include "frontends/Application.h"
|
||||
@ -372,6 +373,33 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
docstring screenLabel(InsetExternalParams const & params,
|
||||
Buffer const & buffer)
|
||||
{
|
||||
external::Template const * const ptr =
|
||||
external::getTemplatePtr(params);
|
||||
if (!ptr)
|
||||
// FIXME UNICODE
|
||||
return bformat((_("External template %1$s is not installed")),
|
||||
from_utf8(params.templatename()));
|
||||
// FIXME UNICODE
|
||||
docstring gui = _(ptr->guiName);
|
||||
gui += ": ";
|
||||
|
||||
if (params.filename.empty())
|
||||
gui += "???";
|
||||
else
|
||||
gui += from_utf8(params.filename.relFileName(buffer.filePath()));
|
||||
|
||||
return gui;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
InsetExternal::InsetExternal(Buffer * buf)
|
||||
: Inset(buf), renderer_(new RenderButton)
|
||||
{
|
||||
@ -460,6 +488,17 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetExternal::addToToc(DocIterator const & cpit, bool output_active,
|
||||
UpdateType) const
|
||||
{
|
||||
DocIterator pit = cpit;
|
||||
pit.push_back(CursorSlice(const_cast<InsetExternal &>(*this)));
|
||||
shared_ptr<Toc> toc = buffer().tocBackend().toc("external");
|
||||
docstring str = screenLabel(params_, buffer());
|
||||
toc->push_back(TocItem(pit, 0, str, output_active));
|
||||
}
|
||||
|
||||
|
||||
bool InsetExternal::showInsetDialog(BufferView * bv) const
|
||||
{
|
||||
bv->showDialog("external", params2string(params(), bv->buffer()),
|
||||
@ -498,28 +537,6 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
|
||||
return gparams;
|
||||
}
|
||||
|
||||
|
||||
docstring screenLabel(InsetExternalParams const & params,
|
||||
Buffer const & buffer)
|
||||
{
|
||||
external::Template const * const ptr =
|
||||
external::getTemplatePtr(params);
|
||||
if (!ptr)
|
||||
// FIXME UNICODE
|
||||
return bformat((_("External template %1$s is not installed")),
|
||||
from_utf8(params.templatename()));
|
||||
// FIXME UNICODE
|
||||
docstring gui = _(ptr->guiName);
|
||||
gui += ": ";
|
||||
|
||||
if (params.filename.empty())
|
||||
gui += "???";
|
||||
else
|
||||
gui += from_utf8(params.filename.relFileName(buffer.filePath()));
|
||||
|
||||
return gui;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
@ -120,6 +120,9 @@ public:
|
||||
bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
|
||||
///
|
||||
bool clickable(int, int) const { return true; }
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
UpdateType utype) const;
|
||||
private:
|
||||
///
|
||||
InsetExternal(InsetExternal const &);
|
||||
|
Loading…
Reference in New Issue
Block a user