[atlantik-cvs] CVS: kdegames/atlantik/client atlantik.cpp,1.121.6.1,1.121.6.2 main.h,1.24.4.2,1.24.4.3 monopigator.cpp,1.9.8.1,1.9.8.2 monopigator.h,1.8.8.1,1.8.8.2 selectconfiguration_widget.cpp,1.26,1.26.6.1 selectconfiguration_widget.h,1.12,1.12.6.1

[email protected]
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv11080/client

Modified Files:
      Tag: KDE_3_1_BRANCH
	atlantik.cpp main.h monopigator.cpp monopigator.h 
	selectconfiguration_widget.cpp selectconfiguration_widget.h 
Log Message:
backport of core changes, fixes #52933

Index: atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.121.6.1
retrieving revision 1.121.6.2
diff -u -d -r1.121.6.1 -r1.121.6.2
--- atlantik.cpp	19 Dec 2002 00:41:29 -0000	1.121.6.1
+++ atlantik.cpp	13 Jan 2003 17:14:39 -0000	1.121.6.2
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
@@ -102,6 +102,8 @@
 	m_portfolioWidget->show();
 	m_portfolioLayout = new QVBoxLayout(m_portfolioWidget);
 
+	m_portfolioViews.setAutoDelete(true);
+
 	// Nice label
 //	m_portfolioLabel = new QLabel(i18n("Players"), m_portfolioWidget, "pfLabel");
 //	m_portfolioLayout->addWidget(m_portfolioLabel);
@@ -168,6 +170,9 @@
 
 	m_board->addToken(player);
 
+	if (m_selectConfiguration)
+		m_selectConfiguration->addPlayer(player);
+
 	PortfolioView *portfolioView = new PortfolioView(m_atlanticCore, player, m_config.activeColor, m_config.inactiveColor, m_portfolioWidget);
 	m_portfolioViews.append(portfolioView);
 
@@ -232,6 +237,17 @@
 	m_selectGame = new SelectGame(m_mainWidget, "selectGame");
 	m_mainLayout->addMultiCellWidget(m_selectGame, 0, 2, 1, 1);
 	m_selectGame->show();
+
+	// Reset core and GUI
+	if (m_board)
+	{
+		delete m_board;
+		m_board = 0;
+
+		m_portfolioViews.clear();
+		m_atlanticCore->reset();
+	}
+
 	if (m_selectServer)
 	{
 		delete m_selectServer;
@@ -274,10 +290,6 @@
 	m_mainLayout->addMultiCellWidget(m_selectConfiguration, 0, 2, 1, 1);
 	m_selectConfiguration->show();
 
-	connect(m_atlantikNetwork, SIGNAL(playerListClear()), m_selectConfiguration, SLOT(slotPlayerListClear()));
-	connect(m_atlantikNetwork, SIGNAL(playerListAdd(QString, QString, QString)), m_selectConfiguration, SLOT(slotPlayerListAdd(QString, QString, QString)));
-	connect(m_atlantikNetwork, SIGNAL(playerListEdit(QString, QString, QString)), m_selectConfiguration, SLOT(slotPlayerListEdit(QString, QString, QString)));
-	connect(m_atlantikNetwork, SIGNAL(playerListDel(QString)), m_selectConfiguration, SLOT(slotPlayerListDel(QString)));
 	connect(m_atlantikNetwork, SIGNAL(gameListClear()), this, SLOT(showSelectGame()));
 	connect(m_atlantikNetwork, SIGNAL(gameOption(QString, QString, QString, QString, QString)), m_selectConfiguration, SLOT(gameOption(QString, QString, QString, QString, QString)));
 	connect(m_selectConfiguration, SIGNAL(startGame()), m_atlantikNetwork, SLOT(startGame()));

Index: main.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/main.h,v
retrieving revision 1.24.4.2
retrieving revision 1.24.4.3
diff -u -d -r1.24.4.2 -r1.24.4.3
--- main.h	6 Jan 2003 01:45:16 -0000	1.24.4.2
+++ main.h	13 Jan 2003 17:14:39 -0000	1.24.4.3
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License

Index: monopigator.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/monopigator.cpp,v
retrieving revision 1.9.8.1
retrieving revision 1.9.8.2
diff -u -d -r1.9.8.1 -r1.9.8.2
--- monopigator.cpp	7 Jan 2003 22:57:46 -0000	1.9.8.1
+++ monopigator.cpp	13 Jan 2003 17:14:39 -0000	1.9.8.2
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License

Index: monopigator.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/monopigator.h,v
retrieving revision 1.8.8.1
retrieving revision 1.8.8.2
diff -u -d -r1.8.8.1 -r1.8.8.2
--- monopigator.h	7 Jan 2003 22:57:46 -0000	1.8.8.1
+++ monopigator.h	13 Jan 2003 17:14:39 -0000	1.8.8.2
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License

Index: selectconfiguration_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.cpp,v
retrieving revision 1.26
retrieving revision 1.26.6.1
diff -u -d -r1.26 -r1.26.6.1
--- selectconfiguration_widget.cpp	11 Sep 2002 01:40:59 -0000	1.26
+++ selectconfiguration_widget.cpp	13 Jan 2003 17:14:39 -0000	1.26.6.1
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
@@ -25,6 +25,8 @@
 #include <klocale.h>
 #include <kiconloader.h>
 #include <kmessagebox.h>
+
+#include <player.h>
  
 #include "selectconfiguration_widget.moc"
 
@@ -39,7 +41,6 @@
 
 	// List of  players
 	m_playerList = new KListView(m_playerBox, "m_playerList");
-	m_playerList->addColumn(QString(i18n("Id")));
 	m_playerList->addColumn(QString(i18n("Name")));
 	m_playerList->addColumn(QString(i18n("Host")));
 	m_playerList->setAllColumnsShowFocus(true);
@@ -73,51 +74,36 @@
 	m_mainLayout->addWidget(status_label);
 }
 
