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