LibGUI: Minor tidying.

This commit is contained in:
Andreas Kling 2019-03-09 14:39:24 +01:00
parent 46caa2663b
commit 7d2c962836
Notes: sideshowbarker 2024-07-19 15:06:46 +09:00
2 changed files with 5 additions and 8 deletions

View file

@ -103,14 +103,15 @@ Rect GTableView::header_rect(int column_index) const
void GTableView::mousedown_event(GMouseEvent& event)
{
if (event.y() < header_height()) {
// FIXME: Do something when clicking on a header.
auto adjusted_position = event.position().translated(m_horizontal_scrollbar->value(), 0);
for (int i = 0; i < m_model->column_count(); ++i) {
auto header_rect = this->header_rect(i);
if (header_rect.contains(adjusted_position)) {
auto new_sort_order = GSortOrder::Ascending;
if (m_model->key_column() == i)
new_sort_order = m_model->sort_order() == GSortOrder::Ascending ? GSortOrder::Descending : GSortOrder::Ascending;
new_sort_order = m_model->sort_order() == GSortOrder::Ascending
? GSortOrder::Descending
: GSortOrder::Ascending;
m_model->set_key_column_and_sort_order(i, new_sort_order);
return;
}