+ int c = podcastsParent->childCount();
+ for( int i = 0; i < c; i++ )
+ {
+ QTreeWidgetItem *item = podcastsParent->child(i);
+ if( item->data( 0, PL_ITEM_ID_ROLE ).toInt() == id )
+ {
+ input_item_t *p_input = item->data( 0, IN_ITEM_ROLE ).value<input_item_t*>();
+ //msg_Dbg( p_intf, "Removing podcast: (%d) %s", id, p_input->psz_uri );
+ vlc_gc_decref( p_input );
+ delete item;
+ return;
+ }
+ }
+}
+
+void PLSelector::inputItemUpdate( input_item_t *arg )
+{
+ int c = podcastsParent->childCount();
+ for( int i = 0; i < c; i++ )
+ {
+ QTreeWidgetItem *item = podcastsParent->child(i);
+ input_item_t *p_input = item->data( 0, IN_ITEM_ROLE ).value<input_item_t*>();
+ if( p_input == arg )
+ {
+ PLSelItem *si = itemWidget( item );
+ char *psz_name = input_item_GetName( p_input );
+ si->setText( qfu( psz_name ) );
+ free( psz_name );
+ return;
+ }
+ }
+}
+
+void PLSelector::podcastAdd( PLSelItem * )
+{
+ bool ok;
+ QString url = QInputDialog::getText( this, qtr( "Subscribe" ),
+ qtr( "Enter URL of the podcast to subscribe to:" ),
+ QLineEdit::Normal, QString(), &ok );
+ if( !ok || url.isEmpty() ) return;
+
+ setSource( podcastsParent ); //to load the SD in case it's not loaded
+
+ vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name( p_intf->p_libvlc, "podcast" );
+ if( !p_obj ) return;
+
+ QString request("ADD:");
+ request += url.trimmed();
+ var_SetString( p_obj, "podcast-request", qtu( request ) );
+ vlc_object_release( p_obj );
+}
+
+void PLSelector::podcastRemove( PLSelItem* item )
+{
+ QString question ( qtr( "Do you really want to unsubscribe from %1?" ) );
+ question = question.arg( item->text() );
+ QMessageBox::StandardButton res =
+ QMessageBox::question( this, qtr( "Unsubscribe" ), question,
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel );
+ if( res == QMessageBox::Cancel ) return;
+
+ input_item_t *input = item->treeItem()->data( 0, IN_ITEM_ROLE ).value<input_item_t*>();
+ if( !input ) return;
+
+ vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name(
+ p_intf->p_libvlc, "podcast" );
+ if( !p_obj ) return;
+
+ QString request("RM:");
+ char *psz_uri = input_item_GetURI( input );
+ request += qfu( psz_uri );
+ var_SetString( p_obj, "podcast-request", qtu( request ) );
+ vlc_object_release( p_obj );
+ free( psz_uri );
+}
+
+PLSelItem * PLSelector::itemWidget( QTreeWidgetItem *item )
+{
+ return ( static_cast<PLSelItem*>( QTreeWidget::itemWidget( item, 0 ) ) );
+}
+
+void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) const
+{
+ if( !model()->hasChildren( index ) ) return;
+ QStyleOption option;
+ option.initFrom( this );
+ option.rect = rect.adjusted( rect.width() - indentation(), 0, 0, 0 );
+ style()->drawPrimitive( isExpanded( index ) ?
+ QStyle::PE_IndicatorArrowDown :
+ QStyle::PE_IndicatorArrowRight, &option, painter );
+}
+
+void PLSelector::getCurrentItemInfos( int* type, bool* can_delay_search, QString *string)
+{
+ *type = currentItem()->data( 0, TYPE_ROLE ).toInt();
+ *string = currentItem()->data( 0, NAME_ROLE ).toString();
+ *can_delay_search = currentItem()->data( 0, CAP_SEARCH_ROLE ).toBool();
+}
+
+int PLSelector::getCurrentItemCategory()
+{
+ return currentItem()->data( 0, SPECIAL_ROLE ).toInt();
+}
+
+void PLSelector::wheelEvent( QWheelEvent *e )
+{
+ if( verticalScrollBar()->isVisible() && (
+ (verticalScrollBar()->value() != verticalScrollBar()->minimum() && e->delta() >= 0 ) ||
+ (verticalScrollBar()->value() != verticalScrollBar()->maximum() && e->delta() < 0 )
+ ) )
+ QApplication::sendEvent(verticalScrollBar(), e);
+
+ // Accept this event in order to prevent unwanted volume up/down changes
+ e->accept();