void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
{
- switch(cmd.action) {
-
- case LFUN_COPY_LABEL_AS_REF:
- case LFUN_INSERT_LABEL_AS_REF: {
- QModelIndex index = tocTV->currentIndex();
- TocItem const & item =
- gui_view_.tocModels().currentItem(current_type_, index);
- if (!item.str().empty()) {
- InsetCommandParams p(REF_CODE, "ref");
- p["reference"] = item.str();
- if (cmd.action == LFUN_COPY_LABEL_AS_REF) {
- cap::clearSelection();
- cap::copyInset(cur, new InsetRef(*cur.buffer(), p), item.str());
- } else {
- string const data = InsetCommand::params2string("ref", p);
- dispatch(FuncRequest(LFUN_INSET_INSERT, data));
- }
- }
- break;
- }
-
- default:
- break;
- }
}
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "InsetIterator.h"
+#include "LyXFunc.h"
#include "ParIterator.h"
#include "sgml.h"
#include "Text.h"
break;
}
+ case LFUN_INSERT_LABEL_AS_REF: {
+ InsetCommandParams p(REF_CODE, "ref");
+ p["reference"] = getParam("name");
+ string const data = InsetCommand::params2string("ref", p);
+ lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
+ break;
+ }
+
default:
InsetCommand::doDispatch(cur, cmd);
break;