KChat Class Reference

#include <kchat.h>

Inheritance diagram for KChat:

Inheritance graph
[legend]
Collaboration diagram for KChat:

Collaboration graph
[legend]

List of all members.

Signals

void signalSendMessage (int id, const QString &msg)
 This signal is emitted when the player wants to send a message.

Public Member Functions

 KChat (QWidget *parent, bool twoPlayerGame=false)
 
Parameters:
parent The parent widget for this widget.

virtual ~KChat ()
virtual QString fromName () const
 Equivalent to player(fromId()).
void setFromNickname (const QString &name)
 This sets the name that will be shown on all chat widgets if this widget sends a message.
int addPlayer (const QString &nick)
 Adds a player nickname.
void removePlayer (const QString &nick)
 Removes all players with this nickname.
void removePlayer (int id)
 Removes the player with this id, as returned by addPlayer.
bool autoAddMessages () const
 
Returns:
true if the messages which will be sent from here will be added automatically using KChatBase::addMessage.

void setAutoAddMessages (bool add)
 Usually the messages which will be sent from here (see signalSendMessage) are added autmatically to this widget.
QString player (int id) const
 
Returns:
The nickname of the player which belongs to this id

int fromId () const
 
Returns:
The ID that belongs to the local player.


Protected Member Functions

virtual void returnPressed (const QString &)
 This emits signalSendMessage and, if autoAddMessages is true, calls KChatBase::addMessage.
int uniqueId ()
 The Id of the next player.


Detailed Description

A chat widget for non-KGame games Docu is TODO
Author:
Andreas Beckermann <b_mann@gmx.de>

Definition at line 34 of file kchat.h.


Constructor & Destructor Documentation

KChat::KChat ( QWidget *  parent,
bool  twoPlayerGame = false 
) [explicit]

Parameters:
parent The parent widget for this widget.

Parameters:
twoPlayerGame If true the combo box where the player can choose to send to a single player or to all players will not be added as you will hardly need it in 2-player games.

Definition at line 44 of file kchat.cpp.

KChat::~KChat (  )  [virtual]

Definition at line 53 of file kchat.cpp.


Member Function Documentation

QString KChat::fromName (  )  const [virtual]

Equivalent to player(fromId()).

Returns:
The name that will be shown for messages from this widget. That is the string from setFromNickname

Implements KChatBase.

Definition at line 69 of file kchat.cpp.

References fromId(), and player().

Here is the call graph for this function:

void KChat::setFromNickname ( const QString &  name  ) 

This sets the name that will be shown on all chat widgets if this widget sends a message.

See signalSendMessage

Parameters:
name The name of the player owning this widget

Definition at line 67 of file kchat.cpp.

References addPlayer(), and KChatPrivate::mFromId.

Here is the call graph for this function:

int KChat::addPlayer ( const QString &  nick  ) 

Adds a player nickname.

Returns:
The unique ID of the player

Definition at line 100 of file kchat.cpp.

References KChatPrivate::mPlayerMap, and uniqueId().

Referenced by setFromNickname().

Here is the call graph for this function:

void KChat::removePlayer ( const QString &  nick  ) 

Removes all players with this nickname.

Better don't use this as it will remove *all* players with this nickname. Save the id instead and call removePlayer(id)

Parameters:
nick The nickname of the removed players

Definition at line 112 of file kchat.cpp.

References KChatPrivate::mPlayerMap.

void KChat::removePlayer ( int  id  ) 

Removes the player with this id, as returned by addPlayer.

Parameters:
id The id of the player to be removed

Definition at line 107 of file kchat.cpp.

References KChatPrivate::mPlayerMap.

bool KChat::autoAddMessages (  )  const

Returns:
true if the messages which will be sent from here will be added automatically using KChatBase::addMessage.

See also setAutoAddMessages

Definition at line 73 of file kchat.cpp.

References KChatPrivate::mAutoAddMessages.

Referenced by returnPressed().

void KChat::setAutoAddMessages ( bool  add  ) 

Usually the messages which will be sent from here (see signalSendMessage) are added autmatically to this widget.

But under some circumstances that would be very unhandy. So you can deactivate this behaviour here and call KChatBase::addMessage yourself

Parameters:
add If true (default) messages sent from here will be added automatically. Otherwise you will have to add them yourself

Definition at line 71 of file kchat.cpp.

References KChatPrivate::mAutoAddMessages.

QString KChat::player ( int  id  )  const

Returns:
The nickname of the player which belongs to this id

Definition at line 79 of file kchat.cpp.

References KChatPrivate::mPlayerMap.

Referenced by fromName(), and returnPressed().

int KChat::fromId (  )  const

Returns:
The ID that belongs to the local player.

See also:
setFromNickname

Definition at line 77 of file kchat.cpp.

References KChatPrivate::mFromId.

Referenced by fromName(), and returnPressed().

void KChat::signalSendMessage ( int  id,
const QString &  msg 
) [signal]

This signal is emitted when the player wants to send a message.

The message is added automatically using KChatBase::addMessage if autoAddMessages is enabled.

Parameters:
id The id of the player who sends the message - see setFromNickname and player
msg The message itself

Referenced by returnPressed().

void KChat::returnPressed ( const QString &  text  )  [protected, virtual]

This emits signalSendMessage and, if autoAddMessages is true, calls KChatBase::addMessage.

Implements KChatBase.

Definition at line 82 of file kchat.cpp.

References KChatBase::addMessage(), autoAddMessages(), fromId(), player(), and signalSendMessage().

Here is the call graph for this function:

int KChat::uniqueId (  )  [protected]

The Id of the next player.

Incremented after every call.

Definition at line 75 of file kchat.cpp.

References KChatPrivate::mPlayerId.

Referenced by addPlayer().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 08:03:08 2008 for Libkdegames by  doxygen 1.5.3