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