From: Vincent van Ravesteijn Date: Wed, 8 Apr 2009 22:03:28 +0000 (+0000) Subject: Add "Insert label as reference" to the context menu of the TOC. X-Git-Tag: 2.0.0~6898 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=df3cddcd374d290988bcd97096c765f19a5d635a;p=features.git Add "Insert label as reference" to the context menu of the TOC. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29157 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc index 21215af4a2..41540037b5 100644 --- a/lib/ui/stdcontext.inc +++ b/lib/ui/stdcontext.inc @@ -414,11 +414,12 @@ Menuset End # -# InsetTocLabel context menu +# Toc Labels and References context menu # Menu "context-toc-label" Item "Copy Label as Reference|C" "copy-label-as-reference" + Item "Insert Reference at Cursor Position|I" "insert-label-as-reference" End End diff --git a/src/FuncCode.h b/src/FuncCode.h index f46f0e1e60..33cca3a56c 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -412,10 +412,10 @@ enum FuncCode LFUN_TAB_DELETE, LFUN_WORD_FINDADV, // Tommaso, 20081003 LFUN_REGEXP_MODE, // Tommaso, 20081003 - LFUN_COPY_LABEL_AS_REF, // sts, 20081116 - // 320 LFUN_VC_COMMAND, - LFUN_MATH_FONT_STYLE, + // 320 + LFUN_COPY_LABEL_AS_REF, // sts, 20081116 + LFUN_INSERT_LABEL_AS_REF, // vfr, 20090407 LFUN_PHANTOM_INSERT, // uwestoehr, 20090130 LFUN_INSET_BEGIN, // JMarc, 20090316 LFUN_INSET_END, // JMarc, 20090316 @@ -427,6 +427,7 @@ enum FuncCode LFUN_BUFFER_ZOOM_OUT, // vfr, 20090330 // 330 LFUN_MATH_BIGDELIM, + LFUN_MATH_FONT_STYLE, LFUN_LASTACTION // end of the table diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index ac12e743aa..f5669b166a 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3225,6 +3225,15 @@ void LyXAction::init() */ { LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference", ReadOnly | NoUpdate, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_INSERT_LABEL_AS_REF + * \li Action: Inserts the label as a cross-reference at the position of the cursor. + * \li Syntax: insert-label-as-reference + * \li Origin: vfr, 7 Apr 2009 + * \endvar + */ + { LFUN_INSERT_LABEL_AS_REF, "insert-label-as-reference", Noop, Edit}, + /*! * \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_IN * \li Action: Increases the zoom of the screen fonts. diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 7c985d4d9e..5af9ab4c82 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -98,15 +98,22 @@ void TocWidget::showContextMenu(const QPoint & pos) void TocWidget::doDispatch(Cursor const & cur, FuncRequest const & cmd) { switch(cmd.action) { - case LFUN_COPY_LABEL_AS_REF: { + + case LFUN_COPY_LABEL_AS_REF: + case LFUN_INSERT_LABEL_AS_REF: { QModelIndex index = tocTV->currentIndex(); - TocItem const & item = + TocItem const & item = gui_view_.tocModels().currentItem(current_type_, index); if (!item.str().empty()) { InsetCommandParams p(REF_CODE, "ref"); p["reference"] = item.str(); - cap::clearSelection(); - cap::copyInset(cur, new InsetRef(*cur.buffer(), p), 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; }