-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 29 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 64 |
2 files changed, 47 insertions, 46 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 0be727b..039f3b1 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -5,164 +5,161 @@ | |||
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
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 | //extern PlayListWidget *playList; | 49 | //extern PlayListWidget *playList; |
50 | 50 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
53 | //filePath is path name to m3u | ||
54 | //qDebug("<<<<<<<new m3u "+filePath); | 53 | //qDebug("<<<<<<<new m3u "+filePath); |
55 | f.setName(filePath); | 54 | f.setName(filePath); |
56 | // if(f.exists()) | 55 | f.open(mode); |
57 | // f.open( IO_ReadWrite); | ||
58 | // else | ||
59 | // f.open( IO_ReadWrite | IO_Truncate); | ||
60 | f.open(mode); | ||
61 | |||
62 | } | 56 | } |
63 | 57 | ||
64 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
65 | 59 | ||
66 | void Om3u::readM3u() { | 60 | void Om3u::readM3u() { |
67 | // qDebug("<<<<<<reading m3u "+f.name()); | 61 | // qDebug("<<<<<<reading m3u "+f.name()); |
68 | QTextStream t(&f); | 62 | QTextStream t(&f); |
69 | QString s; | 63 | QString s; |
70 | while ( !t.atEnd() ) { | 64 | while ( !t.atEnd() ) { |
71 | s=t.readLine(); | 65 | s=t.readLine(); |
72 | qDebug(s); | 66 | qDebug(s); |
73 | if( s.find( "#", 0, TRUE) == -1 ) { | 67 | if( s.find( "#", 0, TRUE) == -1 ) { |
74 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
75 | s = s.right( s.length() -2 ); | 69 | s = s.right( s.length() -2 ); |
76 | QFileInfo f( s ); | 70 | QFileInfo f( s ); |
77 | QString name = f.baseName(); | 71 | QString name = f.baseName(); |
78 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
79 | s=s.replace( QRegExp( "\\" ), "/" ); | 73 | s=s.replace( QRegExp( "\\" ), "/" ); |
80 | append(s); | 74 | append(s); |
81 | // qDebug(s); | 75 | // qDebug(s); |
82 | } else { // is url | 76 | } else { // is url |
83 | s.replace( QRegExp( "%20" )," " ); | 77 | s.replace( QRegExp( "%20" )," " ); |
84 | QString name; | 78 | QString name; |
85 | // if( name.left( 4 ) == "http" ) { | 79 | // if( name.left( 4 ) == "http" ) { |
86 | // name = s.right( s.length() - 7 ); | 80 | // name = s.right( s.length() - 7 ); |
87 | // } else { | 81 | // } else { |
88 | name = s; | 82 | name = s; |
89 | // } | 83 | // } |
90 | append(name); | 84 | append(name); |
91 | // qDebug(name); | 85 | // qDebug(name); |
92 | } | 86 | } |
93 | } | 87 | } |
94 | } | 88 | } |
95 | } | 89 | } |
96 | 90 | ||
97 | void Om3u::readPls() { //it's a pls file | 91 | void Om3u::readPls() { //it's a pls file |
98 | QTextStream t( &f ); | 92 | QTextStream t( &f ); |
99 | QString s; | 93 | QString s; |
100 | while ( !t.atEnd() ) { | 94 | while ( !t.atEnd() ) { |
101 | s = t.readLine(); | 95 | s = t.readLine(); |
102 | if( s.left(4) == "File" ) { | 96 | if( s.left(4) == "File" ) { |
103 | s = s.right( s.length() - 6 ); | 97 | s = s.right( s.length() - 6 ); |
104 | s.replace( QRegExp( "%20" )," "); | 98 | s.replace( QRegExp( "%20" )," "); |
105 | // qDebug( "adding " + s + " to playlist" ); | 99 | // qDebug( "adding " + s + " to playlist" ); |
106 | // numberofentries=2 | 100 | // numberofentries=2 |
107 | // File1=http | 101 | // File1=http |
108 | // Title | 102 | // Title |
109 | // Length | 103 | // Length |
110 | // Version | 104 | // Version |
111 | // File2=http | 105 | // File2=http |
112 | s = s.replace( QRegExp( "\\" ), "/" ); | 106 | s = s.replace( QRegExp( "\\" ), "/" ); |
113 | QFileInfo f( s ); | 107 | QFileInfo f( s ); |
114 | QString name = f.baseName(); | 108 | QString name = f.baseName(); |
115 | if( name.left( 4 ) == "http" ) { | 109 | if( name.left( 4 ) == "http" ) { |
116 | name = s.right( s.length() - 7); | 110 | name = s.right( s.length() - 7); |
117 | } else { | 111 | } else { |
118 | name = s; | 112 | name = s; |
119 | } | 113 | } |
120 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
121 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 115 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
122 | append(s); | 116 | append(s); |
123 | else { //if its a url | 117 | else { //if its a url |
124 | if( name.right( 1 ).find( '/' ) == -1) { | 118 | if( name.right( 1 ).find( '/' ) == -1) { |
125 | s += "/"; | 119 | s += "/"; |
126 | } | 120 | } |
127 | append(s); | 121 | append(s); |
128 | } | 122 | } |
129 | } | 123 | } |
130 | } | 124 | } |
131 | } | 125 | } |
132 | 126 | ||
133 | void Om3u::write() { //writes list to m3u file | 127 | void Om3u::write() { //writes list to m3u file |
134 | QString list; | 128 | QString list; |
129 | if(count()>0) { | ||
135 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
136 | qDebug(*it); | 131 | qDebug(*it); |
137 | list += *it+"\n"; | 132 | list += *it+"\n"; |
138 | } | 133 | } |
139 | f.writeBlock( list, list.length() ); | 134 | f.writeBlock( list, list.length() ); |
135 | } | ||
140 | // f.close(); | 136 | // f.close(); |
141 | } | 137 | } |
142 | 138 | ||
143 | void Om3u::add(const QString &filePath) { //adds to m3u file | 139 | void Om3u::add(const QString &filePath) { //adds to m3u file |
144 | append(filePath); | 140 | append(filePath); |
145 | } | 141 | } |
146 | 142 | ||
147 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 143 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
148 | QString list, currentFile; | 144 | QString list, currentFile; |
145 | if(count()>0) { | ||
149 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
150 | currentFile=*it; | 147 | currentFile=*it; |
151 | // qDebug(*it); | 148 | // qDebug(*it); |
152 | 149 | ||
153 | if( filePath != currentFile) | 150 | if( filePath != currentFile) |
154 | list += currentFile+"\n"; | 151 | list += currentFile+"\n"; |
155 | } | 152 | } |
156 | f.writeBlock( list, list.length() ); | 153 | f.writeBlock( list, list.length() ); |
157 | 154 | } | |
158 | } | 155 | } |
159 | 156 | ||
160 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
161 | f.close(); | 158 | f.close(); |
162 | f.remove(); | 159 | f.remove(); |
163 | 160 | ||
164 | } | 161 | } |
165 | 162 | ||
166 | void Om3u::close() { //closes m3u file | 163 | void Om3u::close() { //closes m3u file |
167 | f.close(); | 164 | f.close(); |
168 | } | 165 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e28efd0..f9192e8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -140,109 +140,111 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
140 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 140 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
141 | d->tbPlay, SLOT( setOn( bool ) ) ); | 141 | d->tbPlay, SLOT( setOn( bool ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
143 | d->tbLoop, SLOT( setOn( bool ) ) ); | 143 | d->tbLoop, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
145 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 145 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
147 | this, SLOT( setPlaylist( bool ) ) ); | 147 | this, SLOT( setPlaylist( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 152 | ||
153 | // see which skins are installed | 153 | // see which skins are installed |
154 | videoScan=FALSE; | 154 | videoScan=FALSE; |
155 | audioScan=FALSE; | 155 | audioScan=FALSE; |
156 | populateSkinsMenu(); | 156 | populateSkinsMenu(); |
157 | initializeStates(); | 157 | initializeStates(); |
158 | 158 | ||
159 | cfg.setGroup("PlayList"); | 159 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
161 | loadList(DocLnk( currentPlaylist ) ); | 161 | loadList(DocLnk( currentPlaylist ) ); |
162 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 162 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | PlayListWidget::~PlayListWidget() { | 166 | PlayListWidget::~PlayListWidget() { |
167 | if ( d->current ) { | 167 | if ( d->current ) { |
168 | delete d->current; | 168 | delete d->current; |
169 | } | 169 | } |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 175 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
176 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
178 | setPlaylist( true ); | 178 | setPlaylist( true ); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 182 | ||
183 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 187 | if( currentString == filename) { |
188 | Om3u *m3uList; | 188 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | ||
190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | d->selectedFiles->first(); | ||
192 | do { | 192 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 193 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 194 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 195 | } |
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | |||
202 | } | ||
201 | } | 203 | } |
202 | } | 204 | } |
203 | 205 | ||
204 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
205 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
206 | if ( mediaPlayerState->playlist() ) { | 208 | if ( mediaPlayerState->playlist() ) { |
207 | if( QFileInfo( lnk.file() ).exists() || | 209 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) | 210 | lnk.file().left(4) == "http" ) |
209 | d->selectedFiles->addToSelection( lnk ); | 211 | d->selectedFiles->addToSelection( lnk ); |
210 | // writeCurrentM3u(); | 212 | // writeCurrentM3u(); |
211 | } | 213 | } |
212 | else | 214 | else |
213 | mediaPlayerState->setPlaying( TRUE ); | 215 | mediaPlayerState->setPlaying( TRUE ); |
214 | } | 216 | } |
215 | 217 | ||
216 | 218 | ||
217 | void PlayListWidget::clearList() { | 219 | void PlayListWidget::clearList() { |
218 | while ( first() ) { | 220 | while ( first() ) { |
219 | d->selectedFiles->removeSelected(); | 221 | d->selectedFiles->removeSelected(); |
220 | } | 222 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
224 | switch (mouse) { | 226 | switch (mouse) { |
225 | case 1: | 227 | case 1: |
226 | break; | 228 | break; |
227 | case 2: | 229 | case 2: |
228 | { | 230 | { |
229 | QPopupMenu m; | 231 | QPopupMenu m; |
230 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
232 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
233 | } | 235 | } |
234 | break; | 236 | break; |
235 | } | 237 | } |
236 | } | 238 | } |
237 | 239 | ||
238 | 240 | ||
239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
240 | switch (mouse) { | 242 | switch (mouse) { |
241 | case 1: | 243 | case 1: |
242 | break; | 244 | break; |
243 | case 2: | 245 | case 2: |
244 | { | 246 | { |
245 | QPopupMenu m; | 247 | QPopupMenu m; |
246 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
248 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
@@ -808,167 +810,169 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
808 | qDebug( "pls filename is " + filename ); | 810 | qDebug( "pls filename is " + filename ); |
809 | Om3u *m3uList; | 811 | Om3u *m3uList; |
810 | QString s, name; | 812 | QString s, name; |
811 | m3uList = new Om3u( filename, IO_ReadOnly ); | 813 | m3uList = new Om3u( filename, IO_ReadOnly ); |
812 | m3uList->readPls(); | 814 | m3uList->readPls(); |
813 | 815 | ||
814 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 816 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
815 | s = *it; | 817 | s = *it; |
816 | // s.replace( QRegExp( "%20" )," " ); | 818 | // s.replace( QRegExp( "%20" )," " ); |
817 | DocLnk lnk( s ); | 819 | DocLnk lnk( s ); |
818 | QFileInfo f( s ); | 820 | QFileInfo f( s ); |
819 | QString name = f.baseName(); | 821 | QString name = f.baseName(); |
820 | 822 | ||
821 | if( name.left( 4 ) == "http" ) { | 823 | if( name.left( 4 ) == "http" ) { |
822 | name = s.right( s.length() - 7); | 824 | name = s.right( s.length() - 7); |
823 | } else { | 825 | } else { |
824 | name = s; | 826 | name = s; |
825 | } | 827 | } |
826 | 828 | ||
827 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 829 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
828 | 830 | ||
829 | lnk.setName( name ); | 831 | lnk.setName( name ); |
830 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 832 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
831 | lnk.setFile( s ); | 833 | lnk.setFile( s ); |
832 | } else { //if its a url | 834 | } else { //if its a url |
833 | if( name.right( 1 ).find( '/' ) == -1) { | 835 | if( name.right( 1 ).find( '/' ) == -1) { |
834 | s += "/"; | 836 | s += "/"; |
835 | } | 837 | } |
836 | lnk.setFile( s ); | 838 | lnk.setFile( s ); |
837 | } | 839 | } |
838 | lnk.setType( "audio/x-mpegurl" ); | 840 | lnk.setType( "audio/x-mpegurl" ); |
839 | 841 | ||
840 | lnk.writeLink(); | 842 | lnk.writeLink(); |
841 | d->selectedFiles->addToSelection( lnk ); | 843 | d->selectedFiles->addToSelection( lnk ); |
842 | } | 844 | } |
843 | 845 | ||
844 | m3uList->close(); | 846 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 847 | if(m3uList) delete m3uList; |
846 | } | 848 | } |
847 | 849 | ||
848 | /* | 850 | /* |
849 | writes current playlist to current m3u file */ | 851 | writes current playlist to current m3u file */ |
850 | void PlayListWidget::writeCurrentM3u() { | 852 | void PlayListWidget::writeCurrentM3u() { |
851 | qDebug("writing to current m3u"); | 853 | qDebug("writing to current m3u"); |
852 | Config cfg( "OpiePlayer" ); | 854 | Config cfg( "OpiePlayer" ); |
853 | cfg.setGroup("PlayList"); | 855 | cfg.setGroup("PlayList"); |
854 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 856 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
855 | 857 | ||
858 | if( d->selectedFiles->first()) { | ||
856 | Om3u *m3uList; | 859 | Om3u *m3uList; |
857 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 860 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
858 | d->selectedFiles->first(); | 861 | |
862 | |||
859 | qDebug( d->selectedFiles->current()->file()); | 863 | qDebug( d->selectedFiles->current()->file()); |
860 | do { | 864 | do { |
861 | qDebug( d->selectedFiles->current()->file()); | 865 | qDebug( d->selectedFiles->current()->file()); |
862 | m3uList->add( d->selectedFiles->current()->file() ); | 866 | m3uList->add( d->selectedFiles->current()->file() ); |
863 | } | 867 | } |
864 | while ( d->selectedFiles->next() ); | 868 | while ( d->selectedFiles->next() ); |
865 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 869 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
866 | m3uList->write(); | 870 | m3uList->write(); |
867 | m3uList->close(); | 871 | m3uList->close(); |
868 | 872 | ||
869 | if(m3uList) delete m3uList; | 873 | if(m3uList) delete m3uList; |
874 | } | ||
870 | } | 875 | } |
871 | 876 | ||
872 | /* | 877 | /* |
873 | writes current playlist to m3u file */ | 878 | writes current playlist to m3u file */ |
874 | void PlayListWidget::writem3u() { | 879 | void PlayListWidget::writem3u() { |
875 | InputDialog *fileDlg; | 880 | InputDialog *fileDlg; |
876 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 881 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
877 | fileDlg->exec(); | 882 | fileDlg->exec(); |
878 | QString name, filename, list; | 883 | QString name, filename, list; |
879 | Om3u *m3uList; | 884 | Om3u *m3uList; |
880 | 885 | ||
881 | if( fileDlg->result() == 1 ) { | 886 | if( fileDlg->result() == 1 ) { |
882 | name = fileDlg->text(); | 887 | name = fileDlg->text(); |
883 | // qDebug( filename ); | 888 | // qDebug( filename ); |
884 | 889 | ||
885 | if( name.left( 1) != "/" ) { | 890 | if( name.left( 1) != "/" ) { |
886 | filename = QPEApplication::documentDir() + "/" + name; | 891 | filename = QPEApplication::documentDir() + "/" + name; |
887 | } | 892 | } |
888 | 893 | ||
889 | if( name.right( 3 ) != "m3u" ) { | 894 | if( name.right( 3 ) != "m3u" ) { |
890 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 895 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
891 | } | 896 | } |
892 | 897 | ||
898 | if( d->selectedFiles->first()) { | ||
893 | m3uList = new Om3u(filename, IO_ReadWrite); | 899 | m3uList = new Om3u(filename, IO_ReadWrite); |
894 | |||
895 | d->selectedFiles->first(); | ||
896 | 900 | ||
897 | do { | 901 | do { |
898 | m3uList->add( d->selectedFiles->current()->file()); | 902 | m3uList->add( d->selectedFiles->current()->file()); |
899 | } | 903 | } |
900 | while ( d->selectedFiles->next() ); | 904 | while ( d->selectedFiles->next() ); |
901 | // qDebug( list ); | 905 | // qDebug( list ); |
902 | m3uList->write(); | 906 | m3uList->write(); |
903 | m3uList->close(); | 907 | m3uList->close(); |
904 | if(m3uList) delete m3uList; | 908 | if(m3uList) delete m3uList; |
905 | 909 | ||
906 | if(fileDlg) delete fileDlg; | 910 | if(fileDlg) delete fileDlg; |
907 | 911 | ||
908 | DocLnk lnk; | 912 | DocLnk lnk; |
909 | lnk.setFile( filename); | 913 | lnk.setFile( filename); |
910 | lnk.setIcon("opieplayer2/playlist2"); | 914 | lnk.setIcon("opieplayer2/playlist2"); |
911 | lnk.setName( name); //sets file name | 915 | lnk.setName( name); //sets file name |
912 | 916 | ||
913 | // qDebug(filename); | 917 | // qDebug(filename); |
914 | Config config( "OpiePlayer" ); | 918 | Config config( "OpiePlayer" ); |
915 | config.setGroup( "PlayList" ); | 919 | config.setGroup( "PlayList" ); |
916 | 920 | ||
917 | config.writeEntry("CurrentPlaylist",filename); | 921 | config.writeEntry("CurrentPlaylist",filename); |
918 | currentPlayList=filename; | 922 | currentPlayList=filename; |
919 | 923 | ||
920 | if(!lnk.writeLink()) { | 924 | if(!lnk.writeLink()) { |
921 | qDebug("Writing doclink did not work"); | 925 | qDebug("Writing doclink did not work"); |
922 | } | 926 | } |
923 | 927 | ||
924 | setCaption(tr("OpiePlayer: ") + name); | 928 | setCaption(tr("OpiePlayer: ") + name); |
929 | } | ||
925 | } | 930 | } |
926 | |||
927 | } | 931 | } |
928 | 932 | ||
929 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 933 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
930 | switch ( e->key() ) { | 934 | switch ( e->key() ) { |
931 | ////////////////////////////// Zaurus keys | 935 | ////////////////////////////// Zaurus keys |
932 | case Key_F9: //activity | 936 | case Key_F9: //activity |
933 | // if(audioUI->isHidden()) | 937 | // if(audioUI->isHidden()) |
934 | // audioUI->showMaximized(); | 938 | // audioUI->showMaximized(); |
935 | break; | 939 | break; |
936 | case Key_F10: //contacts | 940 | case Key_F10: //contacts |
937 | // if( videoUI->isHidden()) | 941 | // if( videoUI->isHidden()) |
938 | // videoUI->showMaximized(); | 942 | // videoUI->showMaximized(); |
939 | break; | 943 | break; |
940 | case Key_F11: //menu | 944 | case Key_F11: //menu |
941 | break; | 945 | break; |
942 | case Key_F12: //home | 946 | case Key_F12: //home |
943 | // doBlank(); | 947 | // doBlank(); |
944 | break; | 948 | break; |
945 | case Key_F13: //mail | 949 | case Key_F13: //mail |
946 | // doUnblank(); | 950 | // doUnblank(); |
947 | break; | 951 | break; |
948 | case Key_Q: //add to playlist | 952 | case Key_Q: //add to playlist |
949 | addSelected(); | 953 | addSelected(); |
950 | break; | 954 | break; |
951 | case Key_R: //remove from playlist | 955 | case Key_R: //remove from playlist |
952 | removeSelected(); | 956 | removeSelected(); |
953 | break; | 957 | break; |
954 | // case Key_P: //play | 958 | // case Key_P: //play |
955 | // qDebug("Play"); | 959 | // qDebug("Play"); |
956 | // playSelected(); | 960 | // playSelected(); |
957 | // break; | 961 | // break; |
958 | case Key_Space: | 962 | case Key_Space: |
959 | // playSelected(); puh | 963 | // playSelected(); puh |
960 | break; | 964 | break; |
961 | case Key_1: | 965 | case Key_1: |
962 | tabWidget->setCurrentPage( 0 ); | 966 | tabWidget->setCurrentPage( 0 ); |
963 | break; | 967 | break; |
964 | case Key_2: | 968 | case Key_2: |
965 | tabWidget->setCurrentPage( 1 ); | 969 | tabWidget->setCurrentPage( 1 ); |
966 | break; | 970 | break; |
967 | case Key_3: | 971 | case Key_3: |
968 | tabWidget->setCurrentPage( 2 ); | 972 | tabWidget->setCurrentPage( 2 ); |
969 | break; | 973 | break; |
970 | case Key_4: | 974 | case Key_4: |
971 | tabWidget->setCurrentPage( 3 ); | 975 | tabWidget->setCurrentPage( 3 ); |
972 | break; | 976 | break; |
973 | case Key_Down: | 977 | case Key_Down: |
974 | if ( !d->selectedFiles->next() ) | 978 | if ( !d->selectedFiles->next() ) |