]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/TocWidget.cpp
TOC context menu (part 4)
[lyx.git] / src / frontends / qt4 / TocWidget.cpp
index 5af9ab4c82d3067961c8d32eeae7a4d297bb8dac..57b0282d1342052e6b7a0682c121f08309af50bd 100644 (file)
@@ -95,32 +95,19 @@ void TocWidget::showContextMenu(const QPoint & pos)
 }
 
 
-void TocWidget::doDispatch(Cursor const & cur, FuncRequest const & cmd)
+void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
 {
-       switch(cmd.action) {
+       QModelIndex const & index = tocTV->currentIndex();
+       TocItem const & item =
+               gui_view_.tocModels().currentItem(current_type_, index);
+       DocIterator const & dit = item.dit();
        
-       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;
-       }
+       Inset * inset = 0;
+       if (current_type_ == "label")
+               inset = dit.nextInset();
 
-       default:
-               break;
-       }
+       if (inset)
+               inset->dispatch(cur, FuncRequest(cmd));
 }