diff --git a/Libraries/LibGUI/GAbstractColumnView.cpp b/Libraries/LibGUI/GAbstractColumnView.cpp index 1f094e8008e..a2ca580311e 100644 --- a/Libraries/LibGUI/GAbstractColumnView.cpp +++ b/Libraries/LibGUI/GAbstractColumnView.cpp @@ -396,6 +396,13 @@ GModelIndex GAbstractColumnView::index_at_event_position(const Point& position, return {}; } +GModelIndex GAbstractColumnView::index_at_event_position(const Point& position) const +{ + bool is_toggle; + auto index = index_at_event_position(position, is_toggle); + return is_toggle ? GModelIndex() : index; +} + int GAbstractColumnView::item_count() const { if (!model()) diff --git a/Libraries/LibGUI/GAbstractColumnView.h b/Libraries/LibGUI/GAbstractColumnView.h index 0d804d563ef..80b39cc8266 100644 --- a/Libraries/LibGUI/GAbstractColumnView.h +++ b/Libraries/LibGUI/GAbstractColumnView.h @@ -68,6 +68,9 @@ public: void scroll_into_view(const GModelIndex&, Orientation); + virtual GModelIndex index_at_event_position(const Point&, bool& is_toggle) const; + virtual GModelIndex index_at_event_position(const Point&) const override; + protected: virtual ~GAbstractColumnView() override; explicit GAbstractColumnView(GWidget* parent); @@ -81,7 +84,6 @@ protected: virtual void leave_event(CEvent&) override; virtual void context_menu_event(GContextMenuEvent&) override; - virtual GModelIndex index_at_event_position(const Point&, bool& is_toggle) const; virtual void toggle_index(const GModelIndex&) {} void paint_headers(GPainter&); diff --git a/Libraries/LibGUI/GAbstractView.h b/Libraries/LibGUI/GAbstractView.h index 997818b2045..59def386321 100644 --- a/Libraries/LibGUI/GAbstractView.h +++ b/Libraries/LibGUI/GAbstractView.h @@ -54,6 +54,7 @@ public: virtual void did_update_selection(); virtual Rect content_rect(const GModelIndex&) const { return {}; } + virtual GModelIndex index_at_event_position(const Point&) const = 0; void begin_editing(const GModelIndex&); void stop_editing(); diff --git a/Libraries/LibGUI/GColumnsView.h b/Libraries/LibGUI/GColumnsView.h index 8d7948ae914..f34cca21012 100644 --- a/Libraries/LibGUI/GColumnsView.h +++ b/Libraries/LibGUI/GColumnsView.h @@ -35,11 +35,11 @@ public: int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } + virtual GModelIndex index_at_event_position(const Point&) const override; + private: GColumnsView(GWidget* parent = nullptr); virtual ~GColumnsView(); - - GModelIndex index_at_event_position(const Point&) const; void push_column(GModelIndex& parent_index); void update_column_sizes(); diff --git a/Libraries/LibGUI/GItemView.h b/Libraries/LibGUI/GItemView.h index 8ad181595de..dfb52d30d4f 100644 --- a/Libraries/LibGUI/GItemView.h +++ b/Libraries/LibGUI/GItemView.h @@ -48,6 +48,8 @@ public: int model_column() const { return m_model_column; } void set_model_column(int column) { m_model_column = column; } + virtual GModelIndex index_at_event_position(const Point&) const override; + private: explicit GItemView(GWidget* parent); @@ -64,7 +66,6 @@ private: int item_count() const; Rect item_rect(int item_index) const; - GModelIndex index_at_event_position(const Point&) const; Vector items_intersecting_rect(const Rect&) const; void update_content_size(); void get_item_rects(int item_index, const Font&, const GVariant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const; diff --git a/Libraries/LibGUI/GListView.h b/Libraries/LibGUI/GListView.h index ff5a3d79fe4..4fac12902e6 100644 --- a/Libraries/LibGUI/GListView.h +++ b/Libraries/LibGUI/GListView.h @@ -51,7 +51,7 @@ public: Point adjusted_position(const Point&) const; - GModelIndex index_at_event_position(const Point&) const; + virtual GModelIndex index_at_event_position(const Point&) const override; virtual Rect content_rect(const GModelIndex&) const override; int model_column() const { return m_model_column; }