+
+ if (buf == buf->masterBuffer())
+ return;
+
+ MenuDefinition child_branches;
+
+ BranchList::const_iterator ccit = params.branchlist().begin();
+ BranchList::const_iterator cend = params.branchlist().end();
+
+ for (int ii = 1; ccit != cend; ++ccit, ++ii) {
+ docstring label = ccit->branch();
+ if (ii < 10) {
+ label = convert<docstring>(ii) + ". " + label
+ + char_type('|') + convert<docstring>(ii);
+ }
+ child_branches.addWithStatusCheck(MenuItem(MenuItem::Command,
+ toqstr(label),
+ FuncRequest(LFUN_BRANCH_INSERT,
+ ccit->branch())));
+ }
+
+ if (!child_branches.empty()) {
+ MenuItem item(MenuItem::Submenu, qt_("Child Document"));
+ item.setSubmenu(child_branches);
+ add(item);
+ }
+}
+
+
+void MenuDefinition::expandIndices(Buffer const * buf, bool listof)
+{
+ if (!buf)
+ return;
+
+ BufferParams const & params = buf->masterBuffer()->params();
+ if (!params.use_indices) {
+ if (listof)
+ addWithStatusCheck(MenuItem(MenuItem::Command,
+ qt_("Index List|I"),
+ FuncRequest(LFUN_INDEX_PRINT,
+ from_ascii("idx"))));
+ else
+ addWithStatusCheck(MenuItem(MenuItem::Command,
+ qt_("Index Entry|d"),
+ FuncRequest(LFUN_INDEX_INSERT,
+ from_ascii("idx"))));
+ return;
+ }
+
+ if (params.indiceslist().empty())
+ return;
+
+ IndicesList::const_iterator cit = params.indiceslist().begin();
+ IndicesList::const_iterator end = params.indiceslist().end();
+
+ for (int ii = 1; cit != end; ++cit, ++ii) {
+ if (listof)
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cit->index()),
+ FuncRequest(LFUN_INDEX_PRINT,
+ cit->shortcut())));
+ else {
+ docstring label = _("Index Entry");
+ label += " (" + cit->index() + ")";
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
+ FuncRequest(LFUN_INDEX_INSERT,
+ cit->shortcut())));
+ }
+ }
+}
+
+
+void MenuDefinition::expandIndicesContext(Buffer const * buf, bool listof)
+{
+ if (!buf)
+ return;
+
+ BufferParams const & params = buf->masterBuffer()->params();
+ if (!params.use_indices || params.indiceslist().empty())
+ return;
+
+ IndicesList::const_iterator cit = params.indiceslist().begin();
+ IndicesList::const_iterator end = params.indiceslist().end();
+
+ for (int ii = 1; cit != end; ++cit, ++ii) {
+ if (listof) {
+ InsetCommandParams p(INDEX_PRINT_CODE);
+ p["type"] = cit->shortcut();
+ string const data = InsetCommand::params2string("index_print", p);
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(cit->index()),
+ FuncRequest(LFUN_INSET_MODIFY, data)));
+ } else {
+ docstring label = _("Index Entry");
+ label += " (" + cit->index() + ")";
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
+ FuncRequest(LFUN_INSET_MODIFY,
+ from_ascii("changetype ") + cit->shortcut())));
+ }
+ }