1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

LibGUI: Make inline editing work in ColumnsView

All it took was overriding content_rect() :^)
This commit is contained in:
Andreas Kling 2020-09-24 11:50:47 +02:00
parent f52527ef9c
commit 5a0b1c46aa
2 changed files with 18 additions and 2 deletions

View file

@ -305,8 +305,8 @@ void ColumnsView::move_cursor(CursorMovement movement, SelectionUpdate selection
if (model.is_valid(cursor_index())) if (model.is_valid(cursor_index()))
push_column(cursor_index()); push_column(cursor_index());
update(); update();
break; break;
} }
default: default:
break; break;
} }
@ -328,4 +328,19 @@ void ColumnsView::keydown_event(KeyEvent& event)
AbstractView::keydown_event(event); AbstractView::keydown_event(event);
} }
Gfx::IntRect ColumnsView::content_rect(const ModelIndex& index) const
{
if (!index.is_valid())
return {};
int column_x = 0;
for (auto& column : m_columns) {
if (column.parent_index == index.parent())
return { column_x, index.row() * item_height(), column.width, item_height() };
column_x += column.width;
}
return {};
}
} }

View file

@ -38,6 +38,7 @@ public:
void set_model_column(int column) { m_model_column = column; } void set_model_column(int column) { m_model_column = column; }
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
private: private:
ColumnsView(); ColumnsView();