]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetFloat.cpp
Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=4910 by creating InsetText::addToToc().
[lyx.git] / src / insets / InsetFloat.cpp
index 4ba774314e9d861effbfb1e3a4b34ee80f1bd83e..a98d52170f57a932c5e43ea2bcb0f72da698e8f0 100644 (file)
@@ -127,6 +127,24 @@ InsetFloat::~InsetFloat()
 }
 
 
+docstring InsetFloat::toolTip(BufferView const & bv, int x, int y) const
+{
+       if (InsetCollapsable::toolTip(bv, x, y).empty())
+               return docstring();
+
+       docstring default_tip;
+       if (isOpen())
+               default_tip = _("Left-click to collapse the inset");
+       else
+               default_tip = _("Left-click to open the inset");
+       OutputParams rp(&buffer().params().encoding());
+       docstring caption_tip = getCaptionText(rp);
+       if (!isOpen() && !caption_tip.empty())
+               return caption_tip + '\n' + default_tip;
+       return default_tip;
+}
+
+
 void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
@@ -162,7 +180,7 @@ bool InsetFloat::getStatus(Cursor & cur, FuncRequest const & cmd,
 
        case LFUN_INSET_MODIFY:
        case LFUN_INSET_DIALOG_UPDATE:
-               flag.enabled(true);
+               flag.setEnabled(true);
                return true;
 
        default:
@@ -173,7 +191,7 @@ bool InsetFloat::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetFloat::updateLabels(ParIterator const & it)
 {
-       Counters & cnts = buffer().params().documentClass().counters();
+       Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
        string const saveflt = cnts.current_float();
        bool const savesubflt = cnts.isSubfloat();
 
@@ -424,6 +442,29 @@ docstring InsetFloat::getCaption(OutputParams const & runparams) const
 }
 
 
+docstring InsetFloat::getCaptionText(OutputParams const & runparams) const
+{
+       if (paragraphs().empty())
+               return docstring();
+
+       ParagraphList::const_iterator pit = paragraphs().begin();
+       for (; pit != paragraphs().end(); ++pit) {
+               InsetList::const_iterator it = pit->insetList().begin();
+               for (; it != pit->insetList().end(); ++it) {
+                       Inset & inset = *it->inset;
+                       if (inset.lyxCode() == CAPTION_CODE) {
+                               odocstringstream ods;
+                               InsetCaption * ins =
+                                       static_cast<InsetCaption *>(it->inset);
+                               ins->getCaptionText(ods, runparams);
+                               return ods.str();
+                       }
+               }
+       }
+       return docstring();
+}
+
+
 void InsetFloat::string2params(string const & in, InsetFloatParams & params)
 {
        params = InsetFloatParams();