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