forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IRClient: Add a member list to channel views.
- Loading branch information
1 parent
08c15be
commit 491aa11
Showing
7 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "IRCChannelMemberListModel.h" | ||
#include "IRCChannel.h" | ||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
IRCChannelMemberListModel::IRCChannelMemberListModel(IRCChannel& channel) | ||
: m_channel(channel) | ||
{ | ||
set_activates_on_selection(true); | ||
} | ||
|
||
IRCChannelMemberListModel::~IRCChannelMemberListModel() | ||
{ | ||
} | ||
|
||
int IRCChannelMemberListModel::row_count() const | ||
{ | ||
return m_channel.member_count(); | ||
} | ||
|
||
int IRCChannelMemberListModel::column_count() const | ||
{ | ||
return 1; | ||
} | ||
|
||
String IRCChannelMemberListModel::column_name(int column) const | ||
{ | ||
switch (column) { | ||
case Column::Name: return "Name"; | ||
} | ||
ASSERT_NOT_REACHED(); | ||
} | ||
|
||
GTableModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const | ||
{ | ||
switch (column) { | ||
case Column::Name: return { 70, TextAlignment::CenterLeft }; | ||
} | ||
ASSERT_NOT_REACHED(); | ||
} | ||
|
||
GVariant IRCChannelMemberListModel::data(const GModelIndex& index, Role) const | ||
{ | ||
switch (index.column()) { | ||
case Column::Name: return m_channel.member_at(index.row()); | ||
} | ||
ASSERT_NOT_REACHED(); | ||
} | ||
|
||
void IRCChannelMemberListModel::update() | ||
{ | ||
did_update(); | ||
} | ||
|
||
void IRCChannelMemberListModel::activate(const GModelIndex& index) | ||
{ | ||
if (on_activation) | ||
on_activation(m_channel.member_at(index.row())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <LibGUI/GTableModel.h> | ||
#include <AK/Function.h> | ||
|
||
class IRCChannel; | ||
|
||
class IRCChannelMemberListModel final : public GTableModel { | ||
public: | ||
enum Column { Name }; | ||
explicit IRCChannelMemberListModel(IRCChannel&); | ||
virtual ~IRCChannelMemberListModel() override; | ||
|
||
virtual int row_count() const override; | ||
virtual int column_count() const override; | ||
virtual String column_name(int column) const override; | ||
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: | ||
IRCChannel& m_channel; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters