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