commit 4cd568d3126670503ffab49c87ba21b27a8bdc27
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Feb 22 14:23:04 2023 +0100
Do not change outliner tree depth when not appropriate
This fixes expansion/collapsing on double-click (#12672)
---
src/frontends/qt/TocWidget.cpp | 18 +++++++++++++-----
src/frontends/qt/TocWidget.h | 3 +++
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index fcbd605..ef1a289 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -47,8 +47,8 @@ namespace lyx {
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);
@@ -263,7 +263,8 @@ void TocWidget::on_tocTV_activated(QModelIndex const &
index)
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);
@@ -273,6 +274,12 @@ void TocWidget::on_tocTV_pressed(QModelIndex const & index)
}
+void TocWidget::on_tocTV_doubleClicked(QModelIndex const &)
+{
+ keep_expanded_ = true;
+}
+
+
void TocWidget::goTo(QModelIndex const & index)
{
LYXERR(Debug::GUI, "goto " << index.row()
@@ -492,7 +499,7 @@ void TocWidget::updateView()
// 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);
}
@@ -512,8 +519,9 @@ void TocWidget::finishUpdateView()
// 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()) {
diff --git a/src/frontends/qt/TocWidget.h b/src/frontends/qt/TocWidget.h
index 2838adb..079fd24 100644
--- a/src/frontends/qt/TocWidget.h
+++ b/src/frontends/qt/TocWidget.h
@@ -69,6 +69,7 @@ protected Q_SLOTS:
void on_tocTV_activated(QModelIndex const &);
void on_tocTV_pressed(QModelIndex const &);
+ void on_tocTV_doubleClicked(QModelIndex const &);
void on_updateTB_clicked();
void on_sortCB_stateChanged(int state);
void on_persistentCB_stateChanged(int state);
@@ -115,6 +116,8 @@ private:
int depth_;
/// persistence of uncollapsed nodes in toc view
bool persistent_;
+ /// keep uncollapsed nodes in this event
+ bool keep_expanded_;
///
GuiView & gui_view_;
// Timer for scheduling expensive update operations
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs