From b6c89e2db07a7838c56a94510c79854b23f9810e Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Fri, 19 Oct 2007 16:49:04 +0000 Subject: [PATCH] PrefShortcuts: Hide unmatched items instead of highlighting matched ones (JMarc's suggestion ) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21071 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiPrefs.cpp | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 0c74b58857..e5f6b5bf4e 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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 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) { -- 2.39.5