]> 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 687d4727ab8947b4d55d2e45fed25059b5e0321e..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
@@ -134,7 +136,11 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
                        if (!our_branch)
                                break;
                }
-               our_branch->setSelected(cmd.action() == LFUN_BRANCH_ACTIVATE);
+               bool const activate = (cmd.action() == LFUN_BRANCH_ACTIVATE);
+               if (our_branch->isSelected() != activate) {
+                       our_branch->setSelected(activate);
+                       cur.forceBufferUpdate();
+               }
                break;
        }
        case LFUN_INSET_TOGGLE:
@@ -172,6 +178,7 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
                        flag.setEnabled(true);
                else
                        return InsetCollapsable::getStatus(cur, cmd, flag);     
+               break;
 
        default:
                return InsetCollapsable::getStatus(cur, cmd, flag);
@@ -196,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);
 }
 
 
@@ -231,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);
 }
 
 
@@ -245,7 +260,7 @@ void InsetBranch::validate(LaTeXFeatures & features) const
 }
 
 
-docstring InsetBranch::contextMenu(BufferView const &, int, int) const
+docstring InsetBranch::contextMenuName() const
 {
        return from_ascii("context-branch");
 }
@@ -280,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);
 }