|
@@ -6,12 +6,10 @@
|
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
|
ProcessTableView::ProcessTableView(GWidget* parent)
|
|
: GTableView(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);
|
|
|
|
|
|
+ set_model(make<GSortingProxyTableModel>(make<ProcessTableModel>()));
|
|
|
|
+ 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();
|
|
}
|
|
}
|