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