mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
GTableView: Handle not having a model a bit more gracefully.
This commit is contained in:
parent
f52e66ceda
commit
ef23ed7ef1
Notes:
sideshowbarker
2024-07-19 14:45:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ef23ed7ef18
@ -65,6 +65,9 @@ Rect GTableView::header_rect(int column_index) const
|
||||
|
||||
void GTableView::mousedown_event(GMouseEvent& event)
|
||||
{
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
if (event.y() < header_height()) {
|
||||
auto adjusted_position = event.position().translated(horizontal_scrollbar().value(), 0);
|
||||
for (int i = 0; i < model()->column_count(); ++i) {
|
||||
@ -100,6 +103,9 @@ void GTableView::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GFrame::paint_event(event);
|
||||
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
@ -213,6 +219,8 @@ void GTableView::paint_headers(Painter& painter)
|
||||
|
||||
int GTableView::item_count() const
|
||||
{
|
||||
if (!model())
|
||||
return 0;
|
||||
return model()->row_count();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user