1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:27:35 +00:00

LibGUI: Remove GModel activations to GAbstractView.

Now you can hook activation via GAbstractView::on_activation.
The design still isn't quite right, we should eventually move the selection
away from the model somehow.
This commit is contained in:
Andreas Kling 2019-05-09 04:56:52 +02:00
parent bffaa5ece6
commit fa232ac180
25 changed files with 107 additions and 104 deletions

View file

@ -151,9 +151,11 @@ void IRCAppWindow::setup_widgets()
m_window_list->set_headers_visible(false);
m_window_list->set_alternating_row_colors(false);
m_window_list->set_model(m_client.client_window_list_model());
m_window_list->set_activates_on_selection(true);
m_window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
m_window_list->set_preferred_size({ 100, 0 });
m_client.client_window_list_model()->on_activation = [this] (IRCWindow& window) {
m_window_list->on_activation = [this] (auto& index) {
auto& window = m_client.window_at(index.row());
m_container->set_active_widget(&window);
window.clear_unread_count();
};

View file

@ -6,7 +6,6 @@
IRCChannelMemberListModel::IRCChannelMemberListModel(IRCChannel& channel)
: m_channel(channel)
{
set_activates_on_selection(true);
}
IRCChannelMemberListModel::~IRCChannelMemberListModel()
@ -53,9 +52,3 @@ void IRCChannelMemberListModel::update()
{
did_update();
}
void IRCChannelMemberListModel::activate(const GModelIndex& index)
{
if (on_activation)
on_activation(m_channel.member_at(index.row()));
}

View file

@ -17,9 +17,6 @@ public:
virtual ColumnMetadata column_metadata(int column) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual void update() override;
virtual void activate(const GModelIndex&) override;
Function<void(const String&)> on_activation;
private:
explicit IRCChannelMemberListModel(IRCChannel&);

View file

@ -72,7 +72,3 @@ void IRCLogBufferModel::update()
{
did_update();
}
void IRCLogBufferModel::activate(const GModelIndex&)
{
}

View file

@ -22,7 +22,6 @@ public:
virtual ColumnMetadata column_metadata(int column) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual void update() override;
virtual void activate(const GModelIndex&) override;
private:
explicit IRCLogBufferModel(Retained<IRCLogBuffer>&&);

View file

@ -37,6 +37,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
member_view->set_preferred_size({ 100, 0 });
member_view->set_alternating_row_colors(false);
member_view->set_model(channel().member_model());
member_view->set_activates_on_selection(true);
}
m_text_editor = new GTextEditor(GTextEditor::SingleLine, this);

View file

@ -8,7 +8,6 @@
IRCWindowListModel::IRCWindowListModel(IRCClient& client)
: m_client(client)
{
set_activates_on_selection(true);
}
IRCWindowListModel::~IRCWindowListModel()
@ -72,9 +71,3 @@ void IRCWindowListModel::update()
{
did_update();
}
void IRCWindowListModel::activate(const GModelIndex& index)
{
if (on_activation)
on_activation(m_client.window_at(index.row()));
}

View file

@ -21,7 +21,6 @@ public:
virtual ColumnMetadata column_metadata(int column) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual void update() override;
virtual void activate(const GModelIndex&) override;
Function<void(IRCWindow&)> on_activation;