summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/AbstractTableView.cpp9
-rw-r--r--Libraries/LibGUI/AbstractTableView.h1
-rw-r--r--Libraries/LibGUI/AbstractView.cpp12
-rw-r--r--Libraries/LibGUI/AbstractView.h2
-rw-r--r--Libraries/LibGUI/ColumnsView.cpp23
-rw-r--r--Libraries/LibGUI/ColumnsView.h1
-rw-r--r--Libraries/LibGUI/ItemView.cpp9
-rw-r--r--Libraries/LibGUI/ItemView.h1
-rw-r--r--Libraries/LibGUI/ListView.cpp9
-rw-r--r--Libraries/LibGUI/ListView.h1
10 files changed, 54 insertions, 14 deletions
diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp
index ec94585ba9..430793979b 100644
--- a/Libraries/LibGUI/AbstractTableView.cpp
+++ b/Libraries/LibGUI/AbstractTableView.cpp
@@ -48,6 +48,15 @@ AbstractTableView::~AbstractTableView()
{
}
+void AbstractTableView::select_all()
+{
+ selection().clear();
+ for (int item_index = 0; item_index < item_count(); ++item_index) {
+ auto index = model()->index(item_index);
+ selection().add(index);
+ }
+}
+
void AbstractTableView::update_column_sizes()
{
if (!m_size_columns_to_fit_content)
diff --git a/Libraries/LibGUI/AbstractTableView.h b/Libraries/LibGUI/AbstractTableView.h
index 41b0e905a8..1638e6d03a 100644
--- a/Libraries/LibGUI/AbstractTableView.h
+++ b/Libraries/LibGUI/AbstractTableView.h
@@ -70,6 +70,7 @@ public:
virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const;
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
+ virtual void select_all() override;
protected:
virtual ~AbstractTableView() override;
AbstractTableView();
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index 56e86ae1e4..3842ae117f 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -125,18 +125,6 @@ void AbstractView::stop_editing()
}
}
-void AbstractView::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 AbstractView::activate(const ModelIndex& index)
{
if (on_activation)
diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h
index 151725e6a0..5e041a1d64 100644
--- a/Libraries/LibGUI/AbstractView.h
+++ b/Libraries/LibGUI/AbstractView.h
@@ -43,7 +43,7 @@ public:
ModelSelection& selection() { return m_selection; }
const ModelSelection& selection() const { return m_selection; }
- void select_all();
+ virtual void select_all() = 0;
bool is_editable() const { return m_editable; }
void set_editable(bool editable) { m_editable = editable; }
diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp
index e446e68ef2..580ce71fad 100644
--- a/Libraries/LibGUI/ColumnsView.cpp
+++ b/Libraries/LibGUI/ColumnsView.cpp
@@ -29,7 +29,6 @@
#include <LibGUI/Painter.h>
#include <LibGUI/ScrollBar.h>
#include <LibGfx/CharacterBitmap.h>
-#include <LibGfx/Palette.h>
namespace GUI {
@@ -59,6 +58,28 @@ ColumnsView::~ColumnsView()
{
}
+void ColumnsView::select_all()
+{
+ Vector<Column> columns_for_selection;
+ selection().for_each_index([&](auto& index) {
+ for (auto& column : m_columns) {
+ if (column.parent_index == index.parent()) {
+ columns_for_selection.append(column);
+ return;
+ }
+ }
+ ASSERT_NOT_REACHED();
+ });
+
+ for (Column& column : columns_for_selection) {
+ int row_count = model()->row_count(column.parent_index);
+ for (int row = 0; row < row_count; row++) {
+ ModelIndex index = model()->index(row, m_model_column, column.parent_index);
+ selection().add(index);
+ }
+ }
+}
+
void ColumnsView::paint_event(PaintEvent& event)
{
AbstractView::paint_event(event);
diff --git a/Libraries/LibGUI/ColumnsView.h b/Libraries/LibGUI/ColumnsView.h
index e92f31336e..82ff9529c8 100644
--- a/Libraries/LibGUI/ColumnsView.h
+++ b/Libraries/LibGUI/ColumnsView.h
@@ -55,6 +55,7 @@ private:
virtual void mousedown_event(MouseEvent& event) override;
virtual void keydown_event(KeyEvent& event) override;
+ virtual void select_all() override;
struct Column {
ModelIndex parent_index;
int width;
diff --git a/Libraries/LibGUI/ItemView.cpp b/Libraries/LibGUI/ItemView.cpp
index 73672fbb3a..e52f6021bc 100644
--- a/Libraries/LibGUI/ItemView.cpp
+++ b/Libraries/LibGUI/ItemView.cpp
@@ -48,6 +48,15 @@ ItemView::~ItemView()
{
}
+void ItemView::select_all()
+{
+ selection().clear();
+ for (int item_index = 0; item_index < item_count(); ++item_index) {
+ auto index = model()->index(item_index, model_column());
+ selection().add(index);
+ }
+}
+
void ItemView::scroll_into_view(const ModelIndex& index, Orientation orientation)
{
ScrollableWidget::scroll_into_view(item_rect(index.row()), orientation);
diff --git a/Libraries/LibGUI/ItemView.h b/Libraries/LibGUI/ItemView.h
index a960df73fb..2f91e807d5 100644
--- a/Libraries/LibGUI/ItemView.h
+++ b/Libraries/LibGUI/ItemView.h
@@ -47,6 +47,7 @@ public:
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
+ virtual void select_all() override;
private:
ItemView();
diff --git a/Libraries/LibGUI/ListView.cpp b/Libraries/LibGUI/ListView.cpp
index ec1ca55dc4..57c957f3d2 100644
--- a/Libraries/LibGUI/ListView.cpp
+++ b/Libraries/LibGUI/ListView.cpp
@@ -43,6 +43,15 @@ ListView::~ListView()
{
}
+void ListView::select_all()
+{
+ selection().clear();
+ for (int item_index = 0; item_index < item_count(); ++item_index) {
+ auto index = model()->index(item_index, m_model_column);
+ selection().add(index);
+ }
+}
+
void ListView::update_content_size()
{
if (!model())
diff --git a/Libraries/LibGUI/ListView.h b/Libraries/LibGUI/ListView.h
index 0564a873df..ba18402325 100644
--- a/Libraries/LibGUI/ListView.h
+++ b/Libraries/LibGUI/ListView.h
@@ -52,6 +52,7 @@ public:
int model_column() const { return m_model_column; }
void set_model_column(int column) { m_model_column = column; }
+ virtual void select_all() override;
private:
ListView();