File indexing completed on 2024-12-01 03:46:41

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 #include "kgamedebugdialog.h"
0010 
0011 // own
0012 #include "kfourinline_debug.h"
0013 // KDEGames
0014 #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
0015 #include <libkdegamesprivate/kgame/kgame.h>
0016 #include <libkdegamesprivate/kgame/kgamemessage.h>
0017 #include <libkdegamesprivate/kgame/kgamepropertyhandler.h>
0018 #include <libkdegamesprivate/kgame/kplayer.h>
0019 // KF
0020 #include <KLocalizedString>
0021 #include <KStandardGuiItem>
0022 // Qt
0023 #include <QFrame>
0024 #include <QGridLayout>
0025 #include <QHBoxLayout>
0026 #include <QLabel>
0027 #include <QListWidget>
0028 #include <QPushButton>
0029 #include <QTime>
0030 #include <QTreeWidget>
0031 #include <QVBoxLayout>
0032 // Std
0033 #include <typeinfo>
0034 
0035 class KGameDebugDialogPrivate
0036 {
0037 public:
0038     KGameDebugDialogPrivate()
0039     {
0040         mGame = nullptr;
0041 
0042         mGamePage = nullptr;
0043         mGameProperties = nullptr;
0044         mGameAddress = nullptr;
0045         mGameId = nullptr;
0046         mGameCookie = nullptr;
0047         mGameMaster = nullptr;
0048         mGameAdmin = nullptr;
0049         mGameOffering = nullptr;
0050         mGameStatus = nullptr;
0051         mGameRunning = nullptr;
0052         mGameMaxPlayers = nullptr;
0053         mGameMinPlayers = nullptr;
0054         mGamePlayerCount = nullptr;
0055 
0056         mPlayerPage = nullptr;
0057         mPlayerList = nullptr;
0058         mPlayerProperties = nullptr;
0059         mPlayerAddress = nullptr;
0060         mPlayerId = nullptr;
0061         mPlayerName = nullptr;
0062         mPlayerGroup = nullptr;
0063         mPlayerUserId = nullptr;
0064         mPlayerMyTurn = nullptr;
0065         mPlayerAsyncInput = nullptr;
0066         mPlayerKGameAddress = nullptr;
0067         mPlayerVirtual = nullptr;
0068         mPlayerActive = nullptr;
0069         mPlayerRtti = nullptr;
0070         mPlayerNetworkPriority = nullptr;
0071 
0072         mMessagePage = nullptr;
0073         mMessageList = nullptr;
0074         mHideIdList = nullptr;
0075     }
0076 
0077     const KGame *mGame;
0078 
0079     QFrame *mGamePage;
0080     QTreeWidget *mGameProperties;
0081     QTreeWidgetItem *mGameAddress;
0082     QTreeWidgetItem *mGameId;
0083     QTreeWidgetItem *mGameCookie;
0084     QTreeWidgetItem *mGameMaster;
0085     QTreeWidgetItem *mGameAdmin;
0086     QTreeWidgetItem *mGameOffering;
0087     QTreeWidgetItem *mGameStatus;
0088     QTreeWidgetItem *mGameRunning;
0089     QTreeWidgetItem *mGameMaxPlayers;
0090     QTreeWidgetItem *mGameMinPlayers;
0091     QTreeWidgetItem *mGamePlayerCount;
0092 
0093     QFrame *mPlayerPage;
0094     QListWidget *mPlayerList;
0095     QTreeWidget *mPlayerProperties;
0096     QTreeWidgetItem *mPlayerAddress;
0097     QTreeWidgetItem *mPlayerId;
0098     QTreeWidgetItem *mPlayerName;
0099     QTreeWidgetItem *mPlayerGroup;
0100     QTreeWidgetItem *mPlayerUserId;
0101     QTreeWidgetItem *mPlayerMyTurn;
0102     QTreeWidgetItem *mPlayerAsyncInput;
0103     QTreeWidgetItem *mPlayerKGameAddress;
0104     QTreeWidgetItem *mPlayerVirtual;
0105     QTreeWidgetItem *mPlayerActive;
0106     QTreeWidgetItem *mPlayerRtti;
0107     QTreeWidgetItem *mPlayerNetworkPriority;
0108 
0109     QFrame *mMessagePage;
0110     QTreeWidget *mMessageList;
0111     QListWidget *mHideIdList;
0112 };
0113 
0114 KGameDebugDialog::KGameDebugDialog(KGame *g, QWidget *parent, bool modal)
0115     : KPageDialog(parent)
0116     , d(new KGameDebugDialogPrivate)
0117 {
0118     setWindowTitle(i18nc("@title:window", "KGame Debug Dialog"));
0119     // QT5 setButtons(Close);
0120     // QT5 setDefaultButton(Close);
0121     setModal(modal);
0122     // QT5 showButtonSeparator(true);
0123     setFaceType(KPageDialog::Tabbed);
0124 
0125     initGamePage();
0126     initPlayerPage();
0127     initMessagePage();
0128 
0129     setKGame(g);
0130 }
0131 
0132 KGameDebugDialog::~KGameDebugDialog()
0133 {
0134     delete d;
0135 }
0136 
0137 void KGameDebugDialog::initGamePage()
0138 {
0139     d->mGamePage = new QFrame();
0140     addPage(d->mGamePage, i18n("Debug &KGame"));
0141     QVBoxLayout *topLayout = new QVBoxLayout(d->mGamePage);
0142     // QT5 topLayout->setMargin( marginHint() );
0143     // QT5 topLayout->setSpacing( spacingHint() );
0144     QHBoxLayout *layout = new QHBoxLayout;
0145     topLayout->addLayout(layout);
0146 
0147     QTreeWidget *v = new QTreeWidget(d->mGamePage);
0148     QTreeWidgetItem *vheader = new QTreeWidgetItem();
0149     vheader->setText(0, tr("Data"));
0150     vheader->setText(1, tr("Value"));
0151     v->setHeaderItem(vheader);
0152     layout->addWidget(v);
0153 
0154     d->mGameProperties = new QTreeWidget(d->mGamePage);
0155     QTreeWidgetItem *mGamePropertiesHeader = new QTreeWidgetItem();
0156     mGamePropertiesHeader->setText(0, tr("Property"));
0157     mGamePropertiesHeader->setText(1, tr("Value"));
0158     mGamePropertiesHeader->setText(2, tr("Policy"));
0159     d->mGameProperties->setHeaderItem(mGamePropertiesHeader);
0160     layout->addWidget(d->mGameProperties);
0161 
0162     QPushButton *b = new QPushButton(i18n("Update"), d->mGamePage);
0163     connect(b, &QPushButton::pressed, this, &KGameDebugDialog::slotUpdateGameData);
0164     topLayout->addWidget(b);
0165 
0166     // game data
0167     d->mGameAddress = new QTreeWidgetItem(v, QStringList(i18n("KGame Pointer")));
0168     d->mGameId = new QTreeWidgetItem(v, QStringList(i18n("Game ID")));
0169     d->mGameCookie = new QTreeWidgetItem(v, QStringList(i18n("Game Cookie")));
0170     d->mGameMaster = new QTreeWidgetItem(v, QStringList(i18n("Is Master")));
0171     d->mGameAdmin = new QTreeWidgetItem(v, QStringList(i18n("Is Admin")));
0172     d->mGameOffering = new QTreeWidgetItem(v, QStringList(i18n("Is Offering Connections")));
0173     d->mGameStatus = new QTreeWidgetItem(v, QStringList(i18n("Game Status")));
0174     d->mGameRunning = new QTreeWidgetItem(v, QStringList(i18n("Game is Running")));
0175     d->mGameMaxPlayers = new QTreeWidgetItem(v, QStringList(i18n("Maximal Players")));
0176     d->mGameMinPlayers = new QTreeWidgetItem(v, QStringList(i18n("Minimal Players")));
0177     d->mGamePlayerCount = new QTreeWidgetItem(v, QStringList(i18n("Players")));
0178 }
0179 
0180 void KGameDebugDialog::initPlayerPage()
0181 {
0182     d->mPlayerPage = new QFrame();
0183     addPage(d->mPlayerPage, i18n("Debug &Players"));
0184     QVBoxLayout *topLayout = new QVBoxLayout(d->mPlayerPage);
0185     // QT5 topLayout->setMargin( marginHint() );
0186     // QT5 topLayout->setSpacing( spacingHint() );
0187     QHBoxLayout *layout = new QHBoxLayout;
0188     topLayout->addLayout(layout);
0189 
0190     // TODO: connect to the KGame signals for joined/removed players!!!
0191     QVBoxLayout *listLayout = new QVBoxLayout;
0192     layout->addLayout(listLayout);
0193     QLabel *listLabel = new QLabel(i18n("Available Players"), d->mPlayerPage);
0194     listLayout->addWidget(listLabel);
0195     d->mPlayerList = new QListWidget(d->mPlayerPage);
0196     connect(d->mPlayerList, &QListWidget::itemActivated, this, qOverload<QListWidgetItem *>(&KGameDebugDialog::slotUpdatePlayerData));
0197     listLayout->addWidget(d->mPlayerList);
0198     d->mPlayerList->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
0199 
0200     QTreeWidget *v = new QTreeWidget(d->mPlayerPage);
0201     layout->addWidget(v);
0202     QTreeWidgetItem *vheader = new QTreeWidgetItem();
0203     vheader->setText(0, tr("Data"));
0204     vheader->setText(1, tr("Value"));
0205     v->setHeaderItem(vheader);
0206 
0207     d->mPlayerProperties = new QTreeWidget(d->mPlayerPage);
0208     QTreeWidgetItem *mPlayerPropertiesHeader = new QTreeWidgetItem();
0209     mPlayerPropertiesHeader->setText(0, tr("Property"));
0210     mPlayerPropertiesHeader->setText(1, tr("Value"));
0211     mPlayerPropertiesHeader->setText(2, tr("Policy"));
0212     d->mPlayerProperties->setHeaderItem(mPlayerPropertiesHeader);
0213     layout->addWidget(d->mPlayerProperties);
0214 
0215     QPushButton *b = new QPushButton(i18n("Update"), d->mPlayerPage);
0216     connect(b, &QPushButton::pressed, this, &KGameDebugDialog::slotUpdatePlayerList);
0217     topLayout->addWidget(b);
0218 
0219     d->mPlayerAddress = new QTreeWidgetItem(v, QStringList(i18n("Player Pointer")));
0220     d->mPlayerId = new QTreeWidgetItem(v, QStringList(i18n("Player ID")));
0221     d->mPlayerName = new QTreeWidgetItem(v, QStringList(i18n("Player Name")));
0222     d->mPlayerGroup = new QTreeWidgetItem(v, QStringList(i18n("Player Group")));
0223     d->mPlayerUserId = new QTreeWidgetItem(v, QStringList(i18n("Player User ID")));
0224     d->mPlayerMyTurn = new QTreeWidgetItem(v, QStringList(i18n("My Turn")));
0225     d->mPlayerAsyncInput = new QTreeWidgetItem(v, QStringList(i18n("Async Input")));
0226     d->mPlayerKGameAddress = new QTreeWidgetItem(v, QStringList(i18n("KGame Address")));
0227     d->mPlayerVirtual = new QTreeWidgetItem(v, QStringList(i18n("Player is Virtual")));
0228     d->mPlayerActive = new QTreeWidgetItem(v, QStringList(i18n("Player is Active")));
0229     d->mPlayerRtti = new QTreeWidgetItem(v, QStringList(i18n("RTTI")));
0230     d->mPlayerNetworkPriority = new QTreeWidgetItem(v, QStringList(i18n("Network Priority")));
0231 }
0232 
0233 void KGameDebugDialog::initMessagePage()
0234 {
0235     d->mMessagePage = new QFrame();
0236     addPage(d->mMessagePage, i18n("Debug &Messages"));
0237     QGridLayout *layout = new QGridLayout(d->mMessagePage);
0238     // QT5 layout->setMargin(marginHint());
0239     // QT5 layout->setSpacing(spacingHint());
0240     d->mMessageList = new QTreeWidget(d->mMessagePage);
0241     layout->addWidget(d->mMessageList, 0, 0, 10, 4);
0242 
0243     QTreeWidgetItem *mMessageListHeader = new QTreeWidgetItem();
0244     mMessageListHeader->setText(0, tr("Time"));
0245     mMessageListHeader->setText(1, tr("ID"));
0246     mMessageListHeader->setText(2, tr("Receiver"));
0247     mMessageListHeader->setText(2, tr("Sender"));
0248     mMessageListHeader->setText(2, tr("ID - Text"));
0249     d->mMessageList->setHeaderItem(mMessageListHeader);
0250 
0251     QPushButton *hide = new QPushButton(i18n("&>>"), d->mMessagePage);
0252     connect(hide, &QPushButton::pressed, this, &KGameDebugDialog::slotHideId);
0253     layout->addWidget(hide, 4, 4);
0254 
0255     QPushButton *show = new QPushButton(i18n("&<<"), d->mMessagePage);
0256     connect(show, &QPushButton::pressed, this, &KGameDebugDialog::slotShowId);
0257     layout->addWidget(show, 6, 4);
0258 
0259     QLabel *l = new QLabel(i18n("Do not show IDs:"), d->mMessagePage);
0260     layout->addWidget(l, 0, 5, 1, 2);
0261     d->mHideIdList = new QListWidget(d->mMessagePage);
0262     layout->addWidget(d->mHideIdList, 1, 5, 8, 2);
0263 
0264     QPushButton *clear = new QPushButton(d->mMessagePage);
0265     KGuiItem::assign(clear, KStandardGuiItem::clear());
0266     connect(clear, &QPushButton::pressed, this, &KGameDebugDialog::slotClearMessages);
0267     layout->addWidget(clear, 10, 0, 1, 7);
0268     // TODO: "show all but..." and "show nothing but..."
0269 }
0270 
0271 void KGameDebugDialog::clearPlayerData()
0272 {
0273     d->mPlayerAddress->setText(1, QLatin1String(""));
0274     d->mPlayerId->setText(1, QLatin1String(""));
0275     d->mPlayerName->setText(1, QLatin1String(""));
0276     d->mPlayerGroup->setText(1, QLatin1String(""));
0277     d->mPlayerUserId->setText(1, QLatin1String(""));
0278     d->mPlayerMyTurn->setText(1, QLatin1String(""));
0279     d->mPlayerAsyncInput->setText(1, QLatin1String(""));
0280     d->mPlayerKGameAddress->setText(1, QLatin1String(""));
0281     d->mPlayerVirtual->setText(1, QLatin1String(""));
0282     d->mPlayerActive->setText(1, QLatin1String(""));
0283     d->mPlayerRtti->setText(1, QLatin1String(""));
0284     d->mPlayerNetworkPriority->setText(1, QLatin1String(""));
0285 
0286     d->mPlayerProperties->clear();
0287 }
0288 
0289 void KGameDebugDialog::clearGameData()
0290 {
0291     d->mGameAddress->setText(1, QLatin1String(""));
0292     d->mGameId->setText(1, QLatin1String(""));
0293     d->mGameCookie->setText(1, QLatin1String(""));
0294     d->mGameMaster->setText(1, QLatin1String(""));
0295     d->mGameAdmin->setText(1, QLatin1String(""));
0296     d->mGameOffering->setText(1, QLatin1String(""));
0297     d->mGameStatus->setText(1, QLatin1String(""));
0298     d->mGameRunning->setText(1, QLatin1String(""));
0299     d->mGameMaxPlayers->setText(1, QLatin1String(""));
0300     d->mGameMinPlayers->setText(1, QLatin1String(""));
0301 
0302     d->mGameProperties->clear();
0303 }
0304 
0305 void KGameDebugDialog::slotUpdatePlayerData()
0306 {
0307     if (!d->mGame || d->mPlayerList->currentRow() == -1) {
0308         return;
0309     }
0310     slotUpdatePlayerData(d->mPlayerList->item(d->mPlayerList->currentRow()));
0311 }
0312 
0313 void KGameDebugDialog::slotUpdatePlayerList()
0314 {
0315     QListWidgetItem *i = d->mPlayerList->item(0);
0316     for (; d->mPlayerList->count() > 0; i = d->mPlayerList->item(0)) {
0317         removePlayer(i);
0318     }
0319 
0320     for (QList<KPlayer *>::const_iterator it = d->mGame->playerList()->begin(); it != d->mGame->playerList()->end(); ++it) {
0321         addPlayer(*it);
0322     }
0323 }
0324 
0325 void KGameDebugDialog::slotUpdateGameData()
0326 {
0327     if (!d->mGame) {
0328         d->mGameAddress->setText(1, i18n("NULL pointer"));
0329         return;
0330     }
0331 
0332     clearGameData();
0333 
0334     QString buf = QString::asprintf("%p", (void *)d->mGame);
0335     d->mGameAddress->setText(1, buf);
0336     d->mGameId->setText(1, QString::number(d->mGame->gameId()));
0337     d->mGameCookie->setText(1, QString::number(d->mGame->cookie()));
0338     d->mGameMaster->setText(1, d->mGame->isMaster() ? i18n("True") : i18n("False"));
0339     d->mGameAdmin->setText(1, d->mGame->isAdmin() ? i18n("True") : i18n("False"));
0340     d->mGameOffering->setText(1, d->mGame->isOfferingConnections() ? i18n("True") : i18n("False"));
0341     d->mGameStatus->setText(1, QString::number(d->mGame->gameStatus()));
0342     d->mGameRunning->setText(1, d->mGame->isRunning() ? i18n("True") : i18n("False"));
0343     d->mGameMaxPlayers->setText(1, QString::number(d->mGame->maxPlayers()));
0344     d->mGameMinPlayers->setText(1, QString::number(d->mGame->minPlayers()));
0345     d->mGamePlayerCount->setText(1, QString::number(d->mGame->playerCount()));
0346 
0347     // TODO ios
0348 
0349     KGamePropertyHandler *handler = d->mGame->dataHandler();
0350     for (KGamePropertyBase *property : std::as_const(handler->dict())) {
0351         QString policy;
0352         switch (property->policy()) {
0353         case KGamePropertyBase::PolicyClean:
0354             policy = i18n("Clean");
0355             break;
0356         case KGamePropertyBase::PolicyDirty:
0357             policy = i18n("Dirty");
0358             break;
0359         case KGamePropertyBase::PolicyLocal:
0360             policy = i18n("Local");
0361             break;
0362         case KGamePropertyBase::PolicyUndefined:
0363         default:
0364             policy = i18n("Undefined");
0365             break;
0366         }
0367         QStringList items;
0368         items << handler->propertyName(property->id()) << handler->propertyValue(property) << policy;
0369         new QTreeWidgetItem(d->mGameProperties, items);
0370         //  qCDebug(KFOURINLINE_LOG) << ": checking for all game properties: found property name" << name;
0371     }
0372 }
0373 
0374 void KGameDebugDialog::slotUpdatePlayerData(QListWidgetItem *item)
0375 {
0376     if (!item || !d->mGame) {
0377         return;
0378     }
0379 
0380     KPlayer *p = d->mGame->findPlayer(item->text().toInt());
0381 
0382     if (!p) {
0383         qCCritical(KFOURINLINE_LOG) << ": cannot find player";
0384         return;
0385     }
0386 
0387     clearPlayerData();
0388 
0389     QString buf = QString::asprintf("%p", (void *)p);
0390     d->mPlayerAddress->setText(1, buf);
0391     d->mPlayerId->setText(1, QString::number(p->id()));
0392     d->mPlayerName->setText(1, p->name());
0393     d->mPlayerGroup->setText(1, p->group());
0394     d->mPlayerUserId->setText(1, QString::number(p->userId()));
0395     d->mPlayerMyTurn->setText(1, p->myTurn() ? i18n("True") : i18n("False"));
0396     d->mPlayerAsyncInput->setText(1, p->asyncInput() ? i18n("True") : i18n("False"));
0397     buf = QString::asprintf("%p", (void *)p->game());
0398     d->mPlayerKGameAddress->setText(1, buf);
0399     d->mPlayerVirtual->setText(1, p->isVirtual() ? i18n("True") : i18n("False"));
0400     d->mPlayerActive->setText(1, p->isActive() ? i18n("True") : i18n("False"));
0401     d->mPlayerRtti->setText(1, QString::number(p->rtti()));
0402     d->mPlayerNetworkPriority->setText(1, QString::number(p->networkPriority()));
0403 
0404     // TODO ios
0405 
0406     // Properties
0407     KGamePropertyHandler *handler = p->dataHandler();
0408     for (KGamePropertyBase *property : std::as_const(handler->dict())) {
0409         QString policy;
0410         switch (property->policy()) {
0411         case KGamePropertyBase::PolicyClean:
0412             policy = i18n("Clean");
0413             break;
0414         case KGamePropertyBase::PolicyDirty:
0415             policy = i18n("Dirty");
0416             break;
0417         case KGamePropertyBase::PolicyLocal:
0418             policy = i18n("Local");
0419             break;
0420         case KGamePropertyBase::PolicyUndefined:
0421         default:
0422             policy = i18n("Undefined");
0423             break;
0424         }
0425         QStringList items;
0426         items << handler->propertyName(property->id()) << handler->propertyValue(property) << policy;
0427         new QTreeWidgetItem(d->mPlayerProperties, items);
0428     }
0429 }
0430 
0431 void KGameDebugDialog::clearPages()
0432 {
0433     clearPlayerData();
0434     clearGameData();
0435     d->mPlayerList->clear();
0436     slotClearMessages();
0437 }
0438 
0439 void KGameDebugDialog::setKGame(const KGame *g)
0440 {
0441     slotUnsetKGame();
0442     d->mGame = g;
0443     if (g) {
0444         // TODO: connect to the KGame signals for joined/removed players!!!
0445         connect(d->mGame, &QObject::destroyed, this, &KGameDebugDialog::slotUnsetKGame);
0446         //  connect();
0447 
0448         for (QList<KPlayer *>::const_iterator it = d->mGame->playerList()->begin(); it != d->mGame->playerList()->end(); ++it) {
0449             addPlayer(*it);
0450         }
0451 
0452         slotUpdateGameData();
0453 
0454         connect(d->mGame, &KGame::signalMessageUpdate, this, &KGameDebugDialog::slotMessageUpdate);
0455     }
0456 }
0457 
0458 void KGameDebugDialog::slotUnsetKGame()
0459 {
0460     if (d->mGame) {
0461         disconnect(d->mGame, nullptr, this, nullptr);
0462     }
0463     d->mGame = nullptr;
0464     clearPages();
0465 }
0466 
0467 void KGameDebugDialog::addPlayer(KPlayer *p)
0468 {
0469     if (!p) {
0470         qCCritical(KFOURINLINE_LOG) << "trying to add NULL player";
0471         return;
0472     }
0473 
0474     (void)new QListWidgetItem(QString::number(p->id()), d->mPlayerList);
0475     // TODO connect to signals, like deleted/removed, ...
0476 }
0477 
0478 void KGameDebugDialog::removePlayer(QListWidgetItem *i)
0479 {
0480     if (!i || !d->mGame) {
0481         return;
0482     }
0483     KPlayer *p = d->mGame->findPlayer(i->text().toInt());
0484     if (!p) {
0485         return;
0486     }
0487     disconnect(p, nullptr, this, nullptr);
0488     if (i->isSelected()) {
0489         clearPlayerData();
0490     }
0491     delete i;
0492 }
0493 
0494 void KGameDebugDialog::slotMessageUpdate(int msgid, quint32 receiver, quint32 sender)
0495 {
0496     if (!showId(msgid)) {
0497         return;
0498     }
0499     QString msgidText = KGameMessage::messageId2Text(msgid);
0500     if (msgidText.isNull()) {
0501         if (msgid > KGameMessage::IdUser) {
0502             Q_EMIT signalRequestIdName(msgid - KGameMessage::IdUser, true, msgidText);
0503         } else {
0504             Q_EMIT signalRequestIdName(msgid, false, msgidText);
0505         }
0506         if (msgidText.isNull()) {
0507             msgidText = i18n("Unknown");
0508         }
0509     }
0510     const QStringList items {
0511         QTime::currentTime().toString(),
0512         QString::number(msgid),
0513         QString::number(receiver),
0514         QString::number(sender),
0515         msgidText,
0516     };
0517     new QTreeWidgetItem(d->mMessageList, items);
0518 }
0519 
0520 void KGameDebugDialog::slotClearMessages()
0521 {
0522     d->mMessageList->clear();
0523 }
0524 
0525 void KGameDebugDialog::slotShowId()
0526 {
0527     /* QListBoxItem* i = d->mHideIdList->firstItem();
0528      for (; i; i = i->next()) {
0529         if (i->selected()) {
0530             d->mHideIdList->removeItem(i->);
0531         }
0532      }*/
0533     if (!d->mHideIdList->currentItem()) {
0534         return;
0535     }
0536     d->mHideIdList->takeItem(d->mHideIdList->currentRow());
0537 }
0538 
0539 void KGameDebugDialog::slotHideId()
0540 {
0541     if (!d->mMessageList->currentItem()) {
0542         return;
0543     }
0544     int msgid = d->mMessageList->currentItem()->text(1).toInt();
0545     if (!showId(msgid)) {
0546         return;
0547     }
0548     (void)new QListWidgetItem(QString::number(msgid), d->mHideIdList);
0549 }
0550 
0551 bool KGameDebugDialog::showId(int msgid)
0552 {
0553     for (int j = 0; j < d->mHideIdList->count(); ++j) {
0554         QListWidgetItem *i = d->mHideIdList->item(j);
0555         if (i->text().toInt() == msgid) {
0556             return false;
0557         }
0558     }
0559     return true;
0560 }
0561 
0562 #include "moc_kgamedebugdialog.cpp"