void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
{
+
Inset * inset = itemInset();
FuncRequest tmpcmd(cmd);
void TocWidget::on_tocTV_pressed(QModelIndex const & index)
{
+
Qt::MouseButtons const button = QApplication::mouseButtons();
if (button & Qt::LeftButton) {
goTo(index);
LYXERR(Debug::GUI, "goto " << index.row()
<< ", " << index.column());
- gui_view_.tocModels().goTo(current_type_, index);
+ sendDispatch(gui_view_.tocModels().goTo(current_type_, index));
}
void TocWidget::on_typeCO_currentIndexChanged(int index)
{
+
if (index == -1)
return;
current_type_ = typeCO->itemData(index).toString();
QModelIndexList const & list = tocTV->selectionModel()->selectedIndexes();
if (list.isEmpty())
return;
+
+ //if another window is active, this attempt will fail,
+ //but it will work at least for the second attempt
+ gui_view_.activateWindow();
+
enableControls(false);
goTo(list[0]);
- dispatch(FuncRequest(func_code));
+ sendDispatch(FuncRequest(func_code));
enableControls(true);
gui_view_.setFocus();
}
+void TocWidget::sendDispatch(FuncRequest fr)
+{
+
+ fr.setViewOrigin(&gui_view_);
+ DispatchResult dr=dispatch(fr);
+ if (dr.error())
+ gui_view_.message(dr.message());
+}
+
+
void TocWidget::on_moveUpTB_clicked()
{
outline(LFUN_OUTLINE_UP);
void TocWidget::finishUpdateView()
{
// Profiling shows that this is the expensive stuff in the context of typing
- // text and moving with arrows (still five times less than updateToolbars in
- // my tests with a medium-sized document, however this grows linearly in the
- // size of the document). For bigger operations, this is negligible, and
- // outweighted by TocModels::reset() anyway.
+ // text and moving with arrows. For bigger operations, this is negligible,
+ // and outweighted by TocModels::reset() anyway.
if (canNavigate()) {
if (!persistent_)
setTreeDepth(depth_);
persistentCB->setChecked(persistent_);
- select(gui_view_.tocModels().currentIndex(current_type_));
+ // select the item at current cursor location
+ if (gui_view_.documentBufferView()) {
+ DocIterator const & dit = gui_view_.documentBufferView()->cursor();
+ select(gui_view_.tocModels().currentIndex(current_type_, dit));
+ }
}
filterContents();
}