-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.cpp | 17 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 15 |
3 files changed, 40 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index cb16415..3ef4d03 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp | |||
@@ -1,78 +1,95 @@ | |||
1 | 1 | ||
2 | #include "playlistfileview.h" | 2 | #include "playlistfileview.h" |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qpe/global.h> | 5 | #include <qpe/global.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | 7 | ||
8 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) | 8 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) |
9 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ), | 9 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ), |
10 | m_viewPopulated( false ) | 10 | m_viewPopulated( false ) |
11 | { | 11 | { |
12 | addColumn( tr( "Title" ), 140); | 12 | addColumn( tr( "Title" ), 140); |
13 | addColumn( tr( "Size" ), -1 ); | 13 | addColumn( tr( "Size" ), -1 ); |
14 | addColumn(tr( "Media" ), 0 ); | 14 | addColumn(tr( "Media" ), 0 ); |
15 | addColumn(tr( "Path" ), -1 ); | 15 | addColumn(tr( "Path" ), -1 ); |
16 | setColumnAlignment( 1, Qt::AlignRight ); | 16 | setColumnAlignment( 1, Qt::AlignRight ); |
17 | setColumnAlignment( 2, Qt::AlignRight ); | 17 | setColumnAlignment( 2, Qt::AlignRight ); |
18 | setAllColumnsShowFocus( TRUE ); | 18 | setAllColumnsShowFocus( TRUE ); |
19 | setSorting( 3, TRUE ); | 19 | setSorting( 3, TRUE ); |
20 | setMultiSelection( TRUE ); | 20 | setMultiSelection( TRUE ); |
21 | setSelectionMode( QListView::Extended ); | 21 | setSelectionMode( QListView::Extended ); |
22 | |||
23 | connect( this, SIGNAL( selectionChanged() ), | ||
24 | this, SLOT( checkSelection() ) ); | ||
22 | } | 25 | } |
23 | 26 | ||
24 | PlayListFileView::~PlayListFileView() | 27 | PlayListFileView::~PlayListFileView() |
25 | { | 28 | { |
26 | } | 29 | } |
27 | 30 | ||
31 | bool PlayListFileView::hasSelection() const | ||
32 | { | ||
33 | for ( QListViewItemIterator it( const_cast<PlayListFileView *>( this ) ); it.current(); ++it ) | ||
34 | if ( it.current()->isSelected() ) | ||
35 | return true; | ||
36 | |||
37 | return false; | ||
38 | } | ||
39 | |||
28 | void PlayListFileView::scanFiles() | 40 | void PlayListFileView::scanFiles() |
29 | { | 41 | { |
30 | m_files.detachChildren(); | 42 | m_files.detachChildren(); |
31 | QListIterator<DocLnk> sdit( m_files.children() ); | 43 | QListIterator<DocLnk> sdit( m_files.children() ); |
32 | for ( ; sdit.current(); ++sdit ) | 44 | for ( ; sdit.current(); ++sdit ) |
33 | delete sdit.current(); | 45 | delete sdit.current(); |
34 | 46 | ||
35 | Global::findDocuments( &m_files, m_mimeTypePattern ); | 47 | Global::findDocuments( &m_files, m_mimeTypePattern ); |
36 | 48 | ||
37 | if ( m_viewPopulated ) { | 49 | if ( m_viewPopulated ) { |
38 | m_viewPopulated = false; | 50 | m_viewPopulated = false; |
39 | populateView(); | 51 | populateView(); |
40 | } | 52 | } |
41 | } | 53 | } |
42 | 54 | ||
43 | void PlayListFileView::populateView() | 55 | void PlayListFileView::populateView() |
44 | { | 56 | { |
45 | if ( m_viewPopulated ) | 57 | if ( m_viewPopulated ) |
46 | return; | 58 | return; |
47 | 59 | ||
48 | clear(); | 60 | clear(); |
49 | 61 | ||
50 | if( !m_scannedFiles ) { | 62 | if( !m_scannedFiles ) { |
51 | m_viewPopulated = false; // avoid a recursion :) | 63 | m_viewPopulated = false; // avoid a recursion :) |
52 | scanFiles(); | 64 | scanFiles(); |
53 | m_scannedFiles = true; | 65 | m_scannedFiles = true; |
54 | } | 66 | } |
55 | 67 | ||
56 | m_viewPopulated = true; | 68 | m_viewPopulated = true; |
57 | 69 | ||
58 | QString storage; | 70 | QString storage; |
59 | QListIterator<DocLnk> dit( m_files.children() ); | 71 | QListIterator<DocLnk> dit( m_files.children() ); |
60 | for ( ; dit.current(); ++dit ) { | 72 | for ( ; dit.current(); ++dit ) { |
61 | 73 | ||
62 | QListViewItem *newItem; | 74 | QListViewItem *newItem; |
63 | 75 | ||
64 | if ( QFile::exists( dit.current()->file() ) || | 76 | if ( QFile::exists( dit.current()->file() ) || |
65 | dit.current()->file().left( 4 ) == "http" ) { | 77 | dit.current()->file().left( 4 ) == "http" ) { |
66 | 78 | ||
67 | unsigned long size = QFile( dit.current()->file() ).size(); | 79 | unsigned long size = QFile( dit.current()->file() ).size(); |
68 | 80 | ||
69 | newItem = new QListViewItem( this, dit.current()->name(), | 81 | newItem = new QListViewItem( this, dit.current()->name(), |
70 | QString::number( size ), "" /*storage*/, | 82 | QString::number( size ), "" /*storage*/, |
71 | dit.current()->file() ); | 83 | dit.current()->file() ); |
72 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); | 84 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); |
73 | } | 85 | } |
74 | } | 86 | } |
75 | } | 87 | } |
76 | 88 | ||
89 | void PlayListFileView::checkSelection() | ||
90 | { | ||
91 | emit itemsSelected( hasSelection() ); | ||
92 | } | ||
93 | |||
77 | /* vim: et sw=4 ts=4 | 94 | /* vim: et sw=4 ts=4 |
78 | */ | 95 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index 6eea2fc..5b15526 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h | |||
@@ -1,29 +1,37 @@ | |||
1 | #ifndef PLAYLISTFILEVIEW_H | 1 | #ifndef PLAYLISTFILEVIEW_H |
2 | #define PLAYLISTFILEVIEW_H | 2 | #define PLAYLISTFILEVIEW_H |
3 | 3 | ||
4 | #include "playlistview.h" | 4 | #include "playlistview.h" |
5 | 5 | ||
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | 7 | ||
8 | class PlayListFileView : public PlayListView | 8 | class PlayListFileView : public PlayListView |
9 | { | 9 | { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); | 12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); |
13 | virtual ~PlayListFileView(); | 13 | virtual ~PlayListFileView(); |
14 | 14 | ||
15 | bool hasSelection() const; | ||
16 | |||
15 | public slots: | 17 | public slots: |
16 | void scanFiles(); | 18 | void scanFiles(); |
17 | void populateView(); | 19 | void populateView(); |
18 | 20 | ||
21 | signals: | ||
22 | void itemsSelected( bool selected ); | ||
23 | |||
24 | private slots: | ||
25 | void checkSelection(); | ||
26 | |||
19 | private: | 27 | private: |
20 | QString m_mimeTypePattern; | 28 | QString m_mimeTypePattern; |
21 | QString m_itemPixmapName; | 29 | QString m_itemPixmapName; |
22 | DocLnkSet m_files; | 30 | DocLnkSet m_files; |
23 | bool m_scannedFiles; | 31 | bool m_scannedFiles; |
24 | bool m_viewPopulated; | 32 | bool m_viewPopulated; |
25 | }; | 33 | }; |
26 | 34 | ||
27 | #endif // PLAYLISTFILEVIEW_H | 35 | #endif // PLAYLISTFILEVIEW_H |
28 | /* vim: et sw=4 ts=4 | 36 | /* vim: et sw=4 ts=4 |
29 | */ | 37 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 2df7f27..c05096a 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -163,799 +163,814 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
163 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
164 | delete d; | 164 | delete d; |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void PlayListWidget::initializeStates() { | 168 | void PlayListWidget::initializeStates() { |
169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
172 | d->playListFrame->show(); | 172 | d->playListFrame->show(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void PlayListWidget::writeDefaultPlaylist() { | 175 | void PlayListWidget::writeDefaultPlaylist() { |
176 | 176 | ||
177 | Config config( "OpiePlayer" ); | 177 | Config config( "OpiePlayer" ); |
178 | config.setGroup( "PlayList" ); | 178 | config.setGroup( "PlayList" ); |
179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
181 | if( currentString == filename) { | 181 | if( currentString == filename) { |
182 | Om3u *m3uList; | 182 | Om3u *m3uList; |
183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
184 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
186 | do { | 186 | do { |
187 | // qDebug(d->selectedFiles->current()->file()); | 187 | // qDebug(d->selectedFiles->current()->file()); |
188 | m3uList->add( d->selectedFiles->current()->file() ); | 188 | m3uList->add( d->selectedFiles->current()->file() ); |
189 | } | 189 | } |
190 | while ( d->selectedFiles->next() ); | 190 | while ( d->selectedFiles->next() ); |
191 | 191 | ||
192 | m3uList->write(); | 192 | m3uList->write(); |
193 | m3uList->close(); | 193 | m3uList->close(); |
194 | delete m3uList; | 194 | delete m3uList; |
195 | 195 | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
201 | d->setDocumentUsed = FALSE; | 201 | d->setDocumentUsed = FALSE; |
202 | if( QFileInfo( lnk.file() ).exists() || | 202 | if( QFileInfo( lnk.file() ).exists() || |
203 | lnk.file().left(4) == "http" ) { | 203 | lnk.file().left(4) == "http" ) { |
204 | d->selectedFiles->addToSelection( lnk ); | 204 | d->selectedFiles->addToSelection( lnk ); |
205 | } | 205 | } |
206 | // writeCurrentM3u(); | 206 | // writeCurrentM3u(); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void PlayListWidget::clearList() { | 210 | void PlayListWidget::clearList() { |
211 | while ( first() ) { | 211 | while ( first() ) { |
212 | d->selectedFiles->removeSelected(); | 212 | d->selectedFiles->removeSelected(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case 1: | 218 | case 1: |
219 | break; | 219 | break; |
220 | case 2: | 220 | case 2: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case 1: | 234 | case 1: |
235 | break; | 235 | break; |
236 | case 2: | 236 | case 2: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
292 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
293 | // } | 293 | // } |
294 | // } | 294 | // } |
295 | 295 | ||
296 | // qDebug("elapsed time %d", t.elapsed() ); | 296 | // qDebug("elapsed time %d", t.elapsed() ); |
297 | 297 | ||
298 | tabWidget->setCurrentPage(0); | 298 | tabWidget->setCurrentPage(0); |
299 | 299 | ||
300 | writeCurrentM3u(); | 300 | writeCurrentM3u(); |
301 | d->selectedFiles->first(); | 301 | d->selectedFiles->first(); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void PlayListWidget::addAllMusicToList() { | 305 | void PlayListWidget::addAllMusicToList() { |
306 | 306 | ||
307 | audioView->populateView(); | 307 | audioView->populateView(); |
308 | 308 | ||
309 | QListViewItemIterator audioIt( audioView ); | 309 | QListViewItemIterator audioIt( audioView ); |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | QString filename; | 311 | QString filename; |
312 | // iterate through all items of the listview | 312 | // iterate through all items of the listview |
313 | for ( ; audioIt.current(); ++audioIt ) { | 313 | for ( ; audioIt.current(); ++audioIt ) { |
314 | filename = audioIt.current()->text(3); | 314 | filename = audioIt.current()->text(3); |
315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
316 | lnk.setFile( filename ); //sets file name | 316 | lnk.setFile( filename ); //sets file name |
317 | d->selectedFiles->addToSelection( lnk); | 317 | d->selectedFiles->addToSelection( lnk); |
318 | } | 318 | } |
319 | 319 | ||
320 | /* if(!audioScan) | 320 | /* if(!audioScan) |
321 | scanForAudio(); | 321 | scanForAudio(); |
322 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
323 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
325 | d->selectedFiles->addToSelection( **dit ); | 325 | d->selectedFiles->addToSelection( **dit ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | */ | 328 | */ |
329 | tabWidget->setCurrentPage(0); | 329 | tabWidget->setCurrentPage(0); |
330 | writeCurrentM3u(); | 330 | writeCurrentM3u(); |
331 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void PlayListWidget::addAllVideoToList() { | 335 | void PlayListWidget::addAllVideoToList() { |
336 | 336 | ||
337 | videoView->populateView(); | 337 | videoView->populateView(); |
338 | 338 | ||
339 | QListViewItemIterator videoIt( videoView ); | 339 | QListViewItemIterator videoIt( videoView ); |
340 | DocLnk lnk; | 340 | DocLnk lnk; |
341 | QString filename; | 341 | QString filename; |
342 | for ( ; videoIt.current(); ++videoIt ) { | 342 | for ( ; videoIt.current(); ++videoIt ) { |
343 | filename = videoIt.current()->text(3); | 343 | filename = videoIt.current()->text(3); |
344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
345 | lnk.setFile( filename ); //sets file name | 345 | lnk.setFile( filename ); //sets file name |
346 | d->selectedFiles->addToSelection( lnk); | 346 | d->selectedFiles->addToSelection( lnk); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /* if(!videoScan) | 350 | /* if(!videoScan) |
351 | scanForVideo(); | 351 | scanForVideo(); |
352 | QListIterator<DocLnk> dit( vFiles.children() ); | 352 | QListIterator<DocLnk> dit( vFiles.children() ); |
353 | for ( ; dit.current(); ++dit ) { | 353 | for ( ; dit.current(); ++dit ) { |
354 | if( QFileInfo( dit.current()->file() ).exists() ) { | 354 | if( QFileInfo( dit.current()->file() ).exists() ) { |
355 | d->selectedFiles->addToSelection( **dit ); | 355 | d->selectedFiles->addToSelection( **dit ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | */ | 358 | */ |
359 | tabWidget->setCurrentPage(0); | 359 | tabWidget->setCurrentPage(0); |
360 | writeCurrentM3u(); | 360 | writeCurrentM3u(); |
361 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void PlayListWidget::setDocument( const QString& fileref ) { | 365 | void PlayListWidget::setDocument( const QString& fileref ) { |
366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
367 | fromSetDocument = TRUE; | 367 | fromSetDocument = TRUE; |
368 | if ( fileref.isNull() ) { | 368 | if ( fileref.isNull() ) { |
369 | QMessageBox::warning( this, tr( "Invalid File" ), | 369 | QMessageBox::warning( this, tr( "Invalid File" ), |
370 | tr( "There was a problem in getting the file." ) ); | 370 | tr( "There was a problem in getting the file." ) ); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | clearList(); | 374 | clearList(); |
375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
376 | readm3u( fileref ); | 376 | readm3u( fileref ); |
377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
378 | readm3u( DocLnk( fileref).file() ); | 378 | readm3u( DocLnk( fileref).file() ); |
379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
380 | readPls( fileref ); | 380 | readPls( fileref ); |
381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
382 | readPls( DocLnk( fileref).file() ); | 382 | readPls( DocLnk( fileref).file() ); |
383 | } else { | 383 | } else { |
384 | clearList(); | 384 | clearList(); |
385 | addToSelection( DocLnk( fileref ) ); | 385 | addToSelection( DocLnk( fileref ) ); |
386 | writeCurrentM3u(); | 386 | writeCurrentM3u(); |
387 | 387 | ||
388 | d->setDocumentUsed = TRUE; | 388 | d->setDocumentUsed = TRUE; |
389 | mediaPlayerState.setPlaying( FALSE ); | 389 | mediaPlayerState.setPlaying( FALSE ); |
390 | mediaPlayerState.setPlaying( TRUE ); | 390 | mediaPlayerState.setPlaying( TRUE ); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void PlayListWidget::useSelectedDocument() { | 395 | void PlayListWidget::useSelectedDocument() { |
396 | d->setDocumentUsed = FALSE; | 396 | d->setDocumentUsed = FALSE; |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | const DocLnk *PlayListWidget::current() const { // this is fugly | 400 | const DocLnk *PlayListWidget::current() const { // this is fugly |
401 | assert( currentTab() == CurrentPlayList ); | 401 | assert( currentTab() == CurrentPlayList ); |
402 | 402 | ||
403 | const DocLnk *lnk = d->selectedFiles->current(); | 403 | const DocLnk *lnk = d->selectedFiles->current(); |
404 | if ( !lnk ) { | 404 | if ( !lnk ) { |
405 | d->selectedFiles->first(); | 405 | d->selectedFiles->first(); |
406 | lnk = d->selectedFiles->current(); | 406 | lnk = d->selectedFiles->current(); |
407 | } | 407 | } |
408 | assert( lnk ); | 408 | assert( lnk ); |
409 | return lnk; | 409 | return lnk; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | bool PlayListWidget::prev() { | 413 | bool PlayListWidget::prev() { |
414 | if ( mediaPlayerState.isShuffled() ) { | 414 | if ( mediaPlayerState.isShuffled() ) { |
415 | const DocLnk *cur = current(); | 415 | const DocLnk *cur = current(); |
416 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 416 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
417 | for ( int i = 0; i < j; i++ ) { | 417 | for ( int i = 0; i < j; i++ ) { |
418 | if ( !d->selectedFiles->next() ) | 418 | if ( !d->selectedFiles->next() ) |
419 | d->selectedFiles->first(); | 419 | d->selectedFiles->first(); |
420 | } | 420 | } |
421 | if ( cur == current() ) | 421 | if ( cur == current() ) |
422 | if ( !d->selectedFiles->next() ) { | 422 | if ( !d->selectedFiles->next() ) { |
423 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
424 | } | 424 | } |
425 | return TRUE; | 425 | return TRUE; |
426 | } else { | 426 | } else { |
427 | if ( !d->selectedFiles->prev() ) { | 427 | if ( !d->selectedFiles->prev() ) { |
428 | if ( mediaPlayerState.isLooping() ) { | 428 | if ( mediaPlayerState.isLooping() ) { |
429 | return d->selectedFiles->last(); | 429 | return d->selectedFiles->last(); |
430 | } else { | 430 | } else { |
431 | return FALSE; | 431 | return FALSE; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return TRUE; | 434 | return TRUE; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | bool PlayListWidget::next() { | 439 | bool PlayListWidget::next() { |
440 | //qDebug("<<<<<<<<<<<<next()"); | 440 | //qDebug("<<<<<<<<<<<<next()"); |
441 | if ( mediaPlayerState.isShuffled() ) { | 441 | if ( mediaPlayerState.isShuffled() ) { |
442 | return prev(); | 442 | return prev(); |
443 | } else { | 443 | } else { |
444 | if ( !d->selectedFiles->next() ) { | 444 | if ( !d->selectedFiles->next() ) { |
445 | if ( mediaPlayerState.isLooping() ) { | 445 | if ( mediaPlayerState.isLooping() ) { |
446 | return d->selectedFiles->first(); | 446 | return d->selectedFiles->first(); |
447 | } else { | 447 | } else { |
448 | return FALSE; | 448 | return FALSE; |
449 | } | 449 | } |
450 | } | 450 | } |
451 | return TRUE; | 451 | return TRUE; |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | bool PlayListWidget::first() { | 456 | bool PlayListWidget::first() { |
457 | return d->selectedFiles->first(); | 457 | return d->selectedFiles->first(); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | bool PlayListWidget::last() { | 461 | bool PlayListWidget::last() { |
462 | return d->selectedFiles->last(); | 462 | return d->selectedFiles->last(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | void PlayListWidget::saveList() { | 466 | void PlayListWidget::saveList() { |
467 | writem3u(); | 467 | writem3u(); |
468 | } | 468 | } |
469 | 469 | ||
470 | 470 | ||
471 | void PlayListWidget::loadList( const DocLnk & lnk) { | 471 | void PlayListWidget::loadList( const DocLnk & lnk) { |
472 | QString name = lnk.name(); | 472 | QString name = lnk.name(); |
473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
474 | 474 | ||
475 | if( name.length()>0) { | 475 | if( name.length()>0) { |
476 | setCaption("OpiePlayer: "+name); | 476 | setCaption("OpiePlayer: "+name); |
477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
478 | clearList(); | 478 | clearList(); |
479 | readm3u(lnk.file()); | 479 | readm3u(lnk.file()); |
480 | tabWidget->setCurrentPage(0); | 480 | tabWidget->setCurrentPage(0); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | void PlayListWidget::addSelected() { | 484 | void PlayListWidget::addSelected() { |
485 | assert( inFileListMode() ); | 485 | assert( inFileListMode() ); |
486 | 486 | ||
487 | QListView *fileListView = currentFileListView(); | 487 | QListView *fileListView = currentFileListView(); |
488 | QListViewItemIterator it( fileListView ); | 488 | QListViewItemIterator it( fileListView ); |
489 | for ( ; it.current(); ++it ) | 489 | for ( ; it.current(); ++it ) |
490 | if ( it.current()->isSelected() ) { | 490 | if ( it.current()->isSelected() ) { |
491 | QString filename = it.current()->text(3); | 491 | QString filename = it.current()->text(3); |
492 | 492 | ||
493 | DocLnk lnk; | 493 | DocLnk lnk; |
494 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 494 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
495 | lnk.setFile( filename ); //sets file name | 495 | lnk.setFile( filename ); //sets file name |
496 | 496 | ||
497 | d->selectedFiles->addToSelection( lnk ); | 497 | d->selectedFiles->addToSelection( lnk ); |
498 | } | 498 | } |
499 | 499 | ||
500 | fileListView->clearSelection(); | 500 | fileListView->clearSelection(); |
501 | 501 | ||
502 | tabWidget->setCurrentPage( 0 ); | 502 | tabWidget->setCurrentPage( 0 ); |
503 | writeCurrentM3u(); | 503 | writeCurrentM3u(); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void PlayListWidget::removeSelected() { | 507 | void PlayListWidget::removeSelected() { |
508 | d->selectedFiles->removeSelected( ); | 508 | d->selectedFiles->removeSelected( ); |
509 | writeCurrentM3u(); | 509 | writeCurrentM3u(); |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | void PlayListWidget::playIt( QListViewItem *it) { | 513 | void PlayListWidget::playIt( QListViewItem *it) { |
514 | if(!it) return; | 514 | if(!it) return; |
515 | mediaPlayerState.setPlaying(FALSE); | 515 | mediaPlayerState.setPlaying(FALSE); |
516 | mediaPlayerState.setPlaying(TRUE); | 516 | mediaPlayerState.setPlaying(TRUE); |
517 | d->selectedFiles->unSelect(); | 517 | d->selectedFiles->unSelect(); |
518 | } | 518 | } |
519 | 519 | ||
520 | 520 | ||
521 | void PlayListWidget::addToSelection( QListViewItem *it) { | 521 | void PlayListWidget::addToSelection( QListViewItem *it) { |
522 | d->setDocumentUsed = FALSE; | 522 | d->setDocumentUsed = FALSE; |
523 | 523 | ||
524 | if(it) { | 524 | if(it) { |
525 | if ( currentTab() == CurrentPlayList ) | 525 | if ( currentTab() == CurrentPlayList ) |
526 | return; | 526 | return; |
527 | // case 1: { | 527 | // case 1: { |
528 | DocLnk lnk; | 528 | DocLnk lnk; |
529 | QString filename; | 529 | QString filename; |
530 | 530 | ||
531 | filename=it->text(3); | 531 | filename=it->text(3); |
532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
533 | lnk.setFile( filename ); //sets file name | 533 | lnk.setFile( filename ); //sets file name |
534 | d->selectedFiles->addToSelection( lnk); | 534 | d->selectedFiles->addToSelection( lnk); |
535 | 535 | ||
536 | writeCurrentM3u(); | 536 | writeCurrentM3u(); |
537 | tabWidget->setCurrentPage(0); | 537 | tabWidget->setCurrentPage(0); |
538 | 538 | ||
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void PlayListWidget::tabChanged(QWidget *) { | 543 | void PlayListWidget::tabChanged(QWidget *) { |
544 | 544 | ||
545 | d->tbPlay->setEnabled( true ); | 545 | d->tbPlay->setEnabled( true ); |
546 | 546 | ||
547 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | ||
548 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
549 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | ||
550 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
551 | |||
547 | switch ( currentTab() ) { | 552 | switch ( currentTab() ) { |
548 | case CurrentPlayList: | 553 | case CurrentPlayList: |
549 | { | 554 | { |
550 | if( !tbDeletePlaylist->isHidden() ) { | 555 | if( !tbDeletePlaylist->isHidden() ) { |
551 | tbDeletePlaylist->hide(); | 556 | tbDeletePlaylist->hide(); |
552 | } | 557 | } |
553 | d->tbRemoveFromList->setEnabled(TRUE); | 558 | d->tbRemoveFromList->setEnabled(TRUE); |
554 | d->tbAddToList->setEnabled(FALSE); | 559 | d->tbAddToList->setEnabled(FALSE); |
555 | 560 | ||
556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 561 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
557 | } | 562 | } |
558 | break; | 563 | break; |
559 | case AudioFiles: | 564 | case AudioFiles: |
560 | { | 565 | { |
561 | audioView->populateView(); | 566 | audioView->populateView(); |
562 | 567 | ||
563 | if( !tbDeletePlaylist->isHidden() ) { | 568 | if( !tbDeletePlaylist->isHidden() ) { |
564 | tbDeletePlaylist->hide(); | 569 | tbDeletePlaylist->hide(); |
565 | } | 570 | } |
566 | d->tbRemoveFromList->setEnabled(FALSE); | 571 | d->tbRemoveFromList->setEnabled(FALSE); |
567 | d->tbAddToList->setEnabled(TRUE); | 572 | d->tbAddToList->setEnabled(TRUE); |
573 | |||
574 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | ||
575 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
576 | |||
577 | d->tbPlay->setEnabled( audioView->hasSelection() ); | ||
568 | } | 578 | } |
569 | break; | 579 | break; |
570 | case VideoFiles: | 580 | case VideoFiles: |
571 | { | 581 | { |
572 | videoView->populateView(); | 582 | videoView->populateView(); |
573 | if( !tbDeletePlaylist->isHidden() ) { | 583 | if( !tbDeletePlaylist->isHidden() ) { |
574 | tbDeletePlaylist->hide(); | 584 | tbDeletePlaylist->hide(); |
575 | } | 585 | } |
576 | d->tbRemoveFromList->setEnabled(FALSE); | 586 | d->tbRemoveFromList->setEnabled(FALSE); |
577 | d->tbAddToList->setEnabled(TRUE); | 587 | d->tbAddToList->setEnabled(TRUE); |
588 | |||
589 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | ||
590 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | ||
591 | |||
592 | d->tbPlay->setEnabled( videoView->hasSelection() ); | ||
578 | } | 593 | } |
579 | break; | 594 | break; |
580 | case PlayLists: | 595 | case PlayLists: |
581 | { | 596 | { |
582 | if( tbDeletePlaylist->isHidden() ) { | 597 | if( tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->show(); | 598 | tbDeletePlaylist->show(); |
584 | } | 599 | } |
585 | playLists->reread(); | 600 | playLists->reread(); |
586 | d->tbAddToList->setEnabled(FALSE); | 601 | d->tbAddToList->setEnabled(FALSE); |
587 | 602 | ||
588 | d->tbPlay->setEnabled( false ); | 603 | d->tbPlay->setEnabled( false ); |
589 | } | 604 | } |
590 | break; | 605 | break; |
591 | }; | 606 | }; |
592 | } | 607 | } |
593 | 608 | ||
594 | 609 | ||
595 | void PlayListWidget::btnPlay(bool b) { | 610 | void PlayListWidget::btnPlay(bool b) { |
596 | // mediaPlayerState->setPlaying(false); | 611 | // mediaPlayerState->setPlaying(false); |
597 | mediaPlayerState.setPlaying(b); | 612 | mediaPlayerState.setPlaying(b); |
598 | insanityBool=FALSE; | 613 | insanityBool=FALSE; |
599 | } | 614 | } |
600 | 615 | ||
601 | void PlayListWidget::deletePlaylist() { | 616 | void PlayListWidget::deletePlaylist() { |
602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 617 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
603 | (tr("You really want to delete\nthis playlist?")), | 618 | (tr("You really want to delete\nthis playlist?")), |
604 | (tr("Yes")), (tr("No")), 0 )){ | 619 | (tr("Yes")), (tr("No")), 0 )){ |
605 | case 0: // Yes clicked, | 620 | case 0: // Yes clicked, |
606 | QFile().remove(playLists->selectedDocument().file()); | 621 | QFile().remove(playLists->selectedDocument().file()); |
607 | QFile().remove(playLists->selectedDocument().linkFile()); | 622 | QFile().remove(playLists->selectedDocument().linkFile()); |
608 | playLists->reread(); | 623 | playLists->reread(); |
609 | break; | 624 | break; |
610 | case 1: // Cancel | 625 | case 1: // Cancel |
611 | break; | 626 | break; |
612 | }; | 627 | }; |
613 | } | 628 | } |
614 | 629 | ||
615 | 630 | ||
616 | void PlayListWidget::playSelected() { | 631 | void PlayListWidget::playSelected() { |
617 | btnPlay( TRUE); | 632 | btnPlay( TRUE); |
618 | } | 633 | } |
619 | 634 | ||
620 | QListView *PlayListWidget::currentFileListView() const | 635 | QListView *PlayListWidget::currentFileListView() const |
621 | { | 636 | { |
622 | switch ( currentTab() ) { | 637 | switch ( currentTab() ) { |
623 | case AudioFiles: return audioView; | 638 | case AudioFiles: return audioView; |
624 | case VideoFiles: return videoView; | 639 | case VideoFiles: return videoView; |
625 | default: assert( false ); | 640 | default: assert( false ); |
626 | } | 641 | } |
627 | return 0; | 642 | return 0; |
628 | } | 643 | } |
629 | 644 | ||
630 | bool PlayListWidget::inFileListMode() const | 645 | bool PlayListWidget::inFileListMode() const |
631 | { | 646 | { |
632 | TabType tab = currentTab(); | 647 | TabType tab = currentTab(); |
633 | return tab == AudioFiles || tab == VideoFiles; | 648 | return tab == AudioFiles || tab == VideoFiles; |
634 | } | 649 | } |
635 | 650 | ||
636 | void PlayListWidget::openFile() { | 651 | void PlayListWidget::openFile() { |
637 | // http://66.28.164.33:2080 | 652 | // http://66.28.164.33:2080 |
638 | // http://somafm.com/star0242.m3u | 653 | // http://somafm.com/star0242.m3u |
639 | QString filename, name; | 654 | QString filename, name; |
640 | InputDialog *fileDlg; | 655 | InputDialog *fileDlg; |
641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 656 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
642 | fileDlg->exec(); | 657 | fileDlg->exec(); |
643 | if( fileDlg->result() == 1 ) { | 658 | if( fileDlg->result() == 1 ) { |
644 | filename = fileDlg->text(); | 659 | filename = fileDlg->text(); |
645 | qDebug( "Selected filename is " + filename ); | 660 | qDebug( "Selected filename is " + filename ); |
646 | // Om3u *m3uList; | 661 | // Om3u *m3uList; |
647 | DocLnk lnk; | 662 | DocLnk lnk; |
648 | Config cfg( "OpiePlayer" ); | 663 | Config cfg( "OpiePlayer" ); |
649 | cfg.setGroup("PlayList"); | 664 | cfg.setGroup("PlayList"); |
650 | 665 | ||
651 | if(filename.left(4) == "http") { | 666 | if(filename.left(4) == "http") { |
652 | QString m3uFile, m3uFilePath; | 667 | QString m3uFile, m3uFilePath; |
653 | if(filename.find(":",8,TRUE) != -1) { //found a port | 668 | if(filename.find(":",8,TRUE) != -1) { //found a port |
654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 669 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
655 | m3uFile = m3uFile.right( 7); | 670 | m3uFile = m3uFile.right( 7); |
656 | } else if(filename.left(4) == "http"){ | 671 | } else if(filename.left(4) == "http"){ |
657 | m3uFile=filename; | 672 | m3uFile=filename; |
658 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 673 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
659 | } else{ | 674 | } else{ |
660 | m3uFile=filename; | 675 | m3uFile=filename; |
661 | } | 676 | } |
662 | 677 | ||
663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 678 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
664 | lnk.setName( filename ); //sets name | 679 | lnk.setName( filename ); //sets name |
665 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
666 | 681 | ||
667 | // lnk.setIcon("opieplayer2/musicfile"); | 682 | // lnk.setIcon("opieplayer2/musicfile"); |
668 | 683 | ||
669 | d->selectedFiles->addToSelection( lnk ); | 684 | d->selectedFiles->addToSelection( lnk ); |
670 | writeCurrentM3u(); | 685 | writeCurrentM3u(); |
671 | d->selectedFiles->setSelectedItem( lnk.name()); | 686 | d->selectedFiles->setSelectedItem( lnk.name()); |
672 | } | 687 | } |
673 | else if( filename.right( 3) == "m3u" ) { | 688 | else if( filename.right( 3) == "m3u" ) { |
674 | readm3u( filename ); | 689 | readm3u( filename ); |
675 | 690 | ||
676 | } else if( filename.right(3) == "pls" ) { | 691 | } else if( filename.right(3) == "pls" ) { |
677 | readPls( filename ); | 692 | readPls( filename ); |
678 | } else { | 693 | } else { |
679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 694 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
680 | lnk.setFile( filename ); //sets file name | 695 | lnk.setFile( filename ); //sets file name |
681 | d->selectedFiles->addToSelection( lnk); | 696 | d->selectedFiles->addToSelection( lnk); |
682 | writeCurrentM3u(); | 697 | writeCurrentM3u(); |
683 | d->selectedFiles->setSelectedItem( lnk.name()); | 698 | d->selectedFiles->setSelectedItem( lnk.name()); |
684 | } | 699 | } |
685 | } | 700 | } |
686 | 701 | ||
687 | delete fileDlg; | 702 | delete fileDlg; |
688 | } | 703 | } |
689 | 704 | ||
690 | /* | 705 | /* |
691 | reads m3u and shows files/urls to playlist widget */ | 706 | reads m3u and shows files/urls to playlist widget */ |
692 | void PlayListWidget::readm3u( const QString &filename ) { | 707 | void PlayListWidget::readm3u( const QString &filename ) { |
693 | qDebug( "read m3u filename " + filename ); | 708 | qDebug( "read m3u filename " + filename ); |
694 | 709 | ||
695 | Om3u *m3uList; | 710 | Om3u *m3uList; |
696 | QString s, name; | 711 | QString s, name; |
697 | m3uList = new Om3u( filename, IO_ReadOnly ); | 712 | m3uList = new Om3u( filename, IO_ReadOnly ); |
698 | m3uList->readM3u(); | 713 | m3uList->readM3u(); |
699 | DocLnk lnk; | 714 | DocLnk lnk; |
700 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 715 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
701 | s = *it; | 716 | s = *it; |
702 | // qDebug("reading "+ s); | 717 | // qDebug("reading "+ s); |
703 | if(s.left(4)=="http") { | 718 | if(s.left(4)=="http") { |
704 | lnk.setName( s ); //sets file name | 719 | lnk.setName( s ); //sets file name |
705 | lnk.setIcon("opieplayer2/musicfile"); | 720 | lnk.setIcon("opieplayer2/musicfile"); |
706 | lnk.setFile( s ); //sets file name | 721 | lnk.setFile( s ); //sets file name |
707 | 722 | ||
708 | } else { | 723 | } else { |
709 | // if( QFileInfo( s ).exists() ) { | 724 | // if( QFileInfo( s ).exists() ) { |
710 | lnk.setName( QFileInfo(s).baseName()); | 725 | lnk.setName( QFileInfo(s).baseName()); |
711 | // if(s.right(4) == '.') {//if regular file | 726 | // if(s.right(4) == '.') {//if regular file |
712 | if(s.left(1) != "/") { | 727 | if(s.left(1) != "/") { |
713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 728 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 729 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
715 | // lnk.setIcon(MimeType(s).pixmap() ); | 730 | // lnk.setIcon(MimeType(s).pixmap() ); |
716 | // lnk.setIcon("SoundPlayer"); | 731 | // lnk.setIcon("SoundPlayer"); |
717 | } else { | 732 | } else { |
718 | // qDebug("set link2 "+s); | 733 | // qDebug("set link2 "+s); |
719 | lnk.setFile( s); | 734 | lnk.setFile( s); |
720 | // lnk.setIcon(MimeType(s).pixmap() ); | 735 | // lnk.setIcon(MimeType(s).pixmap() ); |
721 | // lnk.setIcon("SoundPlayer"); | 736 | // lnk.setIcon("SoundPlayer"); |
722 | } | 737 | } |
723 | } | 738 | } |
724 | d->selectedFiles->addToSelection( lnk ); | 739 | d->selectedFiles->addToSelection( lnk ); |
725 | } | 740 | } |
726 | Config config( "OpiePlayer" ); | 741 | Config config( "OpiePlayer" ); |
727 | config.setGroup( "PlayList" ); | 742 | config.setGroup( "PlayList" ); |
728 | 743 | ||
729 | config.writeEntry("CurrentPlaylist",filename); | 744 | config.writeEntry("CurrentPlaylist",filename); |
730 | config.write(); | 745 | config.write(); |
731 | currentPlayList=filename; | 746 | currentPlayList=filename; |
732 | 747 | ||
733 | // m3uList->write(); | 748 | // m3uList->write(); |
734 | m3uList->close(); | 749 | m3uList->close(); |
735 | delete m3uList; | 750 | delete m3uList; |
736 | 751 | ||
737 | d->selectedFiles->setSelectedItem( s); | 752 | d->selectedFiles->setSelectedItem( s); |
738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 753 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
739 | 754 | ||
740 | } | 755 | } |
741 | 756 | ||
742 | /* | 757 | /* |
743 | reads pls and adds files/urls to playlist */ | 758 | reads pls and adds files/urls to playlist */ |
744 | void PlayListWidget::readPls( const QString &filename ) { | 759 | void PlayListWidget::readPls( const QString &filename ) { |
745 | 760 | ||
746 | qDebug( "pls filename is " + filename ); | 761 | qDebug( "pls filename is " + filename ); |
747 | Om3u *m3uList; | 762 | Om3u *m3uList; |
748 | QString s, name; | 763 | QString s, name; |
749 | m3uList = new Om3u( filename, IO_ReadOnly ); | 764 | m3uList = new Om3u( filename, IO_ReadOnly ); |
750 | m3uList->readPls(); | 765 | m3uList->readPls(); |
751 | 766 | ||
752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 767 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
753 | s = *it; | 768 | s = *it; |
754 | // s.replace( QRegExp( "%20" )," " ); | 769 | // s.replace( QRegExp( "%20" )," " ); |
755 | DocLnk lnk( s ); | 770 | DocLnk lnk( s ); |
756 | QFileInfo f( s ); | 771 | QFileInfo f( s ); |
757 | QString name = f.baseName(); | 772 | QString name = f.baseName(); |
758 | 773 | ||
759 | if( name.left( 4 ) == "http" ) { | 774 | if( name.left( 4 ) == "http" ) { |
760 | name = s.right( s.length() - 7); | 775 | name = s.right( s.length() - 7); |
761 | } else { | 776 | } else { |
762 | name = s; | 777 | name = s; |
763 | } | 778 | } |
764 | 779 | ||
765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 780 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
766 | 781 | ||
767 | lnk.setName( name ); | 782 | lnk.setName( name ); |
768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 783 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
769 | lnk.setFile( s ); | 784 | lnk.setFile( s ); |
770 | } else { //if its a url | 785 | } else { //if its a url |
771 | // if( name.right( 1 ).find( '/' ) == -1) { | 786 | // if( name.right( 1 ).find( '/' ) == -1) { |
772 | // s += "/"; | 787 | // s += "/"; |
773 | // } | 788 | // } |
774 | lnk.setFile( s ); | 789 | lnk.setFile( s ); |
775 | } | 790 | } |
776 | lnk.setType( "audio/x-mpegurl" ); | 791 | lnk.setType( "audio/x-mpegurl" ); |
777 | 792 | ||
778 | lnk.writeLink(); | 793 | lnk.writeLink(); |
779 | d->selectedFiles->addToSelection( lnk ); | 794 | d->selectedFiles->addToSelection( lnk ); |
780 | } | 795 | } |
781 | 796 | ||
782 | m3uList->close(); | 797 | m3uList->close(); |
783 | delete m3uList; | 798 | delete m3uList; |
784 | } | 799 | } |
785 | 800 | ||
786 | /* | 801 | /* |
787 | writes current playlist to current m3u file */ | 802 | writes current playlist to current m3u file */ |
788 | void PlayListWidget::writeCurrentM3u() { | 803 | void PlayListWidget::writeCurrentM3u() { |
789 | qDebug("writing to current m3u"); | 804 | qDebug("writing to current m3u"); |
790 | Config cfg( "OpiePlayer" ); | 805 | Config cfg( "OpiePlayer" ); |
791 | cfg.setGroup("PlayList"); | 806 | cfg.setGroup("PlayList"); |
792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 807 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
793 | 808 | ||
794 | Om3u *m3uList; | 809 | Om3u *m3uList; |
795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 810 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
796 | if( d->selectedFiles->first()) { | 811 | if( d->selectedFiles->first()) { |
797 | 812 | ||
798 | do { | 813 | do { |
799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 814 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
800 | m3uList->add( d->selectedFiles->current()->file() ); | 815 | m3uList->add( d->selectedFiles->current()->file() ); |
801 | } | 816 | } |
802 | while ( d->selectedFiles->next() ); | 817 | while ( d->selectedFiles->next() ); |
803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 818 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
804 | m3uList->write(); | 819 | m3uList->write(); |
805 | m3uList->close(); | 820 | m3uList->close(); |
806 | } | 821 | } |
807 | delete m3uList; | 822 | delete m3uList; |
808 | 823 | ||
809 | } | 824 | } |
810 | 825 | ||
811 | /* | 826 | /* |
812 | writes current playlist to m3u file */ | 827 | writes current playlist to m3u file */ |
813 | void PlayListWidget::writem3u() { | 828 | void PlayListWidget::writem3u() { |
814 | InputDialog *fileDlg; | 829 | InputDialog *fileDlg; |
815 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 830 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
816 | fileDlg->exec(); | 831 | fileDlg->exec(); |
817 | QString name, filename, list; | 832 | QString name, filename, list; |
818 | Om3u *m3uList; | 833 | Om3u *m3uList; |
819 | 834 | ||
820 | if( fileDlg->result() == 1 ) { | 835 | if( fileDlg->result() == 1 ) { |
821 | name = fileDlg->text(); | 836 | name = fileDlg->text(); |
822 | // qDebug( filename ); | 837 | // qDebug( filename ); |
823 | 838 | ||
824 | if( name.left( 1) != "/" ) { | 839 | if( name.left( 1) != "/" ) { |
825 | filename = QPEApplication::documentDir() + "/" + name; | 840 | filename = QPEApplication::documentDir() + "/" + name; |
826 | } | 841 | } |
827 | 842 | ||
828 | if( name.right( 3 ) != "m3u" ) { | 843 | if( name.right( 3 ) != "m3u" ) { |
829 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 844 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
830 | } | 845 | } |
831 | 846 | ||
832 | if( d->selectedFiles->first()) { | 847 | if( d->selectedFiles->first()) { |
833 | m3uList = new Om3u(filename, IO_ReadWrite); | 848 | m3uList = new Om3u(filename, IO_ReadWrite); |
834 | 849 | ||
835 | do { | 850 | do { |
836 | m3uList->add( d->selectedFiles->current()->file()); | 851 | m3uList->add( d->selectedFiles->current()->file()); |
837 | } | 852 | } |
838 | while ( d->selectedFiles->next() ); | 853 | while ( d->selectedFiles->next() ); |
839 | // qDebug( list ); | 854 | // qDebug( list ); |
840 | m3uList->write(); | 855 | m3uList->write(); |
841 | m3uList->close(); | 856 | m3uList->close(); |
842 | delete m3uList; | 857 | delete m3uList; |
843 | 858 | ||
844 | delete fileDlg; | 859 | delete fileDlg; |
845 | 860 | ||
846 | DocLnk lnk; | 861 | DocLnk lnk; |
847 | lnk.setFile( filename); | 862 | lnk.setFile( filename); |
848 | lnk.setIcon("opieplayer2/playlist2"); | 863 | lnk.setIcon("opieplayer2/playlist2"); |
849 | lnk.setName( name); //sets file name | 864 | lnk.setName( name); //sets file name |
850 | 865 | ||
851 | // qDebug(filename); | 866 | // qDebug(filename); |
852 | Config config( "OpiePlayer" ); | 867 | Config config( "OpiePlayer" ); |
853 | config.setGroup( "PlayList" ); | 868 | config.setGroup( "PlayList" ); |
854 | 869 | ||
855 | config.writeEntry("CurrentPlaylist",filename); | 870 | config.writeEntry("CurrentPlaylist",filename); |
856 | currentPlayList=filename; | 871 | currentPlayList=filename; |
857 | 872 | ||
858 | if(!lnk.writeLink()) { | 873 | if(!lnk.writeLink()) { |
859 | qDebug("Writing doclink did not work"); | 874 | qDebug("Writing doclink did not work"); |
860 | } | 875 | } |
861 | 876 | ||
862 | setCaption(tr("OpiePlayer: ") + name); | 877 | setCaption(tr("OpiePlayer: ") + name); |
863 | } | 878 | } |
864 | } | 879 | } |
865 | } | 880 | } |
866 | 881 | ||
867 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 882 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
868 | switch ( e->key() ) { | 883 | switch ( e->key() ) { |
869 | ////////////////////////////// Zaurus keys | 884 | ////////////////////////////// Zaurus keys |
870 | case Key_F9: //activity | 885 | case Key_F9: //activity |
871 | // if(audioUI->isHidden()) | 886 | // if(audioUI->isHidden()) |
872 | // audioUI->showMaximized(); | 887 | // audioUI->showMaximized(); |
873 | break; | 888 | break; |
874 | case Key_F10: //contacts | 889 | case Key_F10: //contacts |
875 | // if( videoUI->isHidden()) | 890 | // if( videoUI->isHidden()) |
876 | // videoUI->showMaximized(); | 891 | // videoUI->showMaximized(); |
877 | break; | 892 | break; |
878 | case Key_F11: //menu | 893 | case Key_F11: //menu |
879 | break; | 894 | break; |
880 | case Key_F12: //home | 895 | case Key_F12: //home |
881 | // doBlank(); | 896 | // doBlank(); |
882 | break; | 897 | break; |
883 | case Key_F13: //mail | 898 | case Key_F13: //mail |
884 | // doUnblank(); | 899 | // doUnblank(); |
885 | break; | 900 | break; |
886 | case Key_Q: //add to playlist | 901 | case Key_Q: //add to playlist |
887 | addSelected(); | 902 | addSelected(); |
888 | break; | 903 | break; |
889 | case Key_R: //remove from playlist | 904 | case Key_R: //remove from playlist |
890 | removeSelected(); | 905 | removeSelected(); |
891 | break; | 906 | break; |
892 | // case Key_P: //play | 907 | // case Key_P: //play |
893 | // qDebug("Play"); | 908 | // qDebug("Play"); |
894 | // playSelected(); | 909 | // playSelected(); |
895 | // break; | 910 | // break; |
896 | case Key_Space: | 911 | case Key_Space: |
897 | // playSelected(); puh | 912 | // playSelected(); puh |
898 | break; | 913 | break; |
899 | case Key_1: | 914 | case Key_1: |
900 | tabWidget->setCurrentPage( 0 ); | 915 | tabWidget->setCurrentPage( 0 ); |
901 | break; | 916 | break; |
902 | case Key_2: | 917 | case Key_2: |
903 | tabWidget->setCurrentPage( 1 ); | 918 | tabWidget->setCurrentPage( 1 ); |
904 | break; | 919 | break; |
905 | case Key_3: | 920 | case Key_3: |
906 | tabWidget->setCurrentPage( 2 ); | 921 | tabWidget->setCurrentPage( 2 ); |
907 | break; | 922 | break; |
908 | case Key_4: | 923 | case Key_4: |
909 | tabWidget->setCurrentPage( 3 ); | 924 | tabWidget->setCurrentPage( 3 ); |
910 | break; | 925 | break; |
911 | case Key_Down: | 926 | case Key_Down: |
912 | if ( !d->selectedFiles->next() ) | 927 | if ( !d->selectedFiles->next() ) |
913 | d->selectedFiles->first(); | 928 | d->selectedFiles->first(); |
914 | break; | 929 | break; |
915 | case Key_Up: | 930 | case Key_Up: |
916 | if ( !d->selectedFiles->prev() ) | 931 | if ( !d->selectedFiles->prev() ) |
917 | // d->selectedFiles->last(); | 932 | // d->selectedFiles->last(); |
918 | break; | 933 | break; |
919 | } | 934 | } |
920 | } | 935 | } |
921 | 936 | ||
922 | void PlayListWidget::pmViewActivated(int index) { | 937 | void PlayListWidget::pmViewActivated(int index) { |
923 | // qDebug("%d", index); | 938 | // qDebug("%d", index); |
924 | switch(index) { | 939 | switch(index) { |
925 | case -16: | 940 | case -16: |
926 | { | 941 | { |
927 | mediaPlayerState.toggleFullscreen(); | 942 | mediaPlayerState.toggleFullscreen(); |
928 | bool b=mediaPlayerState.isFullscreen(); | 943 | bool b=mediaPlayerState.isFullscreen(); |
929 | pmView->setItemChecked( index, b); | 944 | pmView->setItemChecked( index, b); |
930 | Config cfg( "OpiePlayer" ); | 945 | Config cfg( "OpiePlayer" ); |
931 | cfg.writeEntry( "FullScreen", b ); | 946 | cfg.writeEntry( "FullScreen", b ); |
932 | } | 947 | } |
933 | break; | 948 | break; |
934 | }; | 949 | }; |
935 | } | 950 | } |
936 | 951 | ||
937 | void PlayListWidget::populateSkinsMenu() { | 952 | void PlayListWidget::populateSkinsMenu() { |
938 | int item = 0; | 953 | int item = 0; |
939 | defaultSkinIndex = 0; | 954 | defaultSkinIndex = 0; |
940 | QString skinName; | 955 | QString skinName; |
941 | Config cfg( "OpiePlayer" ); | 956 | Config cfg( "OpiePlayer" ); |
942 | cfg.setGroup("Options" ); | 957 | cfg.setGroup("Options" ); |
943 | QString skin = cfg.readEntry( "Skin", "default" ); | 958 | QString skin = cfg.readEntry( "Skin", "default" ); |
944 | 959 | ||
945 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 960 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
946 | skinsDir.setFilter( QDir::Dirs ); | 961 | skinsDir.setFilter( QDir::Dirs ); |
947 | skinsDir.setSorting(QDir::Name ); | 962 | skinsDir.setSorting(QDir::Name ); |
948 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 963 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
949 | QFileInfoListIterator it( *skinslist ); | 964 | QFileInfoListIterator it( *skinslist ); |
950 | QFileInfo *fi; | 965 | QFileInfo *fi; |
951 | while ( ( fi = it.current() ) ) { | 966 | while ( ( fi = it.current() ) ) { |
952 | skinName = fi->fileName(); | 967 | skinName = fi->fileName(); |
953 | // qDebug( fi->fileName() ); | 968 | // qDebug( fi->fileName() ); |
954 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 969 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
955 | item = skinsMenu->insertItem( fi->fileName() ) ; | 970 | item = skinsMenu->insertItem( fi->fileName() ) ; |
956 | } | 971 | } |
957 | if( skinName == "default" ) { | 972 | if( skinName == "default" ) { |
958 | defaultSkinIndex = item; | 973 | defaultSkinIndex = item; |
959 | } | 974 | } |
960 | if( skinName == skin ) { | 975 | if( skinName == skin ) { |
961 | skinsMenu->setItemChecked( item, TRUE ); | 976 | skinsMenu->setItemChecked( item, TRUE ); |