[prev in list] [next in list] [prev in thread] [next in thread] 

List:       atlantik-devel
Subject:    [atlantik-cvs] CVS: kdegames/atlantik/libatlantikui
From:       kde () office ! kde ! org
Date:       2003-12-08 17:10:23
[Download RAW message or body]

Update of /home/kde/kdegames/atlantik/libatlantikui
In directory office:/tmp/cvs-serv27872/libatlantikui

Modified Files:
	portfolioview.cpp portfolioview.h 
Log Message:
bugfix: clear portfolioviews when playerSelf is not in game

Index: portfolioview.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/portfolioview.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- portfolioview.cpp	18 Nov 2003 22:20:08 -0000	1.57
+++ portfolioview.cpp	8 Dec 2003 17:10:20 -0000	1.58
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
+// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -48,11 +48,11 @@
 	m_inactiveColor = inactiveColor;
 	m_lastPE = 0;
 
-	setBackgroundColor(Qt::white);
-
 	qpixmap = 0;
 	b_recreate = true;
 
+	m_portfolioEstates.setAutoDelete(true);
+	setBackgroundColor(Qt::white);
 	setMinimumHeight(ICONSIZE);
 
 	// Init icon
@@ -63,8 +63,9 @@
 
 PortfolioView::~PortfolioView()
 {
-    delete m_image;
-    delete qpixmap;
+	clearPortfolio();
+	delete m_image;
+	delete qpixmap;
 }
 
 Player *PortfolioView::player()
@@ -74,7 +75,9 @@
 
 void PortfolioView::buildPortfolio()
 {
-	// TODO: clear current portfolioEstateMap
+	if ( m_portfolioEstates.count() )
+		clearPortfolio();
+
 	// Loop through estate groups in order
 	QPtrList<EstateGroup> estateGroups = m_atlanticCore->estateGroups();
 	PortfolioEstate *lastPE = 0, *firstPEprevGroup = 0;
@@ -99,7 +102,7 @@
 				{
 					// Create PE
 					PortfolioEstate *portfolioEstate = new PortfolioEstate(estate, m_player, false, \
                this, "portfolioestate");
-					portfolioEstateMap[estate->id()] = portfolioEstate;
+					m_portfolioEstates.append(portfolioEstate);
 
  					connect(portfolioEstate, SIGNAL(estateClicked(Estate *)), this, \
SIGNAL(estateClicked(Estate *)));  if (lastPE)
@@ -140,6 +143,11 @@
 		setMinimumHeight(minHeight);
 }
 
+void PortfolioView::clearPortfolio()
+{
+	m_portfolioEstates.clear();
+}
+
 void PortfolioView::loadIcon()
 {
 	if (m_imageName == m_player->image())
@@ -211,7 +219,7 @@
 		painter.setFont(QFont(KGlobalSettings::generalFont().family(), \
KGlobalSettings::generalFont().pointSize(), QFont::Bold));  painter.drawText(ICONSIZE \
+ KDialog::marginHint(), 15, m_player->name());  
-		if (portfolioEstateMap.size())
+		if ( m_portfolioEstates.count() )
 			painter.drawText(width() - 50, 15, QString::number(m_player->money()));
 		else
 		{
@@ -242,7 +250,7 @@
 
 void PortfolioView::mousePressEvent(QMouseEvent *e)
 {
-	if (e->button()==RightButton && !m_player->isSelf() && portfolioEstateMap.size())
+	if (e->button()==RightButton && !m_player->isSelf() && m_portfolioEstates.count() )
 	{
 		KPopupMenu *rmbMenu = new KPopupMenu(this);
 		rmbMenu->insertTitle(m_player->name());

Index: portfolioview.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/portfolioview.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- portfolioview.h	18 Nov 2003 22:20:08 -0000	1.27
+++ portfolioview.h	8 Dec 2003 17:10:20 -0000	1.28
@@ -19,7 +19,7 @@
 
 #include <qwidget.h>
 #include <qpixmap.h>
-#include <qmap.h>
+#include <qptrlist.h>
 
 #include "portfolioestate.h"
 
@@ -36,8 +36,11 @@
 
 public:
 	PortfolioView(AtlanticCore *core, Player *_player, QColor activeColor, QColor \
inactiveColor, QWidget *parent, const char *name = 0); +	~PortfolioView();
+
 	void buildPortfolio();
-    ~PortfolioView();
+	void clearPortfolio();
+
 	Player *player();
 
 protected:
@@ -63,7 +66,7 @@
 	QPixmap *qpixmap, *m_image;
 	QString m_imageName;
 	bool b_recreate;
-	QMap<int, PortfolioEstate*> portfolioEstateMap;
+	QPtrList<PortfolioEstate> m_portfolioEstates;
 };
 
 #endif

_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@kde.org
https://mail.kde.org/mailman/listinfo/atlantik-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic