namespace frontend {
TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
- : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view),
- timer_(new QTimer(this))
+ : QWidget(parent), depth_(0), persistent_(false), keep_expanded_(false),
+ gui_view_(gui_view), timer_(new QTimer(this))
{
setupUi(this);
void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
DispatchResult & dr)
{
-
Inset * inset = itemInset();
QModelIndex const & index = tocTV->currentIndex();
void TocWidget::on_tocTV_pressed(QModelIndex const & index)
{
-
+ DocIterator const & dit = gui_view_.documentBufferView()->cursor();
+ keep_expanded_ = gui_view_.tocModels().currentIndex(current_type_, dit) == index;
Qt::MouseButtons const button = QApplication::mouseButtons();
if (button & Qt::LeftButton) {
goTo(index);
}
+void TocWidget::on_tocTV_doubleClicked(QModelIndex const &)
+{
+ keep_expanded_ = true;
+}
+
+
void TocWidget::goTo(QModelIndex const & index)
{
LYXERR(Debug::GUI, "goto " << index.row()
void TocWidget::sendDispatch(FuncRequest fr)
{
-
fr.setViewOrigin(&gui_view_);
GuiWorkArea * old_wa = gui_view_.currentWorkArea();
GuiWorkArea * doc_wa = gui_view_.currentMainWorkArea();
// Expensive operations are on a timer. We finish the update immediately
// for sparse edition actions, i.e. there was no edition/cursor movement
// recently, then every 300ms.
- if (!timer_->isActive()) {
+ if (!timer_->isActive() && !keep_expanded_) {
finishUpdateView();
timer_->start(300);
}
+ keep_expanded_ = false;
}
// text and moving with arrows. For bigger operations, this is negligible,
// and outweighted by TocModels::reset() anyway.
if (canNavigate()) {
- if (!persistent_)
+ if (!persistent_ && !keep_expanded_)
setTreeDepth(depth_);
+ keep_expanded_ = false;
persistentCB->setChecked(persistent_);
// select the item at current cursor location
if (gui_view_.documentBufferView()) {
typeCO->setCurrentIndex(new_index);
typeCO->blockSignals(false);
updateViewNow();
+ if (persistent_)
+ setTreeDepth(depth_);
}
} // namespace frontend