mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
FileManager: Make the tree view follow the directory view navigations.
This commit is contained in:
parent
f10e0d0546
commit
2c6a597d77
Notes:
sideshowbarker
2024-07-19 14:53:45 +09:00
Author: https://github.com/awesomekling
Commit: 2c6a597d77
10 changed files with 72 additions and 3 deletions
|
@ -92,6 +92,30 @@ struct GFileSystemModel::Node {
|
|||
}
|
||||
};
|
||||
|
||||
GModelIndex GFileSystemModel::index(const String& path) const
|
||||
{
|
||||
FileSystemPath canonical_path(path);
|
||||
const Node* node = m_root;
|
||||
if (canonical_path.string() == "/")
|
||||
return m_root->index(*this);
|
||||
for (int i = 0; i < canonical_path.parts().size(); ++i) {
|
||||
auto& part = canonical_path.parts()[i];
|
||||
bool found = false;
|
||||
for (auto& child : node->children) {
|
||||
if (child->name == part) {
|
||||
node = child;
|
||||
found = true;
|
||||
if (i == canonical_path.parts().size() - 1)
|
||||
return node->index(*this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
return { };
|
||||
}
|
||||
return { };
|
||||
}
|
||||
|
||||
String GFileSystemModel::path(const GModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue