summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 14:38:47 (UTC)
committer simon <simon>2002-12-02 14:38:47 (UTC)
commit46d64cdfe9a3d949e91ea6a72828405d03337225 (patch) (unidiff)
tree992e6fd74384ed4b7126b73b3313d599b5035949
parent77d55b631fa3cf26bfdf809c17ee3252d3c80ac0 (diff)
downloadopie-46d64cdfe9a3d949e91ea6a72828405d03337225.zip
opie-46d64cdfe9a3d949e91ea6a72828405d03337225.tar.gz
opie-46d64cdfe9a3d949e91ea6a72828405d03337225.tar.bz2
- two const fixlets
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index ce9faac..11a7b5c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1170 +1,1170 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdatetime.h> 41#include <qdatetime.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47#include "playlistselection.h" 47#include "playlistselection.h"
48#include "playlistwidget.h" 48#include "playlistwidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "inputDialog.h" 50#include "inputDialog.h"
51#include "om3u.h" 51#include "om3u.h"
52 52
53//only needed for the random play 53//only needed for the random play
54#include <stdlib.h> 54#include <stdlib.h>
55#include <assert.h> 55#include <assert.h>
56 56
57#include "audiowidget.h" 57#include "audiowidget.h"
58#include "videowidget.h" 58#include "videowidget.h"
59 59
60extern MediaPlayerState *mediaPlayerState; 60extern MediaPlayerState *mediaPlayerState;
61// extern AudioWidget *audioUI; 61// extern AudioWidget *audioUI;
62// extern VideoWidget *videoUI; 62// extern VideoWidget *videoUI;
63 63
64QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 64QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
65// no m3u's here please 65// no m3u's here please
66 66
67PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 67PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
68 : PlayListWidgetGui( parent, name, fl ) { 68 : PlayListWidgetGui( parent, name, fl ) {
69 69
70 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 70 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
71 "opieplayer2/add_to_playlist", 71 "opieplayer2/add_to_playlist",
72 this , SLOT(addSelected() ) ); 72 this , SLOT(addSelected() ) );
73 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 73 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
74 "opieplayer2/remove_from_playlist", 74 "opieplayer2/remove_from_playlist",
75 this , SLOT(removeSelected() ) ); 75 this , SLOT(removeSelected() ) );
76 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 76 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
77 this , SLOT( btnPlay( bool) ), TRUE ); 77 this , SLOT( btnPlay( bool) ), TRUE );
78 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 78 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
79 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 79 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
80 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 80 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
81 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 81 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
82 82
83 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 83 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
84 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 84 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
85 this, SLOT( addAllMusicToList() ) ); 85 this, SLOT( addAllMusicToList() ) );
86 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 86 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
87 this, SLOT( addAllVideoToList() ) ); 87 this, SLOT( addAllVideoToList() ) );
88 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 88 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
89 this, SLOT( addAllToList() ) ); 89 this, SLOT( addAllToList() ) );
90 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
91// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 91// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
92// this, SLOT( saveList() ) ); 92// this, SLOT( saveList() ) );
93 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 93 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
94 this, SLOT(writem3u() ) ); 94 this, SLOT(writem3u() ) );
95 pmPlayList->insertSeparator(-1); 95 pmPlayList->insertSeparator(-1);
96 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 96 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
97 this,SLOT( openFile() ) ); 97 this,SLOT( openFile() ) );
98 pmPlayList->insertSeparator(-1); 98 pmPlayList->insertSeparator(-1);
99 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 99 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
100 this,SLOT( scanForAudio() ) ); 100 this,SLOT( scanForAudio() ) );
101 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 101 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
102 this,SLOT( scanForVideo() ) ); 102 this,SLOT( scanForVideo() ) );
103 103
104 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 104 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
105 mediaPlayerState, SLOT( toggleFullscreen() ) ); 105 mediaPlayerState, SLOT( toggleFullscreen() ) );
106 106
107 Config cfg( "OpiePlayer" ); 107 Config cfg( "OpiePlayer" );
108 bool b= cfg.readBoolEntry("FullScreen", 0); 108 bool b= cfg.readBoolEntry("FullScreen", 0);
109 mediaPlayerState->setFullscreen( b ); 109 mediaPlayerState->setFullscreen( b );
110 pmView->setItemChecked( -16, b ); 110 pmView->setItemChecked( -16, b );
111 111
112 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 112 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
113 d->selectedFiles, SLOT(moveSelectedUp() ) ); 113 d->selectedFiles, SLOT(moveSelectedUp() ) );
114 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 114 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
115 d->selectedFiles, SLOT(removeSelected() ) ); 115 d->selectedFiles, SLOT(removeSelected() ) );
116 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 116 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
117 d->selectedFiles, SLOT(moveSelectedDown() ) ); 117 d->selectedFiles, SLOT(moveSelectedDown() ) );
118 // QVBox *stretch2 = new QVBox( vbox1 ); 118 // QVBox *stretch2 = new QVBox( vbox1 );
119 119
120 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 120 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
121 SLOT( deletePlaylist() ) ); 121 SLOT( deletePlaylist() ) );
122 connect( pmView, SIGNAL( activated( int ) ), 122 connect( pmView, SIGNAL( activated( int ) ),
123 this, SLOT( pmViewActivated( int ) ) ); 123 this, SLOT( pmViewActivated( int ) ) );
124 connect( skinsMenu, SIGNAL( activated( int ) ) , 124 connect( skinsMenu, SIGNAL( activated( int ) ) ,
125 this, SLOT( skinsMenuActivated( int ) ) ); 125 this, SLOT( skinsMenuActivated( int ) ) );
126 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 126 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
127 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 127 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
128 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 128 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
130 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 130 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
131 this,SLOT( playIt( QListViewItem *) ) ); 131 this,SLOT( playIt( QListViewItem *) ) );
132 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 132 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
133 this, SLOT( addToSelection( QListViewItem *) ) ); 133 this, SLOT( addToSelection( QListViewItem *) ) );
134 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 134 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
135 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 135 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
136 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 136 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
137 this,SLOT( playIt( QListViewItem *) ) ); 137 this,SLOT( playIt( QListViewItem *) ) );
138 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 138 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
139 this, SLOT( addToSelection( QListViewItem *) ) ); 139 this, SLOT( addToSelection( QListViewItem *) ) );
140 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 140 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
141 this, SLOT( loadList( const DocLnk & ) ) ); 141 this, SLOT( loadList( const DocLnk & ) ) );
142 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 142 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
143 this, SLOT( tabChanged( QWidget* ) ) ); 143 this, SLOT( tabChanged( QWidget* ) ) );
144 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
145 d->tbPlay, SLOT( setOn( bool ) ) ); 145 d->tbPlay, SLOT( setOn( bool ) ) );
146 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 146 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
147 d->tbLoop, SLOT( setOn( bool ) ) ); 147 d->tbLoop, SLOT( setOn( bool ) ) );
148 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 148 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
149 d->tbShuffle, SLOT( setOn( bool ) ) ); 149 d->tbShuffle, SLOT( setOn( bool ) ) );
150 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 150 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
151 this, SLOT( setPlaylist( bool ) ) ); 151 this, SLOT( setPlaylist( bool ) ) );
152 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 152 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
153 this, SLOT( playIt( QListViewItem *) ) ); 153 this, SLOT( playIt( QListViewItem *) ) );
154 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 154 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
155 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 155 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
156 156
157 // see which skins are installed 157 // see which skins are installed
158 videoScan=false; 158 videoScan=false;
159 audioScan=false; 159 audioScan=false;
160 audioPopulated=false; 160 audioPopulated=false;
161 videoPopulated=false; 161 videoPopulated=false;
162 populateSkinsMenu(); 162 populateSkinsMenu();
163 initializeStates(); 163 initializeStates();
164 164
165 cfg.setGroup("PlayList"); 165 cfg.setGroup("PlayList");
166 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 166 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
167 loadList(DocLnk( currentPlaylist ) ); 167 loadList(DocLnk( currentPlaylist ) );
168} 168}
169 169
170 170
171PlayListWidget::~PlayListWidget() { 171PlayListWidget::~PlayListWidget() {
172 if ( d->current ) { 172 if ( d->current ) {
173 delete d->current; 173 delete d->current;
174 } 174 }
175 delete d; 175 delete d;
176} 176}
177 177
178 178
179void PlayListWidget::initializeStates() { 179void PlayListWidget::initializeStates() {
180 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 180 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
181 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 181 d->tbLoop->setOn( mediaPlayerState->isLooping() );
182 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 182 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
183 setPlaylist( true ); 183 setPlaylist( true );
184} 184}
185 185
186void PlayListWidget::writeDefaultPlaylist() { 186void PlayListWidget::writeDefaultPlaylist() {
187 187
188 Config config( "OpiePlayer" ); 188 Config config( "OpiePlayer" );
189 config.setGroup( "PlayList" ); 189 config.setGroup( "PlayList" );
190 QString filename=QPEApplication::documentDir() + "/default.m3u"; 190 QString filename=QPEApplication::documentDir() + "/default.m3u";
191 QString currentString = config.readEntry( "CurrentPlaylist", filename); 191 QString currentString = config.readEntry( "CurrentPlaylist", filename);
192 if( currentString == filename) { 192 if( currentString == filename) {
193 Om3u *m3uList; 193 Om3u *m3uList;
194 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 194 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
195 if( d->selectedFiles->first() ) { 195 if( d->selectedFiles->first() ) {
196 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 196 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
197 do { 197 do {
198 // qDebug(d->selectedFiles->current()->file()); 198 // qDebug(d->selectedFiles->current()->file());
199 m3uList->add( d->selectedFiles->current()->file() ); 199 m3uList->add( d->selectedFiles->current()->file() );
200 } 200 }
201 while ( d->selectedFiles->next() ); 201 while ( d->selectedFiles->next() );
202 202
203 m3uList->write(); 203 m3uList->write();
204 m3uList->close(); 204 m3uList->close();
205 if(m3uList) delete m3uList; 205 if(m3uList) delete m3uList;
206 206
207 } 207 }
208 } 208 }
209} 209}
210 210
211void PlayListWidget::addToSelection( const DocLnk& lnk ) { 211void PlayListWidget::addToSelection( const DocLnk& lnk ) {
212 d->setDocumentUsed = FALSE; 212 d->setDocumentUsed = FALSE;
213 if ( mediaPlayerState->isUsingPlaylist() ) { 213 if ( mediaPlayerState->isUsingPlaylist() ) {
214 if( QFileInfo( lnk.file() ).exists() || 214 if( QFileInfo( lnk.file() ).exists() ||
215 lnk.file().left(4) == "http" ) { 215 lnk.file().left(4) == "http" ) {
216 d->selectedFiles->addToSelection( lnk ); 216 d->selectedFiles->addToSelection( lnk );
217 } 217 }
218// writeCurrentM3u(); 218// writeCurrentM3u();
219 } 219 }
220 else 220 else
221 mediaPlayerState->setPlaying( TRUE ); 221 mediaPlayerState->setPlaying( TRUE );
222} 222}
223 223
224 224
225void PlayListWidget::clearList() { 225void PlayListWidget::clearList() {
226 while ( first() ) { 226 while ( first() ) {
227 d->selectedFiles->removeSelected(); 227 d->selectedFiles->removeSelected();
228 } 228 }
229} 229}
230 230
231void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 231void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
232 switch (mouse) { 232 switch (mouse) {
233 case 1: 233 case 1:
234 break; 234 break;
235 case 2: 235 case 2:
236 { 236 {
237 QPopupMenu m; 237 QPopupMenu m;
238 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 238 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
239 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 239 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
240 m.exec( QCursor::pos() ); 240 m.exec( QCursor::pos() );
241 } 241 }
242 break; 242 break;
243 } 243 }
244} 244}
245 245
246 246
247void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 247void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
248 switch (mouse) { 248 switch (mouse) {
249 case 1: 249 case 1:
250 break; 250 break;
251 case 2: 251 case 2:
252 { 252 {
253 QPopupMenu m; 253 QPopupMenu m;
254 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 254 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
255 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 255 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
256 m.exec( QCursor::pos() ); 256 m.exec( QCursor::pos() );
257 } 257 }
258 break; 258 break;
259 } 259 }
260} 260}
261 261
262 262
263void PlayListWidget::addAllToList() { 263void PlayListWidget::addAllToList() {
264 264
265// QTime t; 265// QTime t;
266// t.start(); 266// t.start();
267 267
268 if(!audioScan) { 268 if(!audioScan) {
269 if(audioView->childCount() < 1) 269 if(audioView->childCount() < 1)
270 populateAudioView(); 270 populateAudioView();
271 } 271 }
272 272
273 QListViewItemIterator audioIt( audioView ); 273 QListViewItemIterator audioIt( audioView );
274 DocLnk lnk; 274 DocLnk lnk;
275 QString filename; 275 QString filename;
276 // iterate through all items of the listview 276 // iterate through all items of the listview
277 for ( ; audioIt.current(); ++audioIt ) { 277 for ( ; audioIt.current(); ++audioIt ) {
278 filename = audioIt.current()->text(3); 278 filename = audioIt.current()->text(3);
279 lnk.setName( QFileInfo(filename).baseName() ); //sets name 279 lnk.setName( QFileInfo(filename).baseName() ); //sets name
280 lnk.setFile( filename ); //sets file name 280 lnk.setFile( filename ); //sets file name
281 d->selectedFiles->addToSelection( lnk); 281 d->selectedFiles->addToSelection( lnk);
282 } 282 }
283 283
284 if(!videoScan) { 284 if(!videoScan) {
285 if(videoView->childCount() < 1) 285 if(videoView->childCount() < 1)
286 populateVideoView(); 286 populateVideoView();
287 } 287 }
288 288
289 QListViewItemIterator videoIt( videoView ); 289 QListViewItemIterator videoIt( videoView );
290 for ( ; videoIt.current(); ++videoIt ) { 290 for ( ; videoIt.current(); ++videoIt ) {
291 filename = videoIt.current()->text(3); 291 filename = videoIt.current()->text(3);
292 lnk.setName( QFileInfo(filename).baseName() ); //sets name 292 lnk.setName( QFileInfo(filename).baseName() ); //sets name
293 lnk.setFile( filename ); //sets file name 293 lnk.setFile( filename ); //sets file name
294 d->selectedFiles->addToSelection( lnk); 294 d->selectedFiles->addToSelection( lnk);
295 } 295 }
296 296
297 // d->selectedFiles->addToSelection( ); 297 // d->selectedFiles->addToSelection( );
298 // if ( it.current()->isSelected() ) 298 // if ( it.current()->isSelected() )
299 // lst->append( audioIt.current() ); 299 // lst->append( audioIt.current() );
300 // } 300 // }
301 301
302 302
303// if(!audioScan) 303// if(!audioScan)
304// scanForAudio(); 304// scanForAudio();
305// if(!videoScan) 305// if(!videoScan)
306// scanForVideo(); 306// scanForVideo();
307 307
308// DocLnkSet filesAll; 308// DocLnkSet filesAll;
309// Global::findDocuments(&filesAll, "video/*;"+audioMimes); 309// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
310// QListIterator<DocLnk> Adit( filesAll.children() ); 310// QListIterator<DocLnk> Adit( filesAll.children() );
311// for ( ; Adit.current(); ++Adit ) { 311// for ( ; Adit.current(); ++Adit ) {
312// if( QFileInfo( Adit.current()->file() ).exists() ) { 312// if( QFileInfo( Adit.current()->file() ).exists() ) {
313// d->selectedFiles->addToSelection( **Adit ); 313// d->selectedFiles->addToSelection( **Adit );
314// } 314// }
315// } 315// }
316 316
317 // qDebug("elapsed time %d", t.elapsed() ); 317 // qDebug("elapsed time %d", t.elapsed() );
318 318
319 tabWidget->setCurrentPage(0); 319 tabWidget->setCurrentPage(0);
320 320
321 writeCurrentM3u(); 321 writeCurrentM3u();
322 d->selectedFiles->first(); 322 d->selectedFiles->first();
323} 323}
324 324
325 325
326void PlayListWidget::addAllMusicToList() { 326void PlayListWidget::addAllMusicToList() {
327 327
328 if(!audioScan) { 328 if(!audioScan) {
329 if(audioView->childCount() < 1) 329 if(audioView->childCount() < 1)
330 populateAudioView(); 330 populateAudioView();
331 } 331 }
332 332
333 QListViewItemIterator audioIt( audioView ); 333 QListViewItemIterator audioIt( audioView );
334 DocLnk lnk; 334 DocLnk lnk;
335 QString filename; 335 QString filename;
336 // iterate through all items of the listview 336 // iterate through all items of the listview
337 for ( ; audioIt.current(); ++audioIt ) { 337 for ( ; audioIt.current(); ++audioIt ) {
338 filename = audioIt.current()->text(3); 338 filename = audioIt.current()->text(3);
339 lnk.setName( QFileInfo(filename).baseName() ); //sets name 339 lnk.setName( QFileInfo(filename).baseName() ); //sets name
340 lnk.setFile( filename ); //sets file name 340 lnk.setFile( filename ); //sets file name
341 d->selectedFiles->addToSelection( lnk); 341 d->selectedFiles->addToSelection( lnk);
342 } 342 }
343 343
344 /* if(!audioScan) 344 /* if(!audioScan)
345 scanForAudio(); 345 scanForAudio();
346 QListIterator<DocLnk> dit( files.children() ); 346 QListIterator<DocLnk> dit( files.children() );
347 for ( ; dit.current(); ++dit ) { 347 for ( ; dit.current(); ++dit ) {
348 if( QFileInfo(dit.current()->file() ).exists() ) { 348 if( QFileInfo(dit.current()->file() ).exists() ) {
349 d->selectedFiles->addToSelection( **dit ); 349 d->selectedFiles->addToSelection( **dit );
350 } 350 }
351 } 351 }
352 */ 352 */
353 tabWidget->setCurrentPage(0); 353 tabWidget->setCurrentPage(0);
354 writeCurrentM3u(); 354 writeCurrentM3u();
355 d->selectedFiles->first(); 355 d->selectedFiles->first();
356} 356}
357 357
358 358
359void PlayListWidget::addAllVideoToList() { 359void PlayListWidget::addAllVideoToList() {
360 360
361 if(!videoScan) { 361 if(!videoScan) {
362 if(videoView->childCount() < 1) 362 if(videoView->childCount() < 1)
363 populateVideoView(); 363 populateVideoView();
364 } 364 }
365 365
366 QListViewItemIterator videoIt( videoView ); 366 QListViewItemIterator videoIt( videoView );
367 DocLnk lnk; 367 DocLnk lnk;
368 QString filename; 368 QString filename;
369 for ( ; videoIt.current(); ++videoIt ) { 369 for ( ; videoIt.current(); ++videoIt ) {
370 filename = videoIt.current()->text(3); 370 filename = videoIt.current()->text(3);
371 lnk.setName( QFileInfo(filename).baseName() ); //sets name 371 lnk.setName( QFileInfo(filename).baseName() ); //sets name
372 lnk.setFile( filename ); //sets file name 372 lnk.setFile( filename ); //sets file name
373 d->selectedFiles->addToSelection( lnk); 373 d->selectedFiles->addToSelection( lnk);
374 } 374 }
375 375
376 376
377 /* if(!videoScan) 377 /* if(!videoScan)
378 scanForVideo(); 378 scanForVideo();
379 QListIterator<DocLnk> dit( vFiles.children() ); 379 QListIterator<DocLnk> dit( vFiles.children() );
380 for ( ; dit.current(); ++dit ) { 380 for ( ; dit.current(); ++dit ) {
381 if( QFileInfo( dit.current()->file() ).exists() ) { 381 if( QFileInfo( dit.current()->file() ).exists() ) {
382 d->selectedFiles->addToSelection( **dit ); 382 d->selectedFiles->addToSelection( **dit );
383 } 383 }
384 } 384 }
385*/ 385*/
386 tabWidget->setCurrentPage(0); 386 tabWidget->setCurrentPage(0);
387 writeCurrentM3u(); 387 writeCurrentM3u();
388 d->selectedFiles->first(); 388 d->selectedFiles->first();
389} 389}
390 390
391 391
392void PlayListWidget::setDocument( const QString& fileref ) { 392void PlayListWidget::setDocument( const QString& fileref ) {
393 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 393 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
394 fromSetDocument = TRUE; 394 fromSetDocument = TRUE;
395 if ( fileref.isNull() ) { 395 if ( fileref.isNull() ) {
396 QMessageBox::warning( this, tr( "Invalid File" ), 396 QMessageBox::warning( this, tr( "Invalid File" ),
397 tr( "There was a problem in getting the file." ) ); 397 tr( "There was a problem in getting the file." ) );
398 return; 398 return;
399 } 399 }
400 400
401 clearList(); 401 clearList();
402 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 402 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
403 readm3u( fileref ); 403 readm3u( fileref );
404 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 404 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
405 readm3u( DocLnk( fileref).file() ); 405 readm3u( DocLnk( fileref).file() );
406 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 406 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
407 readPls( fileref ); 407 readPls( fileref );
408 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 408 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
409 readPls( DocLnk( fileref).file() ); 409 readPls( DocLnk( fileref).file() );
410 } else { 410 } else {
411 clearList(); 411 clearList();
412 addToSelection( DocLnk( fileref ) ); 412 addToSelection( DocLnk( fileref ) );
413 writeCurrentM3u(); 413 writeCurrentM3u();
414 414
415 d->setDocumentUsed = TRUE; 415 d->setDocumentUsed = TRUE;
416 mediaPlayerState->setPlaying( FALSE ); 416 mediaPlayerState->setPlaying( FALSE );
417 mediaPlayerState->setPlaying( TRUE ); 417 mediaPlayerState->setPlaying( TRUE );
418 } 418 }
419} 419}
420 420
421 421
422void PlayListWidget::useSelectedDocument() { 422void PlayListWidget::useSelectedDocument() {
423 d->setDocumentUsed = FALSE; 423 d->setDocumentUsed = FALSE;
424} 424}
425 425
426 426
427const DocLnk *PlayListWidget::current() { // this is fugly 427const DocLnk *PlayListWidget::current() { // this is fugly
428 switch ( whichList() ) { 428 switch ( whichList() ) {
429 case 0: //playlist 429 case 0: //playlist
430 { 430 {
431// qDebug("playlist"); 431// qDebug("playlist");
432 if ( mediaPlayerState->isUsingPlaylist() ) { 432 if ( mediaPlayerState->isUsingPlaylist() ) {
433 return d->selectedFiles->current(); 433 return d->selectedFiles->current();
434 } else if ( d->setDocumentUsed && d->current ) { 434 } else if ( d->setDocumentUsed && d->current ) {
435 return d->current; 435 return d->current;
436 } else { 436 } else {
437 return &(d->files->selectedDocument()); 437 return &(d->files->selectedDocument());
438 } 438 }
439 } 439 }
440 break; 440 break;
441 }; 441 };
442 return 0; 442 return 0;
443} 443}
444 444
445 445
446bool PlayListWidget::prev() { 446bool PlayListWidget::prev() {
447 if ( mediaPlayerState->isUsingPlaylist() ) { 447 if ( mediaPlayerState->isUsingPlaylist() ) {
448 if ( mediaPlayerState->isShuffled() ) { 448 if ( mediaPlayerState->isShuffled() ) {
449 const DocLnk *cur = current(); 449 const DocLnk *cur = current();
450 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 450 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
451 for ( int i = 0; i < j; i++ ) { 451 for ( int i = 0; i < j; i++ ) {
452 if ( !d->selectedFiles->next() ) 452 if ( !d->selectedFiles->next() )
453 d->selectedFiles->first(); 453 d->selectedFiles->first();
454 } 454 }
455 if ( cur == current() ) 455 if ( cur == current() )
456 if ( !d->selectedFiles->next() ) { 456 if ( !d->selectedFiles->next() ) {
457 d->selectedFiles->first(); 457 d->selectedFiles->first();
458 } 458 }
459 return TRUE; 459 return TRUE;
460 } else { 460 } else {
461 if ( !d->selectedFiles->prev() ) { 461 if ( !d->selectedFiles->prev() ) {
462 if ( mediaPlayerState->isLooping() ) { 462 if ( mediaPlayerState->isLooping() ) {
463 return d->selectedFiles->last(); 463 return d->selectedFiles->last();
464 } else { 464 } else {
465 return FALSE; 465 return FALSE;
466 } 466 }
467 } 467 }
468 return TRUE; 468 return TRUE;
469 } 469 }
470 } else { 470 } else {
471 return mediaPlayerState->isLooping(); 471 return mediaPlayerState->isLooping();
472 } 472 }
473} 473}
474 474
475 475
476bool PlayListWidget::next() { 476bool PlayListWidget::next() {
477//qDebug("<<<<<<<<<<<<next()"); 477//qDebug("<<<<<<<<<<<<next()");
478 if ( mediaPlayerState->isUsingPlaylist() ) { 478 if ( mediaPlayerState->isUsingPlaylist() ) {
479 if ( mediaPlayerState->isShuffled() ) { 479 if ( mediaPlayerState->isShuffled() ) {
480 return prev(); 480 return prev();
481 } else { 481 } else {
482 if ( !d->selectedFiles->next() ) { 482 if ( !d->selectedFiles->next() ) {
483 if ( mediaPlayerState->isLooping() ) { 483 if ( mediaPlayerState->isLooping() ) {
484 return d->selectedFiles->first(); 484 return d->selectedFiles->first();
485 } else { 485 } else {
486 return FALSE; 486 return FALSE;
487 } 487 }
488 } 488 }
489 return TRUE; 489 return TRUE;
490 } 490 }
491 } else { 491 } else {
492 return mediaPlayerState->isLooping(); 492 return mediaPlayerState->isLooping();
493 } 493 }
494} 494}
495 495
496 496
497bool PlayListWidget::first() { 497bool PlayListWidget::first() {
498 if ( mediaPlayerState->isUsingPlaylist() ) 498 if ( mediaPlayerState->isUsingPlaylist() )
499 return d->selectedFiles->first(); 499 return d->selectedFiles->first();
500 else 500 else
501 return mediaPlayerState->isLooping(); 501 return mediaPlayerState->isLooping();
502} 502}
503 503
504 504
505bool PlayListWidget::last() { 505bool PlayListWidget::last() {
506 if ( mediaPlayerState->isUsingPlaylist() ) 506 if ( mediaPlayerState->isUsingPlaylist() )
507 return d->selectedFiles->last(); 507 return d->selectedFiles->last();
508 else 508 else
509 return mediaPlayerState->isLooping(); 509 return mediaPlayerState->isLooping();
510} 510}
511 511
512 512
513 void PlayListWidget::saveList() { 513 void PlayListWidget::saveList() {
514 writem3u(); 514 writem3u();
515 } 515 }
516 516
517 517
518void PlayListWidget::loadList( const DocLnk & lnk) { 518void PlayListWidget::loadList( const DocLnk & lnk) {
519 QString name = lnk.name(); 519 QString name = lnk.name();
520 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 520 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
521 521
522 if( name.length()>0) { 522 if( name.length()>0) {
523 setCaption("OpiePlayer: "+name); 523 setCaption("OpiePlayer: "+name);
524// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 524// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
525 clearList(); 525 clearList();
526 readm3u(lnk.file()); 526 readm3u(lnk.file());
527 tabWidget->setCurrentPage(0); 527 tabWidget->setCurrentPage(0);
528 } 528 }
529} 529}
530 530
531 531
532void PlayListWidget::setPlaylist( bool shown ) { 532void PlayListWidget::setPlaylist( bool shown ) {
533 if ( shown ) { 533 if ( shown ) {
534 d->playListFrame->show(); 534 d->playListFrame->show();
535 } else { 535 } else {
536 d->playListFrame->hide(); 536 d->playListFrame->hide();
537 } 537 }
538} 538}
539 539
540 540
541void PlayListWidget::addSelected() { 541void PlayListWidget::addSelected() {
542 qDebug("addSelected"); 542 qDebug("addSelected");
543 DocLnk lnk; 543 DocLnk lnk;
544 QString filename; 544 QString filename;
545 switch (whichList()) { 545 switch (whichList()) {
546 546
547 case 0: //playlist 547 case 0: //playlist
548 return; 548 return;
549 break; 549 break;
550 case 1: { //audio 550 case 1: { //audio
551 QListViewItemIterator it( audioView ); 551 QListViewItemIterator it( audioView );
552 for ( ; it.current(); ++it ) { 552 for ( ; it.current(); ++it ) {
553 if ( it.current()->isSelected() ) { 553 if ( it.current()->isSelected() ) {
554 filename=it.current()->text(3); 554 filename=it.current()->text(3);
555 lnk.setName( QFileInfo(filename).baseName() ); //sets name 555 lnk.setName( QFileInfo(filename).baseName() ); //sets name
556 lnk.setFile( filename ); //sets file name 556 lnk.setFile( filename ); //sets file name
557 d->selectedFiles->addToSelection( lnk); 557 d->selectedFiles->addToSelection( lnk);
558 558
559 } 559 }
560 } 560 }
561 audioView->clearSelection(); 561 audioView->clearSelection();
562 } 562 }
563 break; 563 break;
564 564
565 case 2: { // video 565 case 2: { // video
566 QListViewItemIterator it( videoView ); 566 QListViewItemIterator it( videoView );
567 for ( ; it.current(); ++it ) { 567 for ( ; it.current(); ++it ) {
568 if ( it.current()->isSelected() ) { 568 if ( it.current()->isSelected() ) {
569 filename=it.current()->text(3); 569 filename=it.current()->text(3);
570 lnk.setName( QFileInfo(filename).baseName() ); //sets name 570 lnk.setName( QFileInfo(filename).baseName() ); //sets name
571 lnk.setFile( filename ); //sets file name 571 lnk.setFile( filename ); //sets file name
572 d->selectedFiles->addToSelection( lnk); 572 d->selectedFiles->addToSelection( lnk);
573 } 573 }
574 } 574 }
575 videoView->clearSelection(); 575 videoView->clearSelection();
576 } 576 }
577 break; 577 break;
578 }; 578 };
579 tabWidget->setCurrentPage(0); 579 tabWidget->setCurrentPage(0);
580 writeCurrentM3u(); 580 writeCurrentM3u();
581} 581}
582 582
583 583
584void PlayListWidget::removeSelected() { 584void PlayListWidget::removeSelected() {
585 d->selectedFiles->removeSelected( ); 585 d->selectedFiles->removeSelected( );
586 writeCurrentM3u(); 586 writeCurrentM3u();
587} 587}
588 588
589 589
590void PlayListWidget::playIt( QListViewItem *it) { 590void PlayListWidget::playIt( QListViewItem *it) {
591 if(!it) return; 591 if(!it) return;
592 mediaPlayerState->setPlaying(FALSE); 592 mediaPlayerState->setPlaying(FALSE);
593 mediaPlayerState->setPlaying(TRUE); 593 mediaPlayerState->setPlaying(TRUE);
594 d->selectedFiles->unSelect(); 594 d->selectedFiles->unSelect();
595} 595}
596 596
597 597
598void PlayListWidget::addToSelection( QListViewItem *it) { 598void PlayListWidget::addToSelection( QListViewItem *it) {
599 d->setDocumentUsed = FALSE; 599 d->setDocumentUsed = FALSE;
600 600
601 if(it) { 601 if(it) {
602 switch ( whichList()) { 602 switch ( whichList()) {
603 case 0: //playlist 603 case 0: //playlist
604 return; 604 return;
605 break; 605 break;
606 }; 606 };
607 // case 1: { 607 // case 1: {
608 DocLnk lnk; 608 DocLnk lnk;
609 QString filename; 609 QString filename;
610 610
611 filename=it->text(3); 611 filename=it->text(3);
612 lnk.setName( QFileInfo(filename).baseName() ); //sets name 612 lnk.setName( QFileInfo(filename).baseName() ); //sets name
613 lnk.setFile( filename ); //sets file name 613 lnk.setFile( filename ); //sets file name
614 d->selectedFiles->addToSelection( lnk); 614 d->selectedFiles->addToSelection( lnk);
615 615
616 writeCurrentM3u(); 616 writeCurrentM3u();
617 tabWidget->setCurrentPage(0); 617 tabWidget->setCurrentPage(0);
618 618
619 } 619 }
620} 620}
621 621
622 622
623void PlayListWidget::tabChanged(QWidget *) { 623void PlayListWidget::tabChanged(QWidget *) {
624 624
625 switch ( whichList()) { 625 switch ( whichList()) {
626 case 0: 626 case 0:
627 { 627 {
628 if( !tbDeletePlaylist->isHidden() ) { 628 if( !tbDeletePlaylist->isHidden() ) {
629 tbDeletePlaylist->hide(); 629 tbDeletePlaylist->hide();
630 } 630 }
631 d->tbRemoveFromList->setEnabled(TRUE); 631 d->tbRemoveFromList->setEnabled(TRUE);
632 d->tbAddToList->setEnabled(FALSE); 632 d->tbAddToList->setEnabled(FALSE);
633 } 633 }
634 break; 634 break;
635 case 1: 635 case 1:
636 { 636 {
637 // audioView->clear(); 637 // audioView->clear();
638 if(!audioPopulated) populateAudioView(); 638 if(!audioPopulated) populateAudioView();
639 639
640 if( !tbDeletePlaylist->isHidden() ) { 640 if( !tbDeletePlaylist->isHidden() ) {
641 tbDeletePlaylist->hide(); 641 tbDeletePlaylist->hide();
642 } 642 }
643 d->tbRemoveFromList->setEnabled(FALSE); 643 d->tbRemoveFromList->setEnabled(FALSE);
644 d->tbAddToList->setEnabled(TRUE); 644 d->tbAddToList->setEnabled(TRUE);
645 } 645 }
646 break; 646 break;
647 case 2: 647 case 2:
648 { 648 {
649 // videoView->clear(); 649 // videoView->clear();
650 if(!videoPopulated) populateVideoView(); 650 if(!videoPopulated) populateVideoView();
651 if( !tbDeletePlaylist->isHidden() ) { 651 if( !tbDeletePlaylist->isHidden() ) {
652 tbDeletePlaylist->hide(); 652 tbDeletePlaylist->hide();
653 } 653 }
654 d->tbRemoveFromList->setEnabled(FALSE); 654 d->tbRemoveFromList->setEnabled(FALSE);
655 d->tbAddToList->setEnabled(TRUE); 655 d->tbAddToList->setEnabled(TRUE);
656 } 656 }
657 break; 657 break;
658 case 3: 658 case 3:
659 { 659 {
660 if( tbDeletePlaylist->isHidden() ) { 660 if( tbDeletePlaylist->isHidden() ) {
661 tbDeletePlaylist->show(); 661 tbDeletePlaylist->show();
662 } 662 }
663 playLists->reread(); 663 playLists->reread();
664 } 664 }
665 break; 665 break;
666 }; 666 };
667} 667}
668 668
669 669
670void PlayListWidget::btnPlay(bool b) { 670void PlayListWidget::btnPlay(bool b) {
671// mediaPlayerState->setPlaying(false); 671// mediaPlayerState->setPlaying(false);
672 mediaPlayerState->setPlaying(b); 672 mediaPlayerState->setPlaying(b);
673 insanityBool=FALSE; 673 insanityBool=FALSE;
674} 674}
675 675
676void PlayListWidget::deletePlaylist() { 676void PlayListWidget::deletePlaylist() {
677 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 677 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
678 (tr("You really want to delete\nthis playlist?")), 678 (tr("You really want to delete\nthis playlist?")),
679 (tr("Yes")), (tr("No")), 0 )){ 679 (tr("Yes")), (tr("No")), 0 )){
680 case 0: // Yes clicked, 680 case 0: // Yes clicked,
681 QFile().remove(playLists->selectedDocument().file()); 681 QFile().remove(playLists->selectedDocument().file());
682 QFile().remove(playLists->selectedDocument().linkFile()); 682 QFile().remove(playLists->selectedDocument().linkFile());
683 playLists->reread(); 683 playLists->reread();
684 break; 684 break;
685 case 1: // Cancel 685 case 1: // Cancel
686 break; 686 break;
687 }; 687 };
688} 688}
689 689
690 690
691void PlayListWidget::playSelected() { 691void PlayListWidget::playSelected() {
692 btnPlay( TRUE); 692 btnPlay( TRUE);
693} 693}
694 694
695 695
696void PlayListWidget::scanForAudio() { 696void PlayListWidget::scanForAudio() {
697// qDebug("scan for audio"); 697// qDebug("scan for audio");
698 files.detachChildren(); 698 files.detachChildren();
699 QListIterator<DocLnk> sdit( files.children() ); 699 QListIterator<DocLnk> sdit( files.children() );
700 for ( ; sdit.current(); ++sdit ) { 700 for ( ; sdit.current(); ++sdit ) {
701 delete sdit.current(); 701 delete sdit.current();
702 } 702 }
703// Global::findDocuments( &files, "audio/*"); 703// Global::findDocuments( &files, "audio/*");
704 Global::findDocuments( &files, audioMimes); 704 Global::findDocuments( &files, audioMimes);
705 audioScan = true; 705 audioScan = true;
706 populateAudioView(); 706 populateAudioView();
707} 707}
708 708
709void PlayListWidget::scanForVideo() { 709void PlayListWidget::scanForVideo() {
710// qDebug("scan for video"); 710// qDebug("scan for video");
711 vFiles.detachChildren(); 711 vFiles.detachChildren();
712 QListIterator<DocLnk> sdit( vFiles.children() ); 712 QListIterator<DocLnk> sdit( vFiles.children() );
713 for ( ; sdit.current(); ++sdit ) { 713 for ( ; sdit.current(); ++sdit ) {
714 delete sdit.current(); 714 delete sdit.current();
715 } 715 }
716 Global::findDocuments(&vFiles, "video/*"); 716 Global::findDocuments(&vFiles, "video/*");
717 videoScan = true; 717 videoScan = true;
718 populateVideoView(); 718 populateVideoView();
719} 719}
720 720
721void PlayListWidget::populateAudioView() { 721void PlayListWidget::populateAudioView() {
722 audioView->clear(); 722 audioView->clear();
723 StorageInfo storageInfo; 723 StorageInfo storageInfo;
724 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 724 // const QList<FileSystem> &fs = storageInfo.fileSystems();
725 if(!audioScan) { 725 if(!audioScan) {
726 scanForAudio(); 726 scanForAudio();
727 } 727 }
728 728
729 QListIterator<DocLnk> dit( files.children() ); 729 QListIterator<DocLnk> dit( files.children() );
730 // QListIterator<FileSystem> it ( fs ); 730 // QListIterator<FileSystem> it ( fs );
731 audioView->clear(); 731 audioView->clear();
732 732
733 QString storage; 733 QString storage;
734 for ( ; dit.current(); ++dit ) { 734 for ( ; dit.current(); ++dit ) {
735// // for( ; it.current(); ++it ){ 735// // for( ; it.current(); ++it ){
736// const QString name = (*dit)->name(); 736// const QString name = (*dit)->name();
737// const QString path = (*dit)->path(); 737// const QString path = (*dit)->path();
738// if(dit.current()->file().find(path) != -1 ) { 738// if(dit.current()->file().find(path) != -1 ) {
739// storage = name; 739// storage = name;
740// // } 740// // }
741// } 741// }
742 742
743 QListViewItem * newItem; 743 QListViewItem * newItem;
744 if ( QFile( dit.current()->file()).exists() || 744 if ( QFile( dit.current()->file()).exists() ||
745 dit.current()->file().left(4) == "http" ) { 745 dit.current()->file().left(4) == "http" ) {
746 long size; 746 long size;
747 if( dit.current()->file().left(4) == "http" ) 747 if( dit.current()->file().left(4) == "http" )
748 size=0; 748 size=0;
749 else 749 else
750 size = QFile( dit.current()->file() ).size(); 750 size = QFile( dit.current()->file() ).size();
751 751
752 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 752 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
753 QString::number(size ), "" /*storage*/, 753 QString::number(size ), "" /*storage*/,
754 dit.current()->file() ); 754 dit.current()->file() );
755 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 755 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
756// qDebug("<<<< "+dit.current()->file()); 756// qDebug("<<<< "+dit.current()->file());
757 } 757 }
758 } 758 }
759 audioPopulated=true; 759 audioPopulated=true;
760} 760}
761 761
762 762
763void PlayListWidget::populateVideoView() { 763void PlayListWidget::populateVideoView() {
764 videoView->clear(); 764 videoView->clear();
765 StorageInfo storageInfo; 765 StorageInfo storageInfo;
766 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 766 // const QList<FileSystem> &fs = storageInfo.fileSystems();
767 767
768 if(!videoScan ) { 768 if(!videoScan ) {
769 scanForVideo(); 769 scanForVideo();
770 } 770 }
771 771
772 QListIterator<DocLnk> Vdit( vFiles.children() ); 772 QListIterator<DocLnk> Vdit( vFiles.children() );
773// QListIterator<FileSystem> it ( fs ); 773// QListIterator<FileSystem> it ( fs );
774 videoView->clear(); 774 videoView->clear();
775 QString storage, pathName; 775 QString storage, pathName;
776 for ( ; Vdit.current(); ++Vdit ) { 776 for ( ; Vdit.current(); ++Vdit ) {
777// // for( ; it.current(); ++it ) { 777// // for( ; it.current(); ++it ) {
778// const QString name = (*Vdit)->name(); 778// const QString name = (*Vdit)->name();
779// const QString path = (*Vdit)->path(); 779// const QString path = (*Vdit)->path();
780// if( Vdit.current()->file().find(path) != -1 ) { 780// if( Vdit.current()->file().find(path) != -1 ) {
781// storage=name; 781// storage=name;
782// pathName=path; 782// pathName=path;
783// // } 783// // }
784// } 784// }
785 785
786 QListViewItem * newItem; 786 QListViewItem * newItem;
787 if ( QFile( Vdit.current()->file() ).exists() ) { 787 if ( QFile( Vdit.current()->file() ).exists() ) {
788 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 788 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
789 QString::number( QFile( Vdit.current()->file() ).size() ), 789 QString::number( QFile( Vdit.current()->file() ).size() ),
790 ""/*storage*/, Vdit.current()->file()); 790 ""/*storage*/, Vdit.current()->file());
791 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 791 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
792 } 792 }
793 } 793 }
794 videoPopulated=true; 794 videoPopulated=true;
795} 795}
796 796
797 797
798void PlayListWidget::openFile() { 798void PlayListWidget::openFile() {
799 // http://66.28.164.33:2080 799 // http://66.28.164.33:2080
800 // http://somafm.com/star0242.m3u 800 // http://somafm.com/star0242.m3u
801 QString filename, name; 801 QString filename, name;
802 InputDialog *fileDlg; 802 InputDialog *fileDlg;
803 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 803 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
804 fileDlg->exec(); 804 fileDlg->exec();
805 if( fileDlg->result() == 1 ) { 805 if( fileDlg->result() == 1 ) {
806 filename = fileDlg->text(); 806 filename = fileDlg->text();
807 qDebug( "Selected filename is " + filename ); 807 qDebug( "Selected filename is " + filename );
808 // Om3u *m3uList; 808 // Om3u *m3uList;
809 DocLnk lnk; 809 DocLnk lnk;
810 Config cfg( "OpiePlayer" ); 810 Config cfg( "OpiePlayer" );
811 cfg.setGroup("PlayList"); 811 cfg.setGroup("PlayList");
812 812
813 if(filename.left(4) == "http") { 813 if(filename.left(4) == "http") {
814 QString m3uFile, m3uFilePath; 814 QString m3uFile, m3uFilePath;
815 if(filename.find(":",8,TRUE) != -1) { //found a port 815 if(filename.find(":",8,TRUE) != -1) { //found a port
816 m3uFile = filename.left( filename.find( ":",8,TRUE)); 816 m3uFile = filename.left( filename.find( ":",8,TRUE));
817 m3uFile = m3uFile.right( 7); 817 m3uFile = m3uFile.right( 7);
818 } else if(filename.left(4) == "http"){ 818 } else if(filename.left(4) == "http"){
819 m3uFile=filename; 819 m3uFile=filename;
820 m3uFile = m3uFile.right( m3uFile.length() - 7); 820 m3uFile = m3uFile.right( m3uFile.length() - 7);
821 } else{ 821 } else{
822 m3uFile=filename; 822 m3uFile=filename;
823 } 823 }
824 824
825// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 825// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
826 lnk.setName( filename ); //sets name 826 lnk.setName( filename ); //sets name
827 lnk.setFile( filename ); //sets file name 827 lnk.setFile( filename ); //sets file name
828 828
829// lnk.setIcon("opieplayer2/musicfile"); 829// lnk.setIcon("opieplayer2/musicfile");
830 830
831 d->selectedFiles->addToSelection( lnk ); 831 d->selectedFiles->addToSelection( lnk );
832 writeCurrentM3u(); 832 writeCurrentM3u();
833 d->selectedFiles->setSelectedItem( lnk.name()); 833 d->selectedFiles->setSelectedItem( lnk.name());
834 } 834 }
835 else if( filename.right( 3) == "m3u" ) { 835 else if( filename.right( 3) == "m3u" ) {
836 readm3u( filename ); 836 readm3u( filename );
837 837
838 } else if( filename.right(3) == "pls" ) { 838 } else if( filename.right(3) == "pls" ) {
839 readPls( filename ); 839 readPls( filename );
840 } else { 840 } else {
841 lnk.setName( QFileInfo(filename).baseName() ); //sets name 841 lnk.setName( QFileInfo(filename).baseName() ); //sets name
842 lnk.setFile( filename ); //sets file name 842 lnk.setFile( filename ); //sets file name
843 d->selectedFiles->addToSelection( lnk); 843 d->selectedFiles->addToSelection( lnk);
844 writeCurrentM3u(); 844 writeCurrentM3u();
845 d->selectedFiles->setSelectedItem( lnk.name()); 845 d->selectedFiles->setSelectedItem( lnk.name());
846 } 846 }
847 } 847 }
848 848
849 if( fileDlg ) { 849 if( fileDlg ) {
850 delete fileDlg; 850 delete fileDlg;
851 } 851 }
852} 852}
853 853
854/* 854/*
855reads m3u and shows files/urls to playlist widget */ 855reads m3u and shows files/urls to playlist widget */
856void PlayListWidget::readm3u( const QString &filename ) { 856void PlayListWidget::readm3u( const QString &filename ) {
857 qDebug( "read m3u filename " + filename ); 857 qDebug( "read m3u filename " + filename );
858 858
859 Om3u *m3uList; 859 Om3u *m3uList;
860 QString s, name; 860 QString s, name;
861 m3uList = new Om3u( filename, IO_ReadOnly ); 861 m3uList = new Om3u( filename, IO_ReadOnly );
862 m3uList->readM3u(); 862 m3uList->readM3u();
863 DocLnk lnk; 863 DocLnk lnk;
864 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 864 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
865 s = *it; 865 s = *it;
866// qDebug("reading "+ s); 866// qDebug("reading "+ s);
867 if(s.left(4)=="http") { 867 if(s.left(4)=="http") {
868 lnk.setName( s ); //sets file name 868 lnk.setName( s ); //sets file name
869 lnk.setIcon("opieplayer2/musicfile"); 869 lnk.setIcon("opieplayer2/musicfile");
870 lnk.setFile( s ); //sets file name 870 lnk.setFile( s ); //sets file name
871 871
872 } else { 872 } else {
873 // if( QFileInfo( s ).exists() ) { 873 // if( QFileInfo( s ).exists() ) {
874 lnk.setName( QFileInfo(s).baseName()); 874 lnk.setName( QFileInfo(s).baseName());
875 // if(s.right(4) == '.') {//if regular file 875 // if(s.right(4) == '.') {//if regular file
876 if(s.left(1) != "/") { 876 if(s.left(1) != "/") {
877 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 877 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
878 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 878 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
879// lnk.setIcon(MimeType(s).pixmap() ); 879// lnk.setIcon(MimeType(s).pixmap() );
880// lnk.setIcon("SoundPlayer"); 880// lnk.setIcon("SoundPlayer");
881 } else { 881 } else {
882 // qDebug("set link2 "+s); 882 // qDebug("set link2 "+s);
883 lnk.setFile( s); 883 lnk.setFile( s);
884// lnk.setIcon(MimeType(s).pixmap() ); 884// lnk.setIcon(MimeType(s).pixmap() );
885// lnk.setIcon("SoundPlayer"); 885// lnk.setIcon("SoundPlayer");
886 } 886 }
887 } 887 }
888 d->selectedFiles->addToSelection( lnk ); 888 d->selectedFiles->addToSelection( lnk );
889 } 889 }
890 Config config( "OpiePlayer" ); 890 Config config( "OpiePlayer" );
891 config.setGroup( "PlayList" ); 891 config.setGroup( "PlayList" );
892 892
893 config.writeEntry("CurrentPlaylist",filename); 893 config.writeEntry("CurrentPlaylist",filename);
894 config.write(); 894 config.write();
895 currentPlayList=filename; 895 currentPlayList=filename;
896 896
897// m3uList->write(); 897// m3uList->write();
898 m3uList->close(); 898 m3uList->close();
899 if(m3uList) delete m3uList; 899 if(m3uList) delete m3uList;
900 900
901 d->selectedFiles->setSelectedItem( s); 901 d->selectedFiles->setSelectedItem( s);
902 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 902 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
903 903
904} 904}
905 905
906/* 906/*
907reads pls and adds files/urls to playlist */ 907reads pls and adds files/urls to playlist */
908void PlayListWidget::readPls( const QString &filename ) { 908void PlayListWidget::readPls( const QString &filename ) {
909 909
910 qDebug( "pls filename is " + filename ); 910 qDebug( "pls filename is " + filename );
911 Om3u *m3uList; 911 Om3u *m3uList;
912 QString s, name; 912 QString s, name;
913 m3uList = new Om3u( filename, IO_ReadOnly ); 913 m3uList = new Om3u( filename, IO_ReadOnly );
914 m3uList->readPls(); 914 m3uList->readPls();
915 915
916 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 916 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
917 s = *it; 917 s = *it;
918 // s.replace( QRegExp( "%20" )," " ); 918 // s.replace( QRegExp( "%20" )," " );
919 DocLnk lnk( s ); 919 DocLnk lnk( s );
920 QFileInfo f( s ); 920 QFileInfo f( s );
921 QString name = f.baseName(); 921 QString name = f.baseName();
922 922
923 if( name.left( 4 ) == "http" ) { 923 if( name.left( 4 ) == "http" ) {
924 name = s.right( s.length() - 7); 924 name = s.right( s.length() - 7);
925 } else { 925 } else {
926 name = s; 926 name = s;
927 } 927 }
928 928
929 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 929 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
930 930
931 lnk.setName( name ); 931 lnk.setName( name );
932 if( s.at( s.length() - 4) == '.') {// if this is probably a file 932 if( s.at( s.length() - 4) == '.') {// if this is probably a file
933 lnk.setFile( s ); 933 lnk.setFile( s );
934 } else { //if its a url 934 } else { //if its a url
935// if( name.right( 1 ).find( '/' ) == -1) { 935// if( name.right( 1 ).find( '/' ) == -1) {
936// s += "/"; 936// s += "/";
937// } 937// }
938 lnk.setFile( s ); 938 lnk.setFile( s );
939 } 939 }
940 lnk.setType( "audio/x-mpegurl" ); 940 lnk.setType( "audio/x-mpegurl" );
941 941
942 lnk.writeLink(); 942 lnk.writeLink();
943 d->selectedFiles->addToSelection( lnk ); 943 d->selectedFiles->addToSelection( lnk );
944 } 944 }
945 945
946 m3uList->close(); 946 m3uList->close();
947 if(m3uList) delete m3uList; 947 if(m3uList) delete m3uList;
948} 948}
949 949
950/* 950/*
951 writes current playlist to current m3u file */ 951 writes current playlist to current m3u file */
952void PlayListWidget::writeCurrentM3u() { 952void PlayListWidget::writeCurrentM3u() {
953 qDebug("writing to current m3u"); 953 qDebug("writing to current m3u");
954 Config cfg( "OpiePlayer" ); 954 Config cfg( "OpiePlayer" );
955 cfg.setGroup("PlayList"); 955 cfg.setGroup("PlayList");
956 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 956 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
957 957
958 Om3u *m3uList; 958 Om3u *m3uList;
959 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 959 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
960 if( d->selectedFiles->first()) { 960 if( d->selectedFiles->first()) {
961 961
962 do { 962 do {
963 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 963 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
964 m3uList->add( d->selectedFiles->current()->file() ); 964 m3uList->add( d->selectedFiles->current()->file() );
965 } 965 }
966 while ( d->selectedFiles->next() ); 966 while ( d->selectedFiles->next() );
967 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 967 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
968 m3uList->write(); 968 m3uList->write();
969 m3uList->close(); 969 m3uList->close();
970 970
971 if(m3uList) delete m3uList; 971 if(m3uList) delete m3uList;
972 } 972 }
973 973
974} 974}
975 975
976 /* 976 /*
977 writes current playlist to m3u file */ 977 writes current playlist to m3u file */
978void PlayListWidget::writem3u() { 978void PlayListWidget::writem3u() {
979 InputDialog *fileDlg; 979 InputDialog *fileDlg;
980 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 980 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
981 fileDlg->exec(); 981 fileDlg->exec();
982 QString name, filename, list; 982 QString name, filename, list;
983 Om3u *m3uList; 983 Om3u *m3uList;
984 984
985 if( fileDlg->result() == 1 ) { 985 if( fileDlg->result() == 1 ) {
986 name = fileDlg->text(); 986 name = fileDlg->text();
987// qDebug( filename ); 987// qDebug( filename );
988 988
989 if( name.left( 1) != "/" ) { 989 if( name.left( 1) != "/" ) {
990 filename = QPEApplication::documentDir() + "/" + name; 990 filename = QPEApplication::documentDir() + "/" + name;
991 } 991 }
992 992
993 if( name.right( 3 ) != "m3u" ) { 993 if( name.right( 3 ) != "m3u" ) {
994 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 994 filename = QPEApplication::documentDir() + "/" +name+".m3u";
995 } 995 }
996 996
997 if( d->selectedFiles->first()) { 997 if( d->selectedFiles->first()) {
998 m3uList = new Om3u(filename, IO_ReadWrite); 998 m3uList = new Om3u(filename, IO_ReadWrite);
999 999
1000 do { 1000 do {
1001 m3uList->add( d->selectedFiles->current()->file()); 1001 m3uList->add( d->selectedFiles->current()->file());
1002 } 1002 }
1003 while ( d->selectedFiles->next() ); 1003 while ( d->selectedFiles->next() );
1004 // qDebug( list ); 1004 // qDebug( list );
1005 m3uList->write(); 1005 m3uList->write();
1006 m3uList->close(); 1006 m3uList->close();
1007 if(m3uList) delete m3uList; 1007 if(m3uList) delete m3uList;
1008 1008
1009 if(fileDlg) delete fileDlg; 1009 if(fileDlg) delete fileDlg;
1010 1010
1011 DocLnk lnk; 1011 DocLnk lnk;
1012 lnk.setFile( filename); 1012 lnk.setFile( filename);
1013 lnk.setIcon("opieplayer2/playlist2"); 1013 lnk.setIcon("opieplayer2/playlist2");
1014 lnk.setName( name); //sets file name 1014 lnk.setName( name); //sets file name
1015 1015
1016 // qDebug(filename); 1016 // qDebug(filename);
1017 Config config( "OpiePlayer" ); 1017 Config config( "OpiePlayer" );
1018 config.setGroup( "PlayList" ); 1018 config.setGroup( "PlayList" );
1019 1019
1020 config.writeEntry("CurrentPlaylist",filename); 1020 config.writeEntry("CurrentPlaylist",filename);
1021 currentPlayList=filename; 1021 currentPlayList=filename;
1022 1022
1023 if(!lnk.writeLink()) { 1023 if(!lnk.writeLink()) {
1024 qDebug("Writing doclink did not work"); 1024 qDebug("Writing doclink did not work");
1025 } 1025 }
1026 1026
1027 setCaption(tr("OpiePlayer: ") + name); 1027 setCaption(tr("OpiePlayer: ") + name);
1028 } 1028 }
1029 } 1029 }
1030} 1030}
1031 1031
1032void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1032void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1033 switch ( e->key() ) { 1033 switch ( e->key() ) {
1034 ////////////////////////////// Zaurus keys 1034 ////////////////////////////// Zaurus keys
1035 case Key_F9: //activity 1035 case Key_F9: //activity
1036 // if(audioUI->isHidden()) 1036 // if(audioUI->isHidden())
1037 // audioUI->showMaximized(); 1037 // audioUI->showMaximized();
1038 break; 1038 break;
1039 case Key_F10: //contacts 1039 case Key_F10: //contacts
1040 // if( videoUI->isHidden()) 1040 // if( videoUI->isHidden())
1041 // videoUI->showMaximized(); 1041 // videoUI->showMaximized();
1042 break; 1042 break;
1043 case Key_F11: //menu 1043 case Key_F11: //menu
1044 break; 1044 break;
1045 case Key_F12: //home 1045 case Key_F12: //home
1046 // doBlank(); 1046 // doBlank();
1047 break; 1047 break;
1048 case Key_F13: //mail 1048 case Key_F13: //mail
1049 // doUnblank(); 1049 // doUnblank();
1050 break; 1050 break;
1051 case Key_Q: //add to playlist 1051 case Key_Q: //add to playlist
1052 addSelected(); 1052 addSelected();
1053 break; 1053 break;
1054 case Key_R: //remove from playlist 1054 case Key_R: //remove from playlist
1055 removeSelected(); 1055 removeSelected();
1056 break; 1056 break;
1057 // case Key_P: //play 1057 // case Key_P: //play
1058 // qDebug("Play"); 1058 // qDebug("Play");
1059 // playSelected(); 1059 // playSelected();
1060 // break; 1060 // break;
1061 case Key_Space: 1061 case Key_Space:
1062 // playSelected(); puh 1062 // playSelected(); puh
1063 break; 1063 break;
1064 case Key_1: 1064 case Key_1:
1065 tabWidget->setCurrentPage( 0 ); 1065 tabWidget->setCurrentPage( 0 );
1066 break; 1066 break;
1067 case Key_2: 1067 case Key_2:
1068 tabWidget->setCurrentPage( 1 ); 1068 tabWidget->setCurrentPage( 1 );
1069 break; 1069 break;
1070 case Key_3: 1070 case Key_3:
1071 tabWidget->setCurrentPage( 2 ); 1071 tabWidget->setCurrentPage( 2 );
1072 break; 1072 break;
1073 case Key_4: 1073 case Key_4:
1074 tabWidget->setCurrentPage( 3 ); 1074 tabWidget->setCurrentPage( 3 );
1075 break; 1075 break;
1076 case Key_Down: 1076 case Key_Down:
1077 if ( !d->selectedFiles->next() ) 1077 if ( !d->selectedFiles->next() )
1078 d->selectedFiles->first(); 1078 d->selectedFiles->first();
1079 break; 1079 break;
1080 case Key_Up: 1080 case Key_Up:
1081 if ( !d->selectedFiles->prev() ) 1081 if ( !d->selectedFiles->prev() )
1082 // d->selectedFiles->last(); 1082 // d->selectedFiles->last();
1083 break; 1083 break;
1084 } 1084 }
1085} 1085}
1086 1086
1087void PlayListWidget::pmViewActivated(int index) { 1087void PlayListWidget::pmViewActivated(int index) {
1088// qDebug("%d", index); 1088// qDebug("%d", index);
1089 switch(index) { 1089 switch(index) {
1090 case -16: 1090 case -16:
1091 { 1091 {
1092 mediaPlayerState->toggleFullscreen(); 1092 mediaPlayerState->toggleFullscreen();
1093 bool b=mediaPlayerState->isFullscreen(); 1093 bool b=mediaPlayerState->isFullscreen();
1094 pmView->setItemChecked( index, b); 1094 pmView->setItemChecked( index, b);
1095 Config cfg( "OpiePlayer" ); 1095 Config cfg( "OpiePlayer" );
1096 cfg.writeEntry( "FullScreen", b ); 1096 cfg.writeEntry( "FullScreen", b );
1097 } 1097 }
1098 break; 1098 break;
1099 }; 1099 };
1100} 1100}
1101 1101
1102void PlayListWidget::populateSkinsMenu() { 1102void PlayListWidget::populateSkinsMenu() {
1103 int item = 0; 1103 int item = 0;
1104 defaultSkinIndex = 0; 1104 defaultSkinIndex = 0;
1105 QString skinName; 1105 QString skinName;
1106 Config cfg( "OpiePlayer" ); 1106 Config cfg( "OpiePlayer" );
1107 cfg.setGroup("Options" ); 1107 cfg.setGroup("Options" );
1108 QString skin = cfg.readEntry( "Skin", "default" ); 1108 QString skin = cfg.readEntry( "Skin", "default" );
1109 1109
1110 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1110 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1111 skinsDir.setFilter( QDir::Dirs ); 1111 skinsDir.setFilter( QDir::Dirs );
1112 skinsDir.setSorting(QDir::Name ); 1112 skinsDir.setSorting(QDir::Name );
1113 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1113 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1114 QFileInfoListIterator it( *skinslist ); 1114 QFileInfoListIterator it( *skinslist );
1115 QFileInfo *fi; 1115 QFileInfo *fi;
1116 while ( ( fi = it.current() ) ) { 1116 while ( ( fi = it.current() ) ) {
1117 skinName = fi->fileName(); 1117 skinName = fi->fileName();
1118// qDebug( fi->fileName() ); 1118// qDebug( fi->fileName() );
1119 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1119 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1120 item = skinsMenu->insertItem( fi->fileName() ) ; 1120 item = skinsMenu->insertItem( fi->fileName() ) ;
1121 } 1121 }
1122 if( skinName == "default" ) { 1122 if( skinName == "default" ) {
1123 defaultSkinIndex = item; 1123 defaultSkinIndex = item;
1124 } 1124 }
1125 if( skinName == skin ) { 1125 if( skinName == skin ) {
1126 skinsMenu->setItemChecked( item, TRUE ); 1126 skinsMenu->setItemChecked( item, TRUE );
1127 } 1127 }
1128 ++it; 1128 ++it;
1129 } 1129 }
1130} 1130}
1131 1131
1132void PlayListWidget::skinsMenuActivated( int item ) { 1132void PlayListWidget::skinsMenuActivated( int item ) {
1133 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1133 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1134 skinsMenu->setItemChecked( i, FALSE ); 1134 skinsMenu->setItemChecked( i, FALSE );
1135 } 1135 }
1136 skinsMenu->setItemChecked( item, TRUE ); 1136 skinsMenu->setItemChecked( item, TRUE );
1137 1137
1138 Config cfg( "OpiePlayer" ); 1138 Config cfg( "OpiePlayer" );
1139 cfg.setGroup("Options"); 1139 cfg.setGroup("Options");
1140 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1140 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1141 QMessageBox::warning( this, tr( "OpiePlayer" ), 1141 QMessageBox::warning( this, tr( "OpiePlayer" ),
1142 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1142 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1143} 1143}
1144 1144
1145int PlayListWidget::whichList() { 1145int PlayListWidget::whichList() const {
1146 return tabWidget->currentPageIndex(); 1146 return tabWidget->currentPageIndex();
1147} 1147}
1148 1148
1149PlayListWidget::TabType PlayListWidget::currentTab() const 1149PlayListWidget::TabType PlayListWidget::currentTab() const
1150{ 1150{
1151 static const TabType indexToTabType[ NumTabTypes ] = 1151 static const TabType indexToTabType[ NumTabTypes ] =
1152 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 1152 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
1153 1153
1154 int index = tabWidget->currentPageIndex(); 1154 int index = tabWidget->currentPageIndex();
1155 assert( index < NumTabTypes && index >= 0 ); 1155 assert( index < NumTabTypes && index >= 0 );
1156 1156
1157 return indexToTabType[ index ]; 1157 return indexToTabType[ index ];
1158} 1158}
1159 1159
1160QString PlayListWidget::currentFileListPathName() { 1160QString PlayListWidget::currentFileListPathName() const {
1161 switch (whichList()) { 1161 switch (whichList()) {
1162 case 1: 1162 case 1:
1163 return audioView->currentItem()->text(3); 1163 return audioView->currentItem()->text(3);
1164 break; 1164 break;
1165 case 2: 1165 case 2:
1166 return videoView->currentItem()->text(3); 1166 return videoView->currentItem()->text(3);
1167 break; 1167 break;
1168 }; 1168 };
1169 return ""; 1169 return "";
1170} 1170}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 05d53a4..7044abe 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,124 +1,124 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 };
59 59
60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
61 ~PlayListWidget(); 61 ~PlayListWidget();
62 DocLnkSet files; 62 DocLnkSet files;
63 DocLnkSet vFiles; 63 DocLnkSet vFiles;
64 bool fromSetDocument; 64 bool fromSetDocument;
65 bool insanityBool; 65 bool insanityBool;
66 QString setDocFileRef, currentPlayList; 66 QString setDocFileRef, currentPlayList;
67 // retrieve the current playlist entry (media file link) 67 // retrieve the current playlist entry (media file link)
68 const DocLnk *current(); 68 const DocLnk *current();
69 void useSelectedDocument(); 69 void useSelectedDocument();
70 int selected; 70 int selected;
71 int whichList(); 71 int whichList() const;
72 TabType currentTab() const; 72 TabType currentTab() const;
73 73
74public slots: 74public slots:
75 bool first(); 75 bool first();
76 bool last(); 76 bool last();
77 bool next(); 77 bool next();
78 bool prev(); 78 bool prev();
79 void writeDefaultPlaylist( ); 79 void writeDefaultPlaylist( );
80 QString currentFileListPathName(); 80 QString currentFileListPathName() const;
81protected: 81protected:
82 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
83 83
84private: 84private:
85 int defaultSkinIndex; 85 int defaultSkinIndex;
86 bool audioScan, videoScan, audioPopulated, videoPopulated; 86 bool audioScan, videoScan, audioPopulated, videoPopulated;
87 void readm3u(const QString &); 87 void readm3u(const QString &);
88 void readPls(const QString &); 88 void readPls(const QString &);
89 void initializeStates(); 89 void initializeStates();
90 void populateAudioView(); 90 void populateAudioView();
91 void populateVideoView(); 91 void populateVideoView();
92 92
93private slots: 93private slots:
94 void populateSkinsMenu(); 94 void populateSkinsMenu();
95 void skinsMenuActivated(int); 95 void skinsMenuActivated(int);
96 void pmViewActivated(int); 96 void pmViewActivated(int);
97 void writem3u(); 97 void writem3u();
98 void writeCurrentM3u(); 98 void writeCurrentM3u();
99 void scanForAudio(); 99 void scanForAudio();
100 void scanForVideo(); 100 void scanForVideo();
101 void openFile(); 101 void openFile();
102 void setDocument( const QString& fileref ); 102 void setDocument( const QString& fileref );
103 void addToSelection( const DocLnk& ); // Add a media file to the playlist 103 void addToSelection( const DocLnk& ); // Add a media file to the playlist
104 void addToSelection( QListViewItem* ); // Add a media file to the playlist 104 void addToSelection( QListViewItem* ); // Add a media file to the playlist
105 void setPlaylist( bool ); // Show/Hide the playlist 105 void setPlaylist( bool ); // Show/Hide the playlist
106 void clearList(); 106 void clearList();
107 void addAllToList(); 107 void addAllToList();
108 void addAllMusicToList(); 108 void addAllMusicToList();
109 void addAllVideoToList(); 109 void addAllVideoToList();
110 void saveList(); // Save the playlist 110 void saveList(); // Save the playlist
111 void loadList( const DocLnk &); // Load a playlist 111 void loadList( const DocLnk &); // Load a playlist
112 void playIt( QListViewItem *); 112 void playIt( QListViewItem *);
113 void btnPlay(bool); 113 void btnPlay(bool);
114 void deletePlaylist(); 114 void deletePlaylist();
115 void addSelected(); 115 void addSelected();
116 void removeSelected(); 116 void removeSelected();
117 void tabChanged(QWidget*); 117 void tabChanged(QWidget*);
118 void viewPressed( int, QListViewItem *, const QPoint&, int); 118 void viewPressed( int, QListViewItem *, const QPoint&, int);
119 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 119 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
120 void playSelected(); 120 void playSelected();
121}; 121};
122 122
123#endif // PLAY_LIST_WIDGET_H 123#endif // PLAY_LIST_WIDGET_H
124 124