mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:45:10 +00:00
ProcessManager: Make the toolbar actions work again.
We can't grab at the ProcessTableModel directly anymore since we have a sorting proxy model in the middle now.
This commit is contained in:
parent
2336d43abc
commit
0b32ab12f1
4 changed files with 8 additions and 22 deletions
|
@ -199,10 +199,3 @@ void ProcessTableModel::update()
|
||||||
|
|
||||||
did_update();
|
did_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t ProcessTableModel::selected_pid() const
|
|
||||||
{
|
|
||||||
if (!selected_index().is_valid())
|
|
||||||
return -1;
|
|
||||||
return m_pids[selected_index().row()];
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,8 +31,6 @@ public:
|
||||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
||||||
virtual void update() override;
|
virtual void update() override;
|
||||||
|
|
||||||
pid_t selected_pid() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ProcessState {
|
struct ProcessState {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
ProcessTableView::ProcessTableView(GWidget* parent)
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
||||||
: GTableView(parent)
|
: GTableView(parent)
|
||||||
{
|
{
|
||||||
auto process_model = make<ProcessTableModel>();
|
set_model(make<GSortingProxyTableModel>(make<ProcessTableModel>()));
|
||||||
m_model = process_model.ptr();
|
model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending);
|
||||||
set_model(make<GSortingProxyTableModel>(move(process_model)));
|
|
||||||
GTableView::model()->set_key_column_and_sort_order(ProcessTableModel::Column::CPU, GSortOrder::Descending);
|
|
||||||
start_timer(1000);
|
start_timer(1000);
|
||||||
model().update();
|
model()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessTableView::~ProcessTableView()
|
ProcessTableView::~ProcessTableView()
|
||||||
|
@ -20,19 +18,21 @@ ProcessTableView::~ProcessTableView()
|
||||||
|
|
||||||
void ProcessTableView::timer_event(GTimerEvent&)
|
void ProcessTableView::timer_event(GTimerEvent&)
|
||||||
{
|
{
|
||||||
model().update();
|
model()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessTableView::model_notification(const GModelNotification& notification)
|
void ProcessTableView::model_notification(const GModelNotification& notification)
|
||||||
{
|
{
|
||||||
if (notification.type() == GModelNotification::ModelUpdated) {
|
if (notification.type() == GModelNotification::ModelUpdated) {
|
||||||
if (on_status_message)
|
if (on_status_message)
|
||||||
on_status_message(String::format("%d processes", model().row_count()));
|
on_status_message(String::format("%d processes", model()->row_count()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t ProcessTableView::selected_pid() const
|
pid_t ProcessTableView::selected_pid() const
|
||||||
{
|
{
|
||||||
return model().selected_pid();
|
if (!model()->selected_index().is_valid())
|
||||||
|
return -1;
|
||||||
|
return model()->data({ model()->selected_index().row(), ProcessTableModel::Column::PID }, GTableModel::Role::Sort).as_int();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,5 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void timer_event(GTimerEvent&) override;
|
virtual void timer_event(GTimerEvent&) override;
|
||||||
|
|
||||||
ProcessTableModel& model() { return *m_model; }
|
|
||||||
const ProcessTableModel& model() const { return *m_model; }
|
|
||||||
|
|
||||||
ProcessTableModel* m_model { nullptr };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue