summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 16:03:59 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 16:03:59 +0200
commite7b55037f48b8fcddbe283598cad4ef7dcf323f5 (patch)
treea954b20046204aefd0eec325a54bd20bc57060f4
parentc13b9e22144ab246355d158448a8f6111b5e0a48 (diff)
downloadserenity-e7b55037f48b8fcddbe283598cad4ef7dcf323f5.zip
LibGUI: Convert GTableView to ObjectPtr
-rw-r--r--Applications/ChanViewer/main.cpp2
-rw-r--r--Applications/FileManager/DirectoryView.cpp2
-rw-r--r--Applications/FileManager/DirectoryView.h2
-rw-r--r--Applications/IRCClient/IRCAppWindow.cpp2
-rw-r--r--Applications/IRCClient/IRCAppWindow.h2
-rw-r--r--Applications/IRCClient/IRCWindow.cpp4
-rw-r--r--Applications/IRCClient/IRCWindow.h2
-rw-r--r--Applications/SystemMonitor/NetworkStatisticsWidget.cpp4
-rw-r--r--Applications/SystemMonitor/NetworkStatisticsWidget.h4
-rw-r--r--Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp2
-rw-r--r--Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h2
-rw-r--r--Applications/SystemMonitor/ProcessMemoryMapWidget.cpp2
-rw-r--r--Applications/SystemMonitor/ProcessMemoryMapWidget.h2
-rw-r--r--Applications/SystemMonitor/main.cpp6
-rw-r--r--DevTools/Inspector/main.cpp2
-rw-r--r--DevTools/VisualBuilder/VBPropertiesWindow.cpp2
-rw-r--r--DevTools/VisualBuilder/VBPropertiesWindow.h2
-rw-r--r--Libraries/LibGUI/GFilePicker.cpp2
-rw-r--r--Libraries/LibGUI/GFilePicker.h2
-rw-r--r--Libraries/LibGUI/GTableView.h5
20 files changed, 27 insertions, 26 deletions
diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp
index 9561b69a41..73ecb52c70 100644
--- a/Applications/ChanViewer/main.cpp
+++ b/Applications/ChanViewer/main.cpp
@@ -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());
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp
index 7472713ea5..326fae02ab 100644
--- a/Applications/FileManager/DirectoryView.cpp
+++ b/Applications/FileManager/DirectoryView.cpp
@@ -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);
diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h
index f383596cae..8ea8f41880 100644
--- a/Applications/FileManager/DirectoryView.h
+++ b/Applications/FileManager/DirectoryView.h
@@ -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;
};
diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp
index 9fbbd7f193..201fd2b0df 100644
--- a/Applications/IRCClient/IRCAppWindow.cpp
+++ b/Applications/IRCClient/IRCAppWindow.cpp
@@ -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);
diff --git a/Applications/IRCClient/IRCAppWindow.h b/Applications/IRCClient/IRCAppWindow.h
index a9787850c4..b3cb5013b8 100644
--- a/Applications/IRCClient/IRCAppWindow.h
+++ b/Applications/IRCClient/IRCAppWindow.h
@@ -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;
diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp
index 6fa0de4c42..64d0db3063 100644
--- a/Applications/IRCClient/IRCWindow.cpp
+++ b/Applications/IRCClient/IRCWindow.cpp
@@ -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);
diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h
index 297463c982..a23d028b9f 100644
--- a/Applications/IRCClient/IRCWindow.h
+++ b/Applications/IRCClient/IRCWindow.h
@@ -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 };
diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp
index e728e2cd3e..72081ce7fe 100644
--- a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp
+++ b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp
@@ -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;
diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.h b/Applications/SystemMonitor/NetworkStatisticsWidget.h
index a76e344ebf..564ecc1b79 100644
--- a/Applications/SystemMonitor/NetworkStatisticsWidget.h
+++ b/Applications/SystemMonitor/NetworkStatisticsWidget.h
@@ -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;
};
diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp
index bcc461ede8..d0184638bc 100644
--- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp
+++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp
@@ -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;
diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h
index a858281b6d..66d94a1b23 100644
--- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h
+++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h
@@ -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 };
};
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
index 938f8f5237..9adfd15fe3 100644
--- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
+++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp
@@ -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) {
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.h b/Applications/SystemMonitor/ProcessMemoryMapWidget.h
index fa1091286e..003f896eda 100644
--- a/Applications/SystemMonitor/ProcessMemoryMapWidget.h
+++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.h
@@ -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 };
};
diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp
index 9c8f1abf5c..c0bb1bf4af 100644
--- a/Applications/SystemMonitor/main.cpp
+++ b/Applications/SystemMonitor/main.cpp
@@ -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();
diff --git a/DevTools/Inspector/main.cpp b/DevTools/Inspector/main.cpp
index 4fc29779ab..d940c1216a 100644
--- a/DevTools/Inspector/main.cpp
+++ b/DevTools/Inspector/main.cpp
@@ -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) {
diff --git a/DevTools/VisualBuilder/VBPropertiesWindow.cpp b/DevTools/VisualBuilder/VBPropertiesWindow.cpp
index 3a235b9479..ff2759e5b7 100644
--- a/DevTools/VisualBuilder/VBPropertiesWindow.cpp
+++ b/DevTools/VisualBuilder/VBPropertiesWindow.cpp
@@ -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);
diff --git a/DevTools/VisualBuilder/VBPropertiesWindow.h b/DevTools/VisualBuilder/VBPropertiesWindow.h
index 8dd27dd189..070854568c 100644
--- a/DevTools/VisualBuilder/VBPropertiesWindow.h
+++ b/DevTools/VisualBuilder/VBPropertiesWindow.h
@@ -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;
};
diff --git a/Libraries/LibGUI/GFilePicker.cpp b/Libraries/LibGUI/GFilePicker.cpp
index 7776f63179..9dd57ee8f8 100644
--- a/Libraries/LibGUI/GFilePicker.cpp
+++ b/Libraries/LibGUI/GFilePicker.cpp
@@ -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);
diff --git a/Libraries/LibGUI/GFilePicker.h b/Libraries/LibGUI/GFilePicker.h
index 33bf05def1..f7862161a2 100644
--- a/Libraries/LibGUI/GFilePicker.h
+++ b/Libraries/LibGUI/GFilePicker.h
@@ -42,7 +42,7 @@ private:
}
}
- GTableView* m_view { nullptr };
+ ObjectPtr<GTableView> m_view;
NonnullRefPtr<GDirectoryModel> m_model;
FileSystemPath m_selected_file;
diff --git a/Libraries/LibGUI/GTableView.h b/Libraries/LibGUI/GTableView.h
index a469740cf1..f34d1c887d 100644
--- a/Libraries/LibGUI/GTableView.h
+++ b/Libraries/LibGUI/GTableView.h
@@ -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;