]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/epg/EPGChannels.cpp
Qt: EPG: fix mutex position
[vlc] / modules / gui / qt4 / components / epg / EPGChannels.cpp
index 48cc81538ace2493e25384c937e43fa4d56e7122..42ba6199111acc275c83f2d5ce017266f6844b6a 100644 (file)
@@ -39,6 +39,21 @@ void EPGChannels::setOffset( int offset )
     update();
 }
 
+void EPGChannels::addChannel( QString channelName )
+{
+    if ( !channelList.contains( channelName ) )
+    {
+        channelList << channelName;
+        channelList.sort();
+        update();
+    }
+}
+
+void EPGChannels::removeChannel( QString channelName )
+{
+    if ( channelList.removeOne( channelName ) ) update();
+}
+
 void EPGChannels::paintEvent( QPaintEvent *event )
 {
     Q_UNUSED( event );
@@ -48,16 +63,18 @@ void EPGChannels::paintEvent( QPaintEvent *event )
     /* Draw the top and the bottom lines. */
     p.drawLine( 0, 0, width() - 1, 0 );
 
-    p.setFont( QFont( "Verdana", 8 ) );
-
-    QList<QString> channels = m_epgView->getChannelList();
-
-    for( int i = 0; i < channels.count(); ++i )
+    unsigned int i=0;
+    foreach( QString text, channelList )
     {
-        p.drawText( 0, - m_offset + ( i + 0.5 ) * TRACKS_HEIGHT - 4,
-                    width(), 20, Qt::AlignLeft, channels[i] );
+        /* try to remove the " [Program xxx]" end */
+        int i_idx_channel = text.lastIndexOf(" [Program ");
+        if (i_idx_channel > 0)
+            text = text.left( i_idx_channel );
+
+        p.drawText( 0, - m_offset + ( i++ + 0.5 ) * TRACKS_HEIGHT - 4,
+                    width(), 20, Qt::AlignLeft, text );
 
-        int i_width = fontMetrics().width( channels[i] );
+        int i_width = fontMetrics().width( text );
         if( width() < i_width )
             setMinimumWidth( i_width );
     }