mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGUI: Make inline editing work in ColumnsView
All it took was overriding content_rect() :^)
This commit is contained in:
parent
f52527ef9c
commit
5a0b1c46aa
Notes:
sideshowbarker
2024-07-19 02:15:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5a0b1c46aaa
2 changed files with 18 additions and 2 deletions
|
@ -305,8 +305,8 @@ void ColumnsView::move_cursor(CursorMovement movement, SelectionUpdate selection
|
|||
if (model.is_valid(cursor_index()))
|
||||
push_column(cursor_index());
|
||||
update();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -328,4 +328,19 @@ void ColumnsView::keydown_event(KeyEvent& 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 {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
||||
|
||||
private:
|
||||
ColumnsView();
|
||||
|
|
Loading…
Reference in a new issue