Fix bug 5851: Branch definitions not shown in Insert>Branch menu if master is set.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28934 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-03-27 11:44:40 +00:00
parent 5be56b517a
commit 88421aaeda
2 changed files with 35 additions and 4 deletions

View File

@ -1044,14 +1044,15 @@ void MenuDefinition::expandBranches(Buffer const * buf)
if (!buf) if (!buf)
return; return;
BufferParams const & params = buf->masterBuffer()->params(); BufferParams const & master_params = buf->masterBuffer()->params();
if (params.branchlist().empty()) { BufferParams const & params = buf->params();
if (params.branchlist().empty() && master_params.branchlist().empty() ) {
add(MenuItem(MenuItem::Help, qt_("No branches set for document!"))); add(MenuItem(MenuItem::Help, qt_("No branches set for document!")));
return; return;
} }
BranchList::const_iterator cit = params.branchlist().begin(); BranchList::const_iterator cit = master_params.branchlist().begin();
BranchList::const_iterator end = params.branchlist().end(); BranchList::const_iterator end = master_params.branchlist().end();
for (int ii = 1; cit != end; ++cit, ++ii) { for (int ii = 1; cit != end; ++cit, ++ii) {
docstring label = cit->branch(); docstring label = cit->branch();
@ -1063,6 +1064,32 @@ void MenuDefinition::expandBranches(Buffer const * buf)
FuncRequest(LFUN_BRANCH_INSERT, FuncRequest(LFUN_BRANCH_INSERT,
cit->branch()))); cit->branch())));
} }
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);
}
} }

View File

@ -84,6 +84,10 @@ docstring InsetBranch::toolTip(BufferView const &, int, int) const
docstring const InsetBranch::buttonLabel(BufferView const & bv) const docstring const InsetBranch::buttonLabel(BufferView const & bv) const
{ {
docstring s = _("Branch: ") + params_.branch; docstring s = _("Branch: ") + params_.branch;
Buffer const & realbuffer = *buffer().masterBuffer();
BranchList const & branchlist = realbuffer.params().branchlist();
if (!branchlist.find(params_.branch))
s = _("Branch (child only): ") + params_.branch;
if (!params_.branch.empty()) { if (!params_.branch.empty()) {
// FIXME UNICODE // FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch)); ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));