2
* Copyright 2011 Jörg Ehrichs <joerg.ehichs@gmx.de>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "participantwidget.h"
20
#include "participantlistitem.h"
22
#include "renderer/gametheme.h"
23
#include "renderer/uitheme.h"
24
#include "engine/participant.h"
25
#include "engine/abstractclient.h"
27
#include <QScrollArea>
28
#include <QVBoxLayout>
29
#include <QSpacerItem>
32
using namespace BotRace;
33
using namespace Client;
35
ParticipantWidget::ParticipantWidget( Renderer::GameTheme *renderer, QWidget *parent ) :
37
m_renderer( renderer ),
40
setAcceptDrops( false );
43
m_layout = new QVBoxLayout;
45
m_layout->addStretch();
46
setLayout( m_layout );
49
void ParticipantWidget::setClient( Core::AbstractClient *client )
54
foreach( Core::Participant * p, m_client->getOpponents() ) {
58
addParticipant( m_client->getPlayer() );
60
connect( m_client, SIGNAL( participantAdded( BotRace::Core::Participant * ) ),
61
this, SLOT( addParticipant( BotRace::Core::Participant * ) ) );
64
void ParticipantWidget::resetWidget()
66
qDeleteAll( m_listItems );
71
void ParticipantWidget::paintEvent( QPaintEvent *event )
75
QPainter painter( this );
76
painter.setRenderHint( QPainter::Antialiasing );
78
painter.setBrush( Qt::black );
79
painter.drawRect( rect() );
82
void ParticipantWidget::addParticipant( BotRace::Core::Participant *p )
84
ParticipantListItem *pi = new ParticipantListItem( m_renderer );
85
pi->setGameMode( m_client->getBoardManager()->getGameMode() );
86
pi->setParticipant( p );
88
m_listItems.append( pi );
89
m_layout->insertWidget( m_layout->count() - 1, pi );
91
m_layout->invalidate();