As discussed in another thread, it is not a good idea to update Toc
whenever, e.g., the caption of an InsetListings is changed. This is
because
1. TocBackend::update() is expensive by my standard
2. Too many things will break Toc (such as removal of an inset).
3. Toc does not need to be updated all the time.

The outline panel has its own update button, the only remaining case
is the navigation menu. The following patch does exactly this:


Index: src/MenuBackend.cpp
===================================================================
--- src/MenuBackend.cpp (revision 18692)
+++ src/MenuBackend.cpp (working copy)
@@ -704,6 +704,7 @@
                                   FuncRequest(LFUN_NOACTION)));
               return;
       }
+       const_cast<Buffer*>(buf)->tocBackend().update();

       // Add an entry for the master doc if this is a child doc
       Buffer const * const master = buf->getMasterBuffer();

OK to apply? (The attached patch also show caption, not filename for
InsetInclude, a minor correction of the Toc behavior).

Cheers,
Bo
Index: src/insets/InsetInclude.cpp
===================================================================
--- src/insets/InsetInclude.cpp	(revision 18692)
+++ src/insets/InsetInclude.cpp	(working copy)
@@ -889,7 +889,7 @@
 		if (!caption.empty()) {
 			Toc & toc = toclist["listing"];
 			docstring const str = convert<docstring>(toc.size() + 1)
-				+ ". " +  params_["filename"];
+				+ ". " +  from_utf8(caption);
 			// This inset does not have a valid ParConstIterator 
 			// so it has to use the iterator of its parent paragraph
 			toc.push_back(TocItem(pit, 0, str));
Index: src/insets/InsetListingsParams.cpp
===================================================================
--- src/insets/InsetListingsParams.cpp	(revision 18692)
+++ src/insets/InsetListingsParams.cpp	(working copy)
@@ -830,7 +830,12 @@
 {
 	// is this parameter defined?
 	map<string, string>::const_iterator it = params_.find(param);
-	return (it == params_.end()) ? string() : it->second;
+	string par = (it == params_.end()) ? string() : it->second;
+	if (prefixIs(par, "{") && suffixIs(par, "}"))
+		return par.substr(1, par.size() - 2);
+	else
+		return par;
+		
 }
 
 
Index: src/MenuBackend.cpp
===================================================================
--- src/MenuBackend.cpp	(revision 18692)
+++ src/MenuBackend.cpp	(working copy)
@@ -704,6 +704,7 @@
 				    FuncRequest(LFUN_NOACTION)));
 		return;
 	}
+	const_cast<Buffer*>(buf)->tocBackend().update();
 
 	// Add an entry for the master doc if this is a child doc
 	Buffer const * const master = buf->getMasterBuffer();

Reply via email to