]> git.lyx.org Git - features.git/commitdiff
Fix bug #7224. This allows two different floats to declare the same
authorRichard Heck <rgheck@comcast.net>
Wed, 2 Feb 2011 17:11:56 +0000 (17:11 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 2 Feb 2011 17:11:56 +0000 (17:11 +0000)
ListCommand without our writing it to the menu twice. There's a minor
annoyance, which is that we always take the list name from the first
declaration of the Float, but it's not clear whether this is a real
issue.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37424 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/tufte-book.layout
src/frontends/qt4/Menus.cpp

index 2e29595d5851193de328890e8d0c9599b5261ac2..826476982c51ddf138c4fea55a249c164bccfe2f 100644 (file)
@@ -221,6 +221,7 @@ Float
        NumberWithin    none
        Style           plain
        ListName        "List of Tables"
+       ListCommand listoftables
        NeedsFloatPkg false
 End
 
@@ -232,6 +233,7 @@ Float
        NumberWithin    none
        Style           plain
        ListName        "List of Figures"
+       ListCommand listoffigures
        NeedsFloatPkg false
 End
 
index d3cce1e56b1ef85229199e9730f25d3b80a9a081..70379d9582e4aa8432e959311a6dce856788da10 100644 (file)
@@ -1094,11 +1094,21 @@ void MenuDefinition::expandFloatListInsert(Buffer const * buf)
        FloatList const & floats = buf->params().documentClass().floats();
        FloatList::const_iterator cit = floats.begin();
        FloatList::const_iterator end = floats.end();
+       set<string> seen;
        for (; cit != end; ++cit) {
-               addWithStatusCheck(MenuItem(MenuItem::Command,
-                                   qt_(cit->second.listName()),
-                                   FuncRequest(LFUN_FLOAT_LIST_INSERT,
-                                               cit->second.floattype())));
+               // Different floats could declare the same ListCommand. We only
+               // want it on the list once, though.
+               string const & list_cmd = cit->second.listCommand();
+               // This form of insert returns an iterator pointing to the newly
+               // inserted element OR the existing element with that value, and
+               // a bool indicating whether we inserted a new element. So we can
+               // see if one is there and insert it if not all at once.
+               pair<set<string>::iterator, bool> ret = seen.insert(list_cmd);
+               if (!ret.second)
+                       continue;
+               string const & list_name = cit->second.listName();
+               addWithStatusCheck(MenuItem(MenuItem::Command, qt_(list_name),
+                       FuncRequest(LFUN_FLOAT_LIST_INSERT, cit->second.floattype())));
        }
 }