2019-03-01 15:54:28 +03:00
|
|
|
#include "DirectoryTableView.h"
|
2019-03-09 16:52:25 +03:00
|
|
|
#include <LibGUI/GSortingProxyTableModel.h>
|
2019-03-01 15:54:28 +03:00
|
|
|
|
|
|
|
DirectoryTableView::DirectoryTableView(GWidget* parent)
|
|
|
|
: GTableView(parent)
|
2019-03-20 05:27:07 +03:00
|
|
|
, m_model(DirectoryTableModel::create())
|
2019-03-01 15:54:28 +03:00
|
|
|
{
|
2019-03-20 05:27:07 +03:00
|
|
|
set_model(GSortingProxyTableModel::create(m_model.copy_ref()));
|
2019-03-09 16:52:25 +03:00
|
|
|
GTableView::model()->set_key_column_and_sort_order(DirectoryTableModel::Column::Name, GSortOrder::Ascending);
|
2019-03-01 15:54:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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" : ""));
|
2019-03-01 16:34:53 +03:00
|
|
|
|
|
|
|
if (on_path_change)
|
|
|
|
on_path_change(model().path());
|
2019-03-01 15:54:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DirectoryTableView::set_status_message(const String& message)
|
|
|
|
{
|
|
|
|
if (on_status_message)
|
|
|
|
on_status_message(message);
|
|
|
|
}
|
2019-03-02 11:16:57 +03:00
|
|
|
|
|
|
|
void DirectoryTableView::open_parent_directory()
|
|
|
|
{
|
2019-03-03 02:40:50 +03:00
|
|
|
model().open(String::format("%s/..", model().path().characters()));
|
2019-03-02 11:16:57 +03:00
|
|
|
}
|