author | simon <simon> | 2002-12-09 09:50:33 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 09:50:33 (UTC) |
commit | 94a4c102d20eb63104a66fd8fba141a716ae3623 (patch) (unidiff) | |
tree | d54c220fc94d8d7e7b84c7e6ed07bfb13cab5dcc | |
parent | 7ccd9b65ab621dbf8bf79c053141af81fb39ca4b (diff) | |
download | opie-94a4c102d20eb63104a66fd8fba141a716ae3623.zip opie-94a4c102d20eb63104a66fd8fba141a716ae3623.tar.gz opie-94a4c102d20eb63104a66fd8fba141a716ae3623.tar.bz2 |
switch (mouse) {
- case 1:
+ case LeftButton:
break;
- case 2:
+ case RightButton:
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 889667c..27a3286 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -20,403 +20,403 @@ | |||
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 ) , currentFileListView( 0 ) | 59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
60 | { | 60 | { |
61 | 61 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
69 | this , SLOT( btnPlay( bool) ), TRUE ); | 69 | this , SLOT( btnPlay( bool) ), TRUE ); |
70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
74 | 74 | ||
75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
77 | this, SLOT( addAllMusicToList() ) ); | 77 | this, SLOT( addAllMusicToList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
79 | this, SLOT( addAllVideoToList() ) ); | 79 | this, SLOT( addAllVideoToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
81 | this, SLOT( addAllToList() ) ); | 81 | this, SLOT( addAllToList() ) ); |
82 | pmPlayList->insertSeparator(-1); | 82 | pmPlayList->insertSeparator(-1); |
83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
84 | // this, SLOT( saveList() ) ); | 84 | // this, SLOT( saveList() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
89 | this,SLOT( openFile() ) ); | 89 | this,SLOT( openFile() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 92 | audioView, SLOT( scanFiles() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
94 | videoView, SLOT( scanFiles() ) ); | 94 | videoView, SLOT( scanFiles() ) ); |
95 | 95 | ||
96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
98 | 98 | ||
99 | Config cfg( "OpiePlayer" ); | 99 | Config cfg( "OpiePlayer" ); |
100 | bool b= cfg.readBoolEntry("FullScreen", 0); | 100 | bool b= cfg.readBoolEntry("FullScreen", 0); |
101 | mediaPlayerState.setFullscreen( b ); | 101 | mediaPlayerState.setFullscreen( b ); |
102 | pmView->setItemChecked( -16, b ); | 102 | pmView->setItemChecked( -16, b ); |
103 | 103 | ||
104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
107 | d->selectedFiles, SLOT(removeSelected() ) ); | 107 | d->selectedFiles, SLOT(removeSelected() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
110 | // QVBox *stretch2 = new QVBox( vbox1 ); | 110 | // QVBox *stretch2 = new QVBox( vbox1 ); |
111 | 111 | ||
112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
113 | SLOT( deletePlaylist() ) ); | 113 | SLOT( deletePlaylist() ) ); |
114 | connect( pmView, SIGNAL( activated( int ) ), | 114 | connect( pmView, SIGNAL( activated( int ) ), |
115 | this, SLOT( pmViewActivated( int ) ) ); | 115 | this, SLOT( pmViewActivated( int ) ) ); |
116 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 116 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
117 | this, SLOT( skinsMenuActivated( int ) ) ); | 117 | this, SLOT( skinsMenuActivated( int ) ) ); |
118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
123 | this,SLOT( playIt( QListViewItem *) ) ); | 123 | this,SLOT( playIt( QListViewItem *) ) ); |
124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
125 | this, SLOT( addToSelection( QListViewItem *) ) ); | 125 | this, SLOT( addToSelection( QListViewItem *) ) ); |
126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( videoView, 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( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
133 | this, SLOT( loadList( const DocLnk & ) ) ); | 133 | this, SLOT( loadList( const DocLnk & ) ) ); |
134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
135 | this, SLOT( tabChanged( QWidget* ) ) ); | 135 | this, SLOT( tabChanged( QWidget* ) ) ); |
136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
137 | d->tbPlay, SLOT( setOn( bool ) ) ); | 137 | d->tbPlay, SLOT( setOn( bool ) ) ); |
138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
139 | d->tbLoop, SLOT( setOn( bool ) ) ); | 139 | d->tbLoop, SLOT( setOn( bool ) ) ); |
140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
141 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 141 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
143 | this, SLOT( playIt( QListViewItem *) ) ); | 143 | this, SLOT( playIt( QListViewItem *) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
146 | 146 | ||
147 | // see which skins are installed | 147 | // see which skins are installed |
148 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
149 | initializeStates(); | 149 | initializeStates(); |
150 | 150 | ||
151 | cfg.setGroup("PlayList"); | 151 | cfg.setGroup("PlayList"); |
152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
153 | loadList(DocLnk( currentPlaylist ) ); | 153 | loadList(DocLnk( currentPlaylist ) ); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | PlayListWidget::~PlayListWidget() { | 157 | PlayListWidget::~PlayListWidget() { |
158 | delete d; | 158 | delete d; |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void PlayListWidget::initializeStates() { | 162 | void PlayListWidget::initializeStates() { |
163 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 163 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
164 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 164 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
165 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 165 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
166 | d->playListFrame->show(); | 166 | d->playListFrame->show(); |
167 | } | 167 | } |
168 | 168 | ||
169 | void PlayListWidget::writeDefaultPlaylist() { | 169 | void PlayListWidget::writeDefaultPlaylist() { |
170 | 170 | ||
171 | Config config( "OpiePlayer" ); | 171 | Config config( "OpiePlayer" ); |
172 | config.setGroup( "PlayList" ); | 172 | config.setGroup( "PlayList" ); |
173 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 173 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
174 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 174 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
175 | if( currentString == filename) { | 175 | if( currentString == filename) { |
176 | Om3u *m3uList; | 176 | Om3u *m3uList; |
177 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 177 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
178 | if( d->selectedFiles->first() ) { | 178 | if( d->selectedFiles->first() ) { |
179 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 179 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
180 | do { | 180 | do { |
181 | // qDebug(d->selectedFiles->current()->file()); | 181 | // qDebug(d->selectedFiles->current()->file()); |
182 | m3uList->add( d->selectedFiles->current()->file() ); | 182 | m3uList->add( d->selectedFiles->current()->file() ); |
183 | } | 183 | } |
184 | while ( d->selectedFiles->next() ); | 184 | while ( d->selectedFiles->next() ); |
185 | 185 | ||
186 | m3uList->write(); | 186 | m3uList->write(); |
187 | m3uList->close(); | 187 | m3uList->close(); |
188 | delete m3uList; | 188 | delete m3uList; |
189 | 189 | ||
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 194 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
195 | d->setDocumentUsed = FALSE; | 195 | d->setDocumentUsed = FALSE; |
196 | if( QFileInfo( lnk.file() ).exists() || | 196 | if( QFileInfo( lnk.file() ).exists() || |
197 | lnk.file().left(4) == "http" ) { | 197 | lnk.file().left(4) == "http" ) { |
198 | d->selectedFiles->addToSelection( lnk ); | 198 | d->selectedFiles->addToSelection( lnk ); |
199 | } | 199 | } |
200 | // writeCurrentM3u(); | 200 | // writeCurrentM3u(); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void PlayListWidget::clearList() { | 204 | void PlayListWidget::clearList() { |
205 | while ( first() ) { | 205 | while ( first() ) { |
206 | d->selectedFiles->removeSelected(); | 206 | d->selectedFiles->removeSelected(); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 210 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
211 | switch (mouse) { | 211 | switch (mouse) { |
212 | case 1: | 212 | case LeftButton: |
213 | break; | 213 | break; |
214 | case 2: | 214 | case RightButton: |
215 | { | 215 | { |
216 | QPopupMenu m; | 216 | QPopupMenu m; |
217 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 217 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
218 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 218 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
219 | m.exec( QCursor::pos() ); | 219 | m.exec( QCursor::pos() ); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 226 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
227 | switch (mouse) { | 227 | switch (mouse) { |
228 | case 1: | 228 | case LeftButton: |
229 | break; | 229 | break; |
230 | case 2: | 230 | case RightButton: |
231 | { | 231 | { |
232 | QPopupMenu m; | 232 | QPopupMenu m; |
233 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 233 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
234 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 234 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
235 | m.exec( QCursor::pos() ); | 235 | m.exec( QCursor::pos() ); |
236 | } | 236 | } |
237 | break; | 237 | break; |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void PlayListWidget::addAllToList() { | 242 | void PlayListWidget::addAllToList() { |
243 | 243 | ||
244 | // QTime t; | 244 | // QTime t; |
245 | // t.start(); | 245 | // t.start(); |
246 | 246 | ||
247 | audioView->populateView(); | 247 | audioView->populateView(); |
248 | 248 | ||
249 | QListViewItemIterator audioIt( audioView ); | 249 | QListViewItemIterator audioIt( audioView ); |
250 | DocLnk lnk; | 250 | DocLnk lnk; |
251 | QString filename; | 251 | QString filename; |
252 | // iterate through all items of the listview | 252 | // iterate through all items of the listview |
253 | for ( ; audioIt.current(); ++audioIt ) { | 253 | for ( ; audioIt.current(); ++audioIt ) { |
254 | filename = audioIt.current()->text(3); | 254 | filename = audioIt.current()->text(3); |
255 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 255 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
256 | lnk.setFile( filename ); //sets file name | 256 | lnk.setFile( filename ); //sets file name |
257 | d->selectedFiles->addToSelection( lnk); | 257 | d->selectedFiles->addToSelection( lnk); |
258 | } | 258 | } |
259 | 259 | ||
260 | videoView->populateView(); | 260 | videoView->populateView(); |
261 | 261 | ||
262 | QListViewItemIterator videoIt( videoView ); | 262 | QListViewItemIterator videoIt( videoView ); |
263 | for ( ; videoIt.current(); ++videoIt ) { | 263 | for ( ; videoIt.current(); ++videoIt ) { |
264 | filename = videoIt.current()->text(3); | 264 | filename = videoIt.current()->text(3); |
265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
266 | lnk.setFile( filename ); //sets file name | 266 | lnk.setFile( filename ); //sets file name |
267 | d->selectedFiles->addToSelection( lnk); | 267 | d->selectedFiles->addToSelection( lnk); |
268 | } | 268 | } |
269 | 269 | ||
270 | // d->selectedFiles->addToSelection( ); | 270 | // d->selectedFiles->addToSelection( ); |
271 | // if ( it.current()->isSelected() ) | 271 | // if ( it.current()->isSelected() ) |
272 | // lst->append( audioIt.current() ); | 272 | // lst->append( audioIt.current() ); |
273 | // } | 273 | // } |
274 | 274 | ||
275 | 275 | ||
276 | // if(!audioScan) | 276 | // if(!audioScan) |
277 | // scanForAudio(); | 277 | // scanForAudio(); |
278 | // if(!videoScan) | 278 | // if(!videoScan) |
279 | // scanForVideo(); | 279 | // scanForVideo(); |
280 | 280 | ||
281 | // DocLnkSet filesAll; | 281 | // DocLnkSet filesAll; |
282 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 282 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
283 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 283 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
284 | // for ( ; Adit.current(); ++Adit ) { | 284 | // for ( ; Adit.current(); ++Adit ) { |
285 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 285 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
286 | // d->selectedFiles->addToSelection( **Adit ); | 286 | // d->selectedFiles->addToSelection( **Adit ); |
287 | // } | 287 | // } |
288 | // } | 288 | // } |
289 | 289 | ||
290 | // qDebug("elapsed time %d", t.elapsed() ); | 290 | // qDebug("elapsed time %d", t.elapsed() ); |
291 | 291 | ||
292 | tabWidget->setCurrentPage(0); | 292 | tabWidget->setCurrentPage(0); |
293 | 293 | ||
294 | writeCurrentM3u(); | 294 | writeCurrentM3u(); |
295 | d->selectedFiles->first(); | 295 | d->selectedFiles->first(); |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void PlayListWidget::addAllMusicToList() { | 299 | void PlayListWidget::addAllMusicToList() { |
300 | 300 | ||
301 | audioView->populateView(); | 301 | audioView->populateView(); |
302 | 302 | ||
303 | QListViewItemIterator audioIt( audioView ); | 303 | QListViewItemIterator audioIt( audioView ); |
304 | DocLnk lnk; | 304 | DocLnk lnk; |
305 | QString filename; | 305 | QString filename; |
306 | // iterate through all items of the listview | 306 | // iterate through all items of the listview |
307 | for ( ; audioIt.current(); ++audioIt ) { | 307 | for ( ; audioIt.current(); ++audioIt ) { |
308 | filename = audioIt.current()->text(3); | 308 | filename = audioIt.current()->text(3); |
309 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 309 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
310 | lnk.setFile( filename ); //sets file name | 310 | lnk.setFile( filename ); //sets file name |
311 | d->selectedFiles->addToSelection( lnk); | 311 | d->selectedFiles->addToSelection( lnk); |
312 | } | 312 | } |
313 | 313 | ||
314 | /* if(!audioScan) | 314 | /* if(!audioScan) |
315 | scanForAudio(); | 315 | scanForAudio(); |
316 | QListIterator<DocLnk> dit( files.children() ); | 316 | QListIterator<DocLnk> dit( files.children() ); |
317 | for ( ; dit.current(); ++dit ) { | 317 | for ( ; dit.current(); ++dit ) { |
318 | if( QFileInfo(dit.current()->file() ).exists() ) { | 318 | if( QFileInfo(dit.current()->file() ).exists() ) { |
319 | d->selectedFiles->addToSelection( **dit ); | 319 | d->selectedFiles->addToSelection( **dit ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | */ | 322 | */ |
323 | tabWidget->setCurrentPage(0); | 323 | tabWidget->setCurrentPage(0); |
324 | writeCurrentM3u(); | 324 | writeCurrentM3u(); |
325 | d->selectedFiles->first(); | 325 | d->selectedFiles->first(); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void PlayListWidget::addAllVideoToList() { | 329 | void PlayListWidget::addAllVideoToList() { |
330 | 330 | ||
331 | videoView->populateView(); | 331 | videoView->populateView(); |
332 | 332 | ||
333 | QListViewItemIterator videoIt( videoView ); | 333 | QListViewItemIterator videoIt( videoView ); |
334 | DocLnk lnk; | 334 | DocLnk lnk; |
335 | QString filename; | 335 | QString filename; |
336 | for ( ; videoIt.current(); ++videoIt ) { | 336 | for ( ; videoIt.current(); ++videoIt ) { |
337 | filename = videoIt.current()->text(3); | 337 | filename = videoIt.current()->text(3); |
338 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 338 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
339 | lnk.setFile( filename ); //sets file name | 339 | lnk.setFile( filename ); //sets file name |
340 | d->selectedFiles->addToSelection( lnk); | 340 | d->selectedFiles->addToSelection( lnk); |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | /* if(!videoScan) | 344 | /* if(!videoScan) |
345 | scanForVideo(); | 345 | scanForVideo(); |
346 | QListIterator<DocLnk> dit( vFiles.children() ); | 346 | QListIterator<DocLnk> dit( vFiles.children() ); |
347 | for ( ; dit.current(); ++dit ) { | 347 | for ( ; dit.current(); ++dit ) { |
348 | if( QFileInfo( dit.current()->file() ).exists() ) { | 348 | if( QFileInfo( dit.current()->file() ).exists() ) { |
349 | d->selectedFiles->addToSelection( **dit ); | 349 | d->selectedFiles->addToSelection( **dit ); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | */ | 352 | */ |
353 | tabWidget->setCurrentPage(0); | 353 | tabWidget->setCurrentPage(0); |
354 | writeCurrentM3u(); | 354 | writeCurrentM3u(); |
355 | d->selectedFiles->first(); | 355 | d->selectedFiles->first(); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void PlayListWidget::setDocument( const QString& fileref ) { | 359 | void PlayListWidget::setDocument( const QString& fileref ) { |
360 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 360 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
361 | fromSetDocument = TRUE; | 361 | fromSetDocument = TRUE; |
362 | if ( fileref.isNull() ) { | 362 | if ( fileref.isNull() ) { |
363 | QMessageBox::warning( this, tr( "Invalid File" ), | 363 | QMessageBox::warning( this, tr( "Invalid File" ), |
364 | tr( "There was a problem in getting the file." ) ); | 364 | tr( "There was a problem in getting the file." ) ); |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | 367 | ||
368 | clearList(); | 368 | clearList(); |
369 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 369 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
370 | readm3u( fileref ); | 370 | readm3u( fileref ); |
371 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 371 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
372 | readm3u( DocLnk( fileref).file() ); | 372 | readm3u( DocLnk( fileref).file() ); |
373 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 373 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
374 | readPls( fileref ); | 374 | readPls( fileref ); |
375 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 375 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
376 | readPls( DocLnk( fileref).file() ); | 376 | readPls( DocLnk( fileref).file() ); |
377 | } else { | 377 | } else { |
378 | clearList(); | 378 | clearList(); |
379 | addToSelection( DocLnk( fileref ) ); | 379 | addToSelection( DocLnk( fileref ) ); |
380 | writeCurrentM3u(); | 380 | writeCurrentM3u(); |
381 | 381 | ||
382 | d->setDocumentUsed = TRUE; | 382 | d->setDocumentUsed = TRUE; |
383 | mediaPlayerState.setPlaying( FALSE ); | 383 | mediaPlayerState.setPlaying( FALSE ); |
384 | mediaPlayerState.setPlaying( TRUE ); | 384 | mediaPlayerState.setPlaying( TRUE ); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::useSelectedDocument() { | 389 | void PlayListWidget::useSelectedDocument() { |
390 | d->setDocumentUsed = FALSE; | 390 | d->setDocumentUsed = FALSE; |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | const DocLnk *PlayListWidget::current() const { // this is fugly | 394 | const DocLnk *PlayListWidget::current() const { // this is fugly |
395 | assert( currentTab() == CurrentPlayList ); | 395 | assert( currentTab() == CurrentPlayList ); |
396 | 396 | ||
397 | const DocLnk *lnk = d->selectedFiles->current(); | 397 | const DocLnk *lnk = d->selectedFiles->current(); |
398 | if ( !lnk ) { | 398 | if ( !lnk ) { |
399 | d->selectedFiles->first(); | 399 | d->selectedFiles->first(); |
400 | lnk = d->selectedFiles->current(); | 400 | lnk = d->selectedFiles->current(); |
401 | } | 401 | } |
402 | assert( lnk ); | 402 | assert( lnk ); |
403 | return lnk; | 403 | return lnk; |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | bool PlayListWidget::prev() { | 407 | bool PlayListWidget::prev() { |
408 | if ( mediaPlayerState.isShuffled() ) { | 408 | if ( mediaPlayerState.isShuffled() ) { |
409 | const DocLnk *cur = current(); | 409 | const DocLnk *cur = current(); |
410 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 410 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
411 | for ( int i = 0; i < j; i++ ) { | 411 | for ( int i = 0; i < j; i++ ) { |
412 | if ( !d->selectedFiles->next() ) | 412 | if ( !d->selectedFiles->next() ) |
413 | d->selectedFiles->first(); | 413 | d->selectedFiles->first(); |
414 | } | 414 | } |
415 | if ( cur == current() ) | 415 | if ( cur == current() ) |
416 | if ( !d->selectedFiles->next() ) { | 416 | if ( !d->selectedFiles->next() ) { |
417 | d->selectedFiles->first(); | 417 | d->selectedFiles->first(); |
418 | } | 418 | } |
419 | return TRUE; | 419 | return TRUE; |
420 | } else { | 420 | } else { |
421 | if ( !d->selectedFiles->prev() ) { | 421 | if ( !d->selectedFiles->prev() ) { |
422 | if ( mediaPlayerState.isLooping() ) { | 422 | if ( mediaPlayerState.isLooping() ) { |