Diffstat (limited to 'core/multimedia/opieplayer/om3u.cpp') (more/less context) (show 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 | |||
@@ -25,108 +25,115 @@ | |||
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "playlistwidget.h" | 32 | #include "playlistwidget.h" |
33 | #include "om3u.h" | 33 | #include "om3u.h" |
34 | 34 | ||
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
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 | // } |
84 | append(name); | 91 | append(name); |
85 | // qDebug(name); | 92 | // qDebug(name); |
86 | } | 93 | } |
87 | } | 94 | } |
88 | } | 95 | } |
89 | } | 96 | } |
90 | 97 | ||
91 | void Om3u::readPls() { //it's a pls file | 98 | void Om3u::readPls() { //it's a pls file |
92 | QTextStream t( &f ); | 99 | QTextStream t( &f ); |
93 | QString s; | 100 | QString s; |
94 | while ( !t.atEnd() ) { | 101 | while ( !t.atEnd() ) { |
95 | s = t.readLine(); | 102 | s = t.readLine(); |
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 | } |
121 | append(s); | 128 | append(s); |
122 | } | 129 | } |
123 | } | 130 | } |
124 | } | 131 | } |
125 | } | 132 | } |
126 | 133 | ||
127 | void Om3u::write() { //writes list to m3u file | 134 | void Om3u::write() { //writes list to m3u file |
128 | QString list; | 135 | QString list; |
129 | if(count()>0) { | 136 | if(count()>0) { |
130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 137 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
131 | qDebug(*it); | 138 | qDebug(*it); |
132 | list += *it+"\n"; | 139 | list += *it+"\n"; |