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
This commit is contained in:
Pavel Sanda 2008-10-02 15:00:43 +00:00
parent 4dc976497f
commit 2ca370b135
3 changed files with 102 additions and 42 deletions

View File

@ -35,7 +35,7 @@ namespace lyx {
namespace frontend { namespace frontend {
TocWidget::TocWidget(GuiView & gui_view, QWidget * parent) 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); setupUi(this);
@ -105,6 +105,12 @@ void TocWidget::on_sortCB_stateChanged(int state)
updateView(); updateView();
} }
void TocWidget::on_persistentCB_stateChanged(int state)
{
persistent_ = state == Qt::Checked;
}
/* FIXME (Ugras 17/11/06): /* FIXME (Ugras 17/11/06):
I have implemented a indexDepth function to get the model indices. In my I have implemented a indexDepth function to get the model indices. In my
opinion, somebody should derive a new qvariant class for tocModelItem opinion, somebody should derive a new qvariant class for tocModelItem
@ -228,6 +234,7 @@ void TocWidget::enableControls(bool enable)
moveDownTB->setEnabled(enable); moveDownTB->setEnabled(enable);
moveInTB->setEnabled(enable); moveInTB->setEnabled(enable);
moveOutTB->setEnabled(enable); moveOutTB->setEnabled(enable);
persistentCB->setEnabled(enable);
if (!enable) { if (!enable) {
depthSL->setMaximum(0); depthSL->setMaximum(0);
depthSL->setValue(0); depthSL->setValue(0);
@ -263,19 +270,22 @@ void TocWidget::updateView()
if (tocTV->model() != toc_model) { if (tocTV->model() != toc_model) {
tocTV->setModel(toc_model); tocTV->setModel(toc_model);
tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers); tocTV->setEditTriggers(QAbstractItemView::NoEditTriggers);
setTreeDepth(depth_); if (persistent_) setTreeDepth(depth_);
} }
sortCB->blockSignals(true); sortCB->blockSignals(true);
sortCB->setChecked(gui_view_.tocModels().isSorted(current_type_)); sortCB->setChecked(gui_view_.tocModels().isSorted(current_type_));
sortCB->blockSignals(false); sortCB->blockSignals(false);
persistentCB->setChecked(persistent_);
bool controls_enabled = toc_model && toc_model->rowCount() > 0 bool controls_enabled = toc_model && toc_model->rowCount() > 0
&& !gui_view_.buffer()->isReadonly(); && !gui_view_.buffer()->isReadonly();
enableControls(controls_enabled); enableControls(controls_enabled);
depthSL->setMaximum(gui_view_.tocModels().depth(current_type_)); depthSL->setMaximum(gui_view_.tocModels().depth(current_type_));
depthSL->setValue(depth_); depthSL->setValue(depth_);
if (!persistent_) setTreeDepth(depth_);
if (canNavigate(current_type_)) if (canNavigate(current_type_))
select(gui_view_.tocModels().currentIndex(current_type_)); select(gui_view_.tocModels().currentIndex(current_type_));
tocTV->setEnabled(true); tocTV->setEnabled(true);

View File

@ -49,6 +49,7 @@ protected Q_SLOTS:
void on_tocTV_clicked(QModelIndex const &); void on_tocTV_clicked(QModelIndex const &);
void on_updateTB_clicked(); void on_updateTB_clicked();
void on_sortCB_stateChanged(int state); void on_sortCB_stateChanged(int state);
void on_persistentCB_stateChanged(int state);
void on_depthSL_valueChanged(int depth); void on_depthSL_valueChanged(int depth);
void on_typeCO_currentIndexChanged(int value); void on_typeCO_currentIndexChanged(int value);
void on_moveUpTB_clicked(); void on_moveUpTB_clicked();
@ -68,6 +69,8 @@ private:
/// depth of list shown /// depth of list shown
int depth_; int depth_;
/// persistence of uncollapsed nodes in toc view
bool persistent_;
/// ///
GuiView & gui_view_; GuiView & gui_view_;
}; };

View File

@ -8,15 +8,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>185</width> <width>202</width>
<height>184</height> <height>332</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="gridLayout" > <layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="4" > <item row="0" column="0" colspan="2" >
<widget class="QComboBox" name="typeCO" > <widget class="QComboBox" name="typeCO" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Ignored" > <sizepolicy vsizetype="Fixed" hsizetype="Ignored" >
@ -29,7 +29,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="4" > <item row="1" column="0" colspan="2" >
<widget class="QTreeView" name="tocTV" > <widget class="QTreeView" name="tocTV" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Ignored" > <sizepolicy vsizetype="Expanding" hsizetype="Ignored" >
@ -39,7 +39,89 @@
</property> </property>
</widget> </widget>
</item> </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" > <layout class="QHBoxLayout" >
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
@ -162,41 +244,6 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</widget> </widget>
<tabstops> <tabstops>