diff options
author | Shannon Booth <shannon.ml.booth@gmail.com> | 2020-01-07 22:28:40 +1300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-07 11:06:27 +0100 |
commit | 7cf15bcb75735db6b13160d1756e6ef19068a9ad (patch) | |
tree | d54fc290c8ee079cc875c197db0b740097527854 /Libraries | |
parent | 00596296c4116c42ef3cbb931f93513e8206c165 (diff) | |
download | serenity-7cf15bcb75735db6b13160d1756e6ef19068a9ad.zip |
GAbstractView: Add function for adding all to selection
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/GAbstractView.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibGUI/GAbstractView.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GAbstractView.cpp b/Libraries/LibGUI/GAbstractView.cpp index 0c98a8ffa1..dc2b1edd27 100644 --- a/Libraries/LibGUI/GAbstractView.cpp +++ b/Libraries/LibGUI/GAbstractView.cpp @@ -95,6 +95,18 @@ void GAbstractView::stop_editing() } } +void GAbstractView::select_all() +{ + ASSERT(model()); + int rows = model()->row_count(); + int columns = model()->column_count(); + + for (int i = 0; i < rows; ++i) { + for (int j = 0; j < columns; ++j) + selection().add(model()->index(i, j)); + } +} + void GAbstractView::activate(const GModelIndex& index) { if (on_activation) diff --git a/Libraries/LibGUI/GAbstractView.h b/Libraries/LibGUI/GAbstractView.h index c4293642bd..2f8feb6ee0 100644 --- a/Libraries/LibGUI/GAbstractView.h +++ b/Libraries/LibGUI/GAbstractView.h @@ -18,6 +18,7 @@ public: GModelSelection& selection() { return m_selection; } const GModelSelection& selection() const { return m_selection; } + void select_all(); bool is_editable() const { return m_editable; } void set_editable(bool editable) { m_editable = editable; } |