diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-22 10:40:35 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-22 10:40:35 +0200 |
commit | d0b7d5e84c9ae79478763b7243fcdee14e5f5f63 (patch) | |
tree | 54a9233d60b12c352b012aed26f5f192352dcff1 /LibGUI | |
parent | dd6b8135c265351c62bb3b31dbaf9a9d294665e6 (diff) | |
download | serenity-d0b7d5e84c9ae79478763b7243fcdee14e5f5f63.zip |
GAbstractView: Add on_selection callback.
This callback is fired whenever the model's selection is updated.
Note that it only fires when there is a model, and when the index is valid.
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GAbstractView.cpp | 2 | ||||
-rw-r--r-- | LibGUI/GAbstractView.h | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/LibGUI/GAbstractView.cpp b/LibGUI/GAbstractView.cpp index 2f7c410592..300ede4a6e 100644 --- a/LibGUI/GAbstractView.cpp +++ b/LibGUI/GAbstractView.cpp @@ -44,6 +44,8 @@ void GAbstractView::did_update_selection() { if (!model() || model()->selected_index() != m_edit_index) stop_editing(); + if (model() && on_selection && model()->selected_index().is_valid()) + on_selection(model()->selected_index()); } void GAbstractView::did_scroll() diff --git a/LibGUI/GAbstractView.h b/LibGUI/GAbstractView.h index 1a517c0c16..f57a65c919 100644 --- a/LibGUI/GAbstractView.h +++ b/LibGUI/GAbstractView.h @@ -32,6 +32,7 @@ public: bool activates_on_selection() const { return m_activates_on_selection; } Function<void(const GModelIndex&)> on_activation; + Function<void(const GModelIndex&)> on_selection; Function<void(const GModelNotification&)> on_model_notification; virtual const char* class_name() const override { return "GAbstractView"; } |