podcast_configuration.cpp 3.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*****************************************************************************
 * podcast_configuration.cpp: Podcast configuration dialog
 ****************************************************************************
 * Copyright (C) 2007 the VideoLAN team
 * $Id$
 *
 * Authors: Antoine Cellerier <dionoea at videolan dot org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
23
24
25
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
26
27
28

#include "podcast_configuration.hpp"

29
30
PodcastConfigDialog::PodcastConfigDialog( intf_thread_t *_p_intf)
                    : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
31

32
33
{
    ui.setupUi( this );
34

35
    ui.podcastDelete->setToolTip( qtr( "Deletes the selected item" ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
36
    QPushButton *okButton = new QPushButton( qtr( "&Close" ), this );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
37
    QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ), this );
38
39
    ui.okCancel->addButton( okButton, QDialogButtonBox::AcceptRole );
    ui.okCancel->addButton( cancelButton, QDialogButtonBox::RejectRole );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
40

41
42
    CONNECT( ui.podcastAdd, clicked(), this, add() );
    CONNECT( ui.podcastDelete, clicked(), this, remove() );
43
    CONNECT( okButton, clicked(), this, close() );
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

    char *psz_urls = config_GetPsz( p_intf, "podcast-urls" );
    if( psz_urls )
    {
        char *psz_url = psz_urls;
        while( 1 )
        {
            char *psz_tok = strchr( psz_url, '|' );
            if( psz_tok ) *psz_tok = '\0';
            ui.podcastList->addItem( psz_url );
            if( psz_tok ) psz_url = psz_tok+1;
            else break;
        }
        free( psz_urls );
    }
}

61
62
63
64
65
PodcastConfigDialog::~PodcastConfigDialog()
{
}

void PodcastConfigDialog::accept()
66
67
68
69
70
71
72
{
    QString urls = "";
    for( int i = 0; i < ui.podcastList->count(); i++ )
    {
        urls +=  ui.podcastList->item(i)->text();
        if( i != ui.podcastList->count()-1 ) urls += "|";
    }
ivoire's avatar
ivoire committed
73
    config_PutPsz( p_intf, "podcast-urls", qtu( urls ) );
74
    config_SaveConfigFile( p_intf, "podcast" );
75
76
77
78
79
    vlc_object_t *p_obj = (vlc_object_t*)
                          vlc_object_find_name( p_intf->p_libvlc,
                                                "podcast", FIND_CHILD );
    if( p_obj )
    {
ivoire's avatar
ivoire committed
80
        var_SetString( p_obj, "podcast-urls", qtu( urls ) );
81
82
83
        vlc_object_release( p_obj );
    }

84
85
    if( playlist_IsServicesDiscoveryLoaded( THEPL, "podcast" ) )
    {
86
        msg_Dbg( p_intf, "You will need to reload the podcast module to take into account deleted podcast urls" );
87
88
89
    }
}

90
void PodcastConfigDialog::add()
91
92
93
94
95
96
97
98
{
    if( ui.podcastURL->text() != QString( "" ) )
    {
        ui.podcastList->addItem( ui.podcastURL->text() );
        ui.podcastURL->clear();
    }
}

99
void PodcastConfigDialog::remove()
100
101
102
{
    delete ui.podcastList->currentItem();
}