+
+ // Look if the channel is still used by other events.
+ QList<QGraphicsItem*> itemList = items();
+ bool b_used = false;
+ for( int i = 0; i < itemList.count(); ++i )
+ {
+ EPGItem* item = qgraphicsitem_cast<EPGItem*>( itemList.at( i ) );
+ if ( !item )
+ continue;
+ if( item->getChannelNb() == channelNb )
+ {
+ b_used = true;
+ break;
+ }
+ }
+
+ // If the channel is no more used, then we remove it from the list
+ // and decrease the channel number of the concerned items.
+ if( !b_used )
+ {
+ m_channels.removeAt( channelNb );
+ for( int i = 0; i < itemList.count(); ++i )
+ {
+ EPGItem* item = qgraphicsitem_cast<EPGItem*>( itemList.at( i ) );
+ if ( !item )
+ continue;
+ int itemChannelNb = item->getChannelNb();
+ if( itemChannelNb > channelNb )
+ item->setChannelNb( itemChannelNb - 1 );
+ }
+ }