mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 22:08:59 +00:00
We can't grab at the ProcessTableModel directly anymore since we have a sorting proxy model in the middle now.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#include "ProcessTableView.h"
|
|
#include "ProcessTableModel.h"
|
|
#include <LibGUI/GSortingProxyTableModel.h>
|
|
#include <stdio.h>
|
|
|
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
|
: GTableView(parent)
|
|
{
|
|
set_model(make<GSortingProxyTableModel>(make<ProcessTableModel>()));
|
|
model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending);
|
|
start_timer(1000);
|
|
model()->update();
|
|
}
|
|
|
|
ProcessTableView::~ProcessTableView()
|
|
{
|
|
}
|
|
|
|
void ProcessTableView::timer_event(GTimerEvent&)
|
|
{
|
|
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()));
|
|
return;
|
|
}
|
|
}
|
|
|
|
pid_t ProcessTableView::selected_pid() const
|
|
{
|
|
if (!model()->selected_index().is_valid())
|
|
return -1;
|
|
return model()->data({ model()->selected_index().row(), ProcessTableModel::Column::PID }, GTableModel::Role::Sort).as_int();
|
|
}
|