mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:05:10 +00:00
IRCClient: Rename IRCClientWindowFoo => IRCWindowFoo.
This commit is contained in:
parent
5c2d405e1f
commit
fc7f700c20
9 changed files with 59 additions and 59 deletions
|
@ -1,6 +1,6 @@
|
||||||
#include "IRCAppWindow.h"
|
#include "IRCAppWindow.h"
|
||||||
#include "IRCClientWindow.h"
|
#include "IRCWindow.h"
|
||||||
#include "IRCClientWindowListModel.h"
|
#include "IRCWindowListModel.h"
|
||||||
#include <LibGUI/GApplication.h>
|
#include <LibGUI/GApplication.h>
|
||||||
#include <LibGUI/GStackWidget.h>
|
#include <LibGUI/GStackWidget.h>
|
||||||
#include <LibGUI/GTableView.h>
|
#include <LibGUI/GTableView.h>
|
||||||
|
@ -34,15 +34,15 @@ void IRCAppWindow::setup_client()
|
||||||
};
|
};
|
||||||
|
|
||||||
m_client.on_channel_message = [this] (const String& channel_name) {
|
m_client.on_channel_message = [this] (const String& channel_name) {
|
||||||
ensure_window(IRCClientWindow::Channel, channel_name);
|
ensure_window(IRCWindow::Channel, channel_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_client.on_join = [this] (const String& channel_name) {
|
m_client.on_join = [this] (const String& channel_name) {
|
||||||
ensure_window(IRCClientWindow::Channel, channel_name);
|
ensure_window(IRCWindow::Channel, channel_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_client.on_query_message = [this] (const String& name) {
|
m_client.on_query_message = [this] (const String& name) {
|
||||||
ensure_window(IRCClientWindow::Query, name);
|
ensure_window(IRCWindow::Query, name);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_client.connect();
|
m_client.connect();
|
||||||
|
@ -120,24 +120,24 @@ void IRCAppWindow::setup_widgets()
|
||||||
auto* window_list = new GTableView(horizontal_container);
|
auto* window_list = new GTableView(horizontal_container);
|
||||||
window_list->set_headers_visible(false);
|
window_list->set_headers_visible(false);
|
||||||
window_list->set_alternating_row_colors(false);
|
window_list->set_alternating_row_colors(false);
|
||||||
window_list->set_model(OwnPtr<IRCClientWindowListModel>(m_client.client_window_list_model()));
|
window_list->set_model(OwnPtr<IRCWindowListModel>(m_client.client_window_list_model()));
|
||||||
window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
window_list->set_preferred_size({ 120, 0 });
|
window_list->set_preferred_size({ 120, 0 });
|
||||||
m_client.client_window_list_model()->on_activation = [this] (IRCClientWindow& window) {
|
m_client.client_window_list_model()->on_activation = [this] (IRCWindow& window) {
|
||||||
m_container->set_active_widget(&window);
|
m_container->set_active_widget(&window);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_container = new GStackWidget(horizontal_container);
|
m_container = new GStackWidget(horizontal_container);
|
||||||
|
|
||||||
create_subwindow(IRCClientWindow::Server, "Server");
|
create_subwindow(IRCWindow::Server, "Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
IRCClientWindow& IRCAppWindow::create_subwindow(IRCClientWindow::Type type, const String& name)
|
IRCWindow& IRCAppWindow::create_subwindow(IRCWindow::Type type, const String& name)
|
||||||
{
|
{
|
||||||
return *new IRCClientWindow(m_client, type, name, m_container);
|
return *new IRCWindow(m_client, type, name, m_container);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRCClientWindow& IRCAppWindow::ensure_window(IRCClientWindow::Type type, const String& name)
|
IRCWindow& IRCAppWindow::ensure_window(IRCWindow::Type type, const String& name)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_client.window_count(); ++i) {
|
for (int i = 0; i < m_client.window_count(); ++i) {
|
||||||
auto& window = m_client.window_at(i);
|
auto& window = m_client.window_at(i);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
#include "IRCClient.h"
|
#include "IRCClient.h"
|
||||||
#include "IRCClientWindow.h"
|
#include "IRCWindow.h"
|
||||||
|
|
||||||
class GAction;
|
class GAction;
|
||||||
class GStackWidget;
|
class GStackWidget;
|
||||||
|
@ -19,8 +19,8 @@ private:
|
||||||
void setup_menus();
|
void setup_menus();
|
||||||
void setup_widgets();
|
void setup_widgets();
|
||||||
|
|
||||||
IRCClientWindow& create_subwindow(IRCClientWindow::Type, const String& name);
|
IRCWindow& create_subwindow(IRCWindow::Type, const String& name);
|
||||||
IRCClientWindow& ensure_window(IRCClientWindow::Type, const String& name);
|
IRCWindow& ensure_window(IRCWindow::Type, const String& name);
|
||||||
|
|
||||||
IRCClient m_client;
|
IRCClient m_client;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "IRCChannel.h"
|
#include "IRCChannel.h"
|
||||||
#include "IRCQuery.h"
|
#include "IRCQuery.h"
|
||||||
#include "IRCLogBuffer.h"
|
#include "IRCLogBuffer.h"
|
||||||
#include "IRCClientWindow.h"
|
#include "IRCWindow.h"
|
||||||
#include "IRCClientWindowListModel.h"
|
#include "IRCWindowListModel.h"
|
||||||
#include <LibGUI/GNotifier.h>
|
#include <LibGUI/GNotifier.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -24,7 +24,7 @@ IRCClient::IRCClient(const String& address, int port)
|
||||||
, m_nickname("anon")
|
, m_nickname("anon")
|
||||||
, m_log(IRCLogBuffer::create())
|
, m_log(IRCLogBuffer::create())
|
||||||
{
|
{
|
||||||
m_client_window_list_model = new IRCClientWindowListModel(*this);
|
m_client_window_list_model = new IRCWindowListModel(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRCClient::~IRCClient()
|
IRCClient::~IRCClient()
|
||||||
|
@ -384,26 +384,26 @@ void IRCClient::handle_namreply(const Message& msg)
|
||||||
channel.dump();
|
channel.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCClient::register_subwindow(IRCClientWindow& subwindow)
|
void IRCClient::register_subwindow(IRCWindow& subwindow)
|
||||||
{
|
{
|
||||||
if (subwindow.type() == IRCClientWindow::Server) {
|
if (subwindow.type() == IRCWindow::Server) {
|
||||||
m_server_subwindow = &subwindow;
|
m_server_subwindow = &subwindow;
|
||||||
subwindow.set_log_buffer(*m_log);
|
subwindow.set_log_buffer(*m_log);
|
||||||
} else if (subwindow.type() == IRCClientWindow::Channel) {
|
} else if (subwindow.type() == IRCWindow::Channel) {
|
||||||
auto it = m_channels.find(subwindow.name());
|
auto it = m_channels.find(subwindow.name());
|
||||||
ASSERT(it != m_channels.end());
|
ASSERT(it != m_channels.end());
|
||||||
auto& channel = *(*it).value;
|
auto& channel = *(*it).value;
|
||||||
subwindow.set_log_buffer(channel.log());
|
subwindow.set_log_buffer(channel.log());
|
||||||
} else if (subwindow.type() == IRCClientWindow::Query) {
|
} else if (subwindow.type() == IRCWindow::Query) {
|
||||||
subwindow.set_log_buffer(ensure_query(subwindow.name()).log());
|
subwindow.set_log_buffer(ensure_query(subwindow.name()).log());
|
||||||
}
|
}
|
||||||
m_windows.append(&subwindow);
|
m_windows.append(&subwindow);
|
||||||
m_client_window_list_model->update();
|
m_client_window_list_model->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCClient::unregister_subwindow(IRCClientWindow& subwindow)
|
void IRCClient::unregister_subwindow(IRCWindow& subwindow)
|
||||||
{
|
{
|
||||||
if (subwindow.type() == IRCClientWindow::Server) {
|
if (subwindow.type() == IRCWindow::Server) {
|
||||||
m_server_subwindow = &subwindow;
|
m_server_subwindow = &subwindow;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m_windows.size(); ++i) {
|
for (int i = 0; i < m_windows.size(); ++i) {
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
class IRCChannel;
|
class IRCChannel;
|
||||||
class IRCQuery;
|
class IRCQuery;
|
||||||
class IRCClientWindow;
|
class IRCWindow;
|
||||||
class IRCClientWindowListModel;
|
class IRCWindowListModel;
|
||||||
class GNotifier;
|
class GNotifier;
|
||||||
|
|
||||||
class IRCClient {
|
class IRCClient {
|
||||||
|
@ -37,15 +37,15 @@ public:
|
||||||
Function<void(const String& channel)> on_join;
|
Function<void(const String& channel)> on_join;
|
||||||
Function<void()> on_server_message;
|
Function<void()> on_server_message;
|
||||||
|
|
||||||
void register_subwindow(IRCClientWindow&);
|
void register_subwindow(IRCWindow&);
|
||||||
void unregister_subwindow(IRCClientWindow&);
|
void unregister_subwindow(IRCWindow&);
|
||||||
|
|
||||||
IRCClientWindowListModel* client_window_list_model() { return m_client_window_list_model; }
|
IRCWindowListModel* client_window_list_model() { return m_client_window_list_model; }
|
||||||
const IRCClientWindowListModel* client_window_list_model() const { return m_client_window_list_model; }
|
const IRCWindowListModel* client_window_list_model() const { return m_client_window_list_model; }
|
||||||
|
|
||||||
int window_count() const { return m_windows.size(); }
|
int window_count() const { return m_windows.size(); }
|
||||||
const IRCClientWindow& window_at(int index) const { return *m_windows.at(index); }
|
const IRCWindow& window_at(int index) const { return *m_windows.at(index); }
|
||||||
IRCClientWindow& window_at(int index) { return *m_windows.at(index); }
|
IRCWindow& window_at(int index) { return *m_windows.at(index); }
|
||||||
|
|
||||||
void handle_user_input_in_channel(const String& channel_name, const String&);
|
void handle_user_input_in_channel(const String& channel_name, const String&);
|
||||||
void handle_user_input_in_query(const String& query_name, const String&);
|
void handle_user_input_in_query(const String& query_name, const String&);
|
||||||
|
@ -84,11 +84,11 @@ private:
|
||||||
HashMap<String, RetainPtr<IRCChannel>> m_channels;
|
HashMap<String, RetainPtr<IRCChannel>> m_channels;
|
||||||
HashMap<String, RetainPtr<IRCQuery>> m_queries;
|
HashMap<String, RetainPtr<IRCQuery>> m_queries;
|
||||||
|
|
||||||
Vector<IRCClientWindow*> m_windows;
|
Vector<IRCWindow*> m_windows;
|
||||||
|
|
||||||
IRCClientWindow* m_server_subwindow { nullptr };
|
IRCWindow* m_server_subwindow { nullptr };
|
||||||
|
|
||||||
IRCClientWindowListModel* m_client_window_list_model { nullptr };
|
IRCWindowListModel* m_client_window_list_model { nullptr };
|
||||||
|
|
||||||
Retained<IRCLogBuffer> m_log;
|
Retained<IRCLogBuffer> m_log;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "IRCClientWindow.h"
|
#include "IRCWindow.h"
|
||||||
#include "IRCClient.h"
|
#include "IRCClient.h"
|
||||||
#include "IRCChannel.h"
|
#include "IRCChannel.h"
|
||||||
#include "IRCChannelMemberListModel.h"
|
#include "IRCChannelMemberListModel.h"
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
#include <LibGUI/GTextEditor.h>
|
#include <LibGUI/GTextEditor.h>
|
||||||
#include <LibGUI/GTextBox.h>
|
#include <LibGUI/GTextBox.h>
|
||||||
|
|
||||||
IRCClientWindow::IRCClientWindow(IRCClient& client, Type type, const String& name, GWidget* parent)
|
IRCWindow::IRCWindow(IRCClient& client, Type type, const String& name, GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
, m_client(client)
|
, m_client(client)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
|
@ -50,12 +50,12 @@ IRCClientWindow::IRCClientWindow(IRCClient& client, Type type, const String& nam
|
||||||
m_client.register_subwindow(*this);
|
m_client.register_subwindow(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRCClientWindow::~IRCClientWindow()
|
IRCWindow::~IRCWindow()
|
||||||
{
|
{
|
||||||
m_client.unregister_subwindow(*this);
|
m_client.unregister_subwindow(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCClientWindow::set_log_buffer(const IRCLogBuffer& log_buffer)
|
void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer)
|
||||||
{
|
{
|
||||||
m_log_buffer = &log_buffer;
|
m_log_buffer = &log_buffer;
|
||||||
m_table_view->set_model(OwnPtr<IRCLogBufferModel>((IRCLogBufferModel*)log_buffer.model()));
|
m_table_view->set_model(OwnPtr<IRCLogBufferModel>((IRCLogBufferModel*)log_buffer.model()));
|
|
@ -7,7 +7,7 @@ class IRCLogBuffer;
|
||||||
class GTableView;
|
class GTableView;
|
||||||
class GTextEditor;
|
class GTextEditor;
|
||||||
|
|
||||||
class IRCClientWindow : public GWidget {
|
class IRCWindow : public GWidget {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
Server,
|
Server,
|
||||||
|
@ -15,8 +15,8 @@ public:
|
||||||
Query,
|
Query,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit IRCClientWindow(IRCClient&, Type, const String& name, GWidget* parent);
|
explicit IRCWindow(IRCClient&, Type, const String& name, GWidget* parent);
|
||||||
virtual ~IRCClientWindow() override;
|
virtual ~IRCWindow() override;
|
||||||
|
|
||||||
String name() const { return m_name; }
|
String name() const { return m_name; }
|
||||||
void set_name(const String& name) { m_name = name; }
|
void set_name(const String& name) { m_name = name; }
|
|
@ -1,30 +1,30 @@
|
||||||
#include "IRCClientWindowListModel.h"
|
#include "IRCWindowListModel.h"
|
||||||
#include "IRCClientWindow.h"
|
#include "IRCWindow.h"
|
||||||
#include "IRCClient.h"
|
#include "IRCClient.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
IRCClientWindowListModel::IRCClientWindowListModel(IRCClient& client)
|
IRCWindowListModel::IRCWindowListModel(IRCClient& client)
|
||||||
: m_client(client)
|
: m_client(client)
|
||||||
{
|
{
|
||||||
set_activates_on_selection(true);
|
set_activates_on_selection(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
IRCClientWindowListModel::~IRCClientWindowListModel()
|
IRCWindowListModel::~IRCWindowListModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRCClientWindowListModel::row_count() const
|
int IRCWindowListModel::row_count() const
|
||||||
{
|
{
|
||||||
return m_client.window_count();
|
return m_client.window_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRCClientWindowListModel::column_count() const
|
int IRCWindowListModel::column_count() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
String IRCClientWindowListModel::column_name(int column) const
|
String IRCWindowListModel::column_name(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Name: return "Name";
|
case Column::Name: return "Name";
|
||||||
|
@ -32,7 +32,7 @@ String IRCClientWindowListModel::column_name(int column) const
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
GTableModel::ColumnMetadata IRCClientWindowListModel::column_metadata(int column) const
|
GTableModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Name: return { 70, TextAlignment::CenterLeft };
|
case Column::Name: return { 70, TextAlignment::CenterLeft };
|
||||||
|
@ -40,7 +40,7 @@ GTableModel::ColumnMetadata IRCClientWindowListModel::column_metadata(int column
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant IRCClientWindowListModel::data(const GModelIndex& index, Role) const
|
GVariant IRCWindowListModel::data(const GModelIndex& index, Role) const
|
||||||
{
|
{
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case Column::Name: return m_client.window_at(index.row()).name();
|
case Column::Name: return m_client.window_at(index.row()).name();
|
||||||
|
@ -48,12 +48,12 @@ GVariant IRCClientWindowListModel::data(const GModelIndex& index, Role) const
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCClientWindowListModel::update()
|
void IRCWindowListModel::update()
|
||||||
{
|
{
|
||||||
did_update();
|
did_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCClientWindowListModel::activate(const GModelIndex& index)
|
void IRCWindowListModel::activate(const GModelIndex& index)
|
||||||
{
|
{
|
||||||
if (on_activation)
|
if (on_activation)
|
||||||
on_activation(m_client.window_at(index.row()));
|
on_activation(m_client.window_at(index.row()));
|
|
@ -4,16 +4,16 @@
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
|
|
||||||
class IRCClient;
|
class IRCClient;
|
||||||
class IRCClientWindow;
|
class IRCWindow;
|
||||||
|
|
||||||
class IRCClientWindowListModel final : public GTableModel {
|
class IRCWindowListModel final : public GTableModel {
|
||||||
public:
|
public:
|
||||||
enum Column {
|
enum Column {
|
||||||
Name,
|
Name,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit IRCClientWindowListModel(IRCClient&);
|
explicit IRCWindowListModel(IRCClient&);
|
||||||
virtual ~IRCClientWindowListModel() override;
|
virtual ~IRCWindowListModel() override;
|
||||||
|
|
||||||
virtual int row_count() const override;
|
virtual int row_count() const override;
|
||||||
virtual int column_count() const override;
|
virtual int column_count() const override;
|
||||||
|
@ -23,7 +23,7 @@ public:
|
||||||
virtual void update() override;
|
virtual void update() override;
|
||||||
virtual void activate(const GModelIndex&) override;
|
virtual void activate(const GModelIndex&) override;
|
||||||
|
|
||||||
Function<void(IRCClientWindow&)> on_activation;
|
Function<void(IRCWindow&)> on_activation;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IRCClient& m_client;
|
IRCClient& m_client;
|
|
@ -5,8 +5,8 @@ OBJS = \
|
||||||
IRCLogBuffer.o \
|
IRCLogBuffer.o \
|
||||||
IRCLogBufferModel.o \
|
IRCLogBufferModel.o \
|
||||||
IRCAppWindow.o \
|
IRCAppWindow.o \
|
||||||
IRCClientWindow.o \
|
IRCWindow.o \
|
||||||
IRCClientWindowListModel.o \
|
IRCWindowListModel.o \
|
||||||
IRCChannelMemberListModel.o \
|
IRCChannelMemberListModel.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue