Author: vfr
Date: Mon May 31 14:25:32 2010
New Revision: 34555
URL: http://www.lyx.org/trac/changeset/34555

Log:
branch: Fix bug #6672

part 1: Notes, Footnotes, and Marginals are unnecessarily truncated.

part 2: Add tooltips to the outliner.

see r34286, r34287.

Modified:
   lyx-devel/branches/BRANCH_1_6_X/src/Changes.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.h
   lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/TocModel.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetBranch.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetCollapsable.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetFoot.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetMarginal.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetNote.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.h
   lyx-devel/branches/BRANCH_1_6_X/status.16x

Modified: lyx-devel/branches/BRANCH_1_6_X/src/Changes.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/Changes.cpp     Mon May 31 14:10:06 
2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/Changes.cpp     Mon May 31 14:25:32 
2010        (r34555)
@@ -501,14 +501,16 @@
                Toc::iterator it = change_list.item(0, author);
                if (it == change_list.end()) {
                        change_list.push_back(TocItem(dit, 0, author));
-                       change_list.push_back(TocItem(dit, 1, str));
+                       change_list.push_back(TocItem(dit, 1, str,
+                               support::wrapParas(str, 4)));
                        continue;
                }
                for (++it; it != change_list.end(); ++it) {
                        if (it->depth() == 0 && it->str() != author)
                                break;
                }
-               change_list.insert(it, TocItem(dit, 1, str));
+               change_list.insert(it, TocItem(dit, 1, str,
+                       support::wrapParas(str, 4)));
        }
 }
 

Modified: lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.cpp  Mon May 31 14:10:06 
2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.cpp  Mon May 31 14:25:32 
2010        (r34555)
@@ -44,8 +44,8 @@
 //
 ///////////////////////////////////////////////////////////////////////////
 
-TocItem::TocItem(DocIterator const & dit, int d, docstring const & s)
-       : dit_(dit), depth_(d), str_(s)
+TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
+       docstring const & t) : dit_(dit), depth_(d), str_(s), tooltip_(t)
 {
 }
 
@@ -68,6 +68,12 @@
 }
 
 
+docstring const & TocItem::tooltip() const
+{
+       return tooltip_;
+}
+
+
 docstring const TocItem::asString() const
 {
        return docstring(4 * depth_, ' ') + str_;

Modified: lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.h
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.h    Mon May 31 14:10:06 
2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/TocBackend.h    Mon May 31 14:25:32 
2010        (r34555)
@@ -42,7 +42,8 @@
        ///
        TocItem(DocIterator const & dit,
                int depth,
-               docstring const & s
+               docstring const & s,
+               docstring const & t = docstring()
                );
        ///
        ~TocItem() {}
@@ -53,6 +54,8 @@
        ///
        docstring const & str() const;
        ///
+       docstring const & tooltip() const;
+       ///
        docstring const asString() const;
 
        /// the action corresponding to the goTo above
@@ -67,6 +70,9 @@
 
        /// Full item string
        docstring str_;
+
+       /// The tooltip string
+       docstring tooltip_;
 };
 
 

Modified: lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/TocModel.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/TocModel.cpp      Mon May 
31 14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/TocModel.cpp      Mon May 
31 14:25:32 2010        (r34555)
@@ -155,6 +155,7 @@
        QModelIndex index = modelIndex(dit);
        TocItem const & toc_item = tocItem(index);
        model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
+       model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
 }
 
 
@@ -184,6 +185,7 @@
                QModelIndex top_level_item = model_->index(current_row, 0);
                model_->setData(top_level_item, toqstr(item.str()), 
Qt::DisplayRole);
                model_->setData(top_level_item, index, Qt::UserRole);
+               model_->setData(top_level_item, toqstr(item.tooltip()), 
Qt::ToolTipRole);
 
                LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
                        << ", added item " << item.str());
@@ -225,6 +227,7 @@
                child_item = model_->index(current_row, 0, parent);
                model_->setData(child_item, toqstr(item.str()), 
Qt::DisplayRole);
                model_->setData(child_item, index, Qt::UserRole);
+               model_->setData(child_item, toqstr(item.tooltip()), 
Qt::ToolTipRole);
                populate(index, child_item);
                if (index >= end)
                        break;

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetBranch.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetBranch.cpp  Mon May 31 
14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetBranch.cpp  Mon May 31 
14:25:32 2010        (r34555)
@@ -291,7 +291,7 @@
 
        Toc & toc = buffer().tocBackend().toc("branch");
        docstring const str = params_.branch + ": " + 
