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

FileManager: Port to GTableModel/GTableView.

Replace the custom DirectoryView widget with a GTableView subclass.
This was pleasantly straightforward and it's so cool seeing the huge
increase in app quality from GTableView. :^)
This commit is contained in:
Andreas Kling 2019-03-01 13:54:28 +01:00
parent b5dcad932e
commit ac8fb5da4c
8 changed files with 308 additions and 236 deletions

View file

@ -0,0 +1,33 @@
#include "DirectoryTableView.h"
DirectoryTableView::DirectoryTableView(GWidget* parent)
: GTableView(parent)
{
set_model(make<DirectoryTableModel>());
}
DirectoryTableView::~DirectoryTableView()
{
}
void DirectoryTableView::open(const String& path)
{
model().open(path);
}
void DirectoryTableView::model_notification(const GModelNotification& notification)
{
if (notification.type() == GModelNotification::Type::ModelUpdated) {
set_status_message(String::format("%d item%s (%u byte%s)",
model().row_count(),
model().row_count() != 1 ? "s" : "",
model().bytes_in_files(),
model().bytes_in_files() != 1 ? "s" : ""));
}
}
void DirectoryTableView::set_status_message(const String& message)
{
if (on_status_message)
on_status_message(message);
}