summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/SortingProxyModel.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-07-15 14:33:12 +0300
committerAndreas Kling <kling@serenityos.org>2020-07-15 13:41:46 +0200
commit5fd8dbacb13538c6808e8f40dbcf371af76ca470 (patch)
tree42221935c6f4479b5f67a6b545c315ac466e5a83 /Libraries/LibGUI/SortingProxyModel.cpp
parente12b591509ca54fcdf76a27aa3af43eb3d09744d (diff)
downloadserenity-5fd8dbacb13538c6808e8f40dbcf371af76ca470.zip
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 :^)
Diffstat (limited to 'Libraries/LibGUI/SortingProxyModel.cpp')
-rw-r--r--Libraries/LibGUI/SortingProxyModel.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/Libraries/LibGUI/SortingProxyModel.cpp b/Libraries/LibGUI/SortingProxyModel.cpp
index 991cbb9786..c18b18fac5 100644
--- a/Libraries/LibGUI/SortingProxyModel.cpp
+++ b/Libraries/LibGUI/SortingProxyModel.cpp
@@ -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()