source: smplayer/vendor/0.8.5/src/tvlist.cpp@ 179

Last change on this file since 179 was 140, checked in by Silvan Scherrer, 13 years ago

SMPlayer: update vendor to 0.8.5'

File size: 3.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "tvlist.h"
20#include "favoriteeditor.h"
21#include "images.h"
22
23#include <QFile>
24#include <QDir>
25#include <QTextStream>
26
27TVList::TVList(bool check_channels_conf, Services services, QString filename, QWidget * parent)
28 : Favorites(filename,parent)
29{
30#ifndef Q_OS_WIN
31 if (check_channels_conf) {
32 /* f_list.clear(); */
33 parse_channels_conf(services);
34 updateMenu();
35 }
36#endif
37}
38
39TVList::~TVList() {
40}
41
42Favorites * TVList::createNewObject(QString filename, QWidget * parent) {
43 return new TVList(false, TV, filename, parent);
44}
45
46#ifndef Q_OS_WIN
47void TVList::parse_channels_conf(Services services) {
48 qDebug("TVList::parse_channels_conf");
49
50 QString file = QDir::homePath() + "/.mplayer/channels.conf.ter";
51
52 if (!QFile::exists(file)) {
53 qDebug("VList::parse_channels_conf: %s doesn't exist", file.toUtf8().constData());
54 file = QDir::homePath() + "/.mplayer/channels.conf";
55 }
56
57 QFile f( file );
58 if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
59 qDebug("TVList::parse_channels_conf: can't open %s", file.toUtf8().constData());
60 return;
61 }
62
63 QTextStream in(&f);
64 while (!in.atEnd()) {
65 QString line = in.readLine();
66 qDebug("TVList::parse_channels_conf: '%s'", line.toUtf8().constData());
67 QString channel = line.section(':', 0, 0);
68 QString video_pid = line.section(':', 10, 10);
69 QString audio_pid = line.section(':', 11, 11);
70 bool is_radio = (video_pid == "0" && audio_pid != "0");
71 bool is_data = (video_pid == "0" && audio_pid == "0");
72 bool is_tv = (!is_radio && !is_data);
73 if (!channel.isEmpty()) {
74 qDebug("TVList::parse_channels_conf: channel: '%s' video_pid: %s audio_pid: %s", channel.toUtf8().constData(),video_pid.toUtf8().constData(),audio_pid.toUtf8().constData());
75 QString channel_id = "dvb://"+channel;
76 if (findFile(channel_id) == -1) {
77 if ( (services.testFlag(TVList::TV) && is_tv) ||
78 (services.testFlag(TVList::Radio) && is_radio) ||
79 (services.testFlag(TVList::Data) && is_data) )
80 {
81 f_list.append( Favorite(channel, channel_id) );
82 }
83 }
84 }
85 }
86}
87#endif
88
89void TVList::edit() {
90 qDebug("TVList::edit");
91
92 FavoriteEditor e(parent_widget);
93
94 e.setWindowTitle( tr("Channel editor") );
95 e.setCaption( tr("TV/Radio list") );
96 e.setDialogIcon( Images::icon("open_tv") );
97
98 e.setData(f_list);
99 e.setStorePath( QFileInfo(_filename).absolutePath() );
100
101 if (e.exec() == QDialog::Accepted) {
102 f_list = e.data();
103 updateMenu();
104 }
105}
106
107#include "moc_tvlist.cpp"
Note: See TracBrowser for help on using the repository browser.