author | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
commit | 24097a2790fd7bb241a0a8da24ef2996e4f4ad15 (patch) (unidiff) | |
tree | 142e0fb758067bc9a601b3bd2dabdff27675c0f3 /core/multimedia/opieplayer/om3u.cpp | |
parent | 188319af82322c84f02e1abb848d908ca8f9e26c (diff) | |
download | opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.zip opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.gz opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.bz2 |
fix setDoc for playlists and others. remove qDebugs
Diffstat (limited to 'core/multimedia/opieplayer/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index 3541e5f..8b92a8c 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -27,136 +27,136 @@ | |||
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 ) | 49 | static inline QString fullBaseName ( const QFileInfo &fi ) |
50 | { | 50 | { |
51 | QString str = fi. fileName ( ); | 51 | QString str = fi. fileName ( ); |
52 | return str. left ( str. findRev ( '.' )); | 52 | return str. left ( str. findRev ( '.' )); |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | //extern PlayListWidget *playList; | 56 | //extern PlayListWidget *playList; |
57 | 57 | ||
58 | Om3u::Om3u( const QString &filePath, int mode) | 58 | Om3u::Om3u( const QString &filePath, int mode) |
59 | : QStringList (){ | 59 | : QStringList (){ |
60 | //qDebug("<<<<<<<new m3u "+filePath); | 60 | //qDebug("<<<<<<<new m3u "+filePath); |
61 | f.setName(filePath); | 61 | f.setName(filePath); |
62 | f.open(mode); | 62 | f.open(mode); |
63 | } | 63 | } |
64 | 64 | ||
65 | Om3u::~Om3u(){} | 65 | Om3u::~Om3u(){} |
66 | 66 | ||
67 | void Om3u::readM3u() { | 67 | void Om3u::readM3u() { |
68 | // qDebug("<<<<<<reading m3u "+f.name()); | 68 | // qDebug("<<<<<<reading m3u "+f.name()); |
69 | QTextStream t(&f); | 69 | QTextStream t(&f); |
70 | QString s; | 70 | QString s; |
71 | while ( !t.atEnd() ) { | 71 | while ( !t.atEnd() ) { |
72 | s=t.readLine(); | 72 | s=t.readLine(); |
73 | qDebug(s); | 73 | // qDebug(s); |
74 | if( s.find( "#", 0, TRUE) == -1 ) { | 74 | if( s.find( "#", 0, TRUE) == -1 ) { |
75 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 75 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
76 | s = s.right( s.length() -2 ); | 76 | s = s.right( s.length() -2 ); |
77 | QFileInfo f( s ); | 77 | QFileInfo f( s ); |
78 | QString name = fullBaseName ( f ); | 78 | QString name = fullBaseName ( f ); |
79 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 79 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
80 | s=s.replace( QRegExp( "\\" ), "/" ); | 80 | s=s.replace( QRegExp( "\\" ), "/" ); |
81 | append(s); | 81 | append(s); |
82 | // qDebug(s); | 82 | // qDebug(s); |
83 | } else { // is url | 83 | } else { // is url |
84 | s.replace( QRegExp( "%20" )," " ); | 84 | s.replace( QRegExp( "%20" )," " ); |
85 | QString name; | 85 | QString name; |
86 | // if( name.left( 4 ) == "http" ) { | 86 | // if( name.left( 4 ) == "http" ) { |
87 | // name = s.right( s.length() - 7 ); | 87 | // name = s.right( s.length() - 7 ); |
88 | // } else { | 88 | // } else { |
89 | name = s; | 89 | name = s; |
90 | // } | 90 | // } |
91 | append(name); | 91 | append(name); |
92 | // qDebug(name); | 92 | // qDebug(name); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | void Om3u::readPls() { //it's a pls file | 98 | void Om3u::readPls() { //it's a pls file |
99 | QTextStream t( &f ); | 99 | QTextStream t( &f ); |
100 | QString s; | 100 | QString s; |
101 | while ( !t.atEnd() ) { | 101 | while ( !t.atEnd() ) { |
102 | s = t.readLine(); | 102 | s = t.readLine(); |
103 | if( s.left(4) == "File" ) { | 103 | if( s.left(4) == "File" ) { |
104 | s = s.right( s.length() - 6 ); | 104 | s = s.right( s.length() - 6 ); |
105 | s.replace( QRegExp( "%20" )," "); | 105 | s.replace( QRegExp( "%20" )," "); |
106 | // qDebug( "adding " + s + " to playlist" ); | 106 | // qDebug( "adding " + s + " to playlist" ); |
107 | // numberofentries=2 | 107 | // numberofentries=2 |
108 | // File1=http | 108 | // File1=http |
109 | // Title | 109 | // Title |
110 | // Length | 110 | // Length |
111 | // Version | 111 | // Version |
112 | // File2=http | 112 | // File2=http |
113 | s = s.replace( QRegExp( "\\" ), "/" ); | 113 | s = s.replace( QRegExp( "\\" ), "/" ); |
114 | QFileInfo f( s ); | 114 | QFileInfo f( s ); |
115 | QString name = fullBaseName ( f ); | 115 | QString name = fullBaseName ( f ); |
116 | if( name.left( 4 ) == "http" ) { | 116 | if( name.left( 4 ) == "http" ) { |
117 | name = s.right( s.length() - 7); | 117 | name = s.right( s.length() - 7); |
118 | } else { | 118 | } else { |
119 | name = s; | 119 | name = s; |
120 | } | 120 | } |
121 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 121 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
122 | 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 |
123 | append(s); | 123 | append(s); |
124 | else { //if its a url | 124 | else { //if its a url |
125 | if( name.right( 1 ).find( '/' ) == -1) { | 125 | if( name.right( 1 ).find( '/' ) == -1) { |
126 | s += "/"; | 126 | s += "/"; |
127 | } | 127 | } |
128 | append(s); | 128 | append(s); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | void Om3u::write() { //writes list to m3u file | 134 | void Om3u::write() { //writes list to m3u file |
135 | QString list; | 135 | QString list; |
136 | if(count()>0) { | 136 | if(count()>0) { |
137 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 137 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
138 | qDebug(*it); | 138 | // qDebug(*it); |
139 | list += *it+"\n"; | 139 | list += *it+"\n"; |
140 | } | 140 | } |
141 | f.writeBlock( list, list.length() ); | 141 | f.writeBlock( list, list.length() ); |
142 | } | 142 | } |
143 | // f.close(); | 143 | // f.close(); |
144 | } | 144 | } |
145 | 145 | ||
146 | void Om3u::add(const QString &filePath) { //adds to m3u file | 146 | void Om3u::add(const QString &filePath) { //adds to m3u file |
147 | append(filePath); | 147 | append(filePath); |
148 | } | 148 | } |
149 | 149 | ||
150 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 150 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
151 | QString list, currentFile; | 151 | QString list, currentFile; |
152 | if(count()>0) { | 152 | if(count()>0) { |
153 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 153 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
154 | currentFile=*it; | 154 | currentFile=*it; |
155 | // qDebug(*it); | 155 | // qDebug(*it); |
156 | 156 | ||
157 | if( filePath != currentFile) | 157 | if( filePath != currentFile) |
158 | list += currentFile+"\n"; | 158 | list += currentFile+"\n"; |
159 | } | 159 | } |
160 | f.writeBlock( list, list.length() ); | 160 | f.writeBlock( list, list.length() ); |
161 | } | 161 | } |
162 | } | 162 | } |