]> git.lyx.org Git - features.git/commitdiff
Add "Insert label as reference" to the context menu of the TOC.
authorVincent van Ravesteijn <vfr@lyx.org>
Wed, 8 Apr 2009 22:03:28 +0000 (22:03 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Wed, 8 Apr 2009 22:03:28 +0000 (22:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29157 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/stdcontext.inc
src/FuncCode.h
src/LyXAction.cpp
src/frontends/qt4/TocWidget.cpp

index 21215af4a291167a35fa3cdf8684868fddef5465..41540037b50fbbcf83c966ffff6da3e983f69b90 100644 (file)
@@ -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
index f46f0e1e60b2e827a694f8919cf86beb5e78f2fb..33cca3a56c661a69b6458e666666d96512a1b979 100644 (file)
@@ -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
index ac12e743aa32d892f18363a82dbdeb0abf4f08de..f5669b166aa1698efc21ba1bc7ab69acc6b72559 100644 (file)
@@ -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.
index 7c985d4d9e293cb64314bc46b7dbe6a2d45d629f..5af9ab4c82d3067961c8d32eeae7a4d297bb8dac 100644 (file)
@@ -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;
        }