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