OptItem "Settings...|S" "inset-settings"
End
+#
+# InsetTocLabel context menu
+#
+
+ Menu "context-toc-label"
+ Item "Copy Label as Reference|C" "copy-label-as-reference"
+ End
+
End
}
+TocItem const TocModels::currentItem(QString const & type,
+ QModelIndex const & index) const
+{
+ const_iterator it = models_.find(type);
+ if (it == models_.end() || !index.isValid()) {
+ LYXERR(Debug::GUI, "TocModels::currentItem(): QModelIndex is invalid!");
+ return TocItem();
+ }
+ LASSERT(index.model() == it.value()->model(), return TocItem());
+
+ return it.value()->tocItem(index);
+}
+
+
void TocModels::updateBackend() const
{
bv_->buffer().masterBuffer()->tocBackend().update();
void sort(QString const & type, bool sort_it);
///
bool isSorted(QString const & type) const;
+ /// the item that is currently selected
+ TocItem const currentItem(QString const & type,
+ QModelIndex const & index) const;
Q_SIGNALS:
/// Signal that the internal toc_models_ has been reset.
#include "TocModel.h"
#include "Buffer.h"
+#include "CutAndPaste.h"
#include "FuncRequest.h"
#include "LyXFunc.h"
#include "Menus.h"
+#include "TocBackend.h"
+
+#include "insets/InsetCommand.h"
+#include "insets/InsetRef.h"
#include "support/debug.h"
#include "support/lassert.h"
void TocWidget::doDispatch(Cursor const & cur, FuncRequest const & cmd)
{
switch(cmd.action) {
+ case LFUN_COPY_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();
+ cap::clearSelection();
+ cap::copyInset(cur, new InsetRef(*cur.buffer(), p), item.str());
+ }
+ break;
+ }
+
default:
break;
}