]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Cocoa based Qt-4.6 needs to paint every character separately to match metrics computa...
[lyx.git] / src / insets / InsetBranch.cpp
index 7bb1b655554875d9dd8dac027eb004a5a80a8cc1..4888992ba7819da947374c016d5964b218c030ca 100644 (file)
@@ -116,6 +116,8 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetBranchParams params;
                InsetBranch::string2params(to_utf8(cmd.argument()), params);
+
+               cur.recordUndoInset(ATOMIC_UNDO, this);
                params_.branch = params.branch;
                // what we really want here is a TOC update, but that means
                // a full buffer update
@@ -201,9 +203,10 @@ bool InsetBranch::isBranchSelected() const
 }
 
 
-int InsetBranch::latex(odocstream & os, OutputParams const & runparams) const
+void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
 {
-       return isBranchSelected() ?  InsetText::latex(os, runparams) : 0;
+       if (isBranchSelected())
+               InsetText::latex(os, runparams);
 }
 
 
@@ -236,10 +239,17 @@ docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 }
 
 
-void InsetBranch::tocString(odocstream & os) const
+void InsetBranch::toString(odocstream & os) const
+{
+       if (isBranchSelected())
+               InsetCollapsable::toString(os);
+}
+
+
+void InsetBranch::forToc(docstring & os, size_t maxlen) const
 {
        if (isBranchSelected())
-               InsetCollapsable::tocString(os);
+               InsetCollapsable::forToc(os, maxlen);
 }
 
 
@@ -285,14 +295,15 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
 }
 
 
-void InsetBranch::addToToc(DocIterator const & cpit)
+void InsetBranch::addToToc(DocIterator const & cpit) const
 {
        DocIterator pit = cpit;
-       pit.push_back(CursorSlice(*this));
+       pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
 
        Toc & toc = buffer().tocBackend().toc("branch");
-       docstring const str = params_.branch + ": " + text().getPar(0).asString();
-       toc.push_back(TocItem(pit, 0, str, toolTipText()));
+       docstring str = params_.branch + ": ";
+       text().forToc(str, TOC_ENTRY_LENGTH);
+       toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60)));
        // Proceed with the rest of the inset.
        InsetCollapsable::addToToc(cpit);
 }