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.
This commit is contained in:
Andreas Kling 2019-03-10 02:02:37 +01:00
parent 2336d43abc
commit 0b32ab12f1
Notes: sideshowbarker 2024-07-19 15:05:51 +09:00
4 changed files with 8 additions and 22 deletions

View file

@ -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();
}