80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
/*******************************************************************************
|
|
* *
|
|
* Société de Transports de Montréal. *
|
|
* 2012 - 2013 *
|
|
* *
|
|
* Projet Zones Tests *
|
|
* *
|
|
* *
|
|
* *
|
|
*******************************************************************************/
|
|
/*
|
|
Description:
|
|
Crée une liste d'objets CEventItem et les dispose en ligne dans le bas de
|
|
l'écran.
|
|
|
|
*/
|
|
|
|
/* ************************************************************************** */
|
|
/* Revision:
|
|
### YYYMMDD JFM
|
|
Verision d'origine.
|
|
|
|
### YYYYMMDD Description du besoin ou du bug
|
|
Description du changement.
|
|
*/
|
|
|
|
/* ************************************************************************** */
|
|
|
|
#include "EventsBar.h"
|
|
#include <QPainter>
|
|
#include <QPen>
|
|
|
|
CEventsBar::CEventsBar(QGraphicsItem *Parent)
|
|
{
|
|
setParentItem(Parent);
|
|
resize(SCREEN_RES_WIDTH,25);
|
|
|
|
// QPen temp;
|
|
// temp.setColor(Qt::red);
|
|
// QGraphicsRectItem *temprect = new QGraphicsRectItem(this);
|
|
// temprect->setPen(temp);
|
|
// temprect->setRect(boundingRect());
|
|
// temprect->show();
|
|
}
|
|
|
|
//void CEventsBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
//{
|
|
|
|
//}
|
|
|
|
void CEventsBar::UpdateDisplay()
|
|
{
|
|
if(mEventsItemList.size() == 0)
|
|
return;
|
|
|
|
for(int i = 1; i < mEventsItemList.size(); i++)
|
|
{
|
|
CEventItem *CurEvent = mEventsItemList.at(i), *PrevEvent = mEventsItemList.at(i-1);
|
|
|
|
CurEvent->setPos(PrevEvent->pos().x() + PrevEvent->rect().width()+3,0);
|
|
}
|
|
}
|
|
|
|
void CEventsBar::UpdateEventsList()
|
|
{
|
|
//clear existing list if necessary
|
|
for(int i = 0; i < mEventsItemList.size(); i++)
|
|
{
|
|
delete mEventsItemList.at(i);
|
|
}
|
|
mEventsItemList.clear();
|
|
|
|
for(int i = 0; i < mEventsList->size(); i++)
|
|
{
|
|
CEventItem *NewItem = new CEventItem(mEventsList->at(i)->mEventLabel,mEventsList->at(i)->mItemAnimated,this);
|
|
mEventsItemList.append(NewItem);
|
|
}
|
|
UpdateDisplay();
|
|
}
|