-void SelectConfiguration::slotPlayerListClear()
-{
-	m_playerList->clear();
-//	emit statusChanged();
-}
-
-void SelectConfiguration::slotPlayerListAdd(QString playerId, QString name, QString host)
+void SelectConfiguration::addPlayer(Player *player)
 {
-	kdDebug() << "SelectConfiguration::slotPlayerListAdd" << endl;
-	QListViewItem *item = new QListViewItem(m_playerList, playerId, name, host);
+	QListViewItem *item = new QListViewItem(m_playerList, player->name(), player->host());
 	item->setPixmap(0, QPixmap(SmallIcon("personal")));
+
+	m_items[player] = item;
+
+	connect(player, SIGNAL(changed(Player *)), this, SLOT(slotPlayerChanged(Player *)));
 }
 
-void SelectConfiguration::slotPlayerListEdit(QString playerId, QString name, QString host)
+void SelectConfiguration::slotDelPlayer(Player *player)
 {
-	QListViewItem *item = m_playerList->firstChild();
-	while (item)
+	QListViewItem *item = m_items[player];
+	if (item)
 	{
-		if (item->text(0) == playerId)
-		{
-			if (!name.isEmpty())
-				item->setText(1, name);
-			if (!host.isEmpty())
-				item->setText(2, host);
-			m_playerList->triggerUpdate();
-			return;
-		}
-		item = item->nextSibling();
+		delete item;
+		m_items[player] = 0;
 	}
-//	emit statusChanged();
 }
 
-void SelectConfiguration::slotPlayerListDel(QString playerId)
+void SelectConfiguration::slotPlayerChanged(Player *player)
 {
-	QListViewItem *item = m_playerList->firstChild();
-	while (item)
+	QListViewItem *item = m_items[player];
+	if (item)
 	{
-		if (item->text(0) == playerId)
-		{
-			delete item;
-			return;
-		}
-		item = item->nextSibling();
+		item->setText(0, player->name());
+		item->setText(1, player->host());
+		item->setPixmap(0, QPixmap(SmallIcon("personal")));
+		m_playerList->triggerUpdate();
 	}
-//	emit statusChanged();
 }
 
 void SelectConfiguration::connectClicked()

Index: selectconfiguration_widget.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.h,v
retrieving revision 1.12
retrieving revision 1.12.6.1
diff -u -d -r1.12 -r1.12.6.1
--- selectconfiguration_widget.h	1 Aug 2002 15:16:25 -0000	1.12
+++ selectconfiguration_widget.h	13 Jan 2003 17:14:39 -0000	1.12.6.1
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <[email protected]>
+// Copyright (c) 2002-2003 Rob Kaper <[email protected]>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
@@ -26,6 +26,9 @@
 #include <kpushbutton.h>
 
 class QCheckBox;
+class QListViewItem;
+
+class Player;
 
 class SelectConfiguration : public QWidget
 {
@@ -33,17 +36,16 @@
 
 public:
 	SelectConfiguration(QWidget *parent, const char *name=0);
+	void addPlayer(Player *player);
 
 	void initPage();
-		bool validateNext();
-		QString hostToConnect() const;
-		int portToConnect();
+	bool validateNext();
+	QString hostToConnect() const;
+	int portToConnect();
 
-	public slots:
-		void slotPlayerListClear();
-		void slotPlayerListAdd(QString playerId, QString name, QString host);
-		void slotPlayerListEdit(QString playerId, QString name, QString host);
-		void slotPlayerListDel(QString playerId);
+public slots:
+	void slotDelPlayer(Player *player);
+	void slotPlayerChanged(Player *player);
 
 private slots:
 	void connectClicked();
@@ -66,6 +68,7 @@
 	KPushButton *m_backButton, *m_connectButton;
 	QMap <QObject *, QString> m_optionCommandMap;
 	QMap <QString, QCheckBox *> m_checkBoxMap;
+	QMap <Player *, QListViewItem *> m_items;
 };
 
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.