mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
37 lines
995 B
C++
37 lines
995 B
C++
#include "ProcessTableView.h"
|
|
#include "ProcessTableModel.h"
|
|
#include <LibGUI/GSortingProxyTableModel.h>
|
|
#include <stdio.h>
|
|
|
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
|
: GTableView(parent)
|
|
{
|
|
set_model(GSortingProxyTableModel::create(ProcessTableModel::create()));
|
|
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) {
|
|
// Do something?
|
|
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();
|
|
}
|