GTableView: add 'sortable' column header flag.
This prevents sorting unsortable by unsortable things, like icons.
This commit is contained in:
parent
57c92f943b
commit
823d5d097b
Notes:
sideshowbarker
2024-07-19 17:45:14 +09:00
Author: https://github.com/ignas-sa Commit: https://github.com/SerenityOS/serenity/commit/823d5d097bf Pull-request: https://github.com/SerenityOS/serenity/pull/442 Reviewed-by: https://github.com/awesomekling
2 changed files with 3 additions and 1 deletions
Libraries/LibGUI
|
@ -44,6 +44,7 @@ public:
|
|||
struct ColumnMetadata {
|
||||
int preferred_width { 0 };
|
||||
TextAlignment text_alignment { TextAlignment::CenterLeft };
|
||||
bool sortable { true };
|
||||
const Font* font { nullptr };
|
||||
};
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ void GTableView::mousedown_event(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
auto header_rect = this->header_rect(i);
|
||||
if (header_rect.contains(event.position())) {
|
||||
auto column_metadata = model()->column_metadata(i);
|
||||
if (header_rect.contains(event.position()) && column_metadata.sortable) {
|
||||
auto new_sort_order = GSortOrder::Ascending;
|
||||
if (model()->key_column() == i)
|
||||
new_sort_order = model()->sort_order() == GSortOrder::Ascending
|
||||
|
|
Loading…
Add table
Reference in a new issue