mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
IRClient: Add a member list to channel views.
This commit is contained in:
parent
08c15be0ca
commit
491aa112ab
7 changed files with 115 additions and 3 deletions
59
Applications/IRCClient/IRCChannelMemberListModel.cpp
Normal file
59
Applications/IRCClient/IRCChannelMemberListModel.cpp
Normal file
|
@ -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()));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue