mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
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. :^)
This commit is contained in:
parent
0680fe2383
commit
7d1142c7d9
Notes:
sideshowbarker
2024-07-19 15:06:53 +09:00
Author: https://github.com/awesomekling
Commit: 7d1142c7d9
16 changed files with 278 additions and 40 deletions
|
@ -1,11 +1,15 @@
|
|||
#include "ProcessTableView.h"
|
||||
#include "ProcessTableModel.h"
|
||||
|
||||
#include <LibGUI/GSortingProxyTableModel.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ProcessTableView::ProcessTableView(GWidget* parent)
|
||||
: GTableView(parent)
|
||||
{
|
||||
set_model(make<ProcessTableModel>());
|
||||
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();
|
||||
}
|
||||
|
@ -32,13 +36,3 @@ pid_t ProcessTableView::selected_pid() const
|
|||
{
|
||||
return model().selected_pid();
|
||||
}
|
||||
|
||||
inline ProcessTableModel& ProcessTableView::model()
|
||||
{
|
||||
return static_cast<ProcessTableModel&>(*GTableView::model());
|
||||
}
|
||||
|
||||
inline const ProcessTableModel& ProcessTableView::model() const
|
||||
{
|
||||
return static_cast<const ProcessTableModel&>(*GTableView::model());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue