* TocWidget.{cpp,h}:

* TocWidgetUi.ui:
	- add filter bar.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33457 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-02-13 08:30:16 +00:00
parent 8b91e20a16
commit 23a58c0214
3 changed files with 213 additions and 156 deletions

View File

@ -82,6 +82,8 @@ TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
this, SLOT(showContextMenu(const QPoint &)));
connect(tocTV, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
connect(filterLE, SIGNAL(textEdited(QString)),
this, SLOT(filterContents()));
init(QString());
}
@ -440,7 +442,6 @@ void TocWidget::updateView()
&& gui_view_.tocModels().isSorted(current_type_));
sortCB->blockSignals(false);
bool const can_navigate_ = canNavigate(current_type_);
persistentCB->setEnabled(can_navigate_);
@ -456,11 +457,38 @@ void TocWidget::updateView()
persistentCB->setChecked(persistent_);
select(gui_view_.tocModels().currentIndex(current_type_));
}
filterContents();
tocTV->setEnabled(true);
tocTV->setUpdatesEnabled(true);
}
void TocWidget::filterContents()
{
QModelIndexList indices = tocTV->model()->match(
tocTV->model()->index(0, 0),
Qt::DisplayRole, "*", -1,
Qt::MatchFlags(Qt::MatchWildcard|Qt::MatchRecursive));
int size = indices.size();
for (int i = 0; i < size; i++) {
QModelIndex index = indices[i];
bool const matches =
index.data().toString().contains(
filterLE->text(), Qt::CaseSensitive);
tocTV->setRowHidden(index.row(), index.parent(), !matches);
}
// recursively unhide parents of unhidden children
for (int i = size - 1; i >= 0; i--) {
QModelIndex index = indices[i];
if (!tocTV->isRowHidden(index.row(), index.parent())
&& index.parent() != QModelIndex())
tocTV->setRowHidden(index.parent().row(),
index.parent().parent(), false);
}
}
static QString decodeType(QString const & str)
{
QString type = str;

View File

@ -63,6 +63,7 @@ protected Q_SLOTS:
void on_moveDownTB_clicked();
void on_moveInTB_clicked();
void on_moveOutTB_clicked();
void filterContents();
void showContextMenu(const QPoint & pos);

View File

@ -9,13 +9,46 @@
<x>0</x>
<y>0</y>
<width>202</width>
<height>332</height>
<height>355</height>
</rect>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" name="gridLayout" >
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="filterLA" >
<property name="text" >
<string>Filter:</string>
</property>
<property name="buddy" >
<cstring>filterLE</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filterLE" >
<property name="toolTip" >
<string>Enter string to filter contents</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2" >
<widget class="QComboBox" name="typeCO" >
<property name="sizePolicy" >
@ -31,7 +64,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<item row="2" column="0" colspan="2" >
<widget class="QTreeView" name="tocTV" >
<property name="sizePolicy" >
<sizepolicy>
@ -43,47 +76,135 @@
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QSlider" name="depthSL" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>13</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="4" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="toolTip" >
<string>Adjust the depth of the navigation tree</string>
<property name="spacing" >
<number>6</number>
</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>
<widget class="QToolButton" name="updateTB" >
<property name="toolTip" >
<string>Update navigation tree</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../../../lib/images/reload.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="moveOutTB" >
<property name="toolTip" >
<string>Decrease nesting depth of selected item</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../../../lib/images/promote.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveInTB" >
<property name="toolTip" >
<string>Increase nesting depth of selected item</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../../../lib/images/demote.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveDownTB" >
<property name="toolTip" >
<string>Move selected item down by one</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../../../lib/images/down.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveUpTB" >
<property name="toolTip" >
<string>Move selected item up by one</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../../../lib/images/up.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
<layout class="QVBoxLayout" name="_2" >
<item row="3" column="1" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>4</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<property name="sizeConstraint" >
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="margin" >
<number>4</number>
</property>
<item>
<widget class="QCheckBox" name="sortCB" >
<property name="sizePolicy" >
@ -131,128 +252,35 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
<item row="3" column="0" >
<widget class="QSlider" name="depthSL" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>13</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="margin" >
<number>0</number>
<property name="toolTip" >
<string>Adjust the depth of the navigation tree</string>
</property>
<item>
<widget class="QToolButton" name="updateTB" >
<property name="toolTip" >
<string>Update navigation tree</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>
<normaloff>../../../../lib/images/reload.png</normaloff>../../../../lib/images/reload.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="moveOutTB" >
<property name="toolTip" >
<string>Decrease nesting depth of selected item</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>
<normaloff>../../../../lib/images/promote.png</normaloff>../../../../lib/images/promote.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveInTB" >
<property name="toolTip" >
<string>Increase nesting depth of selected item</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>
<normaloff>../../../../lib/images/demote.png</normaloff>../../../../lib/images/demote.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveDownTB" >
<property name="toolTip" >
<string>Move selected item down by one</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>
<normaloff>../../../../lib/images/down.png</normaloff>../../../../lib/images/down.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moveUpTB" >
<property name="toolTip" >
<string>Move selected item up by one</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>
<normaloff>../../../../lib/images/up.png</normaloff>../../../../lib/images/up.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
<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>
</layout>
</widget>