mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibGUI: Make GTableModel a retainable object.
It became clear that this class needs to support multiple owners.
This commit is contained in:
parent
41c744b3c8
commit
f47945759b
22 changed files with 44 additions and 34 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
class DirectoryTableModel final : public GTableModel {
|
||||
public:
|
||||
DirectoryTableModel();
|
||||
static Retained<DirectoryTableModel> create() { return adopt(*new DirectoryTableModel); }
|
||||
virtual ~DirectoryTableModel() override;
|
||||
|
||||
enum Column {
|
||||
|
@ -33,6 +33,8 @@ public:
|
|||
size_t bytes_in_files() const { return m_bytes_in_files; }
|
||||
|
||||
private:
|
||||
DirectoryTableModel();
|
||||
|
||||
String name_for_uid(uid_t) const;
|
||||
String name_for_gid(gid_t) const;
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
DirectoryTableView::DirectoryTableView(GWidget* parent)
|
||||
: GTableView(parent)
|
||||
, m_model(DirectoryTableModel::create())
|
||||
{
|
||||
auto directory_model = make<DirectoryTableModel>();
|
||||
m_model = directory_model.ptr();
|
||||
set_model(make<GSortingProxyTableModel>(move(directory_model)));
|
||||
set_model(GSortingProxyTableModel::create(m_model.copy_ref()));
|
||||
GTableView::model()->set_key_column_and_sort_order(DirectoryTableModel::Column::Name, GSortOrder::Ascending);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,5 +24,5 @@ private:
|
|||
|
||||
void set_status_message(const String&);
|
||||
|
||||
DirectoryTableModel* m_model { nullptr };
|
||||
Retained<DirectoryTableModel> m_model;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue