summaryrefslogtreecommitdiff
path: root/LibGUI/GSortingProxyModel.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-29 04:58:15 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-29 04:58:15 +0100
commitd02238af48e588e9272413c8345aac31a7b07a33 (patch)
tree7064b540541dfdd3381a19d56c8459a034b3d6e4 /LibGUI/GSortingProxyModel.cpp
parent12ec55ee743589bfcc1a2c876602d7ad72a13da3 (diff)
downloadserenity-d02238af48e588e9272413c8345aac31a7b07a33.zip
LibGUI: Expand GModelIndex a bit, adding internal data and model pointers.
This will be useful for implementing more complicated models.
Diffstat (limited to 'LibGUI/GSortingProxyModel.cpp')
-rw-r--r--LibGUI/GSortingProxyModel.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/LibGUI/GSortingProxyModel.cpp b/LibGUI/GSortingProxyModel.cpp
index 312358a5cf..a2fbe054c6 100644
--- a/LibGUI/GSortingProxyModel.cpp
+++ b/LibGUI/GSortingProxyModel.cpp
@@ -32,7 +32,7 @@ GModelIndex GSortingProxyModel::map_to_target(const GModelIndex& index) const
return { };
if (index.row() >= row_count() || index.column() >= column_count())
return { };
- return { m_row_mappings[index.row()], index.column() };
+ return target().index(m_row_mappings[index.row()], index.column());
}
String GSortingProxyModel::row_name(int index) const
@@ -86,8 +86,8 @@ void GSortingProxyModel::resort()
if (m_key_column == -1)
return;
quick_sort(m_row_mappings.begin(), m_row_mappings.end(), [&] (auto row1, auto row2) -> bool {
- auto data1 = target().data({ row1, m_key_column }, GModel::Role::Sort);
- auto data2 = target().data({ row2, m_key_column }, GModel::Role::Sort);
+ auto data1 = target().data(target().index(row1, m_key_column), GModel::Role::Sort);
+ auto data2 = target().data(target().index(row2, m_key_column), GModel::Role::Sort);
if (data1 == data2)
return 0;
bool is_less_than = data1 < data2;
@@ -97,7 +97,7 @@ void GSortingProxyModel::resort()
// Preserve selection.
for (int i = 0; i < row_count; ++i) {
if (m_row_mappings[i] == previously_selected_target_row) {
- set_selected_index({ i, 0 });
+ set_selected_index(index(i, 0));
break;
}
}