1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 09:35:07 +00:00
serenity/Applications/ProcessManager/ProcessTableView.cpp
Andreas Kling 7d1142c7d9 Make it possible to sort a GTableModel by column+order.
This is accomplished by putting a GSortingProxyTableModel between the model
and the view. It's pretty simplistic but it works for this use case. :^)
2019-03-09 13:33:52 +01:00

38 lines
1,012 B
C++

#include "ProcessTableView.h"
#include "ProcessTableModel.h"
#include <LibGUI/GSortingProxyTableModel.h>
#include <stdio.h>
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);
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
{
return model().selected_pid();
}