summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibGUI/AbstractView.cpp12
-rw-r--r--Libraries/LibGUI/AbstractView.h4
-rw-r--r--Libraries/LibGUI/IconView.cpp8
-rw-r--r--Libraries/LibGUI/MultiView.cpp18
-rw-r--r--Libraries/LibGUI/MultiView.h6
5 files changed, 45 insertions, 3 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index 71d1622c2d..ab6199d55d 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -375,4 +375,16 @@ void AbstractView::drop_event(DropEvent& event)
on_drop(index, event);
}
+void AbstractView::set_multi_select(bool multi_select)
+{
+ if (m_multi_select == multi_select)
+ return;
+ m_multi_select = multi_select;
+ if (!multi_select && m_selection.size() > 1) {
+ auto first_selected = m_selection.first();
+ m_selection.clear();
+ m_selection.set(first_selected);
+ }
+}
+
}
diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h
index 55a7febca7..295efa546e 100644
--- a/Libraries/LibGUI/AbstractView.h
+++ b/Libraries/LibGUI/AbstractView.h
@@ -47,6 +47,9 @@ public:
bool is_editable() const { return m_editable; }
void set_editable(bool editable) { m_editable = editable; }
+ bool is_multi_select() const { return m_multi_select; }
+ void set_multi_select(bool);
+
virtual bool accepts_focus() const override { return true; }
virtual void did_update_model(unsigned flags);
virtual void did_update_selection();
@@ -110,6 +113,7 @@ private:
OwnPtr<ModelEditingDelegate> m_editing_delegate;
ModelSelection m_selection;
bool m_activates_on_selection { false };
+ bool m_multi_select { true };
};
}
diff --git a/Libraries/LibGUI/IconView.cpp b/Libraries/LibGUI/IconView.cpp
index 3c3e32a372..205d9bcc81 100644
--- a/Libraries/LibGUI/IconView.cpp
+++ b/Libraries/LibGUI/IconView.cpp
@@ -221,9 +221,11 @@ void IconView::mousedown_event(MouseEvent& event)
auto adjusted_position = to_content_position(event.position());
m_might_drag = false;
- m_rubber_banding = true;
- m_rubber_band_origin = adjusted_position;
- m_rubber_band_current = adjusted_position;
+ if (is_multi_select()) {
+ m_rubber_banding = true;
+ m_rubber_band_origin = adjusted_position;
+ m_rubber_band_current = adjusted_position;
+ }
}
void IconView::mouseup_event(MouseEvent& event)
diff --git a/Libraries/LibGUI/MultiView.cpp b/Libraries/LibGUI/MultiView.cpp
index 2d0c67cf01..619c8cd1a7 100644
--- a/Libraries/LibGUI/MultiView.cpp
+++ b/Libraries/LibGUI/MultiView.cpp
@@ -108,6 +108,7 @@ MultiView::MultiView()
build_actions();
set_view_mode(ViewMode::Icon);
+ apply_multi_select();
}
MultiView::~MultiView()
@@ -194,4 +195,21 @@ void MultiView::build_actions()
#endif
}
+void MultiView::apply_multi_select()
+{
+ m_table_view->set_multi_select(m_multi_select);
+ m_icon_view->set_multi_select(m_multi_select);
+#ifdef MULTIVIEW_WITH_COLUMNSVIEW
+ //m_columns_view->set_multi_select(m_multi_select);
+#endif
+}
+
+void MultiView::set_multi_select(bool multi_select)
+{
+ if (m_multi_select == multi_select)
+ return;
+ m_multi_select = multi_select;
+ apply_multi_select();
+}
+
}
diff --git a/Libraries/LibGUI/MultiView.h b/Libraries/LibGUI/MultiView.h
index 53d8d0a382..d7dbe6ea49 100644
--- a/Libraries/LibGUI/MultiView.h
+++ b/Libraries/LibGUI/MultiView.h
@@ -103,10 +103,14 @@ public:
Action& view_as_columns_action() { return *m_view_as_columns_action; }
#endif
+ bool is_multi_select() const { return m_multi_select; }
+ void set_multi_select(bool);
+
private:
MultiView();
void build_actions();
+ void apply_multi_select();
ViewMode m_view_mode { Invalid };
int m_model_column { 0 };
@@ -126,6 +130,8 @@ private:
#endif
OwnPtr<ActionGroup> m_view_type_action_group;
+
+ bool m_multi_select { true };
};
}