mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
LibGUI: Add ability to disable multiselect for views
This commit is contained in:
parent
f266f0e880
commit
d4c6ae8263
5 changed files with 45 additions and 3 deletions
|
@ -375,4 +375,16 @@ void AbstractView::drop_event(DropEvent& event)
|
||||||
on_drop(index, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ public:
|
||||||
bool is_editable() const { return m_editable; }
|
bool is_editable() const { return m_editable; }
|
||||||
void set_editable(bool editable) { m_editable = 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 bool accepts_focus() const override { return true; }
|
||||||
virtual void did_update_model(unsigned flags);
|
virtual void did_update_model(unsigned flags);
|
||||||
virtual void did_update_selection();
|
virtual void did_update_selection();
|
||||||
|
@ -110,6 +113,7 @@ private:
|
||||||
OwnPtr<ModelEditingDelegate> m_editing_delegate;
|
OwnPtr<ModelEditingDelegate> m_editing_delegate;
|
||||||
ModelSelection m_selection;
|
ModelSelection m_selection;
|
||||||
bool m_activates_on_selection { false };
|
bool m_activates_on_selection { false };
|
||||||
|
bool m_multi_select { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,9 +221,11 @@ void IconView::mousedown_event(MouseEvent& event)
|
||||||
auto adjusted_position = to_content_position(event.position());
|
auto adjusted_position = to_content_position(event.position());
|
||||||
|
|
||||||
m_might_drag = false;
|
m_might_drag = false;
|
||||||
m_rubber_banding = true;
|
if (is_multi_select()) {
|
||||||
m_rubber_band_origin = adjusted_position;
|
m_rubber_banding = true;
|
||||||
m_rubber_band_current = adjusted_position;
|
m_rubber_band_origin = adjusted_position;
|
||||||
|
m_rubber_band_current = adjusted_position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconView::mouseup_event(MouseEvent& event)
|
void IconView::mouseup_event(MouseEvent& event)
|
||||||
|
|
|
@ -108,6 +108,7 @@ MultiView::MultiView()
|
||||||
|
|
||||||
build_actions();
|
build_actions();
|
||||||
set_view_mode(ViewMode::Icon);
|
set_view_mode(ViewMode::Icon);
|
||||||
|
apply_multi_select();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiView::~MultiView()
|
MultiView::~MultiView()
|
||||||
|
@ -194,4 +195,21 @@ void MultiView::build_actions()
|
||||||
#endif
|
#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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,14 @@ public:
|
||||||
Action& view_as_columns_action() { return *m_view_as_columns_action; }
|
Action& view_as_columns_action() { return *m_view_as_columns_action; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool is_multi_select() const { return m_multi_select; }
|
||||||
|
void set_multi_select(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MultiView();
|
MultiView();
|
||||||
|
|
||||||
void build_actions();
|
void build_actions();
|
||||||
|
void apply_multi_select();
|
||||||
|
|
||||||
ViewMode m_view_mode { Invalid };
|
ViewMode m_view_mode { Invalid };
|
||||||
int m_model_column { 0 };
|
int m_model_column { 0 };
|
||||||
|
@ -126,6 +130,8 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OwnPtr<ActionGroup> m_view_type_action_group;
|
OwnPtr<ActionGroup> m_view_type_action_group;
|
||||||
|
|
||||||
|
bool m_multi_select { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue