Commit f66b2c98 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: EPGItem: simplify setters

parent b8635eb0
...@@ -32,7 +32,7 @@ class EPGEvent ...@@ -32,7 +32,7 @@ class EPGEvent
{ {
public: public:
EPGEvent( const QString& eventName ) EPGEvent( const QString& eventName )
: current( false ), updated( true ), item( NULL ) : current( false ), updated( true ), simultaneous( false ), item( NULL )
{ {
name = eventName; name = eventName;
} }
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
QString channelName; QString channelName;
bool current; bool current;
bool updated; bool updated;
bool simultaneous;
EPGItem *item; EPGItem *item;
}; };
......
...@@ -40,7 +40,6 @@ EPGItem::EPGItem( EPGView *view ) ...@@ -40,7 +40,6 @@ EPGItem::EPGItem( EPGView *view )
: m_view( view ) : m_view( view )
{ {
m_current = false; m_current = false;
m_boundingRect.setHeight( TRACKS_HEIGHT ); m_boundingRect.setHeight( TRACKS_HEIGHT );
setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable); setFlags( QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
setAcceptHoverEvents( true ); setAcceptHoverEvents( true );
...@@ -137,10 +136,17 @@ void EPGItem::setChannelNb( int channelNb ) ...@@ -137,10 +136,17 @@ void EPGItem::setChannelNb( int channelNb )
updatePos(); updatePos();
} }
void EPGItem::setStart( const QDateTime& start ) void EPGItem::setData( EPGEvent *event )
{ {
m_start = start; m_start = event->start;
m_name = event->name;
m_description = event->description;
m_shortDescription = event->shortDescription;
m_current = event->current;
m_simultaneous = event->simultaneous;
setDuration( event->duration );
updatePos(); updatePos();
setToolTip( m_name );
} }
void EPGItem::setDuration( int duration ) void EPGItem::setDuration( int duration )
...@@ -149,27 +155,6 @@ void EPGItem::setDuration( int duration ) ...@@ -149,27 +155,6 @@ void EPGItem::setDuration( int duration )
m_boundingRect.setWidth( duration ); m_boundingRect.setWidth( duration );
} }
void EPGItem::setName( const QString& name )
{
m_name = name;
setToolTip( m_name );
}
void EPGItem::setDescription( const QString& description )
{
m_description = description;
}
void EPGItem::setShortDescription( const QString& shortDescription )
{
m_shortDescription = shortDescription;
}
void EPGItem::setCurrent( bool current )
{
m_current = current;
}
void EPGItem::updatePos() void EPGItem::updatePos()
{ {
int x = m_view->startTime().secsTo( m_start ); int x = m_view->startTime().secsTo( m_start );
......
...@@ -31,6 +31,7 @@ class QString; ...@@ -31,6 +31,7 @@ class QString;
class QDateTime; class QDateTime;
class EPGView; class EPGView;
class EPGEvent;
class EPGItem : public QGraphicsItem class EPGItem : public QGraphicsItem
{ {
...@@ -46,13 +47,9 @@ public: ...@@ -46,13 +47,9 @@ public:
int duration() const; int duration() const;
int getChannelNb() const; int getChannelNb() const;
void setData( EPGEvent * );
void setChannelNb( int channelNb ); void setChannelNb( int channelNb );
void setStart( const QDateTime& start );
void setDuration( int duration ); void setDuration( int duration );
void setName( const QString& name );
void setDescription( const QString& description );
void setShortDescription( const QString& shortDescription );
void setCurrent( bool current );
void updatePos(); void updatePos();
protected: protected:
...@@ -70,6 +67,7 @@ private: ...@@ -70,6 +67,7 @@ private:
QString m_description; QString m_description;
QString m_shortDescription; QString m_shortDescription;
bool m_current; bool m_current;
bool m_simultaneous;
}; };
#endif // EPGITEM_H #endif // EPGITEM_H
...@@ -92,13 +92,9 @@ void EPGView::addEvent( EPGEvent* event ) ...@@ -92,13 +92,9 @@ void EPGView::addEvent( EPGEvent* event )
m_channels.append( event->channelName ); m_channels.append( event->channelName );
EPGItem* item = new EPGItem( this ); EPGItem* item = new EPGItem( this );
item->setData( event );
item->setChannelNb( m_channels.indexOf( event->channelName ) ); item->setChannelNb( m_channels.indexOf( event->channelName ) );
item->setStart( event->start );
item->setDuration( event->duration ); item->setDuration( event->duration );
item->setName( event->name );
item->setDescription( event->description );
item->setShortDescription( event->shortDescription );
item->setCurrent( event->current );
event->item = item; event->item = item;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment