mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:15:07 +00:00
LibGUI: Implement searching/jumping as you type in views
This allows the user to start typing and highlighting and jumping to a match in ColumnsView, IconView, TableView and TreeView if the model supports it.
This commit is contained in:
parent
307f0bc778
commit
52a847a0eb
13 changed files with 244 additions and 19 deletions
|
@ -627,4 +627,21 @@ void FileSystemModel::set_data(const ModelIndex& index, const Variant& data)
|
|||
}
|
||||
}
|
||||
|
||||
Vector<ModelIndex, 1> FileSystemModel::matches(const StringView& searching, unsigned flags, const ModelIndex& index)
|
||||
{
|
||||
Node& node = const_cast<Node&>(this->node(index));
|
||||
node.reify_if_needed();
|
||||
Vector<ModelIndex, 1> found_indexes;
|
||||
for (auto& child : node.children) {
|
||||
if (string_matches(child.name, searching, flags)) {
|
||||
const_cast<Node&>(child).reify_if_needed();
|
||||
found_indexes.append(child.index(Column::Name));
|
||||
if (flags & FirstMatchOnly)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found_indexes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue