diff --git a/Userland/Libraries/LibGUI/HeaderView.cpp b/Userland/Libraries/LibGUI/HeaderView.cpp index e59f3110a8..aee2792ee7 100644 --- a/Userland/Libraries/LibGUI/HeaderView.cpp +++ b/Userland/Libraries/LibGUI/HeaderView.cpp @@ -342,6 +342,16 @@ void HeaderView::set_section_visible(int section, bool visible) update(); } +void HeaderView::set_section_selectable(int section, bool selectable) +{ + auto& data = section_data(section); + if (data.selectable == selectable) + return; + data.selectable = selectable; + if (m_context_menu) + m_context_menu = nullptr; +} + Menu& HeaderView::ensure_context_menu() { // FIXME: This menu needs to be rebuilt if the model is swapped out, @@ -358,6 +368,8 @@ Menu& HeaderView::ensure_context_menu() int section_count = this->section_count(); for (int section = 0; section < section_count; ++section) { auto& column_data = this->section_data(section); + if (!column_data.selectable) + continue; auto name = model()->column_name(section).release_value_but_fixme_should_propagate_errors().to_byte_string(); column_data.visibility_action = Action::create_checkable(name, [this, section](auto& action) { set_section_visible(section, action.is_checked()); diff --git a/Userland/Libraries/LibGUI/HeaderView.h b/Userland/Libraries/LibGUI/HeaderView.h index 607543d855..4384731b80 100644 --- a/Userland/Libraries/LibGUI/HeaderView.h +++ b/Userland/Libraries/LibGUI/HeaderView.h @@ -36,6 +36,8 @@ public: bool is_section_visible(int section) const; void set_section_visible(int section, bool); + void set_section_selectable(int section, bool); + int section_count() const; Gfx::IntRect section_rect(int section) const; @@ -92,6 +94,7 @@ private: bool has_initialized_size { false }; bool has_initialized_default_size { false }; bool visibility { true }; + bool selectable { true }; RefPtr visibility_action; Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterLeft }; };