1 /*****************************************************************************
2 * podcast_configuration.cpp: Podcast configuration dialog
3 ****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan dot org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
27 #include "podcast_configuration.hpp"
29 PodcastConfigDialog *PodcastConfigDialog::instance = NULL;
31 PodcastConfigDialog::PodcastConfigDialog( QWidget *parent, intf_thread_t *_p_intf)
32 : QVLCDialog( parent, _p_intf )
37 ui.podcastDelete->setToolTip( qtr( "Delete the selected item" ) );
38 QPushButton *okButton = new QPushButton( qtr( "&Close" ), this );
39 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ), this );
40 ui.okCancel->addButton( okButton, QDialogButtonBox::AcceptRole );
41 ui.okCancel->addButton( cancelButton, QDialogButtonBox::RejectRole );
43 CONNECT( ui.podcastAdd, clicked(), this, add() );
44 CONNECT( ui.podcastDelete, clicked(), this, remove() );
46 char *psz_urls = config_GetPsz( p_intf, "podcast-urls" );
49 char *psz_url = psz_urls;
52 char *psz_tok = strchr( psz_url, '|' );
53 if( psz_tok ) *psz_tok = '\0';
54 ui.podcastList->addItem( psz_url );
55 if( psz_tok ) psz_url = psz_tok+1;
62 PodcastConfigDialog::~PodcastConfigDialog()
66 void PodcastConfigDialog::accept()
69 for( int i = 0; i < ui.podcastList->count(); i++ )
71 urls += ui.podcastList->item(i)->text();
72 if( i != ui.podcastList->count()-1 ) urls += "|";
74 const char *psz_urls = qtu( urls );
75 config_PutPsz( p_intf, "podcast-urls", psz_urls );
76 vlc_object_t *p_obj = (vlc_object_t*)
77 vlc_object_find_name( p_intf->p_libvlc,
78 "podcast", FIND_CHILD );
81 var_SetString( p_obj, "podcast-urls", psz_urls );
82 vlc_object_release( p_obj );
85 if( playlist_IsServicesDiscoveryLoaded( THEPL, "podcast" ) )
87 msg_Dbg( p_intf, "You will need to reload the podcast module to take into account deleted podcast urls" );
91 void PodcastConfigDialog::add()
93 if( ui.podcastURL->text() != QString( "" ) )
95 ui.podcastList->addItem( ui.podcastURL->text() );
96 ui.podcastURL->clear();
100 void PodcastConfigDialog::remove()
102 delete ui.podcastList->currentItem();