text().getPar(0).asString();
-       toc.push_back(TocItem(pit, 0, str));
+       toc.push_back(TocItem(pit, 0, str, toolTipText()));
        // Proceed with the rest of the inset.
        InsetCollapsable::addToToc(cpit);
 }

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetCollapsable.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetCollapsable.cpp     Mon May 
31 14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetCollapsable.cpp     Mon May 
31 14:25:32 2010        (r34555)
@@ -136,11 +136,7 @@
        if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
                return docstring();
 
-       OutputParams rp(&buffer().params().encoding());
-       odocstringstream ods;
-       InsetText::plaintext(ods, rp);
-       docstring const content_tip = ods.str();
-       return support::wrapParas(content_tip, 4);
+       return toolTipText();
 }
 
 

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetFoot.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetFoot.cpp    Mon May 31 
14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetFoot.cpp    Mon May 31 
14:25:32 2010        (r34555)
@@ -71,8 +71,8 @@
 
        Toc & toc = buffer().tocBackend().toc("footnote");
        docstring str;
-       str = custom_label_ + ": " + getNewLabel(str);
-       toc.push_back(TocItem(pit, 0, str));
+       str = custom_label_ + ": " + text().getPar(0).asString();
+       toc.push_back(TocItem(pit, 0, str, toolTipText()));
        // Proceed with the rest of the inset.
        InsetFootlike::addToToc(cpit);
 }

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetMarginal.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetMarginal.cpp        Mon May 
31 14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetMarginal.cpp        Mon May 
31 14:25:32 2010        (r34555)
@@ -76,8 +76,8 @@
 
        Toc & toc = buffer().tocBackend().toc("marginalnote");
        docstring str;
-       str = getNewLabel(str);
-       toc.push_back(TocItem(pit, 0, str));
+       str = text().getPar(0).asString();
+       toc.push_back(TocItem(pit, 0, str, toolTipText()));
        // Proceed with the rest of the inset.
        InsetFootlike::addToToc(cpit);
 }

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetNote.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetNote.cpp    Mon May 31 
14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetNote.cpp    Mon May 31 
14:25:32 2010        (r34555)
@@ -230,8 +230,8 @@
        Toc & toc = buffer().tocBackend().toc("note");
        docstring str;
        str = notetranslator_loc().find(params_.type) + from_ascii(": ")
-               + getNewLabel(str);
-       toc.push_back(TocItem(pit, 0, str));
+               + text().getPar(0).asString();
+       toc.push_back(TocItem(pit, 0, str, toolTipText()));
        // Proceed with the rest of the inset.
        InsetCollapsable::addToToc(cpit);
 }

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.cpp    Mon May 31 
14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.cpp    Mon May 31 
14:25:32 2010        (r34555)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author J�rgen Vigna
+ * \author Jürgen Vigna
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -537,7 +537,8 @@
                        // insert this into the table of contents
                        if (tocstring.empty())
                                tocstring = par.asString(AS_STR_LABEL | 
AS_STR_INSETS);
-                       toc.push_back(TocItem(dit, toclevel - min_toclevel, 
tocstring));
+                       toc.push_back(TocItem(dit, toclevel - min_toclevel,
+                               tocstring, tocstring));
                }
                
                // And now the list of changes.
@@ -636,4 +637,17 @@
 }
 
 
+
+docstring InsetText::toolTipText() const
+{
+       OutputParams rp(&buffer().params().encoding());
+       odocstringstream ods;
+       // do not remove InsetText::, otherwise there
+       // will be no tooltip text for InsetNotes
+       InsetText::plaintext(ods, rp);
+       docstring const content_tip = ods.str();
+       return support::wrapParas(content_tip, 4);
+}
+
+
 } // namespace lyx

Modified: lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.h
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.h      Mon May 31 
14:10:06 2010        (r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/src/insets/InsetText.h      Mon May 31 
14:25:32 2010        (r34555)
@@ -162,6 +162,8 @@
        bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
        ///
        void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & 
dim) const;
+       /// returns the text to be used as tooltip
+       docstring toolTipText() const;
 
        ///
        virtual docstring contextMenu(BufferView const & bv, int x, int y) 
const;

Modified: lyx-devel/branches/BRANCH_1_6_X/status.16x
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/status.16x  Mon May 31 14:10:06 2010        
(r34554)
+++ lyx-devel/branches/BRANCH_1_6_X/status.16x  Mon May 31 14:25:32 2010        
(r34555)
@@ -38,6 +38,11 @@
 - Layout and template file for document class article(IEEEtran) has been
   updated for IEEEtran 1.7a.
 
+- Do not unnecessarily truncate the text of notes, footnotes and marginals
+  (bug 6672, part 1).
+
+- Tooltips are added to the outliner (bug 6672, part 2).
+
 
 * DOCUMENTATION AND LOCALIZATION
 

Reply via email to