]> git.lyx.org Git - features.git/commitdiff
Leave handling of LFUN_COPY_LABEL_AS_REF to InsetLabel and move handling of LFUN_INSE...
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 9 Apr 2009 18:31:17 +0000 (18:31 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 9 Apr 2009 18:31:17 +0000 (18:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29163 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocWidget.cpp
src/insets/InsetLabel.cpp

index 688c7fe74a06ce26554e48474b125b753511c000..3d4838a36ba2625702d0eed8444c7c5a84eee0d4 100644 (file)
@@ -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;
-       }
 }
 
 
index bcbae9e3a6e188c98091fb1ebc43d9020547f724..bbbff3a06f4b7b5c78020e1dd8367379ad5f9f05 100644 (file)
@@ -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;