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());
}
&& gui_view_.tocModels().isSorted(current_type_));
sortCB->blockSignals(false);
-
bool const can_navigate_ = canNavigate(current_type_);
persistentCB->setEnabled(can_navigate_);
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;
<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" >
</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>
</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>
- </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>
+ <item row="4" column="0" colspan="2" >
+ <layout class="QHBoxLayout" >
<property name="margin" >
- <number>4</number>
+ <number>0</number>
</property>
- <item>
- <widget class="QCheckBox" name="sortCB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- <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>
- <hsizetype>0</hsizetype>
- <vsizetype>1</vsizetype>
- <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>
</property>
- <property name="margin" >
- <number>0</number>
- </property>
<item>
<widget class="QToolButton" name="updateTB" >
<property name="toolTip" >
<string>...</string>
</property>
<property name="icon" >
- <iconset>
- <normaloff>../../../../lib/images/reload.png</normaloff>../../../../lib/images/reload.png</iconset>
+ <iconset>../../../../lib/images/reload.png</iconset>
</property>
<property name="iconSize" >
<size>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" >
<size>
<width>16</width>
<height>20</height>
<string>...</string>
</property>
<property name="icon" >
- <iconset>
- <normaloff>../../../../lib/images/promote.png</normaloff>../../../../lib/images/promote.png</iconset>
+ <iconset>../../../../lib/images/promote.png</iconset>
</property>
<property name="iconSize" >
<size>
<string>...</string>
</property>
<property name="icon" >
- <iconset>
- <normaloff>../../../../lib/images/demote.png</normaloff>../../../../lib/images/demote.png</iconset>
+ <iconset>../../../../lib/images/demote.png</iconset>
</property>
<property name="iconSize" >
<size>
<string>...</string>
</property>
<property name="icon" >
- <iconset>
- <normaloff>../../../../lib/images/down.png</normaloff>../../../../lib/images/down.png</iconset>
+ <iconset>../../../../lib/images/down.png</iconset>
</property>
<property name="iconSize" >
<size>
<string>...</string>
</property>
<property name="icon" >
- <iconset>
- <normaloff>../../../../lib/images/up.png</normaloff>../../../../lib/images/up.png</iconset>
+ <iconset>../../../../lib/images/up.png</iconset>
</property>
<property name="iconSize" >
<size>
</item>
</layout>
</item>
+ <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>
+ <item>
+ <widget class="QCheckBox" name="sortCB" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <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>
+ <hsizetype>0</hsizetype>
+ <vsizetype>1</vsizetype>
+ <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" >
+ <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="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>
</layout>
</widget>
<tabstops>