LibGUI: Let GTableModel handle the selection instead of doing it virtually.

It's silly to force every subclass models to deal with selection.
This commit is contained in:
Andreas Kling 2019-03-01 13:03:13 +01:00
parent 9c21874d33
commit e1d0a3f226
Notes: sideshowbarker 2024-07-19 15:34:42 +09:00
3 changed files with 6 additions and 22 deletions

View file

@ -75,21 +75,6 @@ GTableModel::ColumnMetadata ProcessTableModel::column_metadata(int column) const
}
}
GModelIndex ProcessTableModel::selected_index() const
{
return { m_selected_row, 0 };
}
void ProcessTableModel::set_selected_index(GModelIndex index)
{
if (!index.is_valid()) {
m_selected_row = -1;
return;
}
if (index.row() >= 0 && index.row() < m_pids.size())
m_selected_row = index.row();
}
static String pretty_byte_size(size_t size)
{
return String::format("%uK", size / 1024);
@ -207,7 +192,7 @@ void ProcessTableModel::update()
pid_t ProcessTableModel::selected_pid() const
{
if (m_selected_row == -1)
if (!selected_index().is_valid())
return -1;
return m_pids[m_selected_row];
return m_pids[selected_index().row()];
}