mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 20:45:08 +00:00
LibGUI: Use a separate data role for the table model sorting order.
This allows data to be displayed nicely while sorting happens based on some underlying raw data. :^)
This commit is contained in:
parent
3681a402ba
commit
46caa2663b
11 changed files with 43 additions and 15 deletions
|
@ -54,9 +54,9 @@ GTableModel::ColumnMetadata GSortingProxyTableModel::column_metadata(int index)
|
|||
return target().column_metadata(index);
|
||||
}
|
||||
|
||||
GVariant GSortingProxyTableModel::data(const GModelIndex& index) const
|
||||
GVariant GSortingProxyTableModel::data(const GModelIndex& index, Role role) const
|
||||
{
|
||||
return target().data(map_to_target(index));
|
||||
return target().data(map_to_target(index), role);
|
||||
}
|
||||
|
||||
void GSortingProxyTableModel::activate(const GModelIndex& index)
|
||||
|
@ -102,8 +102,8 @@ void GSortingProxyTableModel::resort()
|
|||
auto& context = *(Context*)(ctx);
|
||||
GModelIndex index1 { row1, context.key_column };
|
||||
GModelIndex index2 { row2, context.key_column };
|
||||
auto data1 = context.target->data(index1);
|
||||
auto data2 = context.target->data(index2);
|
||||
auto data1 = context.target->data(index1, GTableModel::Role::Sort);
|
||||
auto data2 = context.target->data(index2, GTableModel::Role::Sort);
|
||||
if (data1 == data2)
|
||||
return 0;
|
||||
bool is_less_than = data1 < data2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue