]> git.sesse.net Git - vlc/commitdiff
Qt: EPGItem: add parental rating
authorFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 11 Mar 2013 23:31:38 +0000 (00:31 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 28 Mar 2013 15:41:29 +0000 (16:41 +0100)
modules/gui/qt4/components/epg/EPGItem.cpp
modules/gui/qt4/components/epg/EPGItem.hpp
modules/gui/qt4/dialogs/epg.cpp

index e9c761fa463548d08ac5f007279b8f74c86201f1..0de81492666cc9610f536653a79b4be363d77c97 100644 (file)
@@ -104,6 +104,19 @@ void EPGItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option,
     /* Draw the title. */
     painter->drawText( mapped, Qt::AlignTop | Qt::AlignLeft, fm.elidedText( m_name, Qt::ElideRight, mapped.width() ) );
 
+    if ( m_rating > 0 && mapped.width() > 40 )
+    {
+        QRectF iconsRect = QRectF( mapped.bottomRight(), mapped.bottomRight() );
+        iconsRect.adjust( -20, -20, 0, 0 );
+        painter->save();
+        painter->setBrush( Qt::white );
+        f.setPixelSize( 8 );
+        painter->setFont( f );
+        painter->drawRect( iconsRect );
+        painter->drawText( iconsRect, Qt::AlignCenter, QString("%1+").arg( m_rating ) );
+        painter->restore();
+    }
+
     mapped.adjust( 0, 20, 0, 0 );
 
     QDateTime m_end = m_start.addSecs( m_duration );
@@ -158,6 +171,7 @@ bool EPGItem::setData( vlc_epg_event_t *data )
         m_description = newdesc;
         m_shortDescription = newshortdesc;
         setDuration( data->i_duration );
+        setRating( data->i_rating );
         update();
         return true;
     }
@@ -185,6 +199,11 @@ void EPGItem::setDuration( int duration )
     m_boundingRect.setWidth( duration );
 }
 
+void EPGItem::setRating( uint8_t i_rating )
+{
+    m_rating = i_rating;
+}
+
 QString EPGItem::description()
 {
     if( m_description.isEmpty() )
index 6b1a9501fb38f96b52949da0e9fd69ab90700cec..1a7895a39571c6ae158d77914f38b465ac295773 100644 (file)
@@ -49,10 +49,12 @@ public:
     int duration() const;
     const QString& name() { return m_name; };
     QString description();
+    int rating() { return m_rating; }
     bool setData( vlc_epg_event_t * );
     void setRow( unsigned int );
     void setCurrent( bool );
     void setDuration( int duration );
+    void setRating( uint8_t i_rating );
     void updatePos();
     bool endsBefore( const QDateTime & ) const;
     bool playsAt( const QDateTime & ) const;
@@ -73,6 +75,7 @@ private:
     QString     m_description;
     QString     m_shortDescription;
     bool        m_current;
+    uint8_t     m_rating;
 };
 
 #endif // EPGITEM_H
index 58266f3809f24d4de9b5511e82bdbe99a8a9a5ff..bedd3dad1a806729b4aa1c48434ba9eab0b57a0a 100644 (file)
@@ -109,10 +109,13 @@ void EpgDialog::displayEvent( EPGItem *epgItem )
     if( !epgItem ) return;
 
     QDateTime end = epgItem->start().addSecs( epgItem->duration() );
-    title->setText( QString("%1 - %2 : %3")
+    title->setText( QString("%1 - %2 : %3%4")
                    .arg( epgItem->start().toString( "hh:mm" ) )
                    .arg( end.toString( "hh:mm" ) )
                    .arg( epgItem->name() )
+                   .arg( epgItem->rating() ?
+                             qtr(" (%1+ rated)").arg( epgItem->rating() ) :
+                             QString() )
                    );
     description->setText( epgItem->description() );
 }