From 0b32ab12f1329caebf3ae2e29178fa9fd683510a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Mar 2019 02:02:37 +0100 Subject: ProcessManager: Make the toolbar actions work again. We can't grab at the ProcessTableModel directly anymore since we have a sorting proxy model in the middle now. --- Applications/ProcessManager/ProcessTableModel.cpp | 7 ------- Applications/ProcessManager/ProcessTableModel.h | 2 -- Applications/ProcessManager/ProcessTableView.cpp | 16 ++++++++-------- Applications/ProcessManager/ProcessTableView.h | 5 ----- 4 files changed, 8 insertions(+), 22 deletions(-) (limited to 'Applications/ProcessManager') diff --git a/Applications/ProcessManager/ProcessTableModel.cpp b/Applications/ProcessManager/ProcessTableModel.cpp index ab736006c4..df9320b7b3 100644 --- a/Applications/ProcessManager/ProcessTableModel.cpp +++ b/Applications/ProcessManager/ProcessTableModel.cpp @@ -199,10 +199,3 @@ void ProcessTableModel::update() did_update(); } - -pid_t ProcessTableModel::selected_pid() const -{ - if (!selected_index().is_valid()) - return -1; - return m_pids[selected_index().row()]; -} diff --git a/Applications/ProcessManager/ProcessTableModel.h b/Applications/ProcessManager/ProcessTableModel.h index ced17f0b7f..558b37f643 100644 --- a/Applications/ProcessManager/ProcessTableModel.h +++ b/Applications/ProcessManager/ProcessTableModel.h @@ -31,8 +31,6 @@ public: virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; virtual void update() override; - pid_t selected_pid() const; - private: struct ProcessState { pid_t pid; diff --git a/Applications/ProcessManager/ProcessTableView.cpp b/Applications/ProcessManager/ProcessTableView.cpp index 8dd937223e..66b0f9510d 100644 --- a/Applications/ProcessManager/ProcessTableView.cpp +++ b/Applications/ProcessManager/ProcessTableView.cpp @@ -6,12 +6,10 @@ ProcessTableView::ProcessTableView(GWidget* parent) : GTableView(parent) { - auto process_model = make(); - m_model = process_model.ptr(); - set_model(make(move(process_model))); - GTableView::model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending); + set_model(make(make())); + model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending); start_timer(1000); - model().update(); + model()->update(); } ProcessTableView::~ProcessTableView() @@ -20,19 +18,21 @@ ProcessTableView::~ProcessTableView() void ProcessTableView::timer_event(GTimerEvent&) { - model().update(); + model()->update(); } void ProcessTableView::model_notification(const GModelNotification& notification) { if (notification.type() == GModelNotification::ModelUpdated) { if (on_status_message) - on_status_message(String::format("%d processes", model().row_count())); + on_status_message(String::format("%d processes", model()->row_count())); return; } } pid_t ProcessTableView::selected_pid() const { - return model().selected_pid(); + if (!model()->selected_index().is_valid()) + return -1; + return model()->data({ model()->selected_index().row(), ProcessTableModel::Column::PID }, GTableModel::Role::Sort).as_int(); } diff --git a/Applications/ProcessManager/ProcessTableView.h b/Applications/ProcessManager/ProcessTableView.h index 8c5f37b552..3294ea5d41 100644 --- a/Applications/ProcessManager/ProcessTableView.h +++ b/Applications/ProcessManager/ProcessTableView.h @@ -20,10 +20,5 @@ protected: private: virtual void timer_event(GTimerEvent&) override; - - ProcessTableModel& model() { return *m_model; } - const ProcessTableModel& model() const { return *m_model; } - - ProcessTableModel* m_model { nullptr }; }; -- cgit v1.2.3