kgamechat.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KGAMECHAT_H__
00022 #define __KGAMECHAT_H__
00023
00024 #include <qstring.h>
00025
00026 #include "kchatbase.h"
00027 #include <kdemacros.h>
00028 class KPlayer;
00029 class KGame;
00030 class KGamePropertyBase;
00031
00032 class KGameChatPrivate;
00033
00043 class KDE_EXPORT KGameChat : public KChatBase
00044 {
00045 Q_OBJECT
00046 public:
00052 KGameChat(KGame* game, int msgid, KPlayer* fromPlayer, QWidget * parent);
00053
00059 KGameChat(KGame* game, int msgId, QWidget* parent);
00060
00067 KGameChat(QWidget* parent);
00068
00069 virtual ~KGameChat();
00070
00071 enum SendingIds {
00072 SendToGroup = 1
00073 };
00074
00081 void setFromPlayer(KPlayer* player);
00082
00083 KPlayer* fromPlayer() const;
00084
00092 void setKGame(KGame* g);
00093
00094 KGame* game() const;
00095
00100 int messageId() const;
00101
00111 void setMessageId(int msgid);
00112
00117 virtual const QString& fromName() const;
00118
00119
00120 public slots:
00121 virtual void addMessage(const QString& fromName, const QString& text) { KChatBase::addMessage(fromName, text);}
00122 virtual void addMessage(int fromId, const QString& text);
00123
00124 void slotReceiveMessage(int, const QByteArray&, Q_UINT32 receiver, Q_UINT32 sender);
00125
00126 protected:
00132 bool isSendToAllMessage(int id) const;
00133
00143 bool isToGroupMessage(int id) const;
00144
00145
00158 bool isToPlayerMessage(int id) const;
00159
00169 int playerId(int id) const;
00170
00176 int sendingId(int playerId) const;
00177
00182 bool hasPlayer(int id) const;
00183
00190 virtual QString sendToPlayerEntry(const QString& name) const;
00191
00192
00193 protected slots:
00199 void slotUnsetKGame();
00200
00201
00202 void slotPropertyChanged(KGamePropertyBase*, KPlayer*);
00203 void slotAddPlayer(KPlayer*);
00204 void slotRemovePlayer(KPlayer*);
00205
00211 void slotReceivePrivateMessage(int msgid, const QByteArray& buffer, Q_UINT32 sender, KPlayer* me);
00212
00213 protected:
00214 virtual void returnPressed(const QString& text);
00215
00216 private:
00217 void init(KGame* g, int msgid);
00218
00219 private:
00220 KGameChatPrivate* d;
00221 };
00222
00223 #endif
|