mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-11 21:52:53 +00:00
LibGUI+FileManager: Fix forgetting to map sorting proxy model indexes
Also assert indexes are valid in a few more places. Finally fixes https://github.com/SerenityOS/serenity/issues/1440 and https://github.com/SerenityOS/serenity/issues/2787 :^)
This commit is contained in:
parent
e12b591509
commit
5fd8dbacb1
Notes:
sideshowbarker
2024-07-19 04:48:44 +09:00
Author: https://github.com/bugaevc
Commit: 5fd8dbacb1
Pull-request: https://github.com/SerenityOS/serenity/pull/2809
Issue: https://github.com/SerenityOS/serenity/issues/1440
4 changed files with 21 additions and 17 deletions
Libraries/LibGUI
|
@ -57,12 +57,14 @@ void SortingProxyModel::on_model_update(unsigned flags)
|
|||
|
||||
int SortingProxyModel::row_count(const ModelIndex& index) const
|
||||
{
|
||||
return target().row_count(index);
|
||||
auto target_index = map_to_target(index);
|
||||
return target().row_count(target_index);
|
||||
}
|
||||
|
||||
int SortingProxyModel::column_count(const ModelIndex& index) const
|
||||
{
|
||||
return target().column_count(index);
|
||||
auto target_index = map_to_target(index);
|
||||
return target().column_count(target_index);
|
||||
}
|
||||
|
||||
ModelIndex SortingProxyModel::map_to_target(const ModelIndex& index) const
|
||||
|
@ -74,19 +76,16 @@ ModelIndex SortingProxyModel::map_to_target(const ModelIndex& index) const
|
|||
return target().index(m_row_mappings[index.row()], index.column());
|
||||
}
|
||||
|
||||
String SortingProxyModel::column_name(int index) const
|
||||
String SortingProxyModel::column_name(int column) const
|
||||
{
|
||||
return target().column_name(index);
|
||||
return target().column_name(column);
|
||||
}
|
||||
|
||||
Variant SortingProxyModel::data(const ModelIndex& index, Role role) const
|
||||
{
|
||||
auto target_index = map_to_target(index);
|
||||
if (!target_index.is_valid()) {
|
||||
dbg() << "BUG! SortingProxyModel: Unable to convert " << index << " to target";
|
||||
return {};
|
||||
}
|
||||
return target().data(map_to_target(index), role);
|
||||
ASSERT(target_index.is_valid());
|
||||
return target().data(target_index, role);
|
||||
}
|
||||
|
||||
void SortingProxyModel::update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue