blob: bff01703226f87aaeb6f6fb51824bfbf219b4b63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "ProcessTableView.h"
#include "ProcessModel.h"
#include <LibGUI/GSortingProxyModel.h>
#include <stdio.h>
ProcessTableView::ProcessTableView(GWidget* parent)
: GTableView(parent)
{
set_size_columns_to_fit_content(true);
set_model(GSortingProxyModel::create(ProcessModel::create()));
model()->set_key_column_and_sort_order(ProcessModel::Column::CPU, GSortOrder::Descending);
refresh();
on_selection = [this](auto&) {
if (on_process_selected)
on_process_selected(selected_pid());
};
}
ProcessTableView::~ProcessTableView()
{
}
void ProcessTableView::refresh()
{
model()->update();
}
pid_t ProcessTableView::selected_pid() const
{
if (selection().is_empty())
return -1;
return model()->data(model()->index(selection().first().row(), ProcessModel::Column::PID), GModel::Role::Sort).as_int();
}
|