diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-10 02:02:37 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-10 02:03:36 +0100 |
commit | 0b32ab12f1329caebf3ae2e29178fa9fd683510a (patch) | |
tree | 058f888e8d72705b42f1b8fc0dfac77ced2a85b8 /Applications/ProcessManager | |
parent | 2336d43abce16c6eedcaae508fbf33a946f4e3fa (diff) | |
download | serenity-0b32ab12f1329caebf3ae2e29178fa9fd683510a.zip |
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.
Diffstat (limited to 'Applications/ProcessManager')
-rw-r--r-- | Applications/ProcessManager/ProcessTableModel.cpp | 7 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessTableModel.h | 2 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessTableView.cpp | 16 | ||||
-rw-r--r-- | Applications/ProcessManager/ProcessTableView.h | 5 |
4 files changed, 8 insertions, 22 deletions
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<ProcessTableModel>(); - m_model = process_model.ptr(); - set_model(make<GSortingProxyTableModel>(move(process_model))); - GTableView::model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending); + set_model(make<GSortingProxyTableModel>(make<ProcessTableModel>())); + 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 }; }; |