]> git.lyx.org Git - features.git/commitdiff
PrefShortcuts: Hide unmatched items instead of highlighting matched ones (JMarc's...
authorBo Peng <bpeng@lyx.org>
Fri, 19 Oct 2007 16:49:04 +0000 (16:49 +0000)
committerBo Peng <bpeng@lyx.org>
Fri, 19 Oct 2007 16:49:04 +0000 (16:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21071 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiPrefs.cpp

index 0c74b58857ca0b3ac4fb3b3331166c76279bcd1d..e5f6b5bf4e084828a4a4174a27f60081356c248a 100644 (file)
@@ -1692,8 +1692,8 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent)
        shortcutsTW->headerItem()->setText(0, qt_("Function"));
        shortcutsTW->headerItem()->setText(1, qt_("Shortcut"));
        shortcutsTW->setSortingEnabled(true);
-       // I am not sure if this is a good idea.
-       shortcutsTW->setSelectionMode(QAbstractItemView::MultiSelection);
+       // Multi-selection can be annoying.
+       // shortcutsTW->setSelectionMode(QAbstractItemView::MultiSelection);
        shortcutsTW->header()->resizeSection(0, 200);
 
        connect(bindFilePB, SIGNAL(clicked()),
@@ -1863,30 +1863,27 @@ void PrefShortcuts::on_searchPB_pressed()
                searchLE->text(), 
                Qt::MatchFlags(Qt::MatchContains | Qt::MatchRecursive));
        
-       if (matched.isEmpty())
-               return;
-       
-       QList<QTreeWidgetItem *> const items = shortcutsTW->selectedItems();
-       // clear current selection
-       for (int i = 0; i < items.size(); ++i)
-               items[i]->setSelected(false);
+       // hide everyone (to avoid searching in matched QList repeatedly
+       QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Selectable);
+       while (*it)
+               shortcutsTW->setItemHidden(*it++, true);
+       // show matched items
        for (int i = 0; i < matched.size(); ++i) {
-               if (matched[i]->flags() & Qt::ItemIsSelectable)
-                       matched[i]->setSelected(true);
-               matched[i]->setExpanded(true);
+               shortcutsTW->setItemHidden(matched[i], false);
+        shortcutsTW->setItemExpanded(matched[i], true);
        }
-       // scroll to the first selectable item
-       for (int i = 0; i < matched.size(); ++i)
-               if (matched[i]->flags() & Qt::ItemIsSelectable) {
-                       shortcutsTW->scrollToItem(matched[i]);
-                       break;
-               }
 }
 
 
 void PrefShortcuts::on_searchLE_textChanged()
 {
        searchPB->setEnabled(!searchLE->text().isEmpty());
+       if (searchLE->text().isEmpty()) {
+               // show all hidden items
+               QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);
+               while (*it)
+                       shortcutsTW->setItemHidden(*it++, false);
+       }
 }
        
 
@@ -1895,6 +1892,12 @@ void PrefShortcuts::setShortcut()
 }
 
 
+/////////////////////////////////////////////////////////////////////
+//
+// PrefIdentity
+//
+/////////////////////////////////////////////////////////////////////
+
 PrefIdentity::PrefIdentity(QWidget * parent)
        : PrefModule(_("Identity"), 0, parent)
 {