#include <kchat.h>


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) | ||||
| ||||
| 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 | |||
| ||||
| 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 | |||
| ||||
| int | fromId () const | |||
| ||||
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. | ||||
Definition at line 34 of file kchat.h.
| KChat::KChat | ( | QWidget * | parent, | |
| bool | twoPlayerGame = false | |||
| ) | [explicit] |
| QString KChat::fromName | ( | ) | const [virtual] |
| 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
| name | The name of the player owning this widget |
Definition at line 67 of file kchat.cpp.
References addPlayer(), and KChatPrivate::mFromId.

| int KChat::addPlayer | ( | const QString & | nick | ) |
Adds a player nickname.
Definition at line 100 of file kchat.cpp.
References KChatPrivate::mPlayerMap, and uniqueId().
Referenced by setFromNickname().

| 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)
| 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.
| id | The id of the player to be removed |
Definition at line 107 of file kchat.cpp.
References KChatPrivate::mPlayerMap.
| bool KChat::autoAddMessages | ( | ) | const |
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
| 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 |
Definition at line 79 of file kchat.cpp.
References KChatPrivate::mPlayerMap.
Referenced by fromName(), and returnPressed().
| int KChat::fromId | ( | ) | const |
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.
| 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().

| 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().
1.5.3