-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index ab6b593..26c2896 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,636 +1,636 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
49 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
50 | #include "om3u.h" | 50 | #include "om3u.h" |
51 | 51 | ||
52 | //only needed for the random play | 52 | //only needed for the random play |
53 | #include <stdlib.h> | 53 | #include <stdlib.h> |
54 | 54 | ||
55 | #include "audiowidget.h" | 55 | #include "audiowidget.h" |
56 | #include "videowidget.h" | 56 | #include "videowidget.h" |
57 | 57 | ||
58 | extern MediaPlayerState *mediaPlayerState; | 58 | extern MediaPlayerState *mediaPlayerState; |
59 | 59 | ||
60 | 60 | ||
61 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 61 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
62 | : PlayListWidgetGui( parent, name, fl ) { | 62 | : PlayListWidgetGui( parent, name, fl ) { |
63 | 63 | ||
64 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 64 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
65 | "opieplayer2/add_to_playlist", | 65 | "opieplayer2/add_to_playlist", |
66 | this , SLOT(addSelected() ) ); | 66 | this , SLOT(addSelected() ) ); |
67 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 67 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
68 | "opieplayer2/remove_from_playlist", | 68 | "opieplayer2/remove_from_playlist", |
69 | this , SLOT(removeSelected() ) ); | 69 | this , SLOT(removeSelected() ) ); |
70 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 70 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
71 | this , SLOT( btnPlay( bool) ), TRUE ); | 71 | this , SLOT( btnPlay( bool) ), TRUE ); |
72 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 72 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
73 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 73 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
74 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 74 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
75 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 75 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
76 | 76 | ||
77 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 77 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
79 | this, SLOT( addAllMusicToList() ) ); | 79 | this, SLOT( addAllMusicToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
81 | this, SLOT( addAllVideoToList() ) ); | 81 | this, SLOT( addAllVideoToList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
83 | this, SLOT( addAllToList() ) ); | 83 | this, SLOT( addAllToList() ) ); |
84 | pmPlayList->insertSeparator(-1); | 84 | pmPlayList->insertSeparator(-1); |
85 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 85 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
86 | // this, SLOT( saveList() ) ); | 86 | // this, SLOT( saveList() ) ); |
87 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 87 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
88 | this, SLOT(writem3u() ) ); | 88 | this, SLOT(writem3u() ) ); |
89 | pmPlayList->insertSeparator(-1); | 89 | pmPlayList->insertSeparator(-1); |
90 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 90 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
91 | this,SLOT( openFile() ) ); | 91 | this,SLOT( openFile() ) ); |
92 | pmPlayList->insertSeparator(-1); | 92 | pmPlayList->insertSeparator(-1); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
94 | this,SLOT( scanForAudio() ) ); | 94 | this,SLOT( scanForAudio() ) ); |
95 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 95 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
96 | this,SLOT( scanForVideo() ) ); | 96 | this,SLOT( scanForVideo() ) ); |
97 | 97 | ||
98 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 98 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
99 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 99 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
100 | 100 | ||
101 | Config cfg( "OpiePlayer" ); | 101 | Config cfg( "OpiePlayer" ); |
102 | bool b= cfg.readBoolEntry("FullScreen", 0); | 102 | bool b= cfg.readBoolEntry("FullScreen", 0); |
103 | mediaPlayerState->setFullscreen( b ); | 103 | mediaPlayerState->setFullscreen( b ); |
104 | pmView->setItemChecked( -16, b ); | 104 | pmView->setItemChecked( -16, b ); |
105 | 105 | ||
106 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 106 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
107 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 107 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 108 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
109 | d->selectedFiles, SLOT(removeSelected() ) ); | 109 | d->selectedFiles, SLOT(removeSelected() ) ); |
110 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 110 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
111 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
112 | QVBox *stretch2 = new QVBox( vbox1 ); | 112 | QVBox *stretch2 = new QVBox( vbox1 ); |
113 | 113 | ||
114 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 114 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
115 | SLOT( deletePlaylist() ) ); | 115 | SLOT( deletePlaylist() ) ); |
116 | connect( pmView, SIGNAL( activated( int ) ), | 116 | connect( pmView, SIGNAL( activated( int ) ), |
117 | this, SLOT( pmViewActivated( int ) ) ); | 117 | this, SLOT( pmViewActivated( int ) ) ); |
118 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 118 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
119 | this, SLOT( skinsMenuActivated( int ) ) ); | 119 | this, SLOT( skinsMenuActivated( int ) ) ); |
120 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 120 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
121 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 121 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
122 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 122 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
123 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 123 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
124 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 124 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
125 | this,SLOT( playIt( QListViewItem *) ) ); | 125 | this,SLOT( playIt( QListViewItem *) ) ); |
126 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 126 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
127 | this, SLOT( addToSelection( QListViewItem *) ) ); | 127 | this, SLOT( addToSelection( QListViewItem *) ) ); |
128 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 128 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
130 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 130 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
131 | this,SLOT( playIt( QListViewItem *) ) ); | 131 | this,SLOT( playIt( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 132 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
133 | this, SLOT( addToSelection( QListViewItem *) ) ); | 133 | this, SLOT( addToSelection( QListViewItem *) ) ); |
134 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 134 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
135 | this, SLOT( loadList( const DocLnk & ) ) ); | 135 | this, SLOT( loadList( const DocLnk & ) ) ); |
136 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 136 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
137 | this, SLOT( tabChanged( QWidget* ) ) ); | 137 | this, SLOT( tabChanged( QWidget* ) ) ); |
138 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 138 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
139 | d->tbPlay, SLOT( setOn( bool ) ) ); | 139 | d->tbPlay, SLOT( setOn( bool ) ) ); |
140 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 140 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
141 | d->tbLoop, SLOT( setOn( bool ) ) ); | 141 | d->tbLoop, SLOT( setOn( bool ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
143 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 143 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
145 | this, SLOT( setPlaylist( bool ) ) ); | 145 | this, SLOT( setPlaylist( bool ) ) ); |
146 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 146 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
147 | this, SLOT( playIt( QListViewItem *) ) ); | 147 | this, SLOT( playIt( QListViewItem *) ) ); |
148 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 148 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
149 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 149 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
150 | 150 | ||
151 | // cfg.setGroup( "PlayList" ); | 151 | // cfg.setGroup( "PlayList" ); |
152 | // if( cfg.readBoolEntry("newPlaylist") ){ | 152 | // if( cfg.readBoolEntry("newPlaylist") ){ |
153 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 153 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
154 | loadList(DocLnk( currentPlaylist ) ); | 154 | loadList(DocLnk( currentPlaylist ) ); |
155 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 155 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
156 | // } else { | 156 | // } else { |
157 | // readConfig( cfg ); | 157 | // readConfig( cfg ); |
158 | 158 | ||
159 | // } | 159 | // } |
160 | // see which skins are installed | 160 | // see which skins are installed |
161 | videoScan=FALSE; | 161 | videoScan=FALSE; |
162 | audioScan=FALSE; | 162 | audioScan=FALSE; |
163 | populateSkinsMenu(); | 163 | populateSkinsMenu(); |
164 | initializeStates(); | 164 | initializeStates(); |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | PlayListWidget::~PlayListWidget() { | 168 | PlayListWidget::~PlayListWidget() { |
169 | // WTF?!@?! | 169 | // WTF?!@?! |
170 | 170 | ||
171 | if ( d->current ) { | 171 | if ( d->current ) { |
172 | delete d->current; | 172 | delete d->current; |
173 | } | 173 | } |
174 | delete d; | 174 | delete d; |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void PlayListWidget::initializeStates() { | 178 | void PlayListWidget::initializeStates() { |
179 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 179 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
180 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 180 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
181 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 181 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
182 | setPlaylist( true ); | 182 | setPlaylist( true ); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | void PlayListWidget::readConfig( Config& cfg ) { | 186 | void PlayListWidget::readConfig( Config& cfg ) { |
187 | 187 | ||
188 | cfg.setGroup( "PlayList" ); | 188 | cfg.setGroup( "PlayList" ); |
189 | QString currentString = cfg.readEntry( "current", "" ); | 189 | QString currentString = cfg.readEntry( "current", "" ); |
190 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); | 190 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); |
191 | 191 | ||
192 | for ( int i = 0; i < noOfFiles; i++ ) { | 192 | for ( int i = 0; i < noOfFiles; i++ ) { |
193 | QString entryName; | 193 | QString entryName; |
194 | entryName.sprintf( "File%i", i + 1 ); | 194 | entryName.sprintf( "File%i", i + 1 ); |
195 | 195 | ||
196 | QString linkFile = cfg.readEntry( entryName ); | 196 | QString linkFile = cfg.readEntry( entryName ); |
197 | 197 | ||
198 | qDebug("reading "+linkFile); | 198 | qDebug("reading "+linkFile); |
199 | 199 | ||
200 | if( QFileInfo( linkFile ).exists() ) { | 200 | if( QFileInfo( linkFile ).exists() ) { |
201 | 201 | ||
202 | DocLnk lnk( linkFile ); | 202 | DocLnk lnk( linkFile ); |
203 | 203 | ||
204 | if ( QFileInfo( lnk.file() ).exists() || | 204 | if ( QFileInfo( lnk.file() ).exists() || |
205 | 205 | ||
206 | linkFile.find( "http" , 0, TRUE) != -1) { | 206 | linkFile.find( "http" , 0, TRUE) != -1) { |
207 | 207 | ||
208 | d->selectedFiles->addToSelection( lnk ); | 208 | d->selectedFiles->addToSelection( lnk ); |
209 | 209 | ||
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | d->selectedFiles->setSelectedItem( currentString ); | 213 | d->selectedFiles->setSelectedItem( currentString ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void PlayListWidget::writeConfig( Config& cfg ) const { | 218 | void PlayListWidget::writeConfig( Config& cfg ) const { |
219 | 219 | ||
220 | // Config config( "OpiePlayer" ); | 220 | Config config( "OpiePlayer" ); |
221 | // config.setGroup( "PlayList" ); | 221 | config.setGroup( "PlayList" ); |
222 | 222 | ||
223 | // if(config.readBoolEntry("newPlaylist")) { | 223 | // if(config.readBoolEntry("newPlaylist")) { |
224 | // new for testing | 224 | // new for testing |
225 | QString name, filename, list; | 225 | QString name, filename, list; |
226 | Om3u *m3uList; | 226 | Om3u *m3uList; |
227 | name = "default"; | 227 | name = "default"; |
228 | 228 | ||
229 | filename=QPEApplication::documentDir() + "/" + name+".m3u"; | 229 | filename=QPEApplication::documentDir() + "/" + name+".m3u"; |
230 | 230 | ||
231 | m3uList = new Om3u(filename); | 231 | m3uList = new Om3u(filename); |
232 | 232 | ||
233 | d->selectedFiles->first(); | 233 | d->selectedFiles->first(); |
234 | do { | 234 | do { |
235 | m3uList->add( d->selectedFiles->current()->file()); | 235 | m3uList->add( d->selectedFiles->current()->file()); |
236 | } | 236 | } |
237 | while ( d->selectedFiles->next() ); | 237 | while ( d->selectedFiles->next() ); |
238 | 238 | ||
239 | qDebug( list ); | 239 | qDebug( list ); |
240 | 240 | ||
241 | m3uList->write(); | 241 | m3uList->write(); |
242 | m3uList->close(); | 242 | m3uList->close(); |
243 | if(m3uList) delete m3uList; | 243 | if(m3uList) delete m3uList; |
244 | 244 | ||
245 | DocLnk lnk; | 245 | DocLnk lnk; |
246 | lnk.setFile( filename); | 246 | lnk.setFile( filename); |
247 | lnk.setIcon("opieplayer2/playlist2"); | 247 | lnk.setIcon("opieplayer2/playlist2"); |
248 | lnk.setName( name); //sets file name | 248 | lnk.setName( name); //sets file name |
249 | 249 | ||
250 | qDebug("writing default playlist "+filename); | 250 | qDebug("writing default playlist "+filename); |
251 | 251 | ||
252 | config.writeEntry("CurrentPlaylist", filename); | 252 | config.writeEntry("CurrentPlaylist", filename); |
253 | // currentPlayList=filename; | 253 | // currentPlayList=filename; |
254 | 254 | ||
255 | if(!lnk.writeLink()) { | 255 | if(!lnk.writeLink()) { |
256 | qDebug("Writing doclink did not work"); | 256 | qDebug("Writing doclink did not work"); |
257 | } | 257 | } |
258 | 258 | ||
259 | // } else { | 259 | // } else { |
260 | 260 | ||
261 | // d->selectedFiles->writeCurrent( cfg ); | 261 | // d->selectedFiles->writeCurrent( cfg ); |
262 | // int noOfFiles = 0; | 262 | // int noOfFiles = 0; |
263 | // d->selectedFiles->first(); | 263 | // d->selectedFiles->first(); |
264 | 264 | ||
265 | // do { | 265 | // do { |
266 | // const DocLnk *lnk = d->selectedFiles->current(); | 266 | // const DocLnk *lnk = d->selectedFiles->current(); |
267 | 267 | ||
268 | // if ( lnk ) { | 268 | // if ( lnk ) { |
269 | 269 | ||
270 | // QString entryName; | 270 | // QString entryName; |
271 | // entryName.sprintf( "File%i", noOfFiles + 1 ); | 271 | // entryName.sprintf( "File%i", noOfFiles + 1 ); |
272 | 272 | ||
273 | // cfg.writeEntry( entryName, lnk->linkFile() ); | 273 | // cfg.writeEntry( entryName, lnk->linkFile() ); |
274 | // // if this link does exist, add it so we have the file | 274 | // // if this link does exist, add it so we have the file |
275 | // // next time... | 275 | // // next time... |
276 | 276 | ||
277 | // if ( !QFile::exists( lnk->linkFile() ) ) { | 277 | // if ( !QFile::exists( lnk->linkFile() ) ) { |
278 | // lnk->writeLink(); | 278 | // lnk->writeLink(); |
279 | // } | 279 | // } |
280 | // } | 280 | // } |
281 | // noOfFiles++; | 281 | // noOfFiles++; |
282 | // } | 282 | // } |
283 | // while ( d->selectedFiles->next() ); | 283 | // while ( d->selectedFiles->next() ); |
284 | // cfg.writeEntry("NumberOfFiles", noOfFiles ); | 284 | // cfg.writeEntry("NumberOfFiles", noOfFiles ); |
285 | // } | 285 | // } |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 289 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
290 | d->setDocumentUsed = FALSE; | 290 | d->setDocumentUsed = FALSE; |
291 | if ( mediaPlayerState->playlist() ) { | 291 | if ( mediaPlayerState->playlist() ) { |
292 | if( QFileInfo( lnk.file() ).exists() || | 292 | if( QFileInfo( lnk.file() ).exists() || |
293 | lnk.file().left(4) == "http" ) | 293 | lnk.file().left(4) == "http" ) |
294 | d->selectedFiles->addToSelection( lnk ); | 294 | d->selectedFiles->addToSelection( lnk ); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | mediaPlayerState->setPlaying( TRUE ); | 297 | mediaPlayerState->setPlaying( TRUE ); |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | void PlayListWidget::clearList() { | 301 | void PlayListWidget::clearList() { |
302 | while ( first() ) { | 302 | while ( first() ) { |
303 | d->selectedFiles->removeSelected(); | 303 | d->selectedFiles->removeSelected(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 308 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
309 | switch (mouse) { | 309 | switch (mouse) { |
310 | case 1: | 310 | case 1: |
311 | break; | 311 | break; |
312 | case 2: | 312 | case 2: |
313 | { | 313 | { |
314 | QPopupMenu m; | 314 | QPopupMenu m; |
315 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 315 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
316 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 316 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
317 | m.exec( QCursor::pos() ); | 317 | m.exec( QCursor::pos() ); |
318 | } | 318 | } |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 324 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
325 | switch (mouse) { | 325 | switch (mouse) { |
326 | case 1: | 326 | case 1: |
327 | break; | 327 | break; |
328 | case 2: | 328 | case 2: |
329 | { | 329 | { |
330 | QPopupMenu m; | 330 | QPopupMenu m; |
331 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 331 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
332 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 332 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
333 | m.exec( QCursor::pos() ); | 333 | m.exec( QCursor::pos() ); |
334 | } | 334 | } |
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void PlayListWidget::addAllToList() { | 340 | void PlayListWidget::addAllToList() { |
341 | DocLnkSet filesAll; | 341 | DocLnkSet filesAll; |
342 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 342 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
343 | QListIterator<DocLnk> Adit( filesAll.children() ); | 343 | QListIterator<DocLnk> Adit( filesAll.children() ); |
344 | for ( ; Adit.current(); ++Adit ) { | 344 | for ( ; Adit.current(); ++Adit ) { |
345 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 345 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
346 | d->selectedFiles->addToSelection( **Adit ); | 346 | d->selectedFiles->addToSelection( **Adit ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void PlayListWidget::addAllMusicToList() { | 352 | void PlayListWidget::addAllMusicToList() { |
353 | QListIterator<DocLnk> dit( files.children() ); | 353 | QListIterator<DocLnk> dit( files.children() ); |
354 | for ( ; dit.current(); ++dit ) { | 354 | for ( ; dit.current(); ++dit ) { |
355 | if( QFileInfo(dit.current()->file() ).exists() ) { | 355 | if( QFileInfo(dit.current()->file() ).exists() ) { |
356 | d->selectedFiles->addToSelection( **dit ); | 356 | d->selectedFiles->addToSelection( **dit ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void PlayListWidget::addAllVideoToList() { | 362 | void PlayListWidget::addAllVideoToList() { |
363 | QListIterator<DocLnk> dit( vFiles.children() ); | 363 | QListIterator<DocLnk> dit( vFiles.children() ); |
364 | for ( ; dit.current(); ++dit ) { | 364 | for ( ; dit.current(); ++dit ) { |
365 | if( QFileInfo( dit.current()->file() ).exists() ) { | 365 | if( QFileInfo( dit.current()->file() ).exists() ) { |
366 | d->selectedFiles->addToSelection( **dit ); | 366 | d->selectedFiles->addToSelection( **dit ); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | void PlayListWidget::setDocument( const QString& fileref ) { | 372 | void PlayListWidget::setDocument( const QString& fileref ) { |
373 | //qDebug( fileref ); | 373 | //qDebug( fileref ); |
374 | fromSetDocument = TRUE; | 374 | fromSetDocument = TRUE; |
375 | if ( fileref.isNull() ) { | 375 | if ( fileref.isNull() ) { |
376 | QMessageBox::critical( 0, tr( "Invalid File" ), | 376 | QMessageBox::critical( 0, tr( "Invalid File" ), |
377 | tr( "There was a problem in getting the file." ) ); | 377 | tr( "There was a problem in getting the file." ) ); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | 380 | ||
381 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 381 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
382 | readm3u( fileref ); | 382 | readm3u( fileref ); |
383 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 383 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
384 | readPls( fileref ); | 384 | readPls( fileref ); |
385 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist | 385 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist |
386 | clearList(); | 386 | clearList(); |
387 | loadList( DocLnk( fileref ) ); | 387 | loadList( DocLnk( fileref ) ); |
388 | d->selectedFiles->first(); | 388 | d->selectedFiles->first(); |
389 | } else { | 389 | } else { |
390 | clearList(); | 390 | clearList(); |
391 | addToSelection( DocLnk( fileref ) ); | 391 | addToSelection( DocLnk( fileref ) ); |
392 | d->setDocumentUsed = TRUE; | 392 | d->setDocumentUsed = TRUE; |
393 | mediaPlayerState->setPlaying( FALSE ); | 393 | mediaPlayerState->setPlaying( FALSE ); |
394 | // qApp->processEvents(); | 394 | // qApp->processEvents(); |
395 | mediaPlayerState->setPlaying( TRUE ); | 395 | mediaPlayerState->setPlaying( TRUE ); |
396 | // qApp->processEvents(); | 396 | // qApp->processEvents(); |
397 | setCaption( tr("OpiePlayer") ); | 397 | setCaption( tr("OpiePlayer") ); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void PlayListWidget::useSelectedDocument() { | 402 | void PlayListWidget::useSelectedDocument() { |
403 | d->setDocumentUsed = FALSE; | 403 | d->setDocumentUsed = FALSE; |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | const DocLnk *PlayListWidget::current() { // this is fugly | 407 | const DocLnk *PlayListWidget::current() { // this is fugly |
408 | switch ( whichList() ) { | 408 | switch ( whichList() ) { |
409 | case 0: //playlist | 409 | case 0: //playlist |
410 | { | 410 | { |
411 | // qDebug("playlist"); | 411 | // qDebug("playlist"); |
412 | if ( mediaPlayerState->playlist() ) { | 412 | if ( mediaPlayerState->playlist() ) { |
413 | return d->selectedFiles->current(); | 413 | return d->selectedFiles->current(); |
414 | } else if ( d->setDocumentUsed && d->current ) { | 414 | } else if ( d->setDocumentUsed && d->current ) { |
415 | return d->current; | 415 | return d->current; |
416 | } else { | 416 | } else { |
417 | return &(d->files->selectedDocument()); | 417 | return &(d->files->selectedDocument()); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | break; | 420 | break; |
421 | }; | 421 | }; |
422 | return 0; | 422 | return 0; |
423 | } | 423 | } |
424 | 424 | ||
425 | 425 | ||
426 | bool PlayListWidget::prev() { | 426 | bool PlayListWidget::prev() { |
427 | if ( mediaPlayerState->playlist() ) { | 427 | if ( mediaPlayerState->playlist() ) { |
428 | if ( mediaPlayerState->shuffled() ) { | 428 | if ( mediaPlayerState->shuffled() ) { |
429 | const DocLnk *cur = current(); | 429 | const DocLnk *cur = current(); |
430 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 430 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
431 | for ( int i = 0; i < j; i++ ) { | 431 | for ( int i = 0; i < j; i++ ) { |
432 | if ( !d->selectedFiles->next() ) | 432 | if ( !d->selectedFiles->next() ) |
433 | d->selectedFiles->first(); | 433 | d->selectedFiles->first(); |
434 | } | 434 | } |
435 | if ( cur == current() ) | 435 | if ( cur == current() ) |
436 | if ( !d->selectedFiles->next() ) { | 436 | if ( !d->selectedFiles->next() ) { |
437 | d->selectedFiles->first(); | 437 | d->selectedFiles->first(); |
438 | } | 438 | } |
439 | return TRUE; | 439 | return TRUE; |
440 | } else { | 440 | } else { |
441 | if ( !d->selectedFiles->prev() ) { | 441 | if ( !d->selectedFiles->prev() ) { |
442 | if ( mediaPlayerState->looping() ) { | 442 | if ( mediaPlayerState->looping() ) { |
443 | return d->selectedFiles->last(); | 443 | return d->selectedFiles->last(); |
444 | } else { | 444 | } else { |
445 | return FALSE; | 445 | return FALSE; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | return TRUE; | 448 | return TRUE; |
449 | } | 449 | } |
450 | } else { | 450 | } else { |
451 | return mediaPlayerState->looping(); | 451 | return mediaPlayerState->looping(); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | bool PlayListWidget::next() { | 456 | bool PlayListWidget::next() { |
457 | //qDebug("<<<<<<<<<<<<next()"); | 457 | //qDebug("<<<<<<<<<<<<next()"); |
458 | if ( mediaPlayerState->playlist() ) { | 458 | if ( mediaPlayerState->playlist() ) { |
459 | if ( mediaPlayerState->shuffled() ) { | 459 | if ( mediaPlayerState->shuffled() ) { |
460 | return prev(); | 460 | return prev(); |
461 | } else { | 461 | } else { |
462 | if ( !d->selectedFiles->next() ) { | 462 | if ( !d->selectedFiles->next() ) { |
463 | if ( mediaPlayerState->looping() ) { | 463 | if ( mediaPlayerState->looping() ) { |
464 | return d->selectedFiles->first(); | 464 | return d->selectedFiles->first(); |
465 | } else { | 465 | } else { |
466 | return FALSE; | 466 | return FALSE; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | return TRUE; | 469 | return TRUE; |
470 | } | 470 | } |
471 | } else { | 471 | } else { |
472 | return mediaPlayerState->looping(); | 472 | return mediaPlayerState->looping(); |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
477 | bool PlayListWidget::first() { | 477 | bool PlayListWidget::first() { |
478 | if ( mediaPlayerState->playlist() ) | 478 | if ( mediaPlayerState->playlist() ) |
479 | return d->selectedFiles->first(); | 479 | return d->selectedFiles->first(); |
480 | else | 480 | else |
481 | return mediaPlayerState->looping(); | 481 | return mediaPlayerState->looping(); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | bool PlayListWidget::last() { | 485 | bool PlayListWidget::last() { |
486 | if ( mediaPlayerState->playlist() ) | 486 | if ( mediaPlayerState->playlist() ) |
487 | return d->selectedFiles->last(); | 487 | return d->selectedFiles->last(); |
488 | else | 488 | else |
489 | return mediaPlayerState->looping(); | 489 | return mediaPlayerState->looping(); |
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | void PlayListWidget::saveList() { | 493 | void PlayListWidget::saveList() { |
494 | // Config config( "OpiePlayer" ); | 494 | // Config config( "OpiePlayer" ); |
495 | // config.setGroup( "PlayList" ); | 495 | // config.setGroup( "PlayList" ); |
496 | 496 | ||
497 | // if(config.readBoolEntry("newPlaylist") ){ | 497 | // if(config.readBoolEntry("newPlaylist") ){ |
498 | writem3u(); | 498 | writem3u(); |
499 | 499 | ||
500 | // } else { | 500 | // } else { |
501 | 501 | ||
502 | // QString filename; | 502 | // QString filename; |
503 | // InputDialog *fileDlg = 0l; | 503 | // InputDialog *fileDlg = 0l; |
504 | // fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 504 | // fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
505 | // fileDlg->exec(); | 505 | // fileDlg->exec(); |
506 | // if( fileDlg->result() == 1 ) { | 506 | // if( fileDlg->result() == 1 ) { |
507 | // if ( d->current ) | 507 | // if ( d->current ) |
508 | // delete d->current; | 508 | // delete d->current; |
509 | // filename = fileDlg->text();//+".playlist"; | 509 | // filename = fileDlg->text();//+".playlist"; |
510 | // // qDebug("saving playlist "+filename+".playlist"); | 510 | // // qDebug("saving playlist "+filename+".playlist"); |
511 | 511 | ||
512 | // Config cfg( filename +".playlist"); | 512 | // Config cfg( filename +".playlist"); |
513 | // writeConfig( cfg ); | 513 | // writeConfig( cfg ); |
514 | 514 | ||
515 | // DocLnk lnk; | 515 | // DocLnk lnk; |
516 | // lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); | 516 | // lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); |
517 | // //sets File property | 517 | // //sets File property |
518 | // lnk.setType("playlist/plain"); | 518 | // lnk.setType("playlist/plain"); |
519 | // lnk.setIcon("opieplayer2/playlist2"); | 519 | // lnk.setIcon("opieplayer2/playlist2"); |
520 | // lnk.setName( filename); //sets file name | 520 | // lnk.setName( filename); //sets file name |
521 | // // qDebug(filename); | 521 | // // qDebug(filename); |
522 | // if(!lnk.writeLink()) { | 522 | // if(!lnk.writeLink()) { |
523 | // qDebug("Writing doclink did not work"); | 523 | // qDebug("Writing doclink did not work"); |
524 | // } | 524 | // } |
525 | // } | 525 | // } |
526 | 526 | ||
527 | // config.writeEntry("CurrentPlaylist",filename); | 527 | // config.writeEntry("CurrentPlaylist",filename); |
528 | // setCaption(tr("OpiePlayer: ")+filename); | 528 | // setCaption(tr("OpiePlayer: ")+filename); |
529 | // d->selectedFiles->first(); | 529 | // d->selectedFiles->first(); |
530 | // if(fileDlg) { | 530 | // if(fileDlg) { |
531 | // delete fileDlg; | 531 | // delete fileDlg; |
532 | // } | 532 | // } |
533 | // } | 533 | // } |
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | void PlayListWidget::loadList( const DocLnk & lnk) { | 537 | void PlayListWidget::loadList( const DocLnk & lnk) { |
538 | QString name = lnk.name(); | 538 | QString name = lnk.name(); |
539 | qDebug("currentList is "+name); | 539 | qDebug("currentList is "+name); |
540 | 540 | ||
541 | if( name.length()>0) { | 541 | if( name.length()>0) { |
542 | setCaption("OpiePlayer: "+name); | 542 | setCaption("OpiePlayer: "+name); |
543 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 543 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
544 | clearList(); | 544 | clearList(); |
545 | 545 | ||
546 | // if(name.right(3) == "m3u") { | 546 | // if(name.right(3) == "m3u") { |
547 | 547 | ||
548 | readm3u(lnk.file()); | 548 | readm3u(lnk.file()); |
549 | // } else { | 549 | // } else { |
550 | // / Config cfg( name+".playlist"); | 550 | // / Config cfg( name+".playlist"); |
551 | // readConfig(cfg); | 551 | // readConfig(cfg); |
552 | 552 | ||
553 | tabWidget->setCurrentPage(0); | 553 | tabWidget->setCurrentPage(0); |
554 | 554 | ||
555 | Config config( "OpiePlayer" ); | 555 | Config config( "OpiePlayer" ); |
556 | config.setGroup( "PlayList" ); | 556 | config.setGroup( "PlayList" ); |
557 | config.writeEntry("CurrentPlaylist", lnk.file()); | 557 | config.writeEntry("CurrentPlaylist", lnk.file()); |
558 | // // d->selectedFiles->first(); | 558 | // // d->selectedFiles->first(); |
559 | // } | 559 | // } |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
563 | 563 | ||
564 | void PlayListWidget::setPlaylist( bool shown ) { | 564 | void PlayListWidget::setPlaylist( bool shown ) { |
565 | if ( shown ) { | 565 | if ( shown ) { |
566 | d->playListFrame->show(); | 566 | d->playListFrame->show(); |
567 | } else { | 567 | } else { |
568 | d->playListFrame->hide(); | 568 | d->playListFrame->hide(); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | 572 | ||
573 | void PlayListWidget::addSelected() { | 573 | void PlayListWidget::addSelected() { |
574 | 574 | ||
575 | Config cfg( "OpiePlayer" ); | 575 | Config cfg( "OpiePlayer" ); |
576 | cfg.setGroup("PlayList"); | 576 | cfg.setGroup("PlayList"); |
577 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 577 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
578 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 578 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
579 | 579 | ||
580 | switch (whichList()) { | 580 | switch (whichList()) { |
581 | case 0: //playlist | 581 | case 0: //playlist |
582 | break; | 582 | break; |
583 | case 1: { //audio | 583 | case 1: { //audio |
584 | QListViewItemIterator it( audioView ); | 584 | QListViewItemIterator it( audioView ); |
585 | // iterate through all items of the listview | 585 | // iterate through all items of the listview |
586 | for ( ; it.current(); ++it ) { | 586 | for ( ; it.current(); ++it ) { |
587 | if ( it.current()->isSelected() ) { | 587 | if ( it.current()->isSelected() ) { |
588 | QListIterator<DocLnk> dit( files.children() ); | 588 | QListIterator<DocLnk> dit( files.children() ); |
589 | for ( ; dit.current(); ++dit ) { | 589 | for ( ; dit.current(); ++dit ) { |
590 | if( dit.current()->name() == it.current()->text(0) ) { | 590 | if( dit.current()->name() == it.current()->text(0) ) { |
591 | if(QFileInfo( dit.current()->file()).exists()) | 591 | if(QFileInfo( dit.current()->file()).exists()) |
592 | d->selectedFiles->addToSelection( **dit ); | 592 | d->selectedFiles->addToSelection( **dit ); |
593 | } | 593 | } |
594 | } | 594 | } |
595 | audioView->setSelected( it.current(),FALSE); | 595 | audioView->setSelected( it.current(),FALSE); |
596 | } | 596 | } |
597 | } | 597 | } |
598 | tabWidget->setCurrentPage(0); | 598 | tabWidget->setCurrentPage(0); |
599 | } | 599 | } |
600 | break; | 600 | break; |
601 | case 2: { // video | 601 | case 2: { // video |
602 | QListViewItemIterator it( videoView ); | 602 | QListViewItemIterator it( videoView ); |
603 | // iterate through all items of the listview | 603 | // iterate through all items of the listview |
604 | for ( ; it.current(); ++it ) { | 604 | for ( ; it.current(); ++it ) { |
605 | if ( it.current()->isSelected() ) { | 605 | if ( it.current()->isSelected() ) { |
606 | QListIterator<DocLnk> dit( vFiles.children() ); | 606 | QListIterator<DocLnk> dit( vFiles.children() ); |
607 | for ( ; dit.current(); ++dit ) { | 607 | for ( ; dit.current(); ++dit ) { |
608 | if( dit.current()->name() == it.current()->text(0) ) { | 608 | if( dit.current()->name() == it.current()->text(0) ) { |
609 | if(QFileInfo( dit.current()->file()).exists()) | 609 | if(QFileInfo( dit.current()->file()).exists()) |
610 | d->selectedFiles->addToSelection( **dit ); | 610 | d->selectedFiles->addToSelection( **dit ); |
611 | } | 611 | } |
612 | } | 612 | } |
613 | videoView->setSelected( it.current(),FALSE); | 613 | videoView->setSelected( it.current(),FALSE); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | tabWidget->setCurrentPage(0); | 616 | tabWidget->setCurrentPage(0); |
617 | } | 617 | } |
618 | break; | 618 | break; |
619 | }; | 619 | }; |
620 | } | 620 | } |
621 | 621 | ||
622 | 622 | ||
623 | void PlayListWidget::removeSelected() { | 623 | void PlayListWidget::removeSelected() { |
624 | d->selectedFiles->removeSelected( ); | 624 | d->selectedFiles->removeSelected( ); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | void PlayListWidget::playIt( QListViewItem *it) { | 628 | void PlayListWidget::playIt( QListViewItem *it) { |
629 | if(!it) return; | 629 | if(!it) return; |
630 | mediaPlayerState->setPlaying(FALSE); | 630 | mediaPlayerState->setPlaying(FALSE); |
631 | mediaPlayerState->setPlaying(TRUE); | 631 | mediaPlayerState->setPlaying(TRUE); |
632 | d->selectedFiles->unSelect(); | 632 | d->selectedFiles->unSelect(); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | void PlayListWidget::addToSelection( QListViewItem *it) { | 636 | void PlayListWidget::addToSelection( QListViewItem *it) { |