]> git.lyx.org Git - features.git/commitdiff
Add persistent view switch to the outliner.
authorPavel Sanda <sanda@lyx.org>
Thu, 2 Oct 2008 15:00:43 +0000 (15:00 +0000)
committerPavel Sanda <sanda@lyx.org>
Thu, 2 Oct 2008 15:00:43 +0000 (15:00 +0000)
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
src/frontends/qt4/TocWidget.h
src/frontends/qt4/ui/TocUi.ui

index b854c4d935be87483061656765aedf21e6075b88..5c4e7d419d6824822ce4c98cd2dfab0990cf68e7 100644 (file)
@@ -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);
index b80e4776d016cd364013a9c4506b654193281409..cfac929c9471c4349a93eabebfe2fd7321a9f32d 100644 (file)
@@ -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_;
 };
index 2fe2231eb34d11f0fc431038b0de615e3c23018a..16b6e0c5d5bf0f74193f5520f394e1f1f357d250 100644 (file)
@@ -8,15 +8,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>185</width>
-    <height>184</height>
+    <width>202</width>
+    <height>332</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string/>
   </property>
   <layout class="QGridLayout" name="gridLayout" >
-   <item row="0" column="0" colspan="4" >
+   <item row="0" column="0" colspan="2" >
     <widget class="QComboBox" name="typeCO" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="Fixed" hsizetype="Ignored" >
@@ -29,7 +29,7 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="0" colspan="4" >
+   <item row="1" column="0" colspan="2" >
     <widget class="QTreeView" name="tocTV" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="Expanding" hsizetype="Ignored" >
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="4" >
+   <item row="2" column="0" >
+    <widget class="QSlider" name="depthSL" >
+     <property name="sizePolicy" >
+      <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="toolTip" >
+      <string>Adjust the depth of the navigation tree</string>
+     </property>
+     <property name="maximum" >
+      <number>5</number>
+     </property>
+     <property name="pageStep" >
+      <number>1</number>
+     </property>
+     <property name="value" >
+      <number>2</number>
+     </property>
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="tickPosition" >
+      <enum>QSlider::TicksBothSides</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1" >
+    <layout class="QVBoxLayout" name="_2" >
+     <property name="spacing" >
+      <number>0</number>
+     </property>
+     <property name="sizeConstraint" >
+      <enum>QLayout::SetMinimumSize</enum>
+     </property>
+     <property name="leftMargin" >
+      <number>4</number>
+     </property>
+     <item>
+      <widget class="QCheckBox" name="sortCB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize" >
+        <size>
+         <width>0</width>
+         <height>21</height>
+        </size>
+       </property>
+       <property name="text" >
+        <string>Sort</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="persistentCB" >
+       <property name="sizePolicy" >
+        <sizepolicy vsizetype="Minimum" hsizetype="Fixed" >
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize" >
+        <size>
+         <width>0</width>
+         <height>21</height>
+        </size>
+       </property>
+       <property name="toolTip" >
+        <string>Try to keep persistent view of the uncollapsed nodes</string>
+       </property>
+       <property name="text" >
+        <string>Keep</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="3" column="0" colspan="2" >
     <layout class="QHBoxLayout" >
      <property name="spacing" >
       <number>6</number>
      </item>
     </layout>
    </item>
-   <item row="2" column="0" colspan="3" >
-    <widget class="QSlider" name="depthSL" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Fixed" hsizetype="Ignored" >
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="toolTip" >
-      <string>Adjust the depth of the navigation tree</string>
-     </property>
-     <property name="maximum" >
-      <number>5</number>
-     </property>
-     <property name="pageStep" >
-      <number>1</number>
-     </property>
-     <property name="value" >
-      <number>2</number>
-     </property>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="tickPosition" >
-      <enum>QSlider::TicksBothSides</enum>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="3" >
-    <widget class="QCheckBox" name="sortCB" >
-     <property name="text" >
-      <string>Sort</string>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <tabstops>