From 2ca370b135be04418e36eaede28f6e1ee6374844 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Thu, 2 Oct 2008 15:00:43 +0000 Subject: [PATCH] Add persistent view switch to the outliner. http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg144343.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26684 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/TocWidget.cpp | 14 +++- src/frontends/qt4/TocWidget.h | 3 + src/frontends/qt4/ui/TocUi.ui | 127 ++++++++++++++++++++++---------- 3 files changed, 102 insertions(+), 42 deletions(-) diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index b854c4d935..5c4e7d419d 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -35,7 +35,7 @@ namespace lyx { namespace frontend { TocWidget::TocWidget(GuiView & gui_view, QWidget * parent) - : QWidget(parent), depth_(0), gui_view_(gui_view) + : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view) { setupUi(this); @@ -105,6 +105,12 @@ void TocWidget::on_sortCB_stateChanged(int state) updateView(); } +void TocWidget::on_persistentCB_stateChanged(int state) +{ + persistent_ = state == Qt::Checked; +} + + /* FIXME (Ugras 17/11/06): I have implemented a indexDepth function to get the model indices. In my opinion, somebody should derive a new qvariant class for tocModelItem @@ -228,6 +234,7 @@ void TocWidget::enableControls(bool enable) moveDownTB->setEnabled(enable); moveInTB->setEnabled(enable); moveOutTB->setEnabled(enable); + persistentCB->setEnabled(enable); if (!enable) { depthSL->setMaximum(0); depthSL->setValue(0); @@ -263,19 +270,22 @@ void TocWidget::updateView() if (tocTV->model() != toc_model) { tocTV->setModel(toc_model); tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers); - setTreeDepth(depth_); + if (persistent_) setTreeDepth(depth_); } sortCB->blockSignals(true); sortCB->setChecked(gui_view_.tocModels().isSorted(current_type_)); sortCB->blockSignals(false); + persistentCB->setChecked(persistent_); + bool controls_enabled = toc_model && toc_model->rowCount() > 0 && !gui_view_.buffer()->isReadonly(); enableControls(controls_enabled); depthSL->setMaximum(gui_view_.tocModels().depth(current_type_)); depthSL->setValue(depth_); + if (!persistent_) setTreeDepth(depth_); if (canNavigate(current_type_)) select(gui_view_.tocModels().currentIndex(current_type_)); tocTV->setEnabled(true); diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index b80e4776d0..cfac929c94 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -49,6 +49,7 @@ protected Q_SLOTS: void on_tocTV_clicked(QModelIndex const &); void on_updateTB_clicked(); void on_sortCB_stateChanged(int state); + void on_persistentCB_stateChanged(int state); void on_depthSL_valueChanged(int depth); void on_typeCO_currentIndexChanged(int value); void on_moveUpTB_clicked(); @@ -68,6 +69,8 @@ private: /// depth of list shown int depth_; + /// persistence of uncollapsed nodes in toc view + bool persistent_; /// GuiView & gui_view_; }; diff --git a/src/frontends/qt4/ui/TocUi.ui b/src/frontends/qt4/ui/TocUi.ui index 2fe2231eb3..16b6e0c5d5 100644 --- a/src/frontends/qt4/ui/TocUi.ui +++ b/src/frontends/qt4/ui/TocUi.ui @@ -8,15 +8,15 @@ 0 0 - 185 - 184 + 202 + 332 - + @@ -29,7 +29,7 @@ - + @@ -39,7 +39,89 @@ - + + + + + 0 + 0 + + + + Adjust the depth of the navigation tree + + + 5 + + + 1 + + + 2 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + + + + + 0 + + + QLayout::SetMinimumSize + + + 4 + + + + + + 0 + 0 + + + + + 0 + 21 + + + + Sort + + + + + + + + 0 + 0 + + + + + 0 + 21 + + + + Try to keep persistent view of the uncollapsed nodes + + + Keep + + + + + + 6 @@ -162,41 +244,6 @@ - - - - - 0 - 0 - - - - Adjust the depth of the navigation tree - - - 5 - - - 1 - - - 2 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - - - - - Sort - - - -- 2.39.2