author | simon <simon> | 2002-12-04 11:55:24 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-04 11:55:24 (UTC) |
commit | ba2de7d7233c0fbbd8ef31fae7aa5a9ded70225e (patch) (unidiff) | |
tree | b84f73c9df4610b4cf957031c8ca7d0ece407614 | |
parent | d75c4d9a27fcfc38ac3f9fd58f6b398809ec6a94 (diff) | |
download | opie-ba2de7d7233c0fbbd8ef31fae7aa5a9ded70225e.zip opie-ba2de7d7233c0fbbd8ef31fae7aa5a9ded70225e.tar.gz opie-ba2de7d7233c0fbbd8ef31fae7aa5a9ded70225e.tar.bz2 |
- scanForAudio and scanForVideo is scanFiles in the file list view, so
removed the former and connect to the latter
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 2 |
2 files changed, 2 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e754067..86b3424 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,292 +1,292 @@ | |||
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 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
59 | #include "videowidget.h" | 59 | #include "videowidget.h" |
60 | 60 | ||
61 | extern MediaPlayerState *mediaPlayerState; | 61 | extern MediaPlayerState *mediaPlayerState; |
62 | // extern AudioWidget *audioUI; | 62 | // extern AudioWidget *audioUI; |
63 | // extern VideoWidget *videoUI; | 63 | // extern VideoWidget *videoUI; |
64 | 64 | ||
65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { | 66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { |
67 | 67 | ||
68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
69 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
70 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
72 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
73 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
75 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
80 | 80 | ||
81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
83 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
85 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
87 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
88 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
90 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
92 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
93 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
95 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
96 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
98 | this,SLOT( scanForAudio() ) ); | 98 | audioView, SLOT( scanFiles() ) ); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
100 | this,SLOT( scanForVideo() ) ); | 100 | videoView, SLOT( scanFiles() ) ); |
101 | 101 | ||
102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
104 | 104 | ||
105 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
106 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
107 | mediaPlayerState.setFullscreen( b ); | 107 | mediaPlayerState.setFullscreen( b ); |
108 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
109 | 109 | ||
110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
113 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
116 | // QVBox *stretch2 = new QVBox( vbox1 ); | 116 | // QVBox *stretch2 = new QVBox( vbox1 ); |
117 | 117 | ||
118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
119 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
120 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
121 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
122 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
123 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
135 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
137 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
139 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
141 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
143 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
145 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
147 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 152 | ||
153 | // see which skins are installed | 153 | // see which skins are installed |
154 | populateSkinsMenu(); | 154 | populateSkinsMenu(); |
155 | initializeStates(); | 155 | initializeStates(); |
156 | 156 | ||
157 | cfg.setGroup("PlayList"); | 157 | cfg.setGroup("PlayList"); |
158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
159 | loadList(DocLnk( currentPlaylist ) ); | 159 | loadList(DocLnk( currentPlaylist ) ); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
164 | delete d; | 164 | delete d; |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void PlayListWidget::initializeStates() { | 168 | void PlayListWidget::initializeStates() { |
169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
172 | d->playListFrame->show(); | 172 | d->playListFrame->show(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void PlayListWidget::writeDefaultPlaylist() { | 175 | void PlayListWidget::writeDefaultPlaylist() { |
176 | 176 | ||
177 | Config config( "OpiePlayer" ); | 177 | Config config( "OpiePlayer" ); |
178 | config.setGroup( "PlayList" ); | 178 | config.setGroup( "PlayList" ); |
179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
181 | if( currentString == filename) { | 181 | if( currentString == filename) { |
182 | Om3u *m3uList; | 182 | Om3u *m3uList; |
183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
184 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
186 | do { | 186 | do { |
187 | // qDebug(d->selectedFiles->current()->file()); | 187 | // qDebug(d->selectedFiles->current()->file()); |
188 | m3uList->add( d->selectedFiles->current()->file() ); | 188 | m3uList->add( d->selectedFiles->current()->file() ); |
189 | } | 189 | } |
190 | while ( d->selectedFiles->next() ); | 190 | while ( d->selectedFiles->next() ); |
191 | 191 | ||
192 | m3uList->write(); | 192 | m3uList->write(); |
193 | m3uList->close(); | 193 | m3uList->close(); |
194 | if(m3uList) delete m3uList; | 194 | if(m3uList) delete m3uList; |
195 | 195 | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
201 | d->setDocumentUsed = FALSE; | 201 | d->setDocumentUsed = FALSE; |
202 | if( QFileInfo( lnk.file() ).exists() || | 202 | if( QFileInfo( lnk.file() ).exists() || |
203 | lnk.file().left(4) == "http" ) { | 203 | lnk.file().left(4) == "http" ) { |
204 | d->selectedFiles->addToSelection( lnk ); | 204 | d->selectedFiles->addToSelection( lnk ); |
205 | } | 205 | } |
206 | // writeCurrentM3u(); | 206 | // writeCurrentM3u(); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void PlayListWidget::clearList() { | 210 | void PlayListWidget::clearList() { |
211 | while ( first() ) { | 211 | while ( first() ) { |
212 | d->selectedFiles->removeSelected(); | 212 | d->selectedFiles->removeSelected(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case 1: | 218 | case 1: |
219 | break; | 219 | break; |
220 | case 2: | 220 | case 2: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case 1: | 234 | case 1: |
235 | break; | 235 | break; |
236 | case 2: | 236 | case 2: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
292 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
@@ -428,393 +428,384 @@ bool PlayListWidget::prev() { | |||
428 | if ( mediaPlayerState.isLooping() ) { | 428 | if ( mediaPlayerState.isLooping() ) { |
429 | return d->selectedFiles->last(); | 429 | return d->selectedFiles->last(); |
430 | } else { | 430 | } else { |
431 | return FALSE; | 431 | return FALSE; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return TRUE; | 434 | return TRUE; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | bool PlayListWidget::next() { | 439 | bool PlayListWidget::next() { |
440 | //qDebug("<<<<<<<<<<<<next()"); | 440 | //qDebug("<<<<<<<<<<<<next()"); |
441 | if ( mediaPlayerState.isShuffled() ) { | 441 | if ( mediaPlayerState.isShuffled() ) { |
442 | return prev(); | 442 | return prev(); |
443 | } else { | 443 | } else { |
444 | if ( !d->selectedFiles->next() ) { | 444 | if ( !d->selectedFiles->next() ) { |
445 | if ( mediaPlayerState.isLooping() ) { | 445 | if ( mediaPlayerState.isLooping() ) { |
446 | return d->selectedFiles->first(); | 446 | return d->selectedFiles->first(); |
447 | } else { | 447 | } else { |
448 | return FALSE; | 448 | return FALSE; |
449 | } | 449 | } |
450 | } | 450 | } |
451 | return TRUE; | 451 | return TRUE; |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | bool PlayListWidget::first() { | 456 | bool PlayListWidget::first() { |
457 | return d->selectedFiles->first(); | 457 | return d->selectedFiles->first(); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | bool PlayListWidget::last() { | 461 | bool PlayListWidget::last() { |
462 | return d->selectedFiles->last(); | 462 | return d->selectedFiles->last(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | void PlayListWidget::saveList() { | 466 | void PlayListWidget::saveList() { |
467 | writem3u(); | 467 | writem3u(); |
468 | } | 468 | } |
469 | 469 | ||
470 | 470 | ||
471 | void PlayListWidget::loadList( const DocLnk & lnk) { | 471 | void PlayListWidget::loadList( const DocLnk & lnk) { |
472 | QString name = lnk.name(); | 472 | QString name = lnk.name(); |
473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
474 | 474 | ||
475 | if( name.length()>0) { | 475 | if( name.length()>0) { |
476 | setCaption("OpiePlayer: "+name); | 476 | setCaption("OpiePlayer: "+name); |
477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
478 | clearList(); | 478 | clearList(); |
479 | readm3u(lnk.file()); | 479 | readm3u(lnk.file()); |
480 | tabWidget->setCurrentPage(0); | 480 | tabWidget->setCurrentPage(0); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | void PlayListWidget::addSelected() { | 484 | void PlayListWidget::addSelected() { |
485 | assert( inFileListMode() ); | 485 | assert( inFileListMode() ); |
486 | 486 | ||
487 | QListView *fileListView = currentFileListView(); | 487 | QListView *fileListView = currentFileListView(); |
488 | QListViewItemIterator it( fileListView ); | 488 | QListViewItemIterator it( fileListView ); |
489 | for ( ; it.current(); ++it ) | 489 | for ( ; it.current(); ++it ) |
490 | if ( it.current()->isSelected() ) { | 490 | if ( it.current()->isSelected() ) { |
491 | QString filename = it.current()->text(3); | 491 | QString filename = it.current()->text(3); |
492 | 492 | ||
493 | DocLnk lnk; | 493 | DocLnk lnk; |
494 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 494 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
495 | lnk.setFile( filename ); //sets file name | 495 | lnk.setFile( filename ); //sets file name |
496 | 496 | ||
497 | d->selectedFiles->addToSelection( lnk ); | 497 | d->selectedFiles->addToSelection( lnk ); |
498 | } | 498 | } |
499 | 499 | ||
500 | fileListView->clearSelection(); | 500 | fileListView->clearSelection(); |
501 | 501 | ||
502 | tabWidget->setCurrentPage( 0 ); | 502 | tabWidget->setCurrentPage( 0 ); |
503 | writeCurrentM3u(); | 503 | writeCurrentM3u(); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void PlayListWidget::removeSelected() { | 507 | void PlayListWidget::removeSelected() { |
508 | d->selectedFiles->removeSelected( ); | 508 | d->selectedFiles->removeSelected( ); |
509 | writeCurrentM3u(); | 509 | writeCurrentM3u(); |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | void PlayListWidget::playIt( QListViewItem *it) { | 513 | void PlayListWidget::playIt( QListViewItem *it) { |
514 | if(!it) return; | 514 | if(!it) return; |
515 | mediaPlayerState.setPlaying(FALSE); | 515 | mediaPlayerState.setPlaying(FALSE); |
516 | mediaPlayerState.setPlaying(TRUE); | 516 | mediaPlayerState.setPlaying(TRUE); |
517 | d->selectedFiles->unSelect(); | 517 | d->selectedFiles->unSelect(); |
518 | } | 518 | } |
519 | 519 | ||
520 | 520 | ||
521 | void PlayListWidget::addToSelection( QListViewItem *it) { | 521 | void PlayListWidget::addToSelection( QListViewItem *it) { |
522 | d->setDocumentUsed = FALSE; | 522 | d->setDocumentUsed = FALSE; |
523 | 523 | ||
524 | if(it) { | 524 | if(it) { |
525 | if ( currentTab() == CurrentPlayList ) | 525 | if ( currentTab() == CurrentPlayList ) |
526 | return; | 526 | return; |
527 | // case 1: { | 527 | // case 1: { |
528 | DocLnk lnk; | 528 | DocLnk lnk; |
529 | QString filename; | 529 | QString filename; |
530 | 530 | ||
531 | filename=it->text(3); | 531 | filename=it->text(3); |
532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
533 | lnk.setFile( filename ); //sets file name | 533 | lnk.setFile( filename ); //sets file name |
534 | d->selectedFiles->addToSelection( lnk); | 534 | d->selectedFiles->addToSelection( lnk); |
535 | 535 | ||
536 | writeCurrentM3u(); | 536 | writeCurrentM3u(); |
537 | tabWidget->setCurrentPage(0); | 537 | tabWidget->setCurrentPage(0); |
538 | 538 | ||
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void PlayListWidget::tabChanged(QWidget *) { | 543 | void PlayListWidget::tabChanged(QWidget *) { |
544 | 544 | ||
545 | d->tbPlay->setEnabled( true ); | 545 | d->tbPlay->setEnabled( true ); |
546 | 546 | ||
547 | switch ( currentTab() ) { | 547 | switch ( currentTab() ) { |
548 | case CurrentPlayList: | 548 | case CurrentPlayList: |
549 | { | 549 | { |
550 | if( !tbDeletePlaylist->isHidden() ) { | 550 | if( !tbDeletePlaylist->isHidden() ) { |
551 | tbDeletePlaylist->hide(); | 551 | tbDeletePlaylist->hide(); |
552 | } | 552 | } |
553 | d->tbRemoveFromList->setEnabled(TRUE); | 553 | d->tbRemoveFromList->setEnabled(TRUE); |
554 | d->tbAddToList->setEnabled(FALSE); | 554 | d->tbAddToList->setEnabled(FALSE); |
555 | 555 | ||
556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
557 | } | 557 | } |
558 | break; | 558 | break; |
559 | case AudioFiles: | 559 | case AudioFiles: |
560 | { | 560 | { |
561 | audioView->populateView(); | 561 | audioView->populateView(); |
562 | 562 | ||
563 | if( !tbDeletePlaylist->isHidden() ) { | 563 | if( !tbDeletePlaylist->isHidden() ) { |
564 | tbDeletePlaylist->hide(); | 564 | tbDeletePlaylist->hide(); |
565 | } | 565 | } |
566 | d->tbRemoveFromList->setEnabled(FALSE); | 566 | d->tbRemoveFromList->setEnabled(FALSE); |
567 | d->tbAddToList->setEnabled(TRUE); | 567 | d->tbAddToList->setEnabled(TRUE); |
568 | } | 568 | } |
569 | break; | 569 | break; |
570 | case VideoFiles: | 570 | case VideoFiles: |
571 | { | 571 | { |
572 | videoView->populateView(); | 572 | videoView->populateView(); |
573 | if( !tbDeletePlaylist->isHidden() ) { | 573 | if( !tbDeletePlaylist->isHidden() ) { |
574 | tbDeletePlaylist->hide(); | 574 | tbDeletePlaylist->hide(); |
575 | } | 575 | } |
576 | d->tbRemoveFromList->setEnabled(FALSE); | 576 | d->tbRemoveFromList->setEnabled(FALSE); |
577 | d->tbAddToList->setEnabled(TRUE); | 577 | d->tbAddToList->setEnabled(TRUE); |
578 | } | 578 | } |
579 | break; | 579 | break; |
580 | case PlayLists: | 580 | case PlayLists: |
581 | { | 581 | { |
582 | if( tbDeletePlaylist->isHidden() ) { | 582 | if( tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->show(); | 583 | tbDeletePlaylist->show(); |
584 | } | 584 | } |
585 | playLists->reread(); | 585 | playLists->reread(); |
586 | d->tbAddToList->setEnabled(FALSE); | 586 | d->tbAddToList->setEnabled(FALSE); |
587 | 587 | ||
588 | d->tbPlay->setEnabled( false ); | 588 | d->tbPlay->setEnabled( false ); |
589 | } | 589 | } |
590 | break; | 590 | break; |
591 | }; | 591 | }; |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void PlayListWidget::btnPlay(bool b) { | 595 | void PlayListWidget::btnPlay(bool b) { |
596 | // mediaPlayerState->setPlaying(false); | 596 | // mediaPlayerState->setPlaying(false); |
597 | mediaPlayerState.setPlaying(b); | 597 | mediaPlayerState.setPlaying(b); |
598 | insanityBool=FALSE; | 598 | insanityBool=FALSE; |
599 | } | 599 | } |
600 | 600 | ||
601 | void PlayListWidget::deletePlaylist() { | 601 | void PlayListWidget::deletePlaylist() { |
602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
603 | (tr("You really want to delete\nthis playlist?")), | 603 | (tr("You really want to delete\nthis playlist?")), |
604 | (tr("Yes")), (tr("No")), 0 )){ | 604 | (tr("Yes")), (tr("No")), 0 )){ |
605 | case 0: // Yes clicked, | 605 | case 0: // Yes clicked, |
606 | QFile().remove(playLists->selectedDocument().file()); | 606 | QFile().remove(playLists->selectedDocument().file()); |
607 | QFile().remove(playLists->selectedDocument().linkFile()); | 607 | QFile().remove(playLists->selectedDocument().linkFile()); |
608 | playLists->reread(); | 608 | playLists->reread(); |
609 | break; | 609 | break; |
610 | case 1: // Cancel | 610 | case 1: // Cancel |
611 | break; | 611 | break; |
612 | }; | 612 | }; |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | void PlayListWidget::playSelected() { | 616 | void PlayListWidget::playSelected() { |
617 | btnPlay( TRUE); | 617 | btnPlay( TRUE); |
618 | } | 618 | } |
619 | 619 | ||
620 | |||
621 | void PlayListWidget::scanForAudio() { | ||
622 | audioView->scanFiles(); | ||
623 | } | ||
624 | |||
625 | void PlayListWidget::scanForVideo() { | ||
626 | videoView->scanFiles(); | ||
627 | } | ||
628 | |||
629 | QListView *PlayListWidget::currentFileListView() const | 620 | QListView *PlayListWidget::currentFileListView() const |
630 | { | 621 | { |
631 | switch ( currentTab() ) { | 622 | switch ( currentTab() ) { |
632 | case AudioFiles: return audioView; | 623 | case AudioFiles: return audioView; |
633 | case VideoFiles: return videoView; | 624 | case VideoFiles: return videoView; |
634 | default: assert( false ); | 625 | default: assert( false ); |
635 | } | 626 | } |
636 | return 0; | 627 | return 0; |
637 | } | 628 | } |
638 | 629 | ||
639 | bool PlayListWidget::inFileListMode() const | 630 | bool PlayListWidget::inFileListMode() const |
640 | { | 631 | { |
641 | TabType tab = currentTab(); | 632 | TabType tab = currentTab(); |
642 | return tab == AudioFiles || tab == VideoFiles; | 633 | return tab == AudioFiles || tab == VideoFiles; |
643 | } | 634 | } |
644 | 635 | ||
645 | void PlayListWidget::openFile() { | 636 | void PlayListWidget::openFile() { |
646 | // http://66.28.164.33:2080 | 637 | // http://66.28.164.33:2080 |
647 | // http://somafm.com/star0242.m3u | 638 | // http://somafm.com/star0242.m3u |
648 | QString filename, name; | 639 | QString filename, name; |
649 | InputDialog *fileDlg; | 640 | InputDialog *fileDlg; |
650 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
651 | fileDlg->exec(); | 642 | fileDlg->exec(); |
652 | if( fileDlg->result() == 1 ) { | 643 | if( fileDlg->result() == 1 ) { |
653 | filename = fileDlg->text(); | 644 | filename = fileDlg->text(); |
654 | qDebug( "Selected filename is " + filename ); | 645 | qDebug( "Selected filename is " + filename ); |
655 | // Om3u *m3uList; | 646 | // Om3u *m3uList; |
656 | DocLnk lnk; | 647 | DocLnk lnk; |
657 | Config cfg( "OpiePlayer" ); | 648 | Config cfg( "OpiePlayer" ); |
658 | cfg.setGroup("PlayList"); | 649 | cfg.setGroup("PlayList"); |
659 | 650 | ||
660 | if(filename.left(4) == "http") { | 651 | if(filename.left(4) == "http") { |
661 | QString m3uFile, m3uFilePath; | 652 | QString m3uFile, m3uFilePath; |
662 | if(filename.find(":",8,TRUE) != -1) { //found a port | 653 | if(filename.find(":",8,TRUE) != -1) { //found a port |
663 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
664 | m3uFile = m3uFile.right( 7); | 655 | m3uFile = m3uFile.right( 7); |
665 | } else if(filename.left(4) == "http"){ | 656 | } else if(filename.left(4) == "http"){ |
666 | m3uFile=filename; | 657 | m3uFile=filename; |
667 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 658 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
668 | } else{ | 659 | } else{ |
669 | m3uFile=filename; | 660 | m3uFile=filename; |
670 | } | 661 | } |
671 | 662 | ||
672 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
673 | lnk.setName( filename ); //sets name | 664 | lnk.setName( filename ); //sets name |
674 | lnk.setFile( filename ); //sets file name | 665 | lnk.setFile( filename ); //sets file name |
675 | 666 | ||
676 | // lnk.setIcon("opieplayer2/musicfile"); | 667 | // lnk.setIcon("opieplayer2/musicfile"); |
677 | 668 | ||
678 | d->selectedFiles->addToSelection( lnk ); | 669 | d->selectedFiles->addToSelection( lnk ); |
679 | writeCurrentM3u(); | 670 | writeCurrentM3u(); |
680 | d->selectedFiles->setSelectedItem( lnk.name()); | 671 | d->selectedFiles->setSelectedItem( lnk.name()); |
681 | } | 672 | } |
682 | else if( filename.right( 3) == "m3u" ) { | 673 | else if( filename.right( 3) == "m3u" ) { |
683 | readm3u( filename ); | 674 | readm3u( filename ); |
684 | 675 | ||
685 | } else if( filename.right(3) == "pls" ) { | 676 | } else if( filename.right(3) == "pls" ) { |
686 | readPls( filename ); | 677 | readPls( filename ); |
687 | } else { | 678 | } else { |
688 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
689 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
690 | d->selectedFiles->addToSelection( lnk); | 681 | d->selectedFiles->addToSelection( lnk); |
691 | writeCurrentM3u(); | 682 | writeCurrentM3u(); |
692 | d->selectedFiles->setSelectedItem( lnk.name()); | 683 | d->selectedFiles->setSelectedItem( lnk.name()); |
693 | } | 684 | } |
694 | } | 685 | } |
695 | 686 | ||
696 | if( fileDlg ) { | 687 | if( fileDlg ) { |
697 | delete fileDlg; | 688 | delete fileDlg; |
698 | } | 689 | } |
699 | } | 690 | } |
700 | 691 | ||
701 | /* | 692 | /* |
702 | reads m3u and shows files/urls to playlist widget */ | 693 | reads m3u and shows files/urls to playlist widget */ |
703 | void PlayListWidget::readm3u( const QString &filename ) { | 694 | void PlayListWidget::readm3u( const QString &filename ) { |
704 | qDebug( "read m3u filename " + filename ); | 695 | qDebug( "read m3u filename " + filename ); |
705 | 696 | ||
706 | Om3u *m3uList; | 697 | Om3u *m3uList; |
707 | QString s, name; | 698 | QString s, name; |
708 | m3uList = new Om3u( filename, IO_ReadOnly ); | 699 | m3uList = new Om3u( filename, IO_ReadOnly ); |
709 | m3uList->readM3u(); | 700 | m3uList->readM3u(); |
710 | DocLnk lnk; | 701 | DocLnk lnk; |
711 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 702 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
712 | s = *it; | 703 | s = *it; |
713 | // qDebug("reading "+ s); | 704 | // qDebug("reading "+ s); |
714 | if(s.left(4)=="http") { | 705 | if(s.left(4)=="http") { |
715 | lnk.setName( s ); //sets file name | 706 | lnk.setName( s ); //sets file name |
716 | lnk.setIcon("opieplayer2/musicfile"); | 707 | lnk.setIcon("opieplayer2/musicfile"); |
717 | lnk.setFile( s ); //sets file name | 708 | lnk.setFile( s ); //sets file name |
718 | 709 | ||
719 | } else { | 710 | } else { |
720 | // if( QFileInfo( s ).exists() ) { | 711 | // if( QFileInfo( s ).exists() ) { |
721 | lnk.setName( QFileInfo(s).baseName()); | 712 | lnk.setName( QFileInfo(s).baseName()); |
722 | // if(s.right(4) == '.') {//if regular file | 713 | // if(s.right(4) == '.') {//if regular file |
723 | if(s.left(1) != "/") { | 714 | if(s.left(1) != "/") { |
724 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 715 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
725 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 716 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
726 | // lnk.setIcon(MimeType(s).pixmap() ); | 717 | // lnk.setIcon(MimeType(s).pixmap() ); |
727 | // lnk.setIcon("SoundPlayer"); | 718 | // lnk.setIcon("SoundPlayer"); |
728 | } else { | 719 | } else { |
729 | // qDebug("set link2 "+s); | 720 | // qDebug("set link2 "+s); |
730 | lnk.setFile( s); | 721 | lnk.setFile( s); |
731 | // lnk.setIcon(MimeType(s).pixmap() ); | 722 | // lnk.setIcon(MimeType(s).pixmap() ); |
732 | // lnk.setIcon("SoundPlayer"); | 723 | // lnk.setIcon("SoundPlayer"); |
733 | } | 724 | } |
734 | } | 725 | } |
735 | d->selectedFiles->addToSelection( lnk ); | 726 | d->selectedFiles->addToSelection( lnk ); |
736 | } | 727 | } |
737 | Config config( "OpiePlayer" ); | 728 | Config config( "OpiePlayer" ); |
738 | config.setGroup( "PlayList" ); | 729 | config.setGroup( "PlayList" ); |
739 | 730 | ||
740 | config.writeEntry("CurrentPlaylist",filename); | 731 | config.writeEntry("CurrentPlaylist",filename); |
741 | config.write(); | 732 | config.write(); |
742 | currentPlayList=filename; | 733 | currentPlayList=filename; |
743 | 734 | ||
744 | // m3uList->write(); | 735 | // m3uList->write(); |
745 | m3uList->close(); | 736 | m3uList->close(); |
746 | if(m3uList) delete m3uList; | 737 | if(m3uList) delete m3uList; |
747 | 738 | ||
748 | d->selectedFiles->setSelectedItem( s); | 739 | d->selectedFiles->setSelectedItem( s); |
749 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 740 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
750 | 741 | ||
751 | } | 742 | } |
752 | 743 | ||
753 | /* | 744 | /* |
754 | reads pls and adds files/urls to playlist */ | 745 | reads pls and adds files/urls to playlist */ |
755 | void PlayListWidget::readPls( const QString &filename ) { | 746 | void PlayListWidget::readPls( const QString &filename ) { |
756 | 747 | ||
757 | qDebug( "pls filename is " + filename ); | 748 | qDebug( "pls filename is " + filename ); |
758 | Om3u *m3uList; | 749 | Om3u *m3uList; |
759 | QString s, name; | 750 | QString s, name; |
760 | m3uList = new Om3u( filename, IO_ReadOnly ); | 751 | m3uList = new Om3u( filename, IO_ReadOnly ); |
761 | m3uList->readPls(); | 752 | m3uList->readPls(); |
762 | 753 | ||
763 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 754 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
764 | s = *it; | 755 | s = *it; |
765 | // s.replace( QRegExp( "%20" )," " ); | 756 | // s.replace( QRegExp( "%20" )," " ); |
766 | DocLnk lnk( s ); | 757 | DocLnk lnk( s ); |
767 | QFileInfo f( s ); | 758 | QFileInfo f( s ); |
768 | QString name = f.baseName(); | 759 | QString name = f.baseName(); |
769 | 760 | ||
770 | if( name.left( 4 ) == "http" ) { | 761 | if( name.left( 4 ) == "http" ) { |
771 | name = s.right( s.length() - 7); | 762 | name = s.right( s.length() - 7); |
772 | } else { | 763 | } else { |
773 | name = s; | 764 | name = s; |
774 | } | 765 | } |
775 | 766 | ||
776 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 767 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
777 | 768 | ||
778 | lnk.setName( name ); | 769 | lnk.setName( name ); |
779 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 770 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
780 | lnk.setFile( s ); | 771 | lnk.setFile( s ); |
781 | } else { //if its a url | 772 | } else { //if its a url |
782 | // if( name.right( 1 ).find( '/' ) == -1) { | 773 | // if( name.right( 1 ).find( '/' ) == -1) { |
783 | // s += "/"; | 774 | // s += "/"; |
784 | // } | 775 | // } |
785 | lnk.setFile( s ); | 776 | lnk.setFile( s ); |
786 | } | 777 | } |
787 | lnk.setType( "audio/x-mpegurl" ); | 778 | lnk.setType( "audio/x-mpegurl" ); |
788 | 779 | ||
789 | lnk.writeLink(); | 780 | lnk.writeLink(); |
790 | d->selectedFiles->addToSelection( lnk ); | 781 | d->selectedFiles->addToSelection( lnk ); |
791 | } | 782 | } |
792 | 783 | ||
793 | m3uList->close(); | 784 | m3uList->close(); |
794 | if(m3uList) delete m3uList; | 785 | if(m3uList) delete m3uList; |
795 | } | 786 | } |
796 | 787 | ||
797 | /* | 788 | /* |
798 | writes current playlist to current m3u file */ | 789 | writes current playlist to current m3u file */ |
799 | void PlayListWidget::writeCurrentM3u() { | 790 | void PlayListWidget::writeCurrentM3u() { |
800 | qDebug("writing to current m3u"); | 791 | qDebug("writing to current m3u"); |
801 | Config cfg( "OpiePlayer" ); | 792 | Config cfg( "OpiePlayer" ); |
802 | cfg.setGroup("PlayList"); | 793 | cfg.setGroup("PlayList"); |
803 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 794 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
804 | 795 | ||
805 | Om3u *m3uList; | 796 | Om3u *m3uList; |
806 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 797 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
807 | if( d->selectedFiles->first()) { | 798 | if( d->selectedFiles->first()) { |
808 | 799 | ||
809 | do { | 800 | do { |
810 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 801 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
811 | m3uList->add( d->selectedFiles->current()->file() ); | 802 | m3uList->add( d->selectedFiles->current()->file() ); |
812 | } | 803 | } |
813 | while ( d->selectedFiles->next() ); | 804 | while ( d->selectedFiles->next() ); |
814 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 805 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
815 | m3uList->write(); | 806 | m3uList->write(); |
816 | m3uList->close(); | 807 | m3uList->close(); |
817 | 808 | ||
818 | if(m3uList) delete m3uList; | 809 | if(m3uList) delete m3uList; |
819 | } | 810 | } |
820 | 811 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 8c22f17..5c8f30c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,141 +1,139 @@ | |||
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; | 101 | QListView *currentFileListView() const; |
102 | 102 | ||
103 | bool inFileListMode() const; | 103 | bool inFileListMode() const; |
104 | 104 | ||
105 | private slots: | 105 | private slots: |
106 | void populateSkinsMenu(); | 106 | void populateSkinsMenu(); |
107 | void skinsMenuActivated(int); | 107 | void skinsMenuActivated(int); |
108 | void pmViewActivated(int); | 108 | void pmViewActivated(int); |
109 | void writem3u(); | 109 | void writem3u(); |
110 | void writeCurrentM3u(); | 110 | void writeCurrentM3u(); |
111 | void scanForAudio(); | ||
112 | void scanForVideo(); | ||
113 | void openFile(); | 111 | void openFile(); |
114 | void setDocument( const QString& fileref ); | 112 | void setDocument( const QString& fileref ); |
115 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 113 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
116 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 114 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
117 | void clearList(); | 115 | void clearList(); |
118 | void addAllToList(); | 116 | void addAllToList(); |
119 | void addAllMusicToList(); | 117 | void addAllMusicToList(); |
120 | void addAllVideoToList(); | 118 | void addAllVideoToList(); |
121 | void saveList(); // Save the playlist | 119 | void saveList(); // Save the playlist |
122 | void loadList( const DocLnk &); // Load a playlist | 120 | void loadList( const DocLnk &); // Load a playlist |
123 | void playIt( QListViewItem *); | 121 | void playIt( QListViewItem *); |
124 | void btnPlay(bool); | 122 | void btnPlay(bool); |
125 | void deletePlaylist(); | 123 | void deletePlaylist(); |
126 | void addSelected(); | 124 | void addSelected(); |
127 | void removeSelected(); | 125 | void removeSelected(); |
128 | void tabChanged(QWidget*); | 126 | void tabChanged(QWidget*); |
129 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 127 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 128 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
131 | void playSelected(); | 129 | void playSelected(); |
132 | 130 | ||
133 | private: | 131 | private: |
134 | bool fromSetDocument; | 132 | bool fromSetDocument; |
135 | bool insanityBool; | 133 | bool insanityBool; |
136 | QString setDocFileRef, currentPlayList; | 134 | QString setDocFileRef, currentPlayList; |
137 | int selected; | 135 | int selected; |
138 | }; | 136 | }; |
139 | 137 | ||
140 | #endif // PLAY_LIST_WIDGET_H | 138 | #endif // PLAY_LIST_WIDGET_H |
141 | 139 | ||