summaryrefslogtreecommitdiffstats
path: root/libkdegames/kgame/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'libkdegames/kgame/dialogs')
-rw-r--r--libkdegames/kgame/dialogs/Makefile.am17
-rw-r--r--libkdegames/kgame/dialogs/kgameconnectdialog.cpp278
-rw-r--r--libkdegames/kgame/dialogs/kgameconnectdialog.h171
-rw-r--r--libkdegames/kgame/dialogs/kgamedebugdialog.cpp548
-rw-r--r--libkdegames/kgame/dialogs/kgamedebugdialog.h150
-rw-r--r--libkdegames/kgame/dialogs/kgamedialog.cpp347
-rw-r--r--libkdegames/kgame/dialogs/kgamedialog.h321
-rw-r--r--libkdegames/kgame/dialogs/kgamedialogconfig.cpp773
-rw-r--r--libkdegames/kgame/dialogs/kgamedialogconfig.h368
-rw-r--r--libkdegames/kgame/dialogs/kgameerrordialog.cpp129
-rw-r--r--libkdegames/kgame/dialogs/kgameerrordialog.h115
11 files changed, 0 insertions, 3217 deletions
diff --git a/libkdegames/kgame/dialogs/Makefile.am b/libkdegames/kgame/dialogs/Makefile.am
deleted file mode 100644
index f3c1adbe..00000000
--- a/libkdegames/kgame/dialogs/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-
-noinst_LTLIBRARIES = libkgamedialogs.la
-
-# compile-order doesn't matter here but maybe we will split these section soon
-
-
-libkgamedialogs_la_SOURCES = kgamedialog.cpp kgameconnectdialog.cpp kgameerrordialog.cpp kgamedebugdialog.cpp kgamedialogconfig.cpp
-
-libkgamedialogsincludedir=$(includedir)/kgame
-libkgamedialogsinclude_HEADERS = kgamedialog.h kgameconnectdialog.h kgameerrordialog.h kgamedebugdialog.h kgamedialogconfig.h
-
-INCLUDES = -I$(top_srcdir)/libtdegames -I$(top_srcdir)/libtdegames/kgame $(all_includes)
-METASOURCES = AUTO
-
-messages:
-# $(XGETTEXT) `find . -name \*.h -o -name \*.cpp -o -name \*.cc` -o $(podir)/libtdegames.pot
-
diff --git a/libkdegames/kgame/dialogs/kgameconnectdialog.cpp b/libkdegames/kgame/dialogs/kgameconnectdialog.cpp
deleted file mode 100644
index 98958ffd..00000000
--- a/libkdegames/kgame/dialogs/kgameconnectdialog.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-
-#include "kgameconnectdialog.h"
-
-#include <knuminput.h>
-#include <klocale.h>
-
-#include <tqlineedit.h>
-#include <tqcombobox.h>
-#include <tqvbuttongroup.h>
-#include <tqlayout.h>
-#include <tqradiobutton.h>
-#include <tqlabel.h>
-#include <dnssd/servicebrowser.h>
-#include <tqpushbutton.h>
-#include <tqgrid.h>
-
-class KGameConnectWidgetPrivate
-{
- public:
- KGameConnectWidgetPrivate()
- {
- mPort = 0;
- mHost = 0;
- mButtonGroup = 0;
- mBrowser = 0;
- }
-
- KIntNumInput* mPort;
- TQLineEdit* mHost; //KLineEdit?
- TQVButtonGroup* mButtonGroup;
- TQComboBox *mClientName;
- TQLabel *mClientNameLabel;
- DNSSD::ServiceBrowser *mBrowser;
- TQLabel *mServerNameLabel;
- TQLineEdit *mServerName;
- TQString mType;
-};
-
-KGameConnectWidget::KGameConnectWidget(TQWidget* parent) : TQWidget(parent)
-{
- d = new KGameConnectWidgetPrivate;
-
- TQVBoxLayout* vb = new TQVBoxLayout(this, KDialog::spacingHint());
- d->mButtonGroup = new TQVButtonGroup(this);
- vb->addWidget(d->mButtonGroup);
- connect(d->mButtonGroup, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotTypeChanged(int)));
- (void)new TQRadioButton(i18n("Create a network game"), d->mButtonGroup);
- (void)new TQRadioButton(i18n("Join a network game"), d->mButtonGroup);
-
- TQGrid* g = new TQGrid(2, this);
- vb->addWidget(g);
- g->setSpacing(KDialog::spacingHint());
- d->mServerNameLabel = new TQLabel(i18n("Game name:"), g);
- d->mServerName = new TQLineEdit(g);
- d->mClientNameLabel = new TQLabel(i18n("Network games:"), g);
- d->mClientName = new TQComboBox(g);
- connect(d->mClientName,TQT_SIGNAL(activated(int)),TQT_SLOT(slotGameSelected(int)));
- (void)new TQLabel(i18n("Port to connect to:"), g);
- d->mPort = new KIntNumInput(g);
- (void)new TQLabel(i18n("Host to connect to:"), g);
- d->mHost = new TQLineEdit(g);
-
- TQPushButton *button=new TQPushButton(i18n("&Start Network"), this);
- connect(button, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(signalNetworkSetup()));
- vb->addWidget(button);
- // Hide until type is set
- d->mClientName->hide();
- d->mClientNameLabel->hide();
- d->mServerName->hide();
- d->mServerNameLabel->hide();
-}
-
-void KGameConnectWidget::showDnssdControls()
-{
- if (!d->mBrowser) return;
- if (d->mHost->isEnabled()) { // client
- d->mClientName->show();
- d->mClientNameLabel->show();
- d->mServerName->hide();
- d->mServerNameLabel->hide();
- slotGameSelected(d->mClientName->currentItem());
- } else {
- d->mClientName->hide();
- d->mClientNameLabel->hide();
- d->mServerName->show();
- d->mServerNameLabel->show();
- }
-}
-
-void KGameConnectWidget::setType(const TQString& type)
-{
- d->mType = type;
- delete d->mBrowser;
- d->mBrowser = new DNSSD::ServiceBrowser(type);
- connect(d->mBrowser,TQT_SIGNAL(finished()),TQT_SLOT(slotGamesFound()));
- d->mBrowser->startBrowse();
- showDnssdControls();
-}
-
-void KGameConnectWidget::slotGamesFound()
-{
- bool autoselect=false;
- if (!d->mClientName->count()) autoselect=true;
- d->mClientName->clear();
- TQStringList names;
- TQValueList<DNSSD::RemoteService::Ptr>::ConstIterator itEnd = d->mBrowser->services().end();
- for (TQValueList<DNSSD::RemoteService::Ptr>::ConstIterator it = d->mBrowser->services().begin();
- it!=itEnd; ++it) names << (*it)->serviceName();
- d->mClientName->insertStringList(names);
- if (autoselect && d->mClientName->count()) slotGameSelected(0);
-}
-
-void KGameConnectWidget::setName(const TQString& name)
-{
- d->mServerName->setText(name);
-}
-
-TQString KGameConnectWidget::gameName() const
-{
- return d->mServerName->text();
-}
-
-TQString KGameConnectWidget::type() const
-{
- return d->mType;
-}
-
-void KGameConnectWidget::slotGameSelected(int nr)
-{
- if (nr>=(d->mBrowser->services().count()) || nr<0) return;
- if (!d->mHost->isEnabled()) return; // this is server mode, do not overwrite host and port controls
- DNSSD::RemoteService::Ptr srv = d->mBrowser->services()[nr];
- if (!srv->isResolved() && !srv->resolve()) return;
- d->mHost->setText(srv->hostName());
- d->mPort->setValue(srv->port());
-}
-KGameConnectWidget::~KGameConnectWidget()
-{
- delete d->mBrowser;
- delete d;
-}
-
-TQString KGameConnectWidget::host() const
-{
- if (d->mHost->isEnabled()) {
- return d->mHost->text();
- } else {
- return TQString();
- }
-}
-
-unsigned short int KGameConnectWidget::port() const
-{
- return d->mPort->value();
-}
-
-void KGameConnectWidget::setHost(const TQString& host)
-{
- d->mHost->setText(host);
-}
-
-void KGameConnectWidget::setPort(unsigned short int port)
-{
- d->mPort->setValue(port);
-}
-
-void KGameConnectWidget::setDefault(int state)
-{
- d->mButtonGroup->setButton(state);
- slotTypeChanged(state);
-}
-
-void KGameConnectWidget::slotTypeChanged(int t)
-{
- if (t == 0) {
- d->mHost->setEnabled(false);
- } else if (t == 1) {
- d->mHost->setEnabled(true);
- }
- showDnssdControls();
- emit signalServerTypeChanged(t);
-}
-
-class KGameConnectDialogPrivate
-{
- public:
- KGameConnectDialogPrivate()
- {
- mConnect = 0;
- }
-
- KGameConnectWidget* mConnect;
-};
-
-// buttonmask =Ok|Cancel
-KGameConnectDialog::KGameConnectDialog(TQWidget* parent,int buttonmask) : KDialogBase(Plain,
- i18n("Network Game"),buttonmask , Ok, parent, 0, true, buttonmask!=0)
-{
- d = new KGameConnectDialogPrivate;
- TQVBoxLayout* vb = new TQVBoxLayout(plainPage(), spacingHint());
- d->mConnect = new KGameConnectWidget(plainPage());
- vb->addWidget(d->mConnect);
-}
-
-KGameConnectDialog::~KGameConnectDialog()
-{
- delete d;
-}
-
-int KGameConnectDialog::initConnection( unsigned short int& port,
- TQString& host, TQWidget* parent, bool server)
-{
- KGameConnectDialog d(parent);
- d.setHost(host);
- d.setPort(port);
- if (server) {
- d.setDefault(0);
- } else {
- d.setDefault(1);
- }
-
- int result = d.exec();
- if (result == TQDialog::Accepted) {
- host = d.host();
- port = d.port();
- }
- return result;
-}
-
-TQString KGameConnectDialog::host() const
-{
- return d->mConnect->host();
-}
-
-unsigned short int KGameConnectDialog::port() const
-{
- return d->mConnect->port();
-}
-
-void KGameConnectDialog::setHost(const TQString& host)
-{
- d->mConnect->setHost(host);
-}
-
-void KGameConnectDialog::setPort(unsigned short int port)
-{
- d->mConnect->setPort(port);
-}
-
-void KGameConnectDialog::setDefault(int state)
-{
- d->mConnect->setDefault(state);
-}
-
-
-
-#include "kgameconnectdialog.moc"
-
diff --git a/libkdegames/kgame/dialogs/kgameconnectdialog.h b/libkdegames/kgame/dialogs/kgameconnectdialog.h
deleted file mode 100644
index 0a14183d..00000000
--- a/libkdegames/kgame/dialogs/kgameconnectdialog.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef __KGAMECONNECTDIALOG_H__
-#define __KGAMECONNECTDIALOG_H__
-
-#include <kdialogbase.h>
-
-class KGameConnectDialogPrivate;
-class KGameConnectWidgetPrivate;
-
-class KGameConnectWidget : public TQWidget
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameConnectWidget(TQWidget* parent);
- virtual ~KGameConnectWidget();
-
- /**
- * @param host The host to connect to by default
- **/
- void setHost(const TQString& host);
-
- /**
- * @return The host to connect to or TQString() if the user wants to
- * be the MASTER
- **/
- TQString host() const;
-
- /**
- * @param port The port that will be shown by default
- **/
- void setPort(unsigned short int port);
-
- /**
- * @return The port to connect to / to listen
- **/
- unsigned short int port() const;
-
- /**
- * Specifies which state is the default (0 = server game; 1 = join game)
- * @param state The default state. 0 For a server game, 1 to join a game
- **/
- void setDefault(int state);
-
- /**
- * Sets DNS-SD service type, both for publishing and browsing
- * @param type Service type (something like _kwin4._tcp).
- * It should be unique for application.
- * @since 3.4
- **/
- void setType(const TQString& type);
-
- /**
- * @return service type
- */
- TQString type() const;
-
- /**
- * Set game name for publishing.
- * @param name Game name. Important only for server mode. If not
- * set hostname will be used. In case of name conflict -2, -3 and so on will be added to name.
- */
- void setName(const TQString& name);
-
- /**
- * @return game name.
- */
- TQString gameName() const;
-
-protected slots:
- /**
- * The type has changed, ie the user switched between creating or
- * joining.
- **/
- void slotTypeChanged(int);
- void slotGamesFound();
- void slotGameSelected(int);
-
-signals:
- void signalNetworkSetup();
- void signalServerTypeChanged(int);
-
-private:
- void showDnssdControls();
- KGameConnectWidgetPrivate* d;
-
-};
-
-/**
- * @short Dialog to ask for host and port
- *
- * This Dialog is used to create a game. You call initConnection(port,
- * TQString(), parent, true) to create a network game (as a server)
- * or initConnection(port, host, parent) to join a network game.
- *
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KGameConnectDialog : public KDialogBase
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameConnectDialog(TQWidget* parent = 0,int buttonmask=Ok|Cancel);
- virtual ~KGameConnectDialog();
-
- /**
- * Shows a dialog to either connect to an existing game or to create a
- * server game, depending on user's choice.
- * @param port The port the user wants to connect to.
- * @param host The host the user wants to connect to. Will be
- * TQString() if server game is chosen
- * @param parent The parent of the dialog
- * @param server True to create a network game per default, false to
- * join a game by default
- **/
- static int initConnection(unsigned short int& port, TQString& host, TQWidget* parent, bool server = false);
-
- /**
- * @param host The host to connect to by default
- **/
- void setHost(const TQString& host);
-
- /**
- * @return The host to connect to or TQString() if the user wants to
- * be the MASTER
- **/
- TQString host() const;
-
- /**
- * @param port The port that will be shown by default
- **/
- void setPort(unsigned short int port);
-
- /**
- * @return The port to connect to / to listen
- **/
- unsigned short int port() const;
-
- /**
- * Specifies which state is the default (0 = server game; 1 = join game)
- * @param state The default state. 0 For a server game, 1 to join a game
- **/
- void setDefault(int state);
-
-signals:
- void signalNetworkSetup();
-
-private:
- KGameConnectDialogPrivate* d;
-};
-
-#endif
diff --git a/libkdegames/kgame/dialogs/kgamedebugdialog.cpp b/libkdegames/kgame/dialogs/kgamedebugdialog.cpp
deleted file mode 100644
index 49623238..00000000
--- a/libkdegames/kgame/dialogs/kgamedebugdialog.cpp
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "kgamedebugdialog.h"
-
-#include "kgamemessage.h"
-#include "kgame.h"
-#include "kplayer.h"
-#include "kgamepropertyhandler.h"
-
-#include <klistview.h>
-#include <klistbox.h>
-#include <klocale.h>
-#include <kdebug.h>
-#include <kpushbutton.h>
-#include <kstdguiitem.h>
-
-#include <tqlayout.h>
-#include <tqstring.h>
-#include <tqintdict.h>
-#include <tqlabel.h>
-#include <tqdatetime.h>
-
-#include <typeinfo>
-
-
-class KGameDebugDialogPrivate
-{
-public:
- KGameDebugDialogPrivate()
- {
- mGame = 0;
-
- mGamePage = 0;
- mGameProperties = 0;
- mGameAddress = 0;
- mGameId = 0;
- mGameCookie = 0;
- mGameMaster = 0;
- mGameAdmin = 0;
- mGameOffering = 0;
- mGametqStatus = 0;
- mGameRunning = 0;
- mGameMaxPlayers = 0;
- mGameMinPlayers = 0;
- mGamePlayerCount = 0;
-
- mPlayerPage = 0;
- mPlayerList = 0;
- mPlayerProperties = 0;
- mPlayerAddress = 0;
- mPlayerId = 0;
- mPlayerName = 0;
- mPlayerGroup = 0;
- mPlayerUserId = 0;
- mPlayerMyTurn = 0;
- mPlayerAsyncInput= 0;
- mPlayerKGameAddress = 0;
- mPlayerVirtual = 0;
- mPlayerActive = 0;
- mPlayerRtti = 0;
- mPlayerNetworkPriority = 0;
-
- mMessagePage = 0;
- mMessageList = 0;
- mHideIdList = 0;
- }
-
- const KGame* mGame;
-
- TQFrame* mGamePage;
- KListView* mGameProperties;
- TQListViewItem* mGameAddress;
- TQListViewItem* mGameId;
- TQListViewItem* mGameCookie;
- TQListViewItem* mGameMaster;
- TQListViewItem* mGameAdmin;
- TQListViewItem* mGameOffering;
- TQListViewItem* mGametqStatus;
- TQListViewItem* mGameRunning;
- TQListViewItem* mGameMaxPlayers;
- TQListViewItem* mGameMinPlayers;
- TQListViewItem* mGamePlayerCount;
-
- TQFrame* mPlayerPage;
- KListBox* mPlayerList;
- KListView* mPlayerProperties;
- TQListViewItem* mPlayerAddress;
- TQListViewItem* mPlayerId;
- TQListViewItem* mPlayerName;
- TQListViewItem* mPlayerGroup;
- TQListViewItem* mPlayerUserId;
- TQListViewItem* mPlayerMyTurn;
- TQListViewItem* mPlayerAsyncInput;
- TQListViewItem* mPlayerKGameAddress;
- TQListViewItem* mPlayerVirtual;
- TQListViewItem* mPlayerActive;
- TQListViewItem* mPlayerRtti;
- TQListViewItem* mPlayerNetworkPriority;
-
- TQFrame* mMessagePage;
- KListView* mMessageList;
- KListBox* mHideIdList;
-};
-
-KGameDebugDialog::KGameDebugDialog(KGame* g, TQWidget* parent, bool modal) :
- KDialogBase(Tabbed, i18n("KGame Debug Dialog"), Close, Close,
- parent, 0, modal, true)
-{
- d = new KGameDebugDialogPrivate;
-
- initGamePage();
- initPlayerPage();
- initMessagePage();
-
- setKGame(g);
-}
-
-KGameDebugDialog::~KGameDebugDialog()
-{
- delete d;
-}
-
-void KGameDebugDialog::initGamePage()
-{
- d->mGamePage = addPage(i18n("Debug &KGame"));
- TQVBoxLayout* topLayout = new TQVBoxLayout(d->mGamePage, marginHint(), spacingHint());
- TQHBoxLayout* tqlayout = new TQHBoxLayout(topLayout);
-
- KListView* v = new KListView(d->mGamePage);
- v->addColumn(i18n("Data"));
- v->addColumn(i18n("Value"));
- tqlayout->addWidget(v);
-
- d->mGameProperties = new KListView(d->mGamePage);
- d->mGameProperties->addColumn(i18n("Property"));
- d->mGameProperties->addColumn(i18n("Value"));
- d->mGameProperties->addColumn(i18n("Policy"));
- tqlayout->addWidget(d->mGameProperties);
-
- TQPushButton* b = new TQPushButton(i18n("Update"), d->mGamePage);
- connect(b, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotUpdateGameData()));
- topLayout->addWidget(b);
-
-// game data
- d->mGameAddress = new TQListViewItem(v, i18n("KGame Pointer"));
- d->mGameId = new TQListViewItem(v, i18n("Game ID"));
- d->mGameCookie = new TQListViewItem(v, i18n("Game Cookie"));
- d->mGameMaster = new TQListViewItem(v, i18n("Is Master"));
- d->mGameAdmin = new TQListViewItem(v, i18n("Is Admin"));
- d->mGameOffering = new TQListViewItem(v, i18n("Is Offering Connections"));
- d->mGametqStatus = new TQListViewItem(v, i18n("Game Status"));
- d->mGameRunning = new TQListViewItem(v, i18n("Game is Running"));
- d->mGameMaxPlayers = new TQListViewItem(v, i18n("Maximal Players"));
- d->mGameMinPlayers = new TQListViewItem(v, i18n("Minimal Players"));
- d->mGamePlayerCount = new TQListViewItem(v, i18n("Players"));
-}
-
-void KGameDebugDialog::initPlayerPage()
-{
- d->mPlayerPage = addPage(i18n("Debug &Players"));
- TQVBoxLayout* topLayout = new TQVBoxLayout(d->mPlayerPage, marginHint(), spacingHint());
- TQHBoxLayout* tqlayout = new TQHBoxLayout(topLayout);
-
- //TODO: connect to the KGame signals for joined/removed players!!!
- TQVBoxLayout* listLayout = new TQVBoxLayout(tqlayout);
- TQLabel* listLabel = new TQLabel(i18n("Available Players"), d->mPlayerPage);
- listLayout->addWidget(listLabel);
- d->mPlayerList = new KListBox(d->mPlayerPage);
- connect(d->mPlayerList, TQT_SIGNAL(executed(TQListBoxItem*)), this, TQT_SLOT(slotUpdatePlayerData(TQListBoxItem*)));
- listLayout->addWidget(d->mPlayerList);
- d->mPlayerList->tqsetSizePolicy(TQSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Expanding));
-
- KListView* v = new KListView(d->mPlayerPage);
- tqlayout->addWidget(v);
- v->addColumn(i18n("Data"));
- v->addColumn(i18n("Value"));
-
- d->mPlayerProperties = new KListView(d->mPlayerPage);
- d->mPlayerProperties->addColumn(i18n("Property"));
- d->mPlayerProperties->addColumn(i18n("Value"));
- d->mPlayerProperties->addColumn(i18n("Policy"));
- tqlayout->addWidget(d->mPlayerProperties);
-
- TQPushButton* b = new TQPushButton(i18n("Update"), d->mPlayerPage);
- connect(b, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotUpdatePlayerList()));
- topLayout->addWidget(b);
-
- d->mPlayerAddress = new TQListViewItem(v, i18n("Player Pointer"));
- d->mPlayerId = new TQListViewItem(v, i18n("Player ID"));
- d->mPlayerName = new TQListViewItem(v, i18n("Player Name"));
- d->mPlayerGroup = new TQListViewItem(v, i18n("Player Group"));
- d->mPlayerUserId = new TQListViewItem(v, i18n("Player User ID"));
- d->mPlayerMyTurn = new TQListViewItem(v, i18n("My Turn"));
- d->mPlayerAsyncInput = new TQListViewItem(v, i18n("Async Input"));
- d->mPlayerKGameAddress = new TQListViewItem(v, i18n("KGame Address"));
- d->mPlayerVirtual = new TQListViewItem(v, i18n("Player is Virtual"));
- d->mPlayerActive = new TQListViewItem(v, i18n("Player is Active"));
- d->mPlayerRtti = new TQListViewItem(v, i18n("RTTI"));
- d->mPlayerNetworkPriority = new TQListViewItem(v, i18n("Network Priority"));
-}
-
-void KGameDebugDialog::initMessagePage()
-{
- d->mMessagePage = addPage(i18n("Debug &Messages"));
- TQGridLayout* tqlayout = new TQGridLayout(d->mMessagePage, 11, 7, marginHint(), spacingHint());
- d->mMessageList = new KListView(d->mMessagePage);
- tqlayout->addMultiCellWidget(d->mMessageList, 0, 9, 0, 3);
- d->mMessageList->addColumn(i18n("Time"));
- d->mMessageList->addColumn(i18n("ID"));
- d->mMessageList->addColumn(i18n("Receiver"));
- d->mMessageList->addColumn(i18n("Sender"));
- d->mMessageList->addColumn(i18n("ID - Text"));
-
- TQPushButton* hide = new TQPushButton(i18n("&>>"), d->mMessagePage);
- connect(hide, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotHideId()));
- tqlayout->addWidget(hide, 4, 4);
-
- TQPushButton* show = new TQPushButton(i18n("&<<"), d->mMessagePage);
- connect(show, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotShowId()));
- tqlayout->addWidget(show, 6, 4);
-
- TQLabel* l = new TQLabel(i18n("Do not show IDs:"), d->mMessagePage);
- tqlayout->addMultiCellWidget(l, 0, 0, 5, 6);
- d->mHideIdList = new KListBox(d->mMessagePage);
- tqlayout->addMultiCellWidget(d->mHideIdList, 1, 8, 5, 6);
-
- TQPushButton* clear = new KPushButton(KStdGuiItem::clear(), d->mMessagePage);
- connect(clear, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotClearMessages()));
- tqlayout->addMultiCellWidget(clear, 10, 10, 0, 6);
- //TODO: "show all but..." and "show nothing but..."
-}
-
-void KGameDebugDialog::clearPlayerData()
-{
- d->mPlayerAddress->setText(1, "");
- d->mPlayerId->setText(1, "");
- d->mPlayerName->setText(1, "");
- d->mPlayerGroup->setText(1, "");
- d->mPlayerUserId->setText(1, "");
- d->mPlayerMyTurn->setText(1, "");
- d->mPlayerAsyncInput->setText(1, "");
- d->mPlayerKGameAddress->setText(1, "");
- d->mPlayerVirtual->setText(1, "");
- d->mPlayerActive->setText(1, "");
- d->mPlayerRtti->setText(1, "");
- d->mPlayerNetworkPriority->setText(1, "");
-
- d->mPlayerProperties->clear();
-}
-
-void KGameDebugDialog::clearGameData()
-{
- d->mGameAddress->setText(1, "");
- d->mGameId->setText(1, "");
- d->mGameCookie->setText(1, "");
- d->mGameMaster->setText(1, "");
- d->mGameAdmin->setText(1, "");
- d->mGameOffering->setText(1, "");
- d->mGametqStatus->setText(1, "");
- d->mGameRunning->setText(1, "");
- d->mGameMaxPlayers->setText(1, "");
- d->mGameMinPlayers->setText(1, "");
-
- d->mGameProperties->clear();
-}
-
-void KGameDebugDialog::slotUpdatePlayerData()
-{
- if (!d->mGame || d->mPlayerList->currentItem() == -1) {
- return;
- }
- slotUpdatePlayerData(d->mPlayerList->item(d->mPlayerList->currentItem()));
-}
-
-void KGameDebugDialog::slotUpdatePlayerList()
-{
- TQListBoxItem* i = d->mPlayerList->firstItem();
- for (; i; i = d->mPlayerList->firstItem()) {
- removePlayer(i);
- }
-
- TQPtrList<KPlayer> list = *d->mGame->playerList();
- for (KPlayer* p = list.first(); p; p = list.next()) {
- addPlayer(p);
- }
-}
-
-void KGameDebugDialog::slotUpdateGameData()
-{
- if (!d->mGame) {
- d->mGameAddress->setText(1, i18n("NULL pointer"));
- return;
-}
-
- clearGameData();
-
- TQString buf;
- buf.sprintf("%p", d->mGame);
- d->mGameAddress->setText(1, buf);
- d->mGameId->setText(1, TQString::number(d->mGame->gameId()));
- d->mGameCookie->setText(1, TQString::number(d->mGame->cookie()));
- d->mGameMaster->setText(1, d->mGame->isMaster() ? i18n("True") : i18n("False"));
- d->mGameAdmin->setText(1, d->mGame->isAdmin() ? i18n("True") : i18n("False"));
- d->mGameOffering->setText(1, d->mGame->isOfferingConnections() ? i18n("True") : i18n("False"));
- d->mGametqStatus->setText(1, TQString::number(d->mGame->gametqStatus()));
- d->mGameRunning->setText(1, d->mGame->isRunning() ? i18n("True") : i18n("False"));
- d->mGameMaxPlayers->setText(1, TQString::number(d->mGame->maxPlayers()));
- d->mGameMinPlayers->setText(1, TQString::number(d->mGame->minPlayers()));
- d->mGamePlayerCount->setText(1, TQString::number(d->mGame->playerCount()));
-
-//TODO ios
-
- KGamePropertyHandler* handler = d->mGame->dataHandler();
- TQIntDictIterator<KGamePropertyBase> it(handler->dict());
- while (it.current()) {
- TQString policy;
- switch (it.current()->policy()) {
- case KGamePropertyBase::PolicyClean:
- policy = i18n("Clean");
- break;
- case KGamePropertyBase::PolicyDirty:
- policy = i18n("Dirty");
- break;
- case KGamePropertyBase::PolicyLocal:
- policy = i18n("Local");
- break;
- case KGamePropertyBase::PolicyUndefined:
- default:
- policy = i18n("Undefined");
- break;
- }
- (void) new TQListViewItem(d->mGameProperties,
- handler->propertyName(it.current()->id()),
- handler->propertyValue(it.current()),
- policy);
-// kdDebug(11001) << k_funcinfo << ": checking for all game properties: found property name " << name << endl;
- ++it;
- }
-}
-
-void KGameDebugDialog::slotUpdatePlayerData(TQListBoxItem* item)
-{
- if (!item || !d->mGame) {
- return;
- }
-
- KPlayer* p = d->mGame->findPlayer(item->text().toInt());
-
- if (!p) {
- kdError(11001) << k_funcinfo << ": cannot find player" << endl;
- return;
- }
-
- clearPlayerData();
-
- TQString buf;
- buf.sprintf("%p", p);
- d->mPlayerAddress->setText(1, buf);
- d->mPlayerId->setText(1, TQString::number(p->id()));
- d->mPlayerName->setText(1, p->name());
- d->mPlayerGroup->setText(1, p->group());
- d->mPlayerUserId->setText(1, TQString::number(p->userId()));
- d->mPlayerMyTurn->setText(1, p->myTurn() ? i18n("True") : i18n("False"));
- d->mPlayerAsyncInput->setText(1, p->asyncInput() ? i18n("True") : i18n("False"));
- buf.sprintf("%p", p->game());
- d->mPlayerKGameAddress->setText(1, buf);
- d->mPlayerVirtual->setText(1, p->isVirtual() ? i18n("True") : i18n("False"));
- d->mPlayerActive->setText(1, p->isActive() ? i18n("True") : i18n("False"));
- d->mPlayerRtti->setText(1, TQString::number(p->rtti()));
- d->mPlayerNetworkPriority->setText(1, TQString::number(p->networkPriority()));
-
-//TODO ios
-
-// Properties
- KGamePropertyHandler * handler = p->dataHandler();
- TQIntDictIterator<KGamePropertyBase> it((handler->dict()));
- while (it.current()) {
- TQString policy;
- switch (it.current()->policy()) {
- case KGamePropertyBase::PolicyClean:
- policy = i18n("Clean");
- break;
- case KGamePropertyBase::PolicyDirty:
- policy = i18n("Dirty");
- break;
- case KGamePropertyBase::PolicyLocal:
- policy = i18n("Local");
- break;
- case KGamePropertyBase::PolicyUndefined:
- default:
- policy = i18n("Undefined");
- break;
- }
- (void)new TQListViewItem(d->mPlayerProperties,
- handler->propertyName(it.current()->id()),
- handler->propertyValue(it.current()),
- policy);
- ++it;
- }
-}
-
-void KGameDebugDialog::clearPages()
-{
- clearPlayerData();
- clearGameData();
- d->mPlayerList->clear();
- slotClearMessages();
-}
-
-void KGameDebugDialog::setKGame(const KGame* g)
-{
- slotUnsetKGame();
- d->mGame = g;
- if (g) {
- //TODO: connect to the KGame signals for joined/removed players!!!
- connect(d->mGame, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotUnsetKGame()));
-// connect();
-
- TQPtrList<KPlayer> list = *d->mGame->playerList();
- for (KPlayer* p = list.first(); p; p = list.next()) {
- addPlayer(p);
- }
-
- slotUpdateGameData();
-
- connect(d->mGame, TQT_SIGNAL(signalMessageUpdate(int, TQ_UINT32, TQ_UINT32)), this, TQT_SLOT(slotMessageUpdate(int, TQ_UINT32, TQ_UINT32)));
- }
-}
-
-void KGameDebugDialog::slotUnsetKGame()
-{
- if (d->mGame) {
- disconnect(d->mGame, 0, this, 0);
- }
- d->mGame = 0;
- clearPages();
-}
-
-void KGameDebugDialog::addPlayer(KPlayer* p)
-{
- if (!p) {
- kdError(11001) << "trying to add NULL player" << endl;
- return;
- }
-
- (void) new TQListBoxText(d->mPlayerList, TQString::number(p->id()));
- //TODO connect to signals, like deleted/removed, ...
-}
-
-void KGameDebugDialog::removePlayer(TQListBoxItem* i)
-{
- if (!i || !d->mGame) {
- return;
- }
- KPlayer* p = d->mGame->findPlayer(i->text().toInt());
- if (!p) {
- return;
- }
- disconnect(p, 0, this, 0);
- if (i->isSelected()) {
- clearPlayerData();
- }
- delete i;
-}
-
-void KGameDebugDialog::slotMessageUpdate(int msgid, TQ_UINT32 receiver, TQ_UINT32 sender)
-{
- if (!showId(msgid)) {
- return;
- }
- TQString msgidText = KGameMessage::messageId2Text(msgid);
- if (msgidText.isNull()) {
- if (msgid > KGameMessage::IdUser) {
- emit signalRequestIdName(msgid-KGameMessage::IdUser, true, msgidText);
- } else {
- emit signalRequestIdName(msgid, false, msgidText);
- }
- if (msgidText.isNull()) {
- msgidText = i18n("Unknown");
- }
- }
- (void) new TQListViewItem( d->mMessageList, TQTime::currentTime().toString(),
- TQString::number(msgid), TQString::number(receiver),
- TQString::number(sender), msgidText);
-}
-
-void KGameDebugDialog::slotClearMessages()
-{
- d->mMessageList->clear();
-}
-
-void KGameDebugDialog::slotShowId()
-{
-/* TQListBoxItem* i = d->mHideIdList->firstItem();
- for (; i; i = i->next()) {
- if (i->selected()) {
- d->mHideIdList->removeItem(i->);
- }
- }*/
- if (!d->mHideIdList->currentItem()) {
- return;
- }
- d->mHideIdList->removeItem(d->mHideIdList->currentItem());
-}
-
-void KGameDebugDialog::slotHideId()
-{
- if (!d->mMessageList->currentItem()) {
- return;
- }
- int msgid = d->mMessageList->currentItem()->text(1).toInt();
- if (!showId(msgid)) {
- return;
- }
- (void)new TQListBoxText(d->mHideIdList, TQString::number(msgid));
-}
-
-bool KGameDebugDialog::showId(int msgid)
-{
- TQListBoxItem* i = d->mHideIdList->firstItem();
- for (; i; i = i->next()) {
- if (i->text().toInt() == msgid) {
- return false;
- }
- }
- return true;
-}
-
-
-#include "kgamedebugdialog.moc"
diff --git a/libkdegames/kgame/dialogs/kgamedebugdialog.h b/libkdegames/kgame/dialogs/kgamedebugdialog.h
deleted file mode 100644
index 92b35597..00000000
--- a/libkdegames/kgame/dialogs/kgamedebugdialog.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef __KGAMEDEBUGDIALOG_H__
-#define __KGAMEDEBUGDIALOG_H__
-
-#include <kdialogbase.h>
-#include <kdemacros.h>
-
-class KGame;
-class KGameIO;
-class KPlayer;
-class KGamePropertyBase;
-
-class KGameDebugDialogPrivate;
-
-class KDE_EXPORT KGameDebugDialog : public KDialogBase
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDebugDialog(KGame* g, TQWidget* parent, bool modal = false);
- ~KGameDebugDialog();
-
- /**
- * Automatically connects the KGame object to all error dependant slots.
- * Create a KGameErrorDialog object, call this function and forget
- * everything.
- * @param g The KGame which will emit the erorrs (or not ;-) )
- **/
- void setKGame(const KGame* g);
-
-public slots:
- /**
- * Unsets a @ref KGame which has been set using @ref setKGame before.
- * This is called automatically when the @ref KGame object is destroyed
- * and you normally don't have to call this yourself.
- *
- * Note that @ref setKGame also unsets an already existing @ref KGame
- * object if exising.
- **/
- void slotUnsetKGame();
-
- /**
- * Update the data of the @ref KGame object
- **/
- void slotUpdateGameData();
-
- /**
- * Update the properties of the currently selected player
- **/
- void slotUpdatePlayerData();
-
- /**
- * Updates the list of players and calls @ref clearPlayerData. Note that
- * after this call NO player is selected anymore.
- **/
- void slotUpdatePlayerList();
-
- void slotClearMessages();
-
-signals:
- /**
- * This signal is emitted when the "debug messages" page couldn't find
- * the name of a message id. This is usually the case for user-defined
- * messages. KGameDebugDialog asks you to give the msgid a name.
- * @param messageid The ID of the message. As given to @ref
- * KGame::sendMessage
- * @param userid User defined msgIds are internally increased by
- * @ref KGameMessage::IdUser. You don't have to care about this but if
- * this signal is emitted with userid=false (shouldn't happen) then the
- * name of an internal message as defined in @ref
- * KGameMessage::GameMessageIds couldn't be found.
- * @param name The name of the msgid. You have to fill this!
- **/
- void signalRequestIdName(int messageid, bool userid, TQString& name);
-
-protected:
- void clearPages();
-
- /**
- * Clear the data of the player view. Note that the player list is NOT
- * cleared.
- **/
- void clearPlayerData();
-
- /**
- * Clear the data view of the @ref KGame object
- **/
- void clearGameData();
-
- /**
- * Add a new player to the player list
- **/
- void addPlayer(KPlayer* p);
-
- /**
- * Remove a player from the list
- **/
- void removePlayer(TQListBoxItem* item);
-
- /**
- * @return Whether messages with this msgid shall be displayed or not
- **/
- bool showId(int msgid);
-
-protected slots:
- /**
- * Update the data of the player specified in item
- * @param item The @ref TQListBoxItem of the player to be updated. Note
- * that the text of this item MUST be the ID of the player
- **/
- void slotUpdatePlayerData(TQListBoxItem* item);
-
- void slotShowId();
- void slotHideId();
-
- /**
- * A message has been received - see @ref KGame::signalMessageUpdate
- **/
- void slotMessageUpdate(int msgid, TQ_UINT32 receiver, TQ_UINT32 sender);
-
-private:
- void initGamePage();
- void initPlayerPage();
- void initMessagePage();
-
-private:
- KGameDebugDialogPrivate* d;
-};
-
-
-#endif
diff --git a/libkdegames/kgame/dialogs/kgamedialog.cpp b/libkdegames/kgame/dialogs/kgamedialog.cpp
deleted file mode 100644
index c03df4ff..00000000
--- a/libkdegames/kgame/dialogs/kgamedialog.cpp
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <tqlayout.h>
-#include <tqvbox.h>
-
-#include <klocale.h>
-
-#include "kgame.h"
-#include "kplayer.h"
-#include "kgamedialogconfig.h"
-
-#include "kgamedialog.h"
-
-#include "kgamedialog.moc"
-
-class KGameDialogPrivate
-{
-public:
- KGameDialogPrivate()
- {
- mGamePage = 0;
- mNetworkPage = 0;
- mMsgServerPage = 0;
- mTopLayout = 0;
-
- mNetworkConfig = 0;
- mGameConfig = 0;
-
- mOwner = 0;
- mGame = 0;
- }
-
- TQVBox* mGamePage;
- TQVBox* mNetworkPage;
- TQVBox* mMsgServerPage;// unused here?
- TQVBoxLayout* mTopLayout;
- KGameDialogNetworkConfig* mNetworkConfig;
- KGameDialogGeneralConfig* mGameConfig;
-
-// a list of all config widgets added to this dialog
- TQPtrList<KGameDialogConfig> mConfigWidgets;
-
-// just pointers:
- KPlayer* mOwner;
- KGame* mGame;
-};
-
-KGameDialog::KGameDialog(KGame* g, KPlayer* owner, const TQString& title,
- TQWidget* parent, bool modal)
- : KDialogBase(Tabbed, title, Ok|Default|Apply,
- Ok, parent, 0, modal, true)
-{
- init(g, owner);
-}
-
-KGameDialog::KGameDialog(KGame* g, KPlayer* owner, const TQString& title,
- TQWidget* parent, long initConfigs, int chatMsgId, bool modal)
- : KDialogBase(Tabbed, title, Ok|Default|Apply,
- Ok, parent, 0, modal, true)
-{
- init(g, owner);
- if ((ConfigOptions)initConfigs!=NoConfig) {
- initDefaultDialog((ConfigOptions)initConfigs, chatMsgId);
- }
-}
-
-void KGameDialog::init(KGame* g, KPlayer* owner)
-{
-//AB: do we need a "Cancel" Button? currently removed
-
-// kdDebug(11001) << k_funcinfo << ": this=" << this << endl;
- d = new KGameDialogPrivate;
-
- setOwner(owner);
- setKGame(g);
- if (g) {
- setAdmin(g->isAdmin());
- } else {
- setAdmin(false);
- }
-}
-
-void KGameDialog::initDefaultDialog(ConfigOptions initConfigs, int chatMsgId)
-{
- if (initConfigs & GameConfig) {
- kdDebug() << "add gameconf" << endl;
- addGameConfig(new KGameDialogGeneralConfig(0));
- }
- if (initConfigs & NetworkConfig) {
- addNetworkConfig(new KGameDialogNetworkConfig(0));
- }
- if (initConfigs & (MsgServerConfig) ) {
- addMsgServerConfig(new KGameDialogMsgServerConfig(0));
- }
- if (initConfigs & ChatConfig) {
- KGameDialogChatConfig * c = new KGameDialogChatConfig(chatMsgId, 0);
- if (d->mGamePage) {
- addChatWidget(c, d->mGamePage);
- } else {
- addConfigPage(c, i18n("&Chat"));
- }
- }
- if (initConfigs & BanPlayerConfig) {
- // add the connection management system - ie the widget where the ADMIN can
- // kick players out
- if (d->mNetworkPage) {
- // put it on the network page
- addConnectionList(new KGameDialogConnectionConfig(0), d->mNetworkPage);
- } else {
- // if no network page available put it on an own page
- addConfigPage(new KGameDialogConnectionConfig(0), i18n("C&onnections"));
- }
- }
-}
-
-KGameDialog::~KGameDialog()
-{
-// kdDebug(11001) << "DESTRUCT KGameDialog" << this << endl;
- d->mConfigWidgets.setAutoDelete(true);
- d->mConfigWidgets.clear();
- delete d;
-}
-
-void KGameDialog::addGameConfig(KGameDialogGeneralConfig* conf)
-{
- if (!conf) {
- return;
- }
- d->mGameConfig = conf;
- d->mGamePage = addConfigPage(d->mGameConfig, i18n("&Game"));
-}
-
-void KGameDialog::addNetworkConfig(KGameDialogNetworkConfig* netConf)
-{
- if (!netConf) {
- return;
- }
- d->mNetworkConfig = netConf;
- d->mNetworkPage = addConfigPage(netConf, i18n("&Network"));
-}
-
-void KGameDialog::addMsgServerConfig(KGameDialogMsgServerConfig* msgConf)
-{
- if (!msgConf) {
- return;
- }
- d->mMsgServerPage = addConfigPage(msgConf, i18n("&Message Server"));
-}
-
-void KGameDialog::addChatWidget(KGameDialogChatConfig* chat, TQVBox* parent)
-{
- if (!chat) {
- return;
- }
- if (!parent) {
- parent = d->mGamePage;
- }
- if (!parent) {
- kdError(11001) << "cannot add chat widget without page" << endl;
- return;
- }
- addConfigWidget(chat, parent);
-}
-
-void KGameDialog::addConnectionList(KGameDialogConnectionConfig* c, TQVBox* parent)
-{
- if (!c) {
- return;
- }
- if (!parent) {
- parent = d->mNetworkPage;
- }
- if (!parent) {
- kdError(11001) << "Cannot add connection list without page" << endl;
- return;
- }
- addConfigWidget(c, parent);
-}
-
-TQVBox *KGameDialog::configPage(ConfigOptions which)
-{
- TQVBox *box = 0;
- switch(which)
- {
- case NetworkConfig:
- box = d->mNetworkPage;
- break;
- case GameConfig:
- box = d->mGamePage;
- break;
- case MsgServerConfig:
- box = d->mMsgServerPage;
- break;
- default:
- kdError(11001) << k_funcinfo << ": Parameter " << which << " not supported" << endl;
- }
- return box;
-}
-
-TQVBox* KGameDialog::addConfigPage(KGameDialogConfig* widget, const TQString& title)
-{
- if (!widget) {
- kdError(11001) << "Cannot add NULL config widget" << endl;
- return 0;
- }
- TQVBox* page = addVBoxPage(title);
- addConfigWidget(widget, page);
- return page;
-}
-
-void KGameDialog::addConfigWidget(KGameDialogConfig* widget, TQWidget* parent)
-{
- if (!widget) {
- kdError(11001) << "Cannot add NULL config widget" << endl;
- return;
- }
- if (!parent) {
- kdError(11001) << "Cannot reparent to NULL widget" << endl;
- return;
- }
-// kdDebug(11001) << "reparenting widget" << endl;
- widget->reparent(parent, TQPoint(0,0));
- d->mConfigWidgets.append(widget);
- connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(slotRemoveConfigWidget(TQObject*)));
- if (!d->mGame) {
- kdWarning(11001) << "No game has been set!" << endl;
- } else {
- widget->setKGame(d->mGame);
- widget->setAdmin(d->mGame->isAdmin());
- }
- if (!d->mOwner) {
- kdWarning(11001) << "No player has been set!" << endl;
- } else {
- widget->setOwner(d->mOwner);
- }
- widget->show();
-}
-
-KGameDialogGeneralConfig* KGameDialog::gameConfig() const
-{ return d->mGameConfig; }
-KGameDialogNetworkConfig* KGameDialog::networkConfig() const
-{ return d->mNetworkConfig; }
-
-void KGameDialog::slotApply()
-{
- submitToKGame();
-}
-
-void KGameDialog::slotDefault()
-{
- if (!d->mGame) {
- return;
- }
-
-//TODO *only* call setKGame/setOwner for the *current* page!!
- setKGame(d->mGame);
- setOwner(d->mOwner);
-}
-
-void KGameDialog::slotOk()
-{
- slotApply();
- TQDialog::accept();
-}
-
-void KGameDialog::setOwner(KPlayer* owner)
-{
-//AB: note: NULL player is ok!
- d->mOwner = owner;
- for (int unsigned i = 0; i < d->mConfigWidgets.count(); i++) {
- if (d->mConfigWidgets.at(i)) {
- d->mConfigWidgets.at(i)->setOwner(d->mOwner);
- //TODO: hide playerName in KGameDialogGeneralConfig
- } else {
- kdError(11001) << "NULL widget??" << endl;
- }
- }
-}
-
-void KGameDialog::setKGame(KGame* g)
-{
- if (d->mGame) {
- disconnect(d->mGame, 0, this, 0);
- }
- d->mGame = g;
- for (int unsigned i = 0; i < d->mConfigWidgets.count(); i++) {
- d->mConfigWidgets.at(i)->setKGame(d->mGame);
- }
- if (d->mGame) {
- setAdmin(d->mGame->isAdmin());
- connect(d->mGame, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotUnsetKGame()));
- connect(d->mGame, TQT_SIGNAL(signalAdminStatusChanged(bool)),
- this, TQT_SLOT(setAdmin(bool)));
- }
-}
-
-void KGameDialog::setAdmin(bool admin)
-{
- for (int unsigned i = 0; i < d->mConfigWidgets.count(); i++) {
- d->mConfigWidgets.at(i)->setAdmin(admin);
- }
-}
-
-void KGameDialog::slotUnsetKGame() // called when KGame is destroyed
-{ setKGame(0); }
-
-void KGameDialog::submitToKGame()
-{
- if (!d->mGame) {
- kdError(11001) << k_funcinfo << ": no game has been set" << endl;
- return;
- }
- if (!d->mOwner) {
- kdError(11001) << k_funcinfo << ": no player has been set" << endl;
- return;
- }
-
- for (int unsigned i = 0; i < d->mConfigWidgets.count(); i++) {
-// kdDebug(11001) << "submit to kgame " << i << endl;
- d->mConfigWidgets.at(i)->submitToKGame(d->mGame, d->mOwner);
-// kdDebug(11001) << "done: submit to kgame " << i << endl;
- }
-}
-
-void KGameDialog::slotRemoveConfigWidget(TQObject* configWidget)
-{
- d->mConfigWidgets.removeRef((KGameDialogConfig*)configWidget);
-}
-
diff --git a/libkdegames/kgame/dialogs/kgamedialog.h b/libkdegames/kgame/dialogs/kgamedialog.h
deleted file mode 100644
index 423f5de1..00000000
--- a/libkdegames/kgame/dialogs/kgamedialog.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-// NAMING
-// please follow these naming rules if you add/change classes:
-// the main dialog is named KGameDialog and the base config widget
-// KGameDialogConfig. All config widgets are named KGameDialogXYZConfig (where
-// XYZ = the name of the config widget, like "general" or "network") and are
-// inherited from KGameDialogConfig.
-
-#ifndef __KGAMEDIALOG_H__
-#define __KGAMEDIALOG_H__
-
-#include <kdialogbase.h>
-#include <kdemacros.h>
-class TQGridLayout;
-class TQVBoxLayout;
-class TQListBoxItem;
-
-class KGame;
-class KPlayer;
-class KGamePropertyBase;
-
-class KGameDialogConfig;
-class KGameDialogGeneralConfig;
-class KGameDialogNetworkConfig;
-class KGameDialogMsgServerConfig;
-class KGameDialogChatConfig;
-class KGameDialogConnectionConfig;
-
-class KGameDialogPrivate;
-/**
- * TODO: rewrite entire documentation. Nearly nothing is valid anymore.
- * The main configuration dialog for KGame. Here all players meat each other,
- * every player can see how many players connected (and their names) and the
- * ADMIN can even "kick" players out. You can talk to each other (using
- * KGameChat and the ADMIN can define the maxPlayers/minPlayers as well as the
- * number of computer players.
- *
- *
- * AB: setDefaultXYZ is obsolete!!
- * You will usually create an instance of KGameDialog or any derived class and
- * call setDefaultXYZ methods. Example (maybe
- * obsoleted parameters - docu is currently changing very fast):
- * \code
- * KGameDialog dlg(kgame, i18n("New Game"), localPlayer, this, true,
- * ID_CHAT);
- * dlg.setDefaultNetworkInfo(port, host); // AB: obsolete!
- * dlg.exec();
- * \endcode
- * This will create a default modal dialog with the title "New Game". You don't
- * have to do more than this.
- *
- * @short Main configuration dialog for KGame
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KDE_EXPORT KGameDialog : public KDialogBase
-{
- Q_OBJECT
- TQ_OBJECT
-public:
-
- enum ConfigOptions
- {
- NoConfig = 0,
- ChatConfig = 1,
- GameConfig = 2,
- NetworkConfig = 4,
- MsgServerConfig = 8,
- BanPlayerConfig = 16,
- AllConfig = 0xffff
- };
-
- /**
- * Create an empty KGameDialog. You can add widgets using
- * addConfigPage.
- * @param g The KGame object of this game
- * @param owner The KPlayer object who is responsible for this
- * dialog, aka "the local player"
- * @param title The title of the dialog - see KDialog::setCaption
- * @param parent The parent of the dialog
- * @param modal Whether the dialog is modal or not
- **/
- KGameDialog(KGame* g, KPlayer* owner, const TQString& title,
- TQWidget* parent, bool modal = false);
-
- /**
- * Create a KGameDialog with the standard configuration widgets. This
- * creates the following widgets:
- * <ul>
- * <li> KGameDialogGeneralConfig
- * <li> KGameDialogNetworkConfig
- * <li> KGameDialogMsgServerConfig
- * <li> KGameDialogChatConfig
- * <li> KGameDialogConnectionConfig
- * </ul>
- * If you want to use your own implementations (or none) of the widgets
- * above you should subclass KGameDialog. Use addGameConfig,
- * addNetworkConfig, addMsgConfig, addChatWidget and
- * addConnectionList in this case.
- *
- * If you want to add further configuration widget you can simply use
- * addConfigPage
- * @param g The KGame object of this game
- * @param owner The KPlayer object who is responsible for this
- * dialog, aka "the local player"
- * @param title The title of the dialog - see KDialog::setCaption
- * @param parent The parent of the dialog
- * @param modal Whether the dialog is modal or not
- * @param initConfigs whether the default KGameDialogConfig widgets
- * shall be created using initDefaultDialog. Use false if you want
- * to use custom widgets.
- * @param chatMsgId The ID of Chat messages. See KGameChat. Unused
- * if initConfigs = false
- **/
- KGameDialog(KGame* g, KPlayer* owner, const TQString& title,
- TQWidget* parent, long initConfigs = AllConfig,
- int chatMsgId = 15432, bool modal = false);
-
- virtual ~KGameDialog();
-
-
- /**
- * Change the owner of the dialog. This will be used as the fromPlayer in
- * KGameChat and will receive the entered player name.
- * @param owner The owner of the dialog. It must already be added to the
- * KGame object!
- *
- * Calls the KGameDialogConfig::setOwner implementation of all
- * widgets that have been added by addConfigWidget
- * @param owner The new owner player of this dialog must already be
- * added to the KGame object. Can even be NULL (then no player
- * configuration is made)
- **/
- void setOwner(KPlayer* owner);
-
- /**
- * Change the KGame object this dialog is used for.
- *
- * Calls the KGameDialogConfig::setKGame implementation of all
- * widgets that have been added by addConfigWidget
- * @param g The new KGame object
- **/
- void setKGame(KGame* g);
-
- /**
- * This will submit all configuration data to the KGame object.
- * Automatically called by slotApply and slotOk
- * There is no need to replace this unless you
- * want to add widgets which are not derived from those classes
- **/
- virtual void submitToKGame();
-
- /**
- * Adds a KGameChat to the dialog. If no parent is specified the
- * game page will be used.
- * @param chat The chat widget
- * @param parent The parent of the chat widget. This MUST be an
- * already added config widget. Note that the game page will be used
- * if parent is 0.
- **/
- void addChatWidget(KGameDialogChatConfig* chat, TQVBox* parent = 0);
-
- /**
- * Add a connection list to the dialog. The list consists of a
- * KLisBox containing all players in the current game (see
- * KGame::playerList). The admin can "ban" players, ie kick them out of
- * the game.
- *
- * This is another not-really-config-config-widget. It just displays the
- * connections and lets you ban players.
- * @param c The KGameDialogConnectionConfig object
- * @param parent The parent of the widget. If 0 the networkConfig
- * page is used.
- **/
- void addConnectionList(KGameDialogConnectionConfig* c, TQVBox* parent = 0);
-
- /**
- * Add a new page to the dialog. The page will contain you new config
- * widget and will have your provided title.
- *
- * The widget will be reparented to this dialog. This also calls
- * KGameDialogConfig::setKGame and KGameDialogConfig::setOwner.
- * @param widget The new config widget
- * @param title The title of the newly added page.
- * @return The newly added page which contains your config widget.
- **/
- TQVBox* addConfigPage(KGameDialogConfig* widget, const TQString& title);
-
- /**
- * @return The TQVBox of the given key, The key is from ConfigOptions
- * Note that not all are supported yet
- **/
- TQVBox *configPage(ConfigOptions which);
-
- /**
- * @return The default netowrk config. Note that this always returns 0 if
- * you did not specify NetworkConfig in the constructor!
- **/
- KGameDialogNetworkConfig* networkConfig() const;
-
- /**
- * @return The default game config. Note that this always returns 0 if
- * you did not specify GameConfig in the constructor!
- **/
- KGameDialogGeneralConfig* gameConfig() const;
-
- /**
- * Add a config widget to the specified parent. Usually you call
- * addConfigPage for one widget and addConfigWidget for another to add
- * it to the same page. Just use the returned page of
- * addConfigPage.
- **/
- void addConfigWidget(KGameDialogConfig* widget, TQWidget* parent);
-
- /**
- * Used to add the main network config widget in a new page. Use this to
- * make networkConfig return something useful.
- **/
- void addNetworkConfig(KGameDialogNetworkConfig* netConf);
-
- /**
- * Add the main game config widget in a new page. Use this to make
- * gameConfig return something useful.
- **/
- void addGameConfig(KGameDialogGeneralConfig* conf);
-
- /**
- * Used to add the message server config widget in a new page.
- **/
- void addMsgServerConfig(KGameDialogMsgServerConfig* conf);
-
-protected:
-
- /**
- * This is used to create a dialog containing all the default widgets.
- *
- * You may want to use this if you just want to use your own
- * configuration widgets which inherit the standard ones.
- *
- * Note that if one of the widgets is NULL the default implementation
- * will be used! (except the chat widget - you need to create it
- * yourself as you have to provide a message id)
- * @param initConfigs The widgets to be created
- * @param chatMsgId The msgid for the chat config (only if specified in
- * initConfigs) - see KGameDialogChatConfig
- **/
- void initDefaultDialog(ConfigOptions initConfigs, int chatMsgId = 15432);
-
- /**
- * Go through all config widgets and call their
- * KGameDialogConfig::setKGame and KGameDialogConfig::setOwner implementation
- *
- * This function could be private and probably will be very soon.
- * Don't use it yourself
- **/
- void configureConfigWidgets();
-
-protected slots:
- /**
- * Called when the user clicks on Ok. Calls slotApply and
- * TQDialog::accept()
- **/
- virtual void slotOk();
-
- /**
- * Just calls submitToKGame()
- **/
- virtual void slotApply();
-
- /**
- * Sets the default values for the configuration widgets. Set these
- * values by (e.g.) setDefaultMaxPlayers()
- * @deprecated
- **/
- virtual void slotDefault();
-
- /**
- * Called when the KGame object is destroyed. Calls setKGame(0) so
- * that all widgets can disconnect their slots and so on.
- **/
- void slotUnsetKGame();
-
- /**
- * Called when the ADMIN status of this KGame client changes. See
- * KGameNetwork::signalAdminStatusChanged
- * @param isAdmin TRUE if this client is now the ADMIN otherwise FALSE
- **/
- void setAdmin(bool isAdmin);
-
- /**
- * Remove a config widget from the widget list.
- * @see TQObject::destroyed
- **/
- void slotRemoveConfigWidget(TQObject* configWidget);
-
-private:
- void init(KGame*, KPlayer*);
-
-private:
- KGameDialogPrivate* d;
-};
-
-#endif
diff --git a/libkdegames/kgame/dialogs/kgamedialogconfig.cpp b/libkdegames/kgame/dialogs/kgamedialogconfig.cpp
deleted file mode 100644
index f6845650..00000000
--- a/libkdegames/kgame/dialogs/kgamedialogconfig.cpp
+++ /dev/null
@@ -1,773 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "kgamedialogconfig.h"
-
-#include "kgame.h"
-#include "kplayer.h"
-#include "kgamechat.h"
-#include "kgameconnectdialog.h"
-
-#include <klocale.h>
-#include <knuminput.h>
-#include <kdialog.h>
-#include <klistbox.h>
-#include <kmessagebox.h>
-
-#include <tqlayout.h>
-#include <tqhgroupbox.h>
-#include <tqlabel.h>
-#include <tqpushbutton.h>
-#include <tqlineedit.h>
-#include <tqvbox.h>
-#include <tqptrdict.h>
-
-#include "kgamedialogconfig.moc"
-
-class KGameDialogConfigPrivate
-{
-public:
- KGameDialogConfigPrivate()
- {
- mOwner = 0;
- mGame = 0;
-
- mAdmin = false;
- }
-
- bool mAdmin;
- KGame* mGame;
- KPlayer* mOwner;
-};
-
-KGameDialogConfig::KGameDialogConfig(TQWidget* parent) : TQWidget(parent)
-{
- d = new KGameDialogConfigPrivate;
-}
-
-KGameDialogConfig::~KGameDialogConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- delete d;
-}
-
-void KGameDialogConfig::setKGame(KGame* g)
-{
- d->mGame = g;
-}
-
-void KGameDialogConfig::setOwner(KPlayer* p)
-{
- d->mOwner = p;
-}
-
-void KGameDialogConfig::setAdmin(bool a)
-{
- d->mAdmin = a;
-}
-
-KGame* KGameDialogConfig::game() const
-{ return d->mGame; }
-bool KGameDialogConfig::admin() const
-{ return d->mAdmin; }
-KPlayer* KGameDialogConfig::owner() const
-{ return d->mOwner; }
-
-/////////////////////////// KGameDialogNetworkConfig /////////////////////////
-class KGameDialogNetworkConfigPrivate
-{
-public:
- KGameDialogNetworkConfigPrivate()
- {
- mInitConnection = 0;
- mNetworkLabel = 0;
- mDisconnectButton = 0;
- mConnect = 0;
- mDefaultServer=true;
-
- }
-
- // TQPushButton* mInitConnection;
- TQHGroupBox* mInitConnection;
- TQLabel* mNetworkLabel;
- TQPushButton *mDisconnectButton;
-
- bool mDefaultServer;
- TQString mDefaultHost;
- unsigned short int mDefaultPort;
- KGameConnectWidget *mConnect;
-};
-
-
-KGameDialogNetworkConfig::KGameDialogNetworkConfig(TQWidget* parent)
- : KGameDialogConfig(parent)
-{
-// kdDebug(11001) << k_funcinfo << ": this=" << this << endl;
- d = new KGameDialogNetworkConfigPrivate();
-
- TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint(), "toptqlayout");
-
- TQHBoxLayout *hb = new TQHBoxLayout(topLayout, KDialog::spacingHint());
-
- d->mNetworkLabel = new TQLabel(this);
- hb->addWidget(d->mNetworkLabel);
-
- d->mDisconnectButton=new TQPushButton(i18n("Disconnect"),this);
- connect(d->mDisconnectButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotExitConnection()));
- hb->addWidget(d->mDisconnectButton);
-
- d->mInitConnection = new TQHGroupBox(i18n("Network Configuration"), this);
- topLayout->addWidget(d->mInitConnection);
-
- d->mConnect = new KGameConnectWidget(d->mInitConnection);
- connect(d->mConnect, TQT_SIGNAL(signalNetworkSetup()), this, TQT_SLOT(slotInitConnection()));
- connect(d->mConnect, TQT_SIGNAL(signalServerTypeChanged(int)),
- this, TQT_SIGNAL(signalServerTypeChanged(int)));
-
- // Needs to be AFTER the creation of the dialogs
- setConnected(false);
- setDefaultNetworkInfo("localhost", 7654,true);
-}
-
-KGameDialogNetworkConfig::~KGameDialogNetworkConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- delete d;
-}
-
-void KGameDialogNetworkConfig::slotExitConnection()
-{
- kdDebug(11001) << k_funcinfo << " !!!!!!!!!!!!!!!!!!!!!!!" << endl;
- if (game()) game()->disconnect();
- setConnected(false,false);
-}
-
-void KGameDialogNetworkConfig::slotInitConnection()
-{
- kdDebug(11001) << k_funcinfo << endl;
- bool connected = false;
- bool master = true;
- unsigned short int port = d->mConnect->port();
- TQString host = d->mConnect->host();
-
- if (host.isNull()) {
- master = true;
- if (game()) {
- game()->setDiscoveryInfo(d->mConnect->type(),d->mConnect->gameName());
- connected = game()->offerConnections(port);
- }
- } else {
- master = false;
- if (game()) {
- connected = game()->connectToServer(host, port);
- }
- // We need to learn about failed connections
- if (game()) {
- connect(game(), TQT_SIGNAL(signalConnectionBroken()),
- this, TQT_SLOT(slotConnectionBroken()));
- }
- }
- setConnected(connected, master);
-}
-
-void KGameDialogNetworkConfig::slotConnectionBroken()
-{
- kdDebug(11001) << k_funcinfo << endl;
- setConnected(false,false);
- KMessageBox::error(this, i18n("Cannot connect to the network"));
-}
-
-void KGameDialogNetworkConfig::setConnected(bool connected, bool master)
-{
- if (!connected) {
- d->mNetworkLabel->setText(i18n("Network status: No Network"));
- d->mInitConnection->setEnabled(true);
- d->mDisconnectButton->setEnabled(false);
- return;
- }
- if (master) {
- d->mNetworkLabel->setText(i18n("Network status: You are MASTER"));
- } else {
- d->mNetworkLabel->setText(i18n("Network status: You are connected"));
- }
- d->mInitConnection->setEnabled(false);
- d->mDisconnectButton->setEnabled(true);
-}
-
-void KGameDialogNetworkConfig::submitToKGame(KGame* , KPlayer* )
-{
-}
-
-void KGameDialogNetworkConfig::setKGame(KGame* g)
-{
- KGameDialogConfig::setKGame(g);
- if (!game()) {
- setConnected(false);
- return;
- }
- setConnected(game()->isNetwork(), game()->isMaster());
-}
-
-void KGameDialogNetworkConfig::setDefaultNetworkInfo(const TQString& host, unsigned short int port,bool server)
-{
- d->mDefaultPort = port;
- d->mDefaultHost = host;
- d->mDefaultServer = server;
-
- d->mConnect->setHost(host);
- d->mConnect->setPort(port);
- if (server) {
- d->mConnect->setDefault(0);
- } else {
- d->mConnect->setDefault(1);
- }
-}
-
-void KGameDialogNetworkConfig::setDiscoveryInfo(const TQString& type, const TQString& name)
-{
- d->mConnect->setType(type);
- d->mConnect->setName(name);
-}
-
-/////////////////////////// KGameDialogGeneralConfig /////////////////////////
-class KGameDialogGeneralConfigPrivate
-{
-public:
- KGameDialogGeneralConfigPrivate()
- {
- mTopLayout = 0;
- mName = 0;
- }
-
- TQLineEdit* mName;
-
- TQVBoxLayout* mTopLayout;
-};
-
-KGameDialogGeneralConfig::KGameDialogGeneralConfig(TQWidget* parent, bool initializeGUI)
- : KGameDialogConfig(parent)
-{
-// kdDebug(11001) << k_funcinfo << ": this=" << this << endl;
- d = new KGameDialogGeneralConfigPrivate;
-
- if (initializeGUI) {
- d->mTopLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
- d->mTopLayout->setAutoAdd(true);
-
- TQWidget* nameWidget = new TQWidget(this);
- TQHBoxLayout* l = new TQHBoxLayout(nameWidget);
- TQLabel* nameLabel = new TQLabel(i18n("Your name:"), nameWidget);
- l->addWidget(nameLabel);
- d->mName = new TQLineEdit(nameWidget);
- l->addWidget(d->mName);
- }
-}
-
-KGameDialogGeneralConfig::~KGameDialogGeneralConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- delete d;
-}
-
-void KGameDialogGeneralConfig::setPlayerName(const TQString& name)
-{
- if (d->mName) {
- d->mName->setText(name);
- }
-}
-
-TQString KGameDialogGeneralConfig::playerName() const
-{
- return d->mName ? d->mName->text() : TQString();
-}
-
-void KGameDialogGeneralConfig::setOwner(KPlayer* p)
-{
- if (owner()) {
- owner()->disconnect(this);
- }
- KGameDialogConfig::setOwner(p);
- if (!owner()) {
- // can this config be used at all?
- // maybe call hide()
- return;
- }
- connect(owner(), TQT_SIGNAL(signalPropertyChanged(KGamePropertyBase*, KPlayer*)),
- this, TQT_SLOT(slotPropertyChanged(KGamePropertyBase*, KPlayer*)));
- setPlayerName(p->name());
- //TODO: connect signalPropertyChanged and check for playername changes!
-}
-
-void KGameDialogGeneralConfig::setKGame(KGame* g)
-{
- KGameDialogConfig::setKGame(g);
- if (!g) {
- // TODO
- // can this config be used at all?
- // maybe call hide()
- return;
- }
-}
-
-void KGameDialogGeneralConfig::setAdmin(bool admin)
-{
- KGameDialogConfig::setAdmin(admin);
-// enable/disable widgets
-
-}
-
-void KGameDialogGeneralConfig::submitToKGame(KGame* g, KPlayer* p)
-{
-//FIXME
- if (p) {
- p->setName(playerName());
- }
- if (g) {
- }
-}
-
-void KGameDialogGeneralConfig::slotPropertyChanged(KGamePropertyBase* prop, KPlayer* p)
-{
- if (!prop || !p || p != owner()) {
- return;
- }
- switch (prop->id()) {
- case KGamePropertyBase::IdName:
- setPlayerName(p->name());
- break;
- default:
- break;
- }
-}
-
-class KGameDialogMsgServerConfigPrivate
-{
-public:
- KGameDialogMsgServerConfigPrivate()
- {
- senderLayout = 0;
- localLayout = 0;
-
- changeMaxClients = 0;
- changeAdmin= 0;
- removeClient= 0;
- noAdmin = 0;
-
- noMaster = 0;
- }
-
- TQVBoxLayout* senderLayout;
- TQHBoxLayout* localLayout;
-
- TQPushButton* changeMaxClients;
- TQPushButton* changeAdmin;
- TQPushButton* removeClient;
- TQLabel* noAdmin;
-
- TQLabel* noMaster;
-};
-
-
-// TODO: change ADMIN ID, remove CLIENTS, change MAXCLIENTS
-// we do everything here with TQPushButtons as we want to wait a moment before
-// continuing - the message must be sent over network first
-KGameDialogMsgServerConfig::KGameDialogMsgServerConfig(TQWidget* parent)
- : KGameDialogConfig(parent)
-{
- d = new KGameDialogMsgServerConfigPrivate;
-
- TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
- d->senderLayout = new TQVBoxLayout(topLayout);
- d->localLayout = new TQHBoxLayout(topLayout);
-}
-
-KGameDialogMsgServerConfig::~KGameDialogMsgServerConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- delete d;
-}
-
-void KGameDialogMsgServerConfig::setKGame(KGame* g)
-{
- KGameDialogConfig::setKGame(g);
- //TODO display the ID of the admin if we aren't
- // connect(g, TQT_SIGNAL(signalAdminChanged(int)), this, TQT_SLOT(slotChangeIsAdmin(int)));//TODO
- if (!game()) {
- // we cannot do anything without a KGame object!
- setAdmin(false);
- return;
- }
- setAdmin(game()->isAdmin());
- setHasMsgServer(game()->messageServer());
-}
-
-
-void KGameDialogMsgServerConfig::slotChangeMaxClients()
-{
- if (!game()) {
- kdError(11001) << k_funcinfo << ": no valid game object available!" << endl;
- return;
- }
- if (!game()->isAdmin()) {
- kdError(11001) << k_funcinfo << ": only ADMIN is allowed to call this!" << endl;
- return;
- }
- int max;
-// edit->setText(TQString::number()); // current max clients! //TODO
-
- TQDialog* dialog = new TQDialog();
- dialog->setCaption(i18n("Maximal Number of Clients"));
- TQHBoxLayout* l = new TQHBoxLayout(dialog, KDialog::marginHint(), KDialog::spacingHint());
- l->setAutoAdd(true);
-
- (void) new TQLabel(i18n("Maximal number of clients (-1 = infinite):"), dialog);
- TQLineEdit* edit = new TQLineEdit(dialog);//TODO: use KIntNumInput
-// edit->setText(TQString::number(max)); // current max clients! //TODO
- if (dialog->exec() == TQDialog::Accepted) {
- bool ok;
- max = edit->text().toInt(&ok);
- if (ok) {
- game()->setMaxClients(max);
- }
- }
-
-}
-
-void KGameDialogMsgServerConfig::slotRemoveClient()
-{
-}
-
-void KGameDialogMsgServerConfig::slotChangeAdmin()
-{
- if (!game()) {
- kdError(11001) << k_funcinfo << ": no valid game object available!" << endl;
- return;
- }
- if (!admin()) {
- kdError(11001) << k_funcinfo << ": only ADMIN is allowed to call this!" << endl;
- return;
- }
- //TODO
- TQ_UINT32 newAdmin = 0;
-// newAdmin = ;
- game()->electAdmin(newAdmin);
-}
-
-void KGameDialogMsgServerConfig::removeClient(TQ_UINT32 /*id*/)
-{
-//TODO
-}
-
-void KGameDialogMsgServerConfig::setAdmin(bool a)
-{
- if (admin() == a) {
- // no need to do anything
- return;
- }
- KGameDialogConfig::setAdmin(a);
- if (admin()) {
- if (d->noAdmin) {
- delete d->noAdmin;
- d->noAdmin = 0;
- }
- d->changeMaxClients = new TQPushButton(i18n("Change Maximal Number of Clients"), this);
- connect(d->changeMaxClients, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotChangeMaxClients()));
- d->changeAdmin = new TQPushButton(i18n("Change Admin"), this);
- connect(d->changeAdmin, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotChangeAdmin()));
- d->removeClient = new TQPushButton(i18n("Remove Client with All Players"), this);
- connect(d->removeClient, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotRemoveClient()));
- d->senderLayout->addWidget(d->changeMaxClients);
- d->senderLayout->addWidget(d->changeAdmin);
- d->senderLayout->addWidget(d->removeClient);
- } else {
- if (d->changeMaxClients) {
- delete d->changeMaxClients;
- d->changeMaxClients = 0;
- }
- if (d->changeAdmin) {
- delete d->changeAdmin;
- d->changeAdmin = 0;
- }
- if (d->removeClient) {
- delete d->removeClient;
- d->removeClient = 0;
- }
- d->noAdmin = new TQLabel(i18n("Only the admin can configure the message server!"), this);
- d->senderLayout->addWidget(d->noAdmin);
- }
-}
-
-
-void KGameDialogMsgServerConfig::setHasMsgServer(bool has)
-{
- if (!has) {
- // delete all inputs
- if (!d->noMaster) {
- d->noMaster = new TQLabel(i18n("You don't own the message server"), this);
- d->localLayout->addWidget(d->noMaster);
- }
- return;
- }
- if (d->noMaster) {
- delete d->noMaster;
- d->noMaster = 0;
- }
- //TODO
- // list all connections, data (max clients) and so on
- // cannot be done above (together with TQPushButtons) as it is possible that
- // this client is ADMIN but not MASTER (i.e. doesn't own the messageserver)
-}
-
-
-class KGameDialogChatConfigPrivate
-{
-public:
- KGameDialogChatConfigPrivate()
- {
- mChat = 0;
- }
-
- KGameChat* mChat;
-};
-
-KGameDialogChatConfig::KGameDialogChatConfig(int chatMsgId, TQWidget* parent)
- : KGameDialogConfig(parent)
-{
- d = new KGameDialogChatConfigPrivate;
- TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
- topLayout->setAutoAdd(true);
- TQHGroupBox* b = new TQHGroupBox(i18n("Chat"), this);
- d->mChat = new KGameChat(0, chatMsgId, b);
-}
-
-KGameDialogChatConfig::~KGameDialogChatConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- delete d;
-}
-
-void KGameDialogChatConfig::setKGame(KGame* g)
-{
- KGameDialogConfig::setKGame(g);
- d->mChat->setKGame(game());
- if (!game()) {
- hide();
- } else {
- show();
- }
-}
-
-void KGameDialogChatConfig::setOwner(KPlayer* p)
-{
- KGameDialogConfig::setOwner(p);
- if (!owner()) {
- hide();
- return;
- }
- d->mChat->setFromPlayer(owner());
- show();
-}
-
-
-
-class KGameDialogConnectionConfigPrivate
-{
-public:
- KGameDialogConnectionConfigPrivate()
- {
- mPlayerBox = 0;
- }
-
- TQPtrDict<KPlayer> mItem2Player;
- KListBox* mPlayerBox;
-};
-
-KGameDialogConnectionConfig::KGameDialogConnectionConfig(TQWidget* parent)
- : KGameDialogConfig(parent)
-{
- //TODO: prevent player to ban himself
- d = new KGameDialogConnectionConfigPrivate;
- TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
- topLayout->setAutoAdd(true);
- TQHGroupBox* b = new TQHGroupBox(i18n("Connected Players"), this);
- d->mPlayerBox = new KListBox(b);
- setMinimumHeight(100);
-}
-
-KGameDialogConnectionConfig::~KGameDialogConnectionConfig()
-{
- kdDebug(11001) << k_funcinfo << endl;
- // d->mIem2Player.clear();
- delete d;
-}
-
-void KGameDialogConnectionConfig::setKGame(KGame* g)
-{
- if (game()) {
- disconnect(game(), 0, this, 0);
- }
- KGameDialogConfig::setKGame(g);
- slotClearPlayers();
- if (game()) {
-// react to changes in KGame::playerList()
- connect(game(), TQT_SIGNAL(signalPlayerJoinedGame(KPlayer*)),
- this, TQT_SLOT(slotPlayerJoinedGame(KPlayer*)));
- connect(game(), TQT_SIGNAL(signalPlayerLeftGame(KPlayer*)),
- this, TQT_SLOT(slotPlayerLeftGame(KPlayer*)));
-
- KGame::KGamePlayerList l = *game()->playerList();
- for (KPlayer* p = l.first(); p; p = l.next()) {
- slotPlayerJoinedGame(p);
- }
- }
-}
-
-void KGameDialogConnectionConfig::setOwner(KPlayer* p)
-{
- KGameDialogConfig::setOwner(p);
-}
-
-void KGameDialogConnectionConfig::setAdmin(bool a)
-{
- if (!game()) {// not possible... in theory
- return;
- }
- if (admin()) {
- disconnect(game(), TQT_SIGNAL(executed(TQListBoxItem*)), this, 0);
- }
- KGameDialogConfig::setAdmin(a);
- if (admin()) {
- connect(d->mPlayerBox, TQT_SIGNAL(executed(TQListBoxItem*)), this,
- TQT_SLOT(slotKickPlayerOut(TQListBoxItem*)));
- }
-}
-
-TQListBoxItem* KGameDialogConnectionConfig::item(KPlayer* p) const
-{
- TQPtrDictIterator<KPlayer> it(d->mItem2Player);
- while (it.current()) {
- if (it.current() == p) {
- return (TQListBoxItem*)it.currentKey();
- }
- ++it;
- }
- return 0;
-}
-
-void KGameDialogConnectionConfig::slotClearPlayers()
-{
- TQPtrDictIterator<KPlayer> it(d->mItem2Player);
- while (it.current()) {
- slotPlayerLeftGame(it.current());
- ++it;
- }
-
- if (d->mItem2Player.count() > 0) {
- kdWarning(11001) << k_funcinfo << ": itemList wasn't cleared properly" << endl;
- d->mItem2Player.clear();
- }
- if (d->mPlayerBox->count() > 0) {
- kdWarning(11001) << k_funcinfo << ": listBox wasn't cleared properly" << endl;
- d->mPlayerBox->clear();
- }
-
-}
-
-void KGameDialogConnectionConfig::slotPlayerJoinedGame(KPlayer* p)
-{
- if (!p) {
- kdError(11001) << k_funcinfo << ": Cannot add NULL player" << endl;
- }
- if (d->mItem2Player[p]) {
- kdError(11001) << k_funcinfo << ": attempt to double add player" << endl;
- return;
- }
- kdDebug(11001) << k_funcinfo << ": add player " << p->id() << endl;
- TQListBoxText* t = new TQListBoxText(p->name());
- d->mItem2Player.insert(t, p);
- d->mPlayerBox->insertItem(t);
-
- connect(p, TQT_SIGNAL(signalPropertyChanged(KGamePropertyBase*, KPlayer*)),
- this, TQT_SLOT(slotPropertyChanged(KGamePropertyBase*, KPlayer*)));
-
-}
-
-void KGameDialogConnectionConfig::slotPlayerLeftGame(KPlayer* p)
-{
- // disconnect first
- this->disconnect(p);
- if (!item(p)) {
- kdError(11001) << k_funcinfo << ": cannot find " << p->id()
- << " in list" << endl;
- return;
- }
- d->mPlayerBox->removeItem(d->mPlayerBox->index(item(p)));
-
-}
-
-void KGameDialogConnectionConfig::slotKickPlayerOut(TQListBoxItem* item)
-{
- kdDebug(11001) << "kick player out" << endl;
- KPlayer* p = d->mItem2Player[item];
- if (!p) {
- kdError(11001) << "invalid item selected - no player found" << endl;
- return;
- }
- if (!game()) {
- kdWarning(11001) << "no game set" << endl;
- return;
- }
- if (!admin()) {
- kdDebug(11001) << "Only the ADMIN can kick players" << endl;
- return;
- }
- if (p == owner()) { // you wanna ban the ADMIN ??
- kdDebug(11001) << "you cannot kick the ADMIN" << endl;
- return;
- }
-
- if (KMessageBox::questionYesNo(this, i18n("Do you want to ban player \"%1\" from the game?").tqarg(
- p->name()), TQString(), i18n("Ban Player"), i18n("Do Not Ban")) == KMessageBox::Yes) {
- kdDebug(11001) << "will remove player " << p << endl;
- game()->removePlayer(p);
-// d->mPlayerBox->removeItem(d->mPlayerBox->index(item)); // should be done by signalPlayerLeftGame
- } else {
- kdDebug(11001) << "will NOT remove player " << p << endl;
- }
-}
-
-void KGameDialogConnectionConfig::slotPropertyChanged(KGamePropertyBase* prop, KPlayer* player)
-{
- if(prop->id() == KGamePropertyBase::IdName) {
- TQListBoxText* old = 0;
- TQPtrDictIterator<KPlayer> it(d->mItem2Player);
- while (it.current() && !old) {
- if (it.current() == player) {
- old = (TQListBoxText*)it.currentKey();
- }
- ++it;
- }
- TQListBoxText* t = new TQListBoxText(player->name());
- d->mPlayerBox->changeItem(t, d->mPlayerBox->index(old));
- d->mItem2Player.remove(old);
- d->mItem2Player.insert(t, player);
- }
-}
-
diff --git a/libkdegames/kgame/dialogs/kgamedialogconfig.h b/libkdegames/kgame/dialogs/kgamedialogconfig.h
deleted file mode 100644
index a7f309ac..00000000
--- a/libkdegames/kgame/dialogs/kgamedialogconfig.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-// NAMING
-// please follow these naming rules if you add/change classes:
-// the main dialog is named KGameDialog and the base config widget
-// KGameDialogConfig. All config widgets are named KGameDialogXYZConfig (where
-// XYZ = the name of the config widget, like "general" or "network") and are
-// inherited from KGameDialogConfig.
-
-#ifndef __KGAMEDIALOGCONFIG_H__
-#define __KGAMEDIALOGCONFIG_H__
-
-#include <tqwidget.h>
-#include <kdemacros.h>
-
-class TQGridLayout;
-class TQVBoxLayout;
-class TQListBoxItem;
-
-class KGame;
-class KPlayer;
-class KGamePropertyBase;
-
-class KGameDialogConfigPrivate;
-/**
- * Base class for configuration widgets.
- *
- * You can inherit from this and implement @ref submitToKGame, @ref
- * setOwner and @ref setKGame to create your personal @ref KGame configuration widget :-)
- * @short Base class for configuration widgets
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KDE_EXPORT KGameDialogConfig : public TQWidget
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDialogConfig(TQWidget* parent = 0);
- virtual ~KGameDialogConfig();
-
- /**
- * Called by @ref KGameDialog to submit all settings to the KGame
- * Object.
- * You have to replace this if you add your own widgets!
- * @param g A pointer to your KGame.
- * @param p A pointer to the player owning this dialog
- **/
- virtual void submitToKGame(KGame* g, KPlayer* p) = 0;
-
- /**
- * The owner player of the dialog has been changed. The default
- * changes the pointer for owner so don't forget to call the
- * default implementation if you overwrite this!
- *
- * You can use this e.g. to change a line edit widget containing the
- * player name.
- *
- * Note: even NULL players are allowed!
- * @param p The new owner player of the dialog
- **/
- virtual void setOwner(KPlayer* p);
-
- /**
- * The KGame object of the dialog has been changed. The default
- * implementation changes the pointer for game so don't forget to
- * call the default implementation if you overwrite this!
- *
- * You can use this e.g. to re-read the min/max player settings.
- * @param g The KGame object
- **/
- virtual void setKGame(KGame* g);
-
- /**
- * The admin status has been changed.
- * If the KGame object of this config widget is the
- * admin the user is allowed to configure it. Otherwise most
- * widgets will have to be disabled. Note that you don't necessarily
- * need to deactivate all widget - e.g. the player name must be
- * configured by the player. Mainly the KGame configuration can be done
- * by the admin only.
- *
- * By default this does nothing. Changes the value for admin so
- * don't forget to call the default implementation in derived classes!
- * @param admin Whether the KGame object of this dialog can be
- * configured
- **/
- virtual void setAdmin(bool admin);
-
- /**
- * A pointer to the KGame object that has been set by @ref setKGame.
- *
- * Note that NULL is allowed!
- * @return The KGame object assigned to this dialog
- **/
- KGame* game() const;
-
- /**
- * A pointer to the KPlayer object that has been set by @ref
- * setOwner.
- *
- * Note that NULL is allowed!
- * @return The owner of the dialog
- **/
- KPlayer* owner() const;
-
- /**
- * @return True if the owner is ADMIN otherwise FALSE. See also
- * @ref setAdmin
- **/
- bool admin() const;
-
-protected:
-
-private:
- KGameDialogConfigPrivate* d;
-};
-
-/**
- * The main game configuration widget.
- *
- * It currently contains a line edit for the name of the player only. You can
- * add widgets by using the KGameDialogGeneralConfig as parent parameter as it
- * uses TQLayout::autoAdd == true.
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KGameDialogGeneralConfigPrivate;
-class KGameDialogGeneralConfig : public KGameDialogConfig
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- /**
- * Construct a KGameDialogGeneralConfig. Currently it contains a line
- * edit widget to change the player name only.
- *
- * If you just want to add more widgets you can just create your widgets
- * with the KGameDialogGeneralConfig as parent as it uses
- * TQLayout::setAutoAdd(true).
- *
- * @param parent Parent widget for this dialog.
- * @param initializeGUI If you really don't want to use the
- * predefined widget and/or tqlayout use FALSE here. Note that then none
- * of the predefined widgets (currently only the name of the player)
- * will exist anymore.
- *
- **/
- KGameDialogGeneralConfig(TQWidget* parent = 0, bool initializeGUI = true);
- virtual ~KGameDialogGeneralConfig();
-
- /**
- * Called by @ref KGameDialog to submit all settings to the KGame
- * Object.
- * You have to replace this if you add your own widgets!
- * @param g A pointer to your KGame.
- * @param p A pointer to the player owning this dialog
- **/
- virtual void submitToKGame(KGame* g, KPlayer* p);
-
- /**
- * Change the owner of the config widget.
- *
- * Changes the playername in the line edit
- * @param p The new owner player
- **/
- virtual void setOwner(KPlayer* p);
-
- /**
- * See @ref KGameDialogConfig::setKGame
- *
- * Sets the default values of all KGame related predefined widgets
- * (currently none)
- **/
- virtual void setKGame(KGame* g);
-
- /**
- * See @ref KGameDialogConfig::setAdmin
- *
- * This deactivates the min/max player widgets
- **/
- virtual void setAdmin(bool admin);
-
-protected slots:
- void slotPropertyChanged(KGamePropertyBase*, KPlayer*);
-
-protected:
- void setPlayerName(const TQString& name);
-
- TQString playerName() const;
-
-private:
- KGameDialogGeneralConfigPrivate* d;
-};
-
-class KGameDialogNetworkConfigPrivate;
-class KDE_EXPORT KGameDialogNetworkConfig : public KGameDialogConfig
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDialogNetworkConfig(TQWidget* parent = 0);
- virtual ~KGameDialogNetworkConfig();
-
-
- void disableInitConnection();
-
- /**
- * Called by @ref KGameDialog to submit all settings to the KGame
- * Object.
- * You have to replace this if you add your own widgets!
- * @param g A pointer to your KGame.
- * @param p A pointer to the player owning this dialog
- **/
- virtual void submitToKGame(KGame* g, KPlayer* p);
-
- virtual void setKGame(KGame* g);
-
- /**
- * This sets the default port and host used in @ref KGameConnectDialog.
- * The user will be able to change these defaults!
- *
- * If you don't call this then host "localhost" and port "0" is used.
- * You are strongly encouraged to change at least the port!
- * @param port The default port to connect to / listen on
- * @param host The default host to connect to
- **/
- void setDefaultNetworkInfo(const TQString& host, unsigned short int port,bool server=true);
-
- /**
- * Set service type that will be published or browsed for and game name that will be displayed in
- * server browser. Without this publishing and discovery of LAN servers will not be enabled.
- * @param name Game name. Important only for server mode. If not
- * set hostname will be used. In case of name conflict -2, -3 and so on will be added to name.
- * @param type Service type (something like _kwin4._tcp). It should be unique for application.
- * @since 3.4
- **/
- void setDiscoveryInfo(const TQString& type, const TQString& name=TQString());
-
-signals:
- /**
- * This signal is emmited if the user changes the server type (client/server)
- * in the network configuration dialog.
- *
- * @param t - type type (0/1) of the connection
- **/
- void signalServerTypeChanged(int);
-
-
-protected:
- void setConnected(bool connected, bool master = false);
-
-protected slots:
- void slotInitConnection();
- void slotExitConnection();
- void slotConnectionBroken();
-
-
-private:
- KGameDialogNetworkConfigPrivate* d;
-};
-
-class KGameDialogMsgServerConfigPrivate;
-class KGameDialogMsgServerConfig : public KGameDialogConfig
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDialogMsgServerConfig(TQWidget* parent = 0);
- virtual ~KGameDialogMsgServerConfig();
-
- virtual void submitToKGame(KGame*, KPlayer*) {}
-
- void setHasMsgServer(bool);
-
- virtual void setKGame(KGame* g);
- virtual void setAdmin(bool);
-
-protected slots:
- void slotChangeMaxClients();
- void slotChangeAdmin();
- void slotRemoveClient();
-
-protected:
- void removeClient(TQ_UINT32 id);
-
-private:
- KGameDialogMsgServerConfigPrivate* d;
-};
-
-class KGameDialogChatConfigPrivate;
-/**
- * This is not really a configuration widget but rather a simple chat widget.
- * This widget does nothing but just providing a @ref KGameChat object.
- * @short A chat widget inside a @ref KGameDialog
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KGameDialogChatConfig : public KGameDialogConfig
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDialogChatConfig(int chatMsgId, TQWidget* parent = 0);
- virtual ~KGameDialogChatConfig();
-
- virtual void setKGame(KGame* g);
- virtual void setOwner(KPlayer* p);
-
- virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); }
-
-private:
- KGameDialogChatConfigPrivate* d;
-};
-
-/**
- * @short Lists all connected players and gives the ability to kick them off the
- * game
- **/
-class KGameDialogConnectionConfigPrivate;
-class KGameDialogConnectionConfig : public KGameDialogConfig
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameDialogConnectionConfig(TQWidget* parent = 0);
- virtual ~KGameDialogConnectionConfig();
-
- virtual void setKGame(KGame* g);
- virtual void setOwner(KPlayer* p);
- virtual void setAdmin(bool admin);
-
- virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); }
-
-protected:
- /**
- * @param p A player
- * @return The TQListBoxItem that belongs to the player @p p
- **/
- TQListBoxItem* item(KPlayer* p) const;
-
-protected slots:
- void slotKickPlayerOut(TQListBoxItem* item);
- void slotPropertyChanged(KGamePropertyBase* prop, KPlayer* p);
- void slotPlayerLeftGame(KPlayer* p);
- void slotPlayerJoinedGame(KPlayer* p);
- void slotClearPlayers();
-
-private:
- KGameDialogConnectionConfigPrivate* d;
-
-};
-#endif
diff --git a/libkdegames/kgame/dialogs/kgameerrordialog.cpp b/libkdegames/kgame/dialogs/kgameerrordialog.cpp
deleted file mode 100644
index 6ab9d71c..00000000
--- a/libkdegames/kgame/dialogs/kgameerrordialog.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <kmessagebox.h>
-#include <klocale.h>
-#include <kdebug.h>
-
-#include "kgame.h"
-
-#include "kgameerrordialog.h"
-
-class KGameErrorDialogPrivate
-{
-public:
- KGameErrorDialogPrivate()
- {
- mGame = 0;
- }
-
- const KGame* mGame;
-};
-
-KGameErrorDialog::KGameErrorDialog(TQWidget* parent) : TQObject(parent)
-{
- d = new KGameErrorDialogPrivate;
-}
-
-KGameErrorDialog::~KGameErrorDialog()
-{
- delete d;
-}
-
-void KGameErrorDialog::setKGame(const KGame* g)
-{
- slotUnsetKGame();
- d->mGame = g;
-
- connect(d->mGame, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotUnsetKGame()));
-
-// the error signals:
- connect(d->mGame, TQT_SIGNAL(signalNetworkErrorMessage(int, TQString)),
- this, TQT_SLOT(slotError(int, TQString)));
- connect(d->mGame, TQT_SIGNAL(signalConnectionBroken()),
- this, TQT_SLOT(slotServerConnectionLost()));
- connect(d->mGame, TQT_SIGNAL(signalClientDisconnected(TQ_UINT32,bool)),
- this, TQT_SLOT(slotClientConnectionLost(TQ_UINT32,bool)));
-}
-
-void KGameErrorDialog::slotUnsetKGame()
-{
- if (d->mGame) {
- disconnect(d->mGame, 0, this, 0);
- }
- d->mGame = 0;
-}
-
-void KGameErrorDialog::error(const TQString& errorText, TQWidget* parent)
-{ KMessageBox::error(parent, errorText); }
-
-void KGameErrorDialog::slotServerConnectionLost()
-{
-// TODO: add IP/port of the server
- TQString message = i18n("Connection to the server has been lost!");
- error(message, (TQWidget*)parent());
-}
-
-void KGameErrorDialog::slotClientConnectionLost(TQ_UINT32 /*id*/,bool)
-{
-//TODO: add IP/port of the client
- TQString message;
-// if (c) {
-// message = i18n("Connection to client has been lost!\nID: %1\nIP: %2").tqarg(c->id()).tqarg(c->IP());
-// } else {
-// message = i18n("Connection to client has been lost!");
-// }
- message = i18n("Connection to client has been lost!");
- error(message, (TQWidget*)parent());
-}
-
-void KGameErrorDialog::slotError(int errorNo, TQString text)
-{
- TQString message = i18n("Received a network error!\nError number: %1\nError message: %2").tqarg(errorNo).tqarg(text);
- error(message, (TQWidget*)parent());
-}
-
-void KGameErrorDialog::connectionError(TQString s)
-{
- TQString message;
- if (s.isNull()) {
- message = i18n("No connection could be created.");
- } else {
- message = i18n("No connection could be created.\nThe error message was:\n%1").tqarg(s);
- }
- error(message, (TQWidget*)parent());
-}
-
-
-
-// should become the real dialog - currently we just use messageboxes
-// -> maybe unused forever
-KGameErrorMessageDialog::KGameErrorMessageDialog(TQWidget* parent)
- : KDialogBase(Plain, i18n("Error"), Ok, Ok, parent, 0, true, true)
-{
-}
-
-KGameErrorMessageDialog::~KGameErrorMessageDialog()
-{
-}
-
-
-
-#include "kgameerrordialog.moc"
diff --git a/libkdegames/kgame/dialogs/kgameerrordialog.h b/libkdegames/kgame/dialogs/kgameerrordialog.h
deleted file mode 100644
index 08726dc2..00000000
--- a/libkdegames/kgame/dialogs/kgameerrordialog.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- This file is part of the KDE games library
- Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
- Copyright (C) 2001 Martin Heni (martin@heni-online.de)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef __KGAMEERRORDIALOG_H__
-#define __KGAMEERRORDIALOG_H__
-
-#include <kdialogbase.h>
-
-class KGame;
-class KGameErrorDialogPrivate;
-
-/**
- * Use error(), warning() and information() to display the information about a
- * network game. Maybe a better solution is to use KMessageBoxes
- * You can connect to the public slots, too - they will call the static
- * functions, so that you can always have a KGameErrorDialog object lying around
- * without losing much memory (a KGameErrorMessageDialog Object will be
- * created)
- * @short Error handling for KGame
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KGameErrorDialog : public TQObject
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameErrorDialog(TQWidget* parent);
- ~KGameErrorDialog();
-
- /**
- * Automatically connects the KGame object to all error dependant slots.
- * Create a KGameErrorDialog object, call this function and forget
- * everything.
- * @param g The KGame which will emit the erorrs (or not ;-) )
- **/
- void setKGame(const KGame* g);
-
- /**
- * KGame couldn't establish a connection. Use this if
- * KGame::initConnection returns false
- * @param s A string that describes the error further (like port is
- * already in use). Will be ignored if TQString()
- **/
- void connectionError(TQString s = TQString());
-
-public slots:
- void slotError(int error, TQString text);
-
- /**
- * The connection to the @ref KMessageServer has been lost
- *
- * See @ref KGameNetwork::signalConnectionBroken
- **/
- void slotServerConnectionLost();
-
- /**
- * The connection to a client has been lost by accident
- *
- * See @ref KGameNetwork::signalClientDisconnected
- **/
- void slotClientConnectionLost(TQ_UINT32 clientID,bool broken);
-
- /**
- * Unsets a @ref KGame which has been set using @ref setKGame before.
- * This is called automatically when the @ref KGame object is destroyed
- * and you normally don't have to call this yourself.
- *
- * Note that @ref setKGame also unsets an already existing @ref KGame
- * object if exising.
- **/
- void slotUnsetKGame();
-
-protected:
- void error(const TQString& errorText, TQWidget* parent = 0);
-
-private:
- KGameErrorDialogPrivate* d;
-};
-
-/**
- * The real class for error messages. KGameErrorDialog uses this to create error
- * messages (not yet).
- * Use @ref KGameErrorDialog instead.
- * @short Internally used by @ref KGameErrorDialog
- * @author Andreas Beckermann <b_mann@gmx.de>
- **/
-class KGameErrorMessageDialog : public KDialogBase
-{
- Q_OBJECT
- TQ_OBJECT
-public:
- KGameErrorMessageDialog(TQWidget* parent);
- ~KGameErrorMessageDialog();
-
-private:
-};
-
-#endif