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