2019-02-28 10:57:09 +01:00
|
|
|
#include "ProcessTableView.h"
|
|
|
|
|
#include "ProcessTableModel.h"
|
2019-03-09 13:33:52 +01:00
|
|
|
#include <LibGUI/GSortingProxyTableModel.h>
|
|
|
|
|
#include <stdio.h>
|
2019-02-28 10:57:09 +01:00
|
|
|
|
|
|
|
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
|
|
|
|
: GTableView(parent)
|
|
|
|
|
{
|
2019-03-09 13:33:52 +01:00
|
|
|
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);
|
2019-02-28 10:57:09 +01:00
|
|
|
start_timer(1000);
|
|
|
|
|
model().update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProcessTableView::~ProcessTableView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessTableView::timer_event(GTimerEvent&)
|
|
|
|
|
{
|
|
|
|
|
model().update();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 21:30:17 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 10:57:09 +01:00
|
|
|
pid_t ProcessTableView::selected_pid() const
|
|
|
|
|
{
|
|
|
|
|
return model().selected_pid();
|
|
|
|
|
}
|