tweak shortcut window so that the tree is expanded to actually show search results

This commit is contained in:
Paul Davis 2023-10-04 16:50:08 -06:00
parent febc345414
commit 40a0ad2299
2 changed files with 29 additions and 12 deletions

View File

@ -47,6 +47,7 @@
#include "pbd/error.h"
#include "pbd/openuri.h"
#include "pbd/strsplit.h"
#include "pbd/unwind.h"
#include "ardour/filesystem_paths.h"
#include "ardour/profile.h"
@ -492,22 +493,38 @@ KeyEditor::Tab::visible_func(const Gtk::TreeModel::const_iterator& iter) const
}
// never filter when search string is empty or item is a category
if (owner.filter_string.empty () || !(*iter)[columns.bindable]) {
if (owner.filter_string.empty ()) {
return true;
}
// search name
std::string name = (*iter)[columns.name];
boost::to_lower (name);
if (name.find (owner.filter_string) != std::string::npos) {
return true;
if (!(*iter)[columns.bindable]) {
for (auto const & c : iter->children()) {
if (visible_func (c)) {
TreeModel::Path p (data_model->get_path (iter));
view.expand_row (p, false);
return true;
}
}
return false;
}
// search binding
std::string binding = (*iter)[columns.binding];
boost::to_lower (binding);
if (binding.find (owner.filter_string) != std::string::npos) {
return true;
if (owner.filter_string.find ("k:") == string::npos) {
// search name
std::string name = (*iter)[columns.name];
boost::to_lower (name);
if (name.find (owner.filter_string) != std::string::npos) {
return true;
}
} else {
string s = owner.filter_string.substr (2);
// search binding
std::string binding = (*iter)[columns.binding];
boost::to_lower (binding);
if (binding.find (s) != std::string::npos) {
return true;
}
}
return false;

View File

@ -90,7 +90,7 @@ private:
std::string name;
Gtkmm2ext::Bindings* bindings;
Gtk::ScrolledWindow scroller;
Gtk::TreeView view;
mutable Gtk::TreeView view;
Glib::RefPtr<Gtk::TreeStore> data_model;
Glib::RefPtr<Gtk::TreeModelFilter> filter;
Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;