2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-03-15 14:25:51 -03:00
|
|
|
#include "IRCChannelMemberListModel.h"
|
|
|
|
|
#include "IRCChannel.h"
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
IRCChannelMemberListModel::IRCChannelMemberListModel(IRCChannel& channel)
|
|
|
|
|
: m_channel(channel)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRCChannelMemberListModel::~IRCChannelMemberListModel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
int IRCChannelMemberListModel::row_count(const GUI::ModelIndex&) const
|
2019-03-15 14:25:51 -03:00
|
|
|
{
|
|
|
|
|
return m_channel.member_count();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
int IRCChannelMemberListModel::column_count(const GUI::ModelIndex&) const
|
2019-03-15 14:25:51 -03:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String IRCChannelMemberListModel::column_name(int column) const
|
|
|
|
|
{
|
|
|
|
|
switch (column) {
|
2019-06-07 06:48:03 -03:00
|
|
|
case Column::Name:
|
|
|
|
|
return "Name";
|
2019-03-15 14:25:51 -03:00
|
|
|
}
|
2021-02-23 16:42:32 -03:00
|
|
|
VERIFY_NOT_REACHED();
|
2019-03-15 14:25:51 -03:00
|
|
|
}
|
|
|
|
|
|
2020-08-16 11:00:07 -03:00
|
|
|
GUI::Variant IRCChannelMemberListModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
2019-03-15 14:25:51 -03:00
|
|
|
{
|
2020-08-16 11:00:07 -03:00
|
|
|
if (role == GUI::ModelRole::TextAlignment)
|
2020-05-21 14:36:09 -03:00
|
|
|
return Gfx::TextAlignment::CenterLeft;
|
2020-08-16 11:00:07 -03:00
|
|
|
if (role == GUI::ModelRole::Display) {
|
2019-03-18 00:54:07 -03:00
|
|
|
switch (index.column()) {
|
2019-06-07 06:48:03 -03:00
|
|
|
case Column::Name:
|
|
|
|
|
return m_channel.member_at(index.row());
|
2019-03-18 00:54:07 -03:00
|
|
|
}
|
2019-03-15 14:25:51 -03:00
|
|
|
}
|
2019-06-07 06:48:03 -03:00
|
|
|
return {};
|
2019-03-15 14:25:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRCChannelMemberListModel::update()
|
|
|
|
|
{
|
|
|
|
|
did_update();
|
|
|
|
|
}
|
2020-04-08 13:45:00 -03:00
|
|
|
|
|
|
|
|
String IRCChannelMemberListModel::nick_at(const GUI::ModelIndex& index) const
|
|
|
|
|
{
|
2020-08-16 11:00:07 -03:00
|
|
|
return data(index, GUI::ModelRole::Display).to_string();
|
2020-04-08 13:45:00 -03:00
|
|
|
}
|