From 2cd997962c3f7311f22a305a0622d834ffae4fde Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 9 Apr 2009 18:31:17 +0000 Subject: [PATCH] Leave handling of LFUN_COPY_LABEL_AS_REF to InsetLabel and move handling of LFUN_INSERT_LABEL_AS_REF also to InsetLabel. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29163 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/TocWidget.cpp | 24 ------------------------ src/insets/InsetLabel.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 688c7fe74a..3d4838a36b 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -97,30 +97,6 @@ void TocWidget::showContextMenu(const QPoint & pos) 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; - } } diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index bcbae9e3a6..bbbff3a06f 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -22,6 +22,7 @@ #include "FuncRequest.h" #include "FuncStatus.h" #include "InsetIterator.h" +#include "LyXFunc.h" #include "ParIterator.h" #include "sgml.h" #include "Text.h" @@ -177,6 +178,14 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd) 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; -- 2.39.2