KGameChat
#include <KGame/KGameChat>
Public Types | |
enum | SendingIds { SendToGroup = 1 } |
Public Types inherited from KChatBase | |
enum | SendingIds { SendToAll = 0 } |
Public Types inherited from QFrame | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Slots | |
void | addMessage (const QString &fromName, const QString &text) override |
virtual void | addMessage (int fromId, const QString &text) |
void | slotReceiveMessage (int, const QByteArray &, quint32 receiver, quint32 sender) |
Public Slots inherited from KChatBase | |
virtual void | addMessage (const QString &fromName, const QString &text) |
virtual void | addSystemMessage (const QString &fromName, const QString &text) |
void | setAcceptMessage (bool a) |
void | slotClear () |
Protected Slots | |
void | slotAddPlayer (KPlayer *) |
void | slotPropertyChanged (KGamePropertyBase *, KPlayer *) |
void | slotReceivePrivateMessage (int msgid, const QByteArray &buffer, quint32 sender, KPlayer *me) |
void | slotRemovePlayer (KPlayer *) |
void | slotUnsetKGame () |
Detailed Description
A Chat widget for KGame-based games.
Call setFromPlayer() first - this will be used as the "from" part of every message you will send. Otherwise it won't work! You can also use the fromPlayer parameter in the constructor though...
Definition at line 35 of file kgamechat.h.
Member Enumeration Documentation
◆ SendingIds
enum KGameChat::SendingIds |
Definition at line 63 of file kgamechat.h.
Constructor & Destructor Documentation
◆ KGameChat() [1/3]
KGameChat::KGameChat | ( | KGame * | game, |
int | msgid, | ||
KPlayer * | fromPlayer, | ||
QWidget * | parent, | ||
KChatBaseModel * | model = nullptr, | ||
KChatBaseItemDelegate * | delegate = nullptr ) |
Construct a KGame chat widget on game
that used msgid
for the chat message.
The fromPlayer
is the local player (see setFromPlayer).
Definition at line 49 of file kgamechat.cpp.
◆ KGameChat() [2/3]
KGameChat::KGameChat | ( | KGame * | game, |
int | msgId, | ||
QWidget * | parent, | ||
KChatBaseModel * | model = nullptr, | ||
KChatBaseItemDelegate * | delegate = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. To make use of this widget you need to call setFromPlayer manually.
Definition at line 43 of file kgamechat.cpp.
◆ KGameChat() [3/3]
|
explicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This constructs a widget that is not usable.
You must call at least setGame, setFromPlayer and setMessageId manually.
Definition at line 56 of file kgamechat.cpp.
◆ ~KGameChat()
|
override |
Definition at line 62 of file kgamechat.cpp.
Member Function Documentation
◆ addMessage [1/2]
Definition at line 109 of file kgamechat.h.
◆ addMessage [2/2]
Definition at line 75 of file kgamechat.cpp.
◆ fromName()
|
overridevirtual |
reimplemented from KChatBase
- Returns
- KPlayer::name() for the player set by setFromPlayer
Implements KChatBase.
Definition at line 201 of file kgamechat.cpp.
◆ fromPlayer()
KPlayer * KGameChat::fromPlayer | ( | ) | const |
Definition at line 267 of file kgamechat.cpp.
◆ game()
KGame * KGameChat::game | ( | ) | const |
Definition at line 260 of file kgamechat.cpp.
◆ hasPlayer()
|
protected |
- Returns
- True if the player with this ID was added before (see slotAddPlayer)
Definition at line 208 of file kgamechat.cpp.
◆ isSendToAllMessage()
|
protected |
- Parameters
-
id The ID of the sending entry, as returned by KChatBase sendingEntry
- Returns
- True if the entry "send to all" was selected, otherwise false
Definition at line 153 of file kgamechat.cpp.
◆ isToGroupMessage()
|
protected |
Used to indicate whether a message shall be sent to a group of players.
Note that this was not yet implemented when this doc was written so this description might be wrong. (FIXME)
- Parameters
-
id The ID of the sending entry, as returned by KChatBase sendingEntry
- Returns
- True if the message is meant to be sent to a group (see KPlayer::group ), e.g. if "send to my group" was selected.
Definition at line 158 of file kgamechat.cpp.
◆ isToPlayerMessage()
|
protected |
Used to indicate whether the message shall be sent to a single player only.
Note that you can also call isSendToAllMessage and isToGroupMessage - if both return false it must be a player message. This behaviour might be changed later - so don't depend on it.
See also toPlayerId
- Parameters
-
id The ID of the sending entry, as returned by KChatBase sendingEntry
- Returns
- True if the message shall be sent to a special player, otherwise false.
Definition at line 165 of file kgamechat.cpp.
◆ messageId()
int KGameChat::messageId | ( | ) | const |
- Returns
- The id of the messages produced by KGameChat. The id will be used in KGame as parameter msgid in the method KGame::sendMessage
Definition at line 146 of file kgamechat.cpp.
◆ playerId()
|
protected |
- Parameters
-
id The ID of the sending entry, as returned by KChatBase sendingEntry
- Returns
- The ID of the player (see KPlayer::id) the sending entry belongs to. Note that the parameter id is an id as returned by KChatBase sendingEntry and the id this method returns is a KPlayer ID. If isToPlayerMessage returns false this method returns -1
Definition at line 177 of file kgamechat.cpp.
◆ returnPressed()
This is called whenever the user pushed return ie wants to send a message.
Note that you MUST add the message to the widget when this function is called as it has already been added to the KCompletion object of the KLineEdit widget!
Must be implemented in derived classes
- Parameters
-
text The message to be sent
Implements KChatBase.
Definition at line 94 of file kgamechat.cpp.
◆ sendingId()
|
protected |
- Parameters
-
playerId The ID of the KPlayer object
- Returns
- The ID of the sending entry (see KChatBase) or -1 if the player id was not found.
Definition at line 188 of file kgamechat.cpp.
◆ sendToPlayerEntry()
- Parameters
-
name The name of the added player
- Returns
- A string that will be added as sending entry in KChatBase. By default this is "send to name" where name is the name that you specify. See also KChatBase::addSendingEntry
Definition at line 172 of file kgamechat.cpp.
◆ setFromPlayer()
This sets the fromPlayer to player
.
The fromPlayer is the player that will appear as "from" when you send messages through this widget.
- Parameters
-
player The player of this widget
Definition at line 213 of file kgamechat.cpp.
◆ setKGame()
Set the KGame object for this chat widget.
All messages will be sent through this object. You don't have to implement any send functions, just call this function, call setFromPlayer and be done :-)
- Parameters
-
g The KGame object the messages will be sent through
Definition at line 237 of file kgamechat.cpp.
◆ setMessageId()
void KGameChat::setMessageId | ( | int | msgid | ) |
Change the message id of the chat widget.
It is recommended that you don't use this but prefer the constructor instead, but in certain situations (such as using this widget in Qt designer) it may be useful to change the message id.
See also messageId
Definition at line 139 of file kgamechat.cpp.
◆ slotAddPlayer
Definition at line 290 of file kgamechat.cpp.
◆ slotPropertyChanged
|
protectedslot |
Definition at line 329 of file kgamechat.cpp.
◆ slotReceiveMessage
|
slot |
Definition at line 351 of file kgamechat.cpp.
◆ slotReceivePrivateMessage
|
protectedslot |
Called when KPlayer::signalNetworkData is emitted.
The message gets forwarded to slotReceiveMessage if me
equals fromPlayer.
Definition at line 342 of file kgamechat.cpp.
◆ slotRemovePlayer
Definition at line 310 of file kgamechat.cpp.
◆ slotUnsetKGame
|
protectedslot |
Unsets a KGame object that has been set using setKGame before.
You don't have to call this - this is usually done automatically.
Definition at line 274 of file kgamechat.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:50 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.