[vlc-devel] [PATCH 2/2] Qt: EPGItem: add parental rating

Francois Cartegnie fcvlcdev at free.fr
Tue Mar 12 00:31:38 CET 2013


---
 modules/gui/qt4/components/epg/EPGItem.cpp |   19 +++++++++++++++++++
 modules/gui/qt4/components/epg/EPGItem.hpp |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/components/epg/EPGItem.cpp b/modules/gui/qt4/components/epg/EPGItem.cpp
index e9c761f..7469ccf 100644
--- a/modules/gui/qt4/components/epg/EPGItem.cpp
+++ b/modules/gui/qt4/components/epg/EPGItem.cpp
@@ -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 )
+    {
+        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() )
diff --git a/modules/gui/qt4/components/epg/EPGItem.hpp b/modules/gui/qt4/components/epg/EPGItem.hpp
index 6b1a950..b1e2761 100644
--- a/modules/gui/qt4/components/epg/EPGItem.hpp
+++ b/modules/gui/qt4/components/epg/EPGItem.hpp
@@ -53,6 +53,7 @@ public:
     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 +74,7 @@ private:
     QString     m_description;
     QString     m_shortDescription;
     bool        m_current;
+    uint8_t     m_rating;
 };
 
 #endif // EPGITEM_H
-- 
1.7.9




More information about the vlc-devel mailing list