File indexing completed on 2024-12-08 06:45:55

0001 /*
0002     This file is part of the KDE games library
0003     SPDX-FileCopyrightText: 2001 Andreas Beckermann (b_mann@gmx.de)
0004     SPDX-FileCopyrightText: 2001 Martin Heni (kde at heni-online.de)
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #ifndef __KGAMEDEBUGDIALOG_H__
0010 #define __KGAMEDEBUGDIALOG_H__
0011 
0012 // KF
0013 #include <KPageDialog>
0014 
0015 class QListWidgetItem;
0016 
0017 class KGame;
0018 class KPlayer;
0019 
0020 class KGameDebugDialogPrivate;
0021 
0022 /**
0023  * \class KGameDebugDialog kgamedebugdialog.h <KGameDebugDialog>
0024  */
0025 class KGameDebugDialog : public KPageDialog
0026 {
0027     Q_OBJECT
0028 public:
0029     KGameDebugDialog(KGame *g, QWidget *parent, bool modal = false);
0030     ~KGameDebugDialog() override;
0031 
0032     /**
0033      * Automatically connects the KGame object to all error dependent slots.
0034      * @param g The KGame which will emit the errors (or not ;-) )
0035      */
0036     void setKGame(const KGame *g);
0037 
0038 public Q_SLOTS:
0039     /**
0040      * Unsets a @ref KGame which has been set using @ref setKGame before.
0041      * This is called automatically when the @ref KGame object is destroyed
0042      * and you normally don't have to call this yourself.
0043      *
0044      * Note that @ref setKGame also unsets an already existing @ref KGame
0045      * object if existing.
0046      */
0047     void slotUnsetKGame();
0048 
0049     /**
0050      * Update the data of the @ref KGame object
0051      */
0052     void slotUpdateGameData();
0053 
0054     /**
0055      * Update the properties of the currently selected player
0056      */
0057     void slotUpdatePlayerData();
0058 
0059     /**
0060      * Updates the list of players and calls @ref clearPlayerData. Note that
0061      * after this call NO player is selected anymore.
0062      */
0063     void slotUpdatePlayerList();
0064 
0065     void slotClearMessages();
0066 
0067 Q_SIGNALS:
0068     /**
0069      * This signal is emitted when the "debug messages" page couldn't find
0070      * the name of a message id. This is usually the case for user-defined
0071      * messages. KGameDebugDialog asks you to give the msgid a name.
0072      * @param messageid The ID of the message. As given to @ref
0073      * KGame::sendMessage
0074      * @param userid User defined msgIds are internally increased by
0075      * KGameMessage::IdUser. You don't have to care about this but if
0076      * this signal is emitted with userid=false (shouldn't happen) then the
0077      * name of an internal message as defined in
0078      * KGameMessage::GameMessageIds couldn't be found.
0079      * @param name The name of the msgid. You have to fill this!
0080      */
0081     void signalRequestIdName(int messageid, bool userid, QString &name);
0082 
0083 protected:
0084     void clearPages();
0085 
0086     /**
0087      * Clear the data of the player view. Note that the player list is NOT
0088      * cleared.
0089      */
0090     void clearPlayerData();
0091 
0092     /**
0093      * Clear the data view of the @ref KGame object
0094      */
0095     void clearGameData();
0096 
0097     /**
0098      * Add a new player to the player list
0099      */
0100     void addPlayer(KPlayer *p);
0101 
0102     /**
0103      * Remove a player from the list
0104      */
0105     void removePlayer(QListWidgetItem *item);
0106 
0107     /**
0108      * @return Whether messages with this msgid shall be displayed or not
0109      */
0110     bool showId(int msgid);
0111 
0112 protected Q_SLOTS:
0113     /**
0114      * Update the data of the player specified in item
0115      * @param item The @ref QListWidgetItem of the player to be updated. Note
0116      * that the text of this item MUST be the ID of the player
0117      */
0118     void slotUpdatePlayerData(QListWidgetItem *item);
0119 
0120     void slotShowId();
0121     void slotHideId();
0122 
0123     /**
0124      * A message has been received - see @ref KGame::signalMessageUpdate
0125      */
0126     void slotMessageUpdate(int msgid, quint32 receiver, quint32 sender);
0127 
0128 private:
0129     void initGamePage();
0130     void initPlayerPage();
0131     void initMessagePage();
0132 
0133 private:
0134     KGameDebugDialogPrivate *const d;
0135 };
0136 
0137 #endif