]> git.lyx.org Git - features.git/commitdiff
* TocWidget.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Sat, 13 Feb 2010 08:30:16 +0000 (08:30 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sat, 13 Feb 2010 08:30:16 +0000 (08:30 +0000)
* TocWidgetUi.ui:
- add filter bar.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33457 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h
src/frontends/qt4/ui/TocUi.ui

index 49e96f511eebfe0566de09c9e423e23f0990bcc1..473d7de3434d38a602ff38ce9960a414edd69d20 100644 (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;
index d2ca8b83758cc19636b0b048ad6f7b336ab412b2..7c7ca3f0e33b2265afe7306313aa7be64c7351b7 100644 (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);
 
index 5fd75fbb8310c4a685a0947166e165e6f3ee6592..8491a1255266364ac5597f486cb6bc17417a9c96 100644 (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>
      </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>