GTreeView: Add basic selection support.

This commit is contained in:
Andreas Kling 2019-03-29 20:36:15 +01:00
parent 967eec1e52
commit 1963391ca6
Notes: sideshowbarker 2024-07-19 14:53:57 +09:00
4 changed files with 44 additions and 26 deletions

View file

@ -26,23 +26,6 @@ struct GFileSystemModel::Node {
ASSERT_NOT_REACHED();
}
String full_path(const GFileSystemModel& model) const
{
Vector<String> lineage;
for (auto* ancestor = parent; ancestor; ancestor = ancestor->parent) {
lineage.append(ancestor->name);
}
StringBuilder builder;
builder.append(model.root_path());
for (int i = lineage.size() - 1; i >= 0; --i) {
builder.append('/');
builder.append(lineage[i]);
}
builder.append('/');
builder.append(name);
return FileSystemPath(builder.to_string()).string();
}
void traverse_if_needed(const GFileSystemModel& model)
{
if (type != Node::Directory || has_traversed)
@ -90,6 +73,23 @@ struct GFileSystemModel::Node {
}
type = S_ISDIR(st.st_mode) ? Node::Type::Directory : Node::Type::File;
}
String full_path(const GFileSystemModel& model) const
{
Vector<String> lineage;
for (auto* ancestor = parent; ancestor; ancestor = ancestor->parent) {
lineage.append(ancestor->name);
}
StringBuilder builder;
builder.append(model.root_path());
for (int i = lineage.size() - 1; i >= 0; --i) {
builder.append('/');
builder.append(lineage[i]);
}
builder.append('/');
builder.append(name);
return FileSystemPath(builder.to_string()).string();
}
};
GFileSystemModel::GFileSystemModel(const String& root_path, Mode mode)