1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 06:15:06 +00:00

LibGUI: Remove GModel activations to GAbstractView.

Now you can hook activation via GAbstractView::on_activation.
The design still isn't quite right, we should eventually move the selection
away from the model somehow.
This commit is contained in:
Andreas Kling 2019-05-09 04:56:52 +02:00
parent bffaa5ece6
commit fa232ac180
25 changed files with 107 additions and 104 deletions

View file

@ -285,42 +285,3 @@ void GDirectoryModel::open(const String& a_path)
update();
set_selected_index(index(0, 0));
}
void GDirectoryModel::activate(const GModelIndex& index)
{
if (!index.is_valid())
return;
auto& entry = this->entry(index.row());
FileSystemPath path(String::format("%s/%s", m_path.characters(), entry.name.characters()));
if (entry.is_directory()) {
open(path.string());
return;
}
if (entry.is_executable()) {
if (fork() == 0) {
int rc = execl(path.string().characters(), path.string().characters(), nullptr);
if (rc < 0)
perror("exec");
ASSERT_NOT_REACHED();
}
return;
}
if (path.string().to_lowercase().ends_with(".png")) {
if (fork() == 0) {
int rc = execl("/bin/qs", "/bin/qs", path.string().characters(), nullptr);
if (rc < 0)
perror("exec");
ASSERT_NOT_REACHED();
}
return;
}
if (fork() == 0) {
int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.string().characters(), nullptr);
if (rc < 0)
perror("exec");
ASSERT_NOT_REACHED();
}
return;
}