From d0b7d5e84c9ae79478763b7243fcdee14e5f5f63 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Jun 2019 10:40:35 +0200 Subject: 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. --- LibGUI/GAbstractView.cpp | 2 ++ LibGUI/GAbstractView.h | 1 + 2 files changed, 3 insertions(+) (limited to 'LibGUI') 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 on_activation; + Function on_selection; Function on_model_notification; virtual const char* class_name() const override { return "GAbstractView"; } -- cgit v1.2.3