mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGUI: Convert GTableView to ObjectPtr
This commit is contained in:
parent
c13b9e2214
commit
e7b55037f4
Notes:
sideshowbarker
2024-07-19 12:02:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e7b55037f48
20 changed files with 27 additions and 26 deletions
|
@ -28,7 +28,7 @@ int main(int argc, char** argv)
|
|||
board_combo->set_preferred_size(0, 20);
|
||||
board_combo->set_model(BoardListModel::create());
|
||||
|
||||
auto* catalog_view = new GTableView(widget);
|
||||
auto catalog_view = GTableView::construct(widget);
|
||||
catalog_view->set_model(ThreadCatalogModel::create());
|
||||
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model());
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
m_item_view = GItemView::construct(this);
|
||||
m_item_view->set_model(model());
|
||||
|
||||
m_table_view = new GTableView(this);
|
||||
m_table_view = GTableView::construct(this);
|
||||
m_table_view->set_model(GSortingProxyModel::create(m_model));
|
||||
|
||||
m_table_view->model()->set_key_column_and_sort_order(GDirectoryModel::Column::Name, GSortOrder::Ascending);
|
||||
|
|
|
@ -72,6 +72,6 @@ private:
|
|||
Vector<String> m_path_history;
|
||||
void add_path_to_history(const StringView& path);
|
||||
|
||||
GTableView* m_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
ObjectPtr<GItemView> m_item_view;
|
||||
};
|
||||
|
|
|
@ -177,7 +177,7 @@ void IRCAppWindow::setup_widgets()
|
|||
|
||||
auto* horizontal_container = new GSplitter(Orientation::Horizontal, outer_container);
|
||||
|
||||
m_window_list = new GTableView(horizontal_container);
|
||||
m_window_list = GTableView::construct(horizontal_container);
|
||||
m_window_list->set_headers_visible(false);
|
||||
m_window_list->set_alternating_row_colors(false);
|
||||
m_window_list->set_size_columns_to_fit_content(true);
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
IRCWindow& create_window(void* owner, IRCWindow::Type, const String& name);
|
||||
IRCClient m_client;
|
||||
GStackWidget* m_container { nullptr };
|
||||
GTableView* m_window_list { nullptr };
|
||||
ObjectPtr<GTableView> m_window_list;
|
||||
RefPtr<GAction> m_join_action;
|
||||
RefPtr<GAction> m_part_action;
|
||||
RefPtr<GAction> m_whois_action;
|
||||
|
|
|
@ -21,7 +21,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
// Make a container for the log buffer view + (optional) member list.
|
||||
auto* container = new GSplitter(Orientation::Horizontal, this);
|
||||
|
||||
m_table_view = new GTableView(container);
|
||||
m_table_view = GTableView::construct(container);
|
||||
m_table_view->set_size_columns_to_fit_content(true);
|
||||
m_table_view->set_headers_visible(false);
|
||||
m_table_view->set_font(Font::default_fixed_width_font());
|
||||
|
@ -32,7 +32,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
}
|
||||
|
||||
if (m_type == Channel) {
|
||||
auto* member_view = new GTableView(container);
|
||||
auto member_view = GTableView::construct(container);
|
||||
member_view->set_headers_visible(false);
|
||||
member_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
member_view->set_preferred_size(100, 0);
|
||||
|
|
|
@ -46,7 +46,7 @@ private:
|
|||
void* m_owner { nullptr };
|
||||
Type m_type;
|
||||
String m_name;
|
||||
GTableView* m_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
ObjectPtr<GTextEditor> m_text_editor;
|
||||
RefPtr<IRCLogBuffer> m_log_buffer;
|
||||
int m_unread_count { 0 };
|
||||
|
|
|
@ -18,7 +18,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
|
|||
adapters_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
adapters_group_box->set_preferred_size(0, 120);
|
||||
|
||||
m_adapter_table_view = new GTableView(adapters_group_box);
|
||||
m_adapter_table_view = GTableView::construct(adapters_group_box);
|
||||
m_adapter_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GJsonArrayModel::FieldSpec> net_adapters_fields;
|
||||
|
@ -38,7 +38,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent)
|
|||
sockets_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
sockets_group_box->set_preferred_size(0, 0);
|
||||
|
||||
m_socket_table_view = new GTableView(sockets_group_box);
|
||||
m_socket_table_view = GTableView::construct(sockets_group_box);
|
||||
m_socket_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GJsonArrayModel::FieldSpec> net_tcp_fields;
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
private:
|
||||
void update_models();
|
||||
|
||||
GTableView* m_adapter_table_view { nullptr };
|
||||
GTableView* m_socket_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_adapter_table_view;
|
||||
ObjectPtr<GTableView> m_socket_table_view;
|
||||
ObjectPtr<CTimer> m_update_timer;
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent)
|
|||
{
|
||||
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
m_table_view = new GTableView(this);
|
||||
m_table_view = GTableView::construct(this);
|
||||
m_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GJsonArrayModel::FieldSpec> pid_fds_fields;
|
||||
|
|
|
@ -13,6 +13,6 @@ public:
|
|||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
GTableView* m_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
|||
{
|
||||
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
m_table_view = new GTableView(this);
|
||||
m_table_view = GTableView::construct(this);
|
||||
m_table_view->set_size_columns_to_fit_content(true);
|
||||
Vector<GJsonArrayModel::FieldSpec> pid_vm_fields;
|
||||
pid_vm_fields.empend("Address", TextAlignment::CenterLeft, [](auto& object) {
|
||||
|
|
|
@ -13,6 +13,6 @@ public:
|
|||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
GTableView* m_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
};
|
||||
|
|
|
@ -239,7 +239,7 @@ GWidget* build_file_systems_tab()
|
|||
auto* fs_widget = new GWidget(nullptr);
|
||||
fs_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
fs_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto* fs_table_view = new GTableView(fs_widget);
|
||||
auto fs_table_view = GTableView::construct(fs_widget);
|
||||
fs_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GJsonArrayModel::FieldSpec> df_fields;
|
||||
|
@ -304,7 +304,7 @@ GWidget* build_pci_devices_tab()
|
|||
auto* pci_widget = new GWidget(nullptr);
|
||||
pci_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
pci_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto* pci_table_view = new GTableView(pci_widget);
|
||||
auto pci_table_view = GTableView::construct(pci_widget);
|
||||
pci_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
auto db = PCIDB::Database::open();
|
||||
|
@ -359,7 +359,7 @@ GWidget* build_devices_tab()
|
|||
devices_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
devices_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto* devices_table_view = new GTableView(devices_widget);
|
||||
auto devices_table_view = GTableView::construct(devices_widget);
|
||||
devices_table_view->set_size_columns_to_fit_content(true);
|
||||
devices_table_view->set_model(GSortingProxyModel::create(DevicesModel::create()));
|
||||
devices_table_view->model()->update();
|
||||
|
|
|
@ -50,7 +50,7 @@ int main(int argc, char** argv)
|
|||
tree_view->set_model(remote_process.object_graph_model());
|
||||
tree_view->set_activates_on_selection(true);
|
||||
|
||||
auto* properties_table_view = new GTableView(splitter);
|
||||
auto properties_table_view = GTableView::construct(splitter);
|
||||
properties_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
tree_view->on_activation = [&](auto& index) {
|
||||
|
|
|
@ -61,7 +61,7 @@ VBPropertiesWindow::VBPropertiesWindow()
|
|||
widget->layout()->set_margins({ 2, 2, 2, 2 });
|
||||
set_main_widget(widget);
|
||||
|
||||
m_table_view = new GTableView(widget);
|
||||
m_table_view = GTableView::construct(widget);
|
||||
m_table_view->set_headers_visible(false);
|
||||
m_table_view->set_editable(true);
|
||||
|
||||
|
|
|
@ -14,5 +14,5 @@ public:
|
|||
const GTableView& table_view() const { return *m_table_view; }
|
||||
|
||||
private:
|
||||
GTableView* m_table_view { nullptr };
|
||||
ObjectPtr<GTableView> m_table_view;
|
||||
};
|
||||
|
|
|
@ -76,7 +76,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
|
|||
location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
location_textbox->set_preferred_size(0, 20);
|
||||
|
||||
m_view = new GTableView(vertical_container);
|
||||
m_view = GTableView::construct(vertical_container);
|
||||
m_view->set_model(GSortingProxyModel::create(*m_model));
|
||||
m_view->set_column_hidden(GDirectoryModel::Column::Owner, true);
|
||||
m_view->set_column_hidden(GDirectoryModel::Column::Group, true);
|
||||
|
|
|
@ -42,7 +42,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
GTableView* m_view { nullptr };
|
||||
ObjectPtr<GTableView> m_view;
|
||||
NonnullRefPtr<GDirectoryModel> m_model;
|
||||
FileSystemPath m_selected_file;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ public:
|
|||
class GTableView : public GAbstractView {
|
||||
C_OBJECT(GTableView)
|
||||
public:
|
||||
explicit GTableView(GWidget* parent);
|
||||
virtual ~GTableView() override;
|
||||
|
||||
int header_height() const { return m_headers_visible ? 16 : 0; }
|
||||
|
@ -48,7 +47,9 @@ public:
|
|||
|
||||
void set_cell_painting_delegate(int column, OwnPtr<GTableCellPaintingDelegate>&&);
|
||||
|
||||
private:
|
||||
protected:
|
||||
explicit GTableView(GWidget* parent);
|
||||
|
||||
virtual void did_update_model() override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
|
|
Loading…
Reference in a new issue