mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:45:06 +00:00
GTableView: Handle not having a model a bit more gracefully.
This commit is contained in:
parent
f52e66ceda
commit
ef23ed7ef1
1 changed files with 8 additions and 0 deletions
|
@ -65,6 +65,9 @@ Rect GTableView::header_rect(int column_index) const
|
||||||
|
|
||||||
void GTableView::mousedown_event(GMouseEvent& event)
|
void GTableView::mousedown_event(GMouseEvent& event)
|
||||||
{
|
{
|
||||||
|
if (!model())
|
||||||
|
return;
|
||||||
|
|
||||||
if (event.y() < header_height()) {
|
if (event.y() < header_height()) {
|
||||||
auto adjusted_position = event.position().translated(horizontal_scrollbar().value(), 0);
|
auto adjusted_position = event.position().translated(horizontal_scrollbar().value(), 0);
|
||||||
for (int i = 0; i < model()->column_count(); ++i) {
|
for (int i = 0; i < model()->column_count(); ++i) {
|
||||||
|
@ -100,6 +103,9 @@ void GTableView::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
GFrame::paint_event(event);
|
GFrame::paint_event(event);
|
||||||
|
|
||||||
|
if (!model())
|
||||||
|
return;
|
||||||
|
|
||||||
GPainter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.add_clip_rect(frame_inner_rect());
|
painter.add_clip_rect(frame_inner_rect());
|
||||||
painter.add_clip_rect(event.rect());
|
painter.add_clip_rect(event.rect());
|
||||||
|
@ -213,6 +219,8 @@ void GTableView::paint_headers(Painter& painter)
|
||||||
|
|
||||||
int GTableView::item_count() const
|
int GTableView::item_count() const
|
||||||
{
|
{
|
||||||
|
if (!model())
|
||||||
|
return 0;
|
||||||
return model()->row_count();
|
return model()->row_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue