Freeciv21
Develop your civilization from humble roots to a global empire
chat_listener Class Reference

#include <chatline.h>

+ Inheritance diagram for chat_listener:
+ Collaboration diagram for chat_listener:

Public Member Functions

 chat_listener ()
 Constructor. More...
 
virtual void chat_message_received (const QString &, const struct text_tag_list *)
 Called whenever a message is received. More...
 
void send_chat_message (const QString &message)
 Sends commands to server, but first searches for custom keys, if it finds then it makes custom action. More...
 
QString back_in_history ()
 Goes back one position in history, and returns the message at the new position. More...
 
QString forward_in_history ()
 Goes forward one position in history, and returns the message at the new position. More...
 
void reset_history_position ()
 Go to the end of the history. More...
 

Static Public Attributes

static const int HISTORY_END = -1
 

Private Attributes

int position
 

Static Private Attributes

static QStringList history = QStringList()
 

Additional Inherited Members

- Public Types inherited from listener< chat_listener >
typedef chat_listener type_t
 
- Static Public Member Functions inherited from listener< chat_listener >
static void invoke (_member_fct_ function, _args_ &&...args)
 
- Protected Member Functions inherited from listener< chat_listener >
 listener ()
 
virtual ~listener ()
 
void listen ()
 

Detailed Description

Definition at line 37 of file chatline.h.

Constructor & Destructor Documentation

◆ chat_listener()

chat_listener::chat_listener ( )
explicit

Constructor.

Definition at line 69 of file chatline.cpp.

Member Function Documentation

◆ back_in_history()

QString chat_listener::back_in_history ( )

Goes back one position in history, and returns the message at the new position.

Definition at line 133 of file chatline.cpp.

Referenced by chat_input::event().

◆ chat_message_received()

void chat_listener::chat_message_received ( const QString &  ,
const struct text_tag_list *   
)
virtual

Called whenever a message is received.

Default implementation does nothing.

Reimplemented in page_pregame, and chat_widget.

Definition at line 75 of file chatline.cpp.

Referenced by real_output_window_append().

◆ forward_in_history()

QString chat_listener::forward_in_history ( )

Goes forward one position in history, and returns the message at the new position.

An empty string is returned if the new position is HISTORY_END.

Definition at line 147 of file chatline.cpp.

Referenced by chat_input::event().

◆ reset_history_position()

void chat_listener::reset_history_position ( )

Go to the end of the history.

Definition at line 164 of file chatline.cpp.

Referenced by send_chat_message().

◆ send_chat_message()

void chat_listener::send_chat_message ( const QString &  message)

Sends commands to server, but first searches for custom keys, if it finds then it makes custom action.

The history position is reset to HISTORY_END.

Definition at line 86 of file chatline.cpp.

Referenced by chat_input::send(), and page_pregame::send_fake_chat_message().

Member Data Documentation

◆ history

QStringList chat_listener::history = QStringList()
staticprivate

Definition at line 39 of file chatline.h.

Referenced by back_in_history(), forward_in_history(), and send_chat_message().

◆ HISTORY_END

const int chat_listener::HISTORY_END = -1
static

Definition at line 45 of file chatline.h.

Referenced by back_in_history(), forward_in_history(), and reset_history_position().

◆ position

int chat_listener::position
private

Definition at line 41 of file chatline.h.

Referenced by back_in_history(), forward_in_history(), and reset_history_position().