mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 02:08:53 +00:00
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:
parent
9c21874d33
commit
e1d0a3f226
Notes:
sideshowbarker
2024-07-19 15:34:42 +09:00
Author: https://github.com/awesomekling
Commit: e1d0a3f226
3 changed files with 6 additions and 22 deletions
|
@ -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()];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue