Diffstat (limited to 'core/multimedia/opieplayer/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index 039f3b1..3541e5f 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -37,47 +37,54 @@ | |||
37 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
38 | #include <qpe/mimetype.h> | 38 | #include <qpe/mimetype.h> |
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | 41 | ||
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qcstring.h> | 47 | #include <qcstring.h> |
48 | 48 | ||
49 | static inline QString fullBaseName ( const QFileInfo &fi ) | ||
50 | { | ||
51 | QString str = fi. fileName ( ); | ||
52 | return str. left ( str. findRev ( '.' )); | ||
53 | } | ||
54 | |||
55 | |||
49 | //extern PlayListWidget *playList; | 56 | //extern PlayListWidget *playList; |
50 | 57 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 58 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 59 | : QStringList (){ |
53 | //qDebug("<<<<<<<new m3u "+filePath); | 60 | //qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 61 | f.setName(filePath); |
55 | f.open(mode); | 62 | f.open(mode); |
56 | } | 63 | } |
57 | 64 | ||
58 | Om3u::~Om3u(){} | 65 | Om3u::~Om3u(){} |
59 | 66 | ||
60 | void Om3u::readM3u() { | 67 | void Om3u::readM3u() { |
61 | // qDebug("<<<<<<reading m3u "+f.name()); | 68 | // qDebug("<<<<<<reading m3u "+f.name()); |
62 | QTextStream t(&f); | 69 | QTextStream t(&f); |
63 | QString s; | 70 | QString s; |
64 | while ( !t.atEnd() ) { | 71 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 72 | s=t.readLine(); |
66 | qDebug(s); | 73 | qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 74 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 75 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 76 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 77 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 78 | QString name = fullBaseName ( f ); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 79 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 80 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 81 | append(s); |
75 | // qDebug(s); | 82 | // qDebug(s); |
76 | } else { // is url | 83 | } else { // is url |
77 | s.replace( QRegExp( "%20" )," " ); | 84 | s.replace( QRegExp( "%20" )," " ); |
78 | QString name; | 85 | QString name; |
79 | // if( name.left( 4 ) == "http" ) { | 86 | // if( name.left( 4 ) == "http" ) { |
80 | // name = s.right( s.length() - 7 ); | 87 | // name = s.right( s.length() - 7 ); |
81 | // } else { | 88 | // } else { |
82 | name = s; | 89 | name = s; |
83 | // } | 90 | // } |
@@ -96,25 +103,25 @@ void Om3u::readPls() { //it's a pls file | |||
96 | if( s.left(4) == "File" ) { | 103 | if( s.left(4) == "File" ) { |
97 | s = s.right( s.length() - 6 ); | 104 | s = s.right( s.length() - 6 ); |
98 | s.replace( QRegExp( "%20" )," "); | 105 | s.replace( QRegExp( "%20" )," "); |
99 | // qDebug( "adding " + s + " to playlist" ); | 106 | // qDebug( "adding " + s + " to playlist" ); |
100 | // numberofentries=2 | 107 | // numberofentries=2 |
101 | // File1=http | 108 | // File1=http |
102 | // Title | 109 | // Title |
103 | // Length | 110 | // Length |
104 | // Version | 111 | // Version |
105 | // File2=http | 112 | // File2=http |
106 | s = s.replace( QRegExp( "\\" ), "/" ); | 113 | s = s.replace( QRegExp( "\\" ), "/" ); |
107 | QFileInfo f( s ); | 114 | QFileInfo f( s ); |
108 | QString name = f.baseName(); | 115 | QString name = fullBaseName ( f ); |
109 | if( name.left( 4 ) == "http" ) { | 116 | if( name.left( 4 ) == "http" ) { |
110 | name = s.right( s.length() - 7); | 117 | name = s.right( s.length() - 7); |
111 | } else { | 118 | } else { |
112 | name = s; | 119 | name = s; |
113 | } | 120 | } |
114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 121 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
115 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 122 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
116 | append(s); | 123 | append(s); |
117 | else { //if its a url | 124 | else { //if its a url |
118 | if( name.right( 1 ).find( '/' ) == -1) { | 125 | if( name.right( 1 ).find( '/' ) == -1) { |
119 | s += "/"; | 126 | s += "/"; |
120 | } | 127 | } |