mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 23:59:49 +00:00
HackStudio: Add file list context menu and file removal action
This commit is contained in:
parent
bbb536ebed
commit
fe1037bcb6
Notes:
sideshowbarker
2024-07-19 10:35:30 +09:00
Author: https://github.com/deoxxa
Commit: fe1037bcb6
Pull-request: https://github.com/SerenityOS/serenity/pull/940
3 changed files with 111 additions and 34 deletions
|
@ -180,6 +180,24 @@ OwnPtr<Project> Project::load_from_file(const String& path)
|
|||
}
|
||||
|
||||
bool Project::add_file(const String& filename)
|
||||
{
|
||||
m_files.append(ProjectFile::construct_with_name(filename));
|
||||
rebuild_tree();
|
||||
m_model->update();
|
||||
return save();
|
||||
}
|
||||
|
||||
bool Project::remove_file(const String& filename)
|
||||
{
|
||||
if (!get_file(filename))
|
||||
return false;
|
||||
m_files.remove_first_matching([filename](auto& file) { return file->name() == filename; });
|
||||
rebuild_tree();
|
||||
m_model->update();
|
||||
return save();
|
||||
}
|
||||
|
||||
bool Project::save()
|
||||
{
|
||||
auto project_file = CFile::construct(m_path);
|
||||
if (!project_file->open(CFile::WriteOnly))
|
||||
|
@ -190,13 +208,9 @@ bool Project::add_file(const String& filename)
|
|||
project_file->printf("%s\n", file.name().characters());
|
||||
}
|
||||
|
||||
project_file->printf("%s\n", filename.characters());
|
||||
|
||||
if (!project_file->close())
|
||||
return false;
|
||||
|
||||
m_files.append(ProjectFile::construct_with_name(filename));
|
||||
m_model->update();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue