[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-cvs] CVS: kdegames/atlantik/libatlantikui portfolioview.cpp,1.46,1.46.6.1 portfolioview.h,
From: kde () office ! kde ! org
Date: 2003-01-21 0:58:15
[Download RAW message or body]
Update of /home/kde/kdegames/atlantik/libatlantikui
In directory office:/tmp/cvs-serv20498/libatlantikui
Modified Files:
Tag: KDE_3_1_BRANCH
portfolioview.cpp portfolioview.h
Log Message:
backport: hostname in portfolioview
Index: portfolioview.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/portfolioview.cpp,v
retrieving revision 1.46
retrieving revision 1.46.6.1
diff -u -d -r1.46 -r1.46.6.1
--- portfolioview.cpp 7 Jul 2002 18:31:38 -0000 1.46
+++ portfolioview.cpp 21 Jan 2003 00:58:12 -0000 1.46.6.1
@@ -17,6 +17,8 @@
#include <qpainter.h>
#include <qcursor.h>
+#include <kdialogbase.h>
+#include <kglobalsettings.h>
#include <klocale.h>
#include <kpopupmenu.h>
@@ -42,36 +44,12 @@
m_inactiveColor = inactiveColor;
m_lastPE = 0;
- b_recreate = true;
- qpixmap = 0;
-
- setFixedSize(QSize(225, 100));
setBackgroundColor(Qt::white);
-
- m_nameLabel = new QLabel(this);
- m_nameLabel->setAlignment(Qt::AlignLeft);
- m_nameLabel->setGeometry(5, 0, width()/2, height());
- m_nameLabel->setBackgroundColor(m_player->hasTurn() ? m_activeColor : \
m_inactiveColor);
- m_nameLabel->setMinimumSize(m_nameLabel->sizeHint());
- m_nameLabel->setMaximumWidth(width()-10);
- m_nameLabel->setMaximumHeight(15);
- m_nameLabel->show();
- m_moneyLabel = new QLabel(this);
- m_moneyLabel->setAlignment(Qt::AlignRight);
- m_moneyLabel->setGeometry(width()/2, 0, width()-5, height());
- m_moneyLabel->setBackgroundColor(m_player->hasTurn() ? m_activeColor : \
m_inactiveColor);
- m_moneyLabel->setMinimumSize(m_moneyLabel->sizeHint());
- m_moneyLabel->setMaximumWidth(width()/2);
- m_moneyLabel->setMaximumHeight(15);
- m_moneyLabel->show();
+ qpixmap = 0;
+ b_recreate = true;
- m_lastGroup = "";
- x = 0;
- y = 0;
-
- // TODO: call buildPortfolio? Although, we should be able to assume no
- // new estates or players are introduced after the game has been started
+ setMinimumHeight(35);
}
Player *PortfolioView::player()
@@ -86,6 +64,9 @@
QPtrList<EstateGroup> estateGroups = m_atlanticCore->estateGroups();
PortfolioEstate *lastPE = 0, *firstPEprevGroup = 0;
+ int x = 100, y = 25, marginHint = 5, bottom;
+ bottom = 20 - PE_HEIGHT - marginHint;
+
EstateGroup *estateGroup;
for (QPtrListIterator<EstateGroup> it(estateGroups); *it; ++it)
{
@@ -106,22 +87,25 @@
portfolioEstateMap[estate->estateId()] = portfolioEstate;
connect(portfolioEstate, SIGNAL(estateClicked(Estate *)), this, \
SIGNAL(estateClicked(Estate *)));
- int x, y;
if (lastPE)
{
x = lastPE->x() + 2;
y = lastPE->y() + 4;
+ if (y > bottom)
+ bottom = y;
}
else if (firstPEprevGroup)
{
x = firstPEprevGroup->x() + PE_WIDTH + 8;
- y = 18;
+ y = 20 + marginHint;
firstPEprevGroup = portfolioEstate;
}
else
{
- x = 5;
- y = 18;
+ x = marginHint;
+ y = 20 + marginHint;
+ if (y > bottom)
+ bottom = y;
firstPEprevGroup = portfolioEstate;
}
@@ -135,9 +119,12 @@
}
}
}
+ setMinimumWidth(x + PE_WIDTH + marginHint);
+ int minHeight = bottom + PE_HEIGHT + marginHint;
+ if (minHeight > minimumHeight())
+ setMinimumHeight(minHeight);
}
-/*
void PortfolioView::paintEvent(QPaintEvent *)
{
if (b_recreate)
@@ -148,22 +135,40 @@
QPainter painter;
painter.begin(qpixmap, this);
+ painter.setPen(Qt::white);
+ painter.setBrush(Qt::white);
+ painter.drawRect(rect());
+
+ painter.setPen(m_player->hasTurn() ? m_activeColor : Qt::black);
+ painter.setBrush(m_player->hasTurn() ? m_activeColor : Qt::black);
+ painter.drawRect(0, 0, width(), 20);
+
+ painter.setPen(Qt::white);
+ painter.setFont(QFont(KGlobalSettings::generalFont().family(), \
KGlobalSettings::generalFont().pointSize(), QFont::Bold)); \
+ painter.drawText(KDialog::marginHint(), 15, m_player->name()); \
+ painter.drawText(width() - 50, 15, QString::number(m_player->money())); +
+ if (!portfolioEstateMap.size())
+ {
+ painter.setPen(Qt::black);
+ painter.setBrush(Qt::white);
+
+ painter.setFont(QFont(KGlobalSettings::generalFont().family(), \
KGlobalSettings::generalFont().pointSize(), QFont::Normal)); \
+ painter.drawText(KDialog::marginHint(), 30, m_player->host()); + }
+
b_recreate = false;
}
bitBlt(this, 0, 0, qpixmap);
}
-*/
-void PortfolioView::playerChanged()
+void PortfolioView::resizeEvent(QResizeEvent *)
{
- m_nameLabel->setText(m_player->name());
- m_nameLabel->setBackgroundColor(m_player->hasTurn() ? m_activeColor : \
m_inactiveColor);
- m_nameLabel->update();
-
- m_moneyLabel->setText(QString::number(m_player->money()));
- m_moneyLabel->setBackgroundColor(m_player->hasTurn() ? m_activeColor : \
m_inactiveColor);
- m_moneyLabel->update();
+ b_recreate = true;
+}
+void PortfolioView::playerChanged()
+{
b_recreate = true;
update();
}
Index: portfolioview.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/portfolioview.h,v
retrieving revision 1.23
retrieving revision 1.23.6.1
diff -u -d -r1.23 -r1.23.6.1
--- portfolioview.h 7 Jul 2002 18:31:38 -0000 1.23
+++ portfolioview.h 21 Jan 2003 00:58:12 -0000 1.23.6.1
@@ -19,7 +19,6 @@
#include <qwidget.h>
#include <qpixmap.h>
-#include <qlabel.h>
#include <qmap.h>
#include "portfolioestate.h"
@@ -42,7 +41,8 @@
Player *player();
protected:
-// void paintEvent(QPaintEvent *);
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *);
void mousePressEvent(QMouseEvent *);
signals:
@@ -60,7 +60,6 @@
QColor m_activeColor, m_inactiveColor;
QPixmap *qpixmap;
bool b_recreate;
- QLabel *m_nameLabel, *m_moneyLabel;
QMap<int, PortfolioEstate*> portfolioEstateMap;
int x, y;
QString m_lastGroup;
_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@mail.kde.org
http://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