20 #include <tdelocale.h> 32 bool mAutoAddMessages;
34 TQMap<int, TQString> mPlayerMap;
46 kdDebug(11000) <<
"DESTRUCT KChat " <<
this << endl;
52 kdDebug(11001) <<
"INIT KChat " <<
this << endl;
54 d->mAutoAddMessages =
true;
64 { d->mAutoAddMessages = add; }
66 {
return d->mAutoAddMessages; }
68 {
return d->mPlayerId++; }
70 {
return d->mFromId; }
72 {
return d->mPlayerMap[id]; }
79 kdWarning(11000) <<
"KChat: no fromNickname has been set!" << endl;
87 kdDebug(11000) <<
"auto adding message from player " << p <<
" ;id=" <<
id << endl;
95 d->mPlayerMap.insert(
id, nickname);
101 d->mPlayerMap.remove(
id);
106 TQMap<int, TQString>::Iterator it;
107 for (it = d->mPlayerMap.begin(); it != d->mPlayerMap.end(); ++it) {
108 if (it.data() == nickname) {
109 d->mPlayerMap.remove(it);
int uniqueId()
The Id of the next player.
const TQString & player(int id) const
void signalSendMessage(int id, const TQString &msg)
This signal is emitted when the player wants to send a message.
The base class for chat widgets.
virtual const TQString & fromName() const
Equivalent to player(fromId())
virtual void addMessage(const TQString &fromName, const TQString &text)
Add a text in the listbox.
KChat(TQWidget *parent, bool twoPlayerGame=false)
void setFromNickname(const TQString &name)
This sets the name that will be shown on all chat widgets if this widget sends a message.
void setAutoAddMessages(bool add)
Usually the messages which will be sent from here (see signalSendMessage) are added autmatically to t...
int addPlayer(const TQString &nick)
Adds a player nickname.
virtual void returnPressed(const TQString &)
This emits signalSendMessage and, if autoAddMessages is true, calls KChatBase::addMessage.
bool autoAddMessages() const
void removePlayer(const TQString &nick)
Removes all players with this nickname.