mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 11:00:29 +00:00
GTableView and friends: API improvements for 'Sortable' flag.
This commit is contained in:
parent
405d7ddec8
commit
6228e18a09
Notes:
sideshowbarker
2024-07-19 17:45:01 +09:00
Author: https://github.com/ignas-sa Commit: https://github.com/SerenityOS/serenity/commit/6228e18a091 Pull-request: https://github.com/SerenityOS/serenity/pull/442 Reviewed-by: https://github.com/awesomekling
3 changed files with 4 additions and 3 deletions
|
@ -119,7 +119,7 @@ GModel::ColumnMetadata GDirectoryModel::column_metadata(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Icon:
|
||||
return { 16, TextAlignment::Center, false };
|
||||
return { 16, TextAlignment::Center, nullptr, GModel::ColumnMetadata::Sortable::False };
|
||||
case Column::Name:
|
||||
return { 120, TextAlignment::CenterLeft };
|
||||
case Column::Size:
|
||||
|
|
|
@ -44,8 +44,9 @@ public:
|
|||
struct ColumnMetadata {
|
||||
int preferred_width { 0 };
|
||||
TextAlignment text_alignment { TextAlignment::CenterLeft };
|
||||
bool sortable { true };
|
||||
const Font* font { nullptr };
|
||||
enum class Sortable { False, True };
|
||||
Sortable sortable { Sortable::True };
|
||||
};
|
||||
|
||||
enum class Role {
|
||||
|
|
|
@ -159,7 +159,7 @@ void GTableView::mousedown_event(GMouseEvent& event)
|
|||
}
|
||||
auto header_rect = this->header_rect(i);
|
||||
auto column_metadata = model()->column_metadata(i);
|
||||
if (header_rect.contains(event.position()) && column_metadata.sortable) {
|
||||
if (header_rect.contains(event.position()) && column_metadata.sortable == GModel::ColumnMetadata::Sortable::True) {
|
||||
auto new_sort_order = GSortOrder::Ascending;
|
||||
if (model()->key_column() == i)
|
||||
new_sort_order = model()->sort_order() == GSortOrder::Ascending
|
||||
|
|
Loading…
Reference in a new issue