]> git.lyx.org Git - lyx.git/blobdiff - src/TocBackend.cpp
Remove tooltips from the data of Toc Items
[lyx.git] / src / TocBackend.cpp
index e8c430d8eb6639acbccc8cbfb161d06d46d83376..2b13d1febfa8d37de5a673ed6d41be971abe4345 100644 (file)
@@ -49,9 +49,9 @@ namespace lyx {
 ///////////////////////////////////////////////////////////////////////////
 
 TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
-                       bool output_active, docstring const & t, FuncRequest action) :
-       dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active),
-       action_(action)
+                 bool output_active, FuncRequest action)
+       : dit_(dit), depth_(d), str_(s), output_(output_active),
+         action_(action)
 {
 }
 
@@ -62,12 +62,6 @@ int TocItem::id() const
 }
 
 
-docstring const & TocItem::tooltip() const
-{
-       return tooltip_.empty() ? str_ : tooltip_;
-}
-
-
 docstring const TocItem::asString() const
 {
        static char_type const cross = 0x2716; // ✖ U+2716 HEAVY MULTIPLICATION X
@@ -160,7 +154,7 @@ TocBuilder::TocBuilder(shared_ptr<Toc> toc)
 }
 
 void TocBuilder::pushItem(DocIterator const & dit, docstring const & s,
-                                                 bool output_active, bool is_captioned)
+                          bool output_active, bool is_captioned)
 {
        toc_->push_back(TocItem(dit, stack_.size(), s, output_active));
        frame f = {
@@ -171,7 +165,7 @@ void TocBuilder::pushItem(DocIterator const & dit, docstring const & s,
 }
 
 void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
-                                                        bool output_active)
+                             bool output_active)
 {
        // first show the float before moving to the caption
        docstring arg = "paragraph-goto " + paragraph_goto_arg(dit);
@@ -207,23 +201,6 @@ void TocBuilder::pop()
 
 
 
-///////////////////////////////////////////////////////////////////////////
-//
-// TocBuilderStore implementation
-//
-///////////////////////////////////////////////////////////////////////////
-
-shared_ptr<TocBuilder> TocBuilderStore::get(string const & type,
-                                            shared_ptr<Toc> toc)
-{
-       map_t::const_iterator it = map_.find(type);
-       if (it == map_.end())
-               it = map_.insert(make_pair(type, make_shared<TocBuilder>(toc))).first;
-       return it->second;
-}
-
-
-
 ///////////////////////////////////////////////////////////////////////////
 //
 // TocBackend implementation
@@ -241,16 +218,17 @@ shared_ptr<Toc const> TocBackend::toc(string const & type) const
 
 shared_ptr<Toc> TocBackend::toc(string const & type)
 {
-       TocList::const_iterator it = tocs_.find(type);
-       if (it == tocs_.end())
-               it = tocs_.insert(make_pair(type, make_shared<Toc>())).first;
-       return it->second;
+       // std::map::insert only really performs the insertion if the key is not
+       // already bound, and otherwise returns an iterator to the element already
+       // there, see manual.
+       return tocs_.insert({type, make_shared<Toc>()}).first->second;
 }
 
 
-shared_ptr<TocBuilder> TocBackend::builder(string const & type)
+TocBuilder & TocBackend::builder(string const & type)
 {
-       return builders_.get(type, toc(type));
+       auto p = make_unique<TocBuilder>(toc(type));
+       return * builders_.insert(make_pair(type, move(p))).first->second;
 }