Simplify and fix the TOGGLE_INSET code for branch inset. If it turns out

that the extra complexity was intended, I would be interested to know
what the idea was.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28979 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-03-30 12:45:33 +00:00
parent 3030a279ac
commit 827c72e1f5

View File

@ -144,20 +144,8 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
break; break;
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign") { if (cmd.argument() == "assign")
// The branch inset uses "assign". setStatus(cur, isBranchSelected() ? Open : Collapsed);
if (isBranchSelected()) {
if (status(cur.bv()) != Open)
setStatus(cur, Open);
else
cur.undispatched();
} else {
if (status(cur.bv()) != Collapsed)
setStatus(cur, Collapsed);
else
cur.undispatched();
}
}
else else
InsetCollapsable::doDispatch(cur, cmd); InsetCollapsable::doDispatch(cur, cmd);
break; break;
@ -179,17 +167,11 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
break; break;
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
if (cmd.argument() == "open" || cmd.argument() == "close" || if (cmd.argument() == "assign") {
cmd.argument() == "toggle")
flag.setEnabled(true); flag.setEnabled(true);
else if (cmd.argument() == "assign" || cmd.argument().empty()) { break;
if (isBranchSelected()) }
flag.setEnabled(status(cur.bv()) != Open); //fall through to generic InsetCollapsable implmementation
else
flag.setEnabled(status(cur.bv()) != Collapsed);
} else
flag.setEnabled(true);
break;
default: default:
return InsetCollapsable::getStatus(cur, cmd, flag); return InsetCollapsable::getStatus(cur, cmd, flag);