author | simon <simon> | 2002-12-04 11:40:01 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-04 11:40:01 (UTC) |
commit | 6a11cf48019e28006172cfb9a61e865816c3657e (patch) (unidiff) | |
tree | 45634eded135f17fcdba8e4cb706e87f47f6d5f0 | |
parent | 84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95 (diff) | |
download | opie-6a11cf48019e28006172cfb9a61e865816c3657e.zip opie-6a11cf48019e28006172cfb9a61e865816c3657e.tar.gz opie-6a11cf48019e28006172cfb9a61e865816c3657e.tar.bz2 |
- move more view population logic into PlayListFileView
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 30 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 3 |
4 files changed, 20 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index 0ed1061..cb16415 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp | |||
@@ -1,66 +1,78 @@ | |||
1 | 1 | ||
2 | #include "playlistfileview.h" | 2 | #include "playlistfileview.h" |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qpe/global.h> | 5 | #include <qpe/global.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | 7 | ||
8 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) | 8 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) |
9 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ) | 9 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ), |
10 | m_viewPopulated( false ) | ||
10 | { | 11 | { |
11 | addColumn( tr( "Title" ), 140); | 12 | addColumn( tr( "Title" ), 140); |
12 | addColumn( tr( "Size" ), -1 ); | 13 | addColumn( tr( "Size" ), -1 ); |
13 | addColumn(tr( "Media" ), 0 ); | 14 | addColumn(tr( "Media" ), 0 ); |
14 | addColumn(tr( "Path" ), -1 ); | 15 | addColumn(tr( "Path" ), -1 ); |
15 | setColumnAlignment( 1, Qt::AlignRight ); | 16 | setColumnAlignment( 1, Qt::AlignRight ); |
16 | setColumnAlignment( 2, Qt::AlignRight ); | 17 | setColumnAlignment( 2, Qt::AlignRight ); |
17 | setAllColumnsShowFocus( TRUE ); | 18 | setAllColumnsShowFocus( TRUE ); |
18 | setSorting( 3, TRUE ); | 19 | setSorting( 3, TRUE ); |
19 | setMultiSelection( TRUE ); | 20 | setMultiSelection( TRUE ); |
20 | setSelectionMode( QListView::Extended ); | 21 | setSelectionMode( QListView::Extended ); |
21 | } | 22 | } |
22 | 23 | ||
23 | PlayListFileView::~PlayListFileView() | 24 | PlayListFileView::~PlayListFileView() |
24 | { | 25 | { |
25 | } | 26 | } |
26 | 27 | ||
27 | void PlayListFileView::scanFiles() | 28 | void PlayListFileView::scanFiles() |
28 | { | 29 | { |
29 | m_files.detachChildren(); | 30 | m_files.detachChildren(); |
30 | QListIterator<DocLnk> sdit( m_files.children() ); | 31 | QListIterator<DocLnk> sdit( m_files.children() ); |
31 | for ( ; sdit.current(); ++sdit ) | 32 | for ( ; sdit.current(); ++sdit ) |
32 | delete sdit.current(); | 33 | delete sdit.current(); |
33 | 34 | ||
34 | Global::findDocuments( &m_files, m_mimeTypePattern ); | 35 | Global::findDocuments( &m_files, m_mimeTypePattern ); |
36 | |||
37 | if ( m_viewPopulated ) { | ||
38 | m_viewPopulated = false; | ||
39 | populateView(); | ||
40 | } | ||
35 | } | 41 | } |
36 | 42 | ||
37 | void PlayListFileView::populateView() | 43 | void PlayListFileView::populateView() |
38 | { | 44 | { |
45 | if ( m_viewPopulated ) | ||
46 | return; | ||
47 | |||
39 | clear(); | 48 | clear(); |
40 | 49 | ||
41 | if( !m_scannedFiles ) { | 50 | if( !m_scannedFiles ) { |
51 | m_viewPopulated = false; // avoid a recursion :) | ||
42 | scanFiles(); | 52 | scanFiles(); |
43 | m_scannedFiles = true; | 53 | m_scannedFiles = true; |
44 | } | 54 | } |
45 | 55 | ||
56 | m_viewPopulated = true; | ||
57 | |||
46 | QString storage; | 58 | QString storage; |
47 | QListIterator<DocLnk> dit( m_files.children() ); | 59 | QListIterator<DocLnk> dit( m_files.children() ); |
48 | for ( ; dit.current(); ++dit ) { | 60 | for ( ; dit.current(); ++dit ) { |
49 | 61 | ||
50 | QListViewItem *newItem; | 62 | QListViewItem *newItem; |
51 | 63 | ||
52 | if ( QFile::exists( dit.current()->file() ) || | 64 | if ( QFile::exists( dit.current()->file() ) || |
53 | dit.current()->file().left( 4 ) == "http" ) { | 65 | dit.current()->file().left( 4 ) == "http" ) { |
54 | 66 | ||
55 | unsigned long size = QFile( dit.current()->file() ).size(); | 67 | unsigned long size = QFile( dit.current()->file() ).size(); |
56 | 68 | ||
57 | newItem = new QListViewItem( this, dit.current()->name(), | 69 | newItem = new QListViewItem( this, dit.current()->name(), |
58 | QString::number( size ), "" /*storage*/, | 70 | QString::number( size ), "" /*storage*/, |
59 | dit.current()->file() ); | 71 | dit.current()->file() ); |
60 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); | 72 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); |
61 | } | 73 | } |
62 | } | 74 | } |
63 | } | 75 | } |
64 | 76 | ||
65 | /* vim: et sw=4 ts=4 | 77 | /* vim: et sw=4 ts=4 |
66 | */ | 78 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index a00349e..448473e 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h | |||
@@ -1,33 +1,34 @@ | |||
1 | #ifndef PLAYLISTFILEVIEW_H | 1 | #ifndef PLAYLISTFILEVIEW_H |
2 | #define PLAYLISTFILEVIEW_H | 2 | #define PLAYLISTFILEVIEW_H |
3 | 3 | ||
4 | #include "playlistview.h" | 4 | #include "playlistview.h" |
5 | 5 | ||
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | 7 | ||
8 | class PlayListFileView : public PlayListView | 8 | class PlayListFileView : public PlayListView |
9 | { | 9 | { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); | 12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); |
13 | virtual ~PlayListFileView(); | 13 | virtual ~PlayListFileView(); |
14 | 14 | ||
15 | // both temporarily accessible that way until the caller code has | 15 | // both temporarily accessible that way until the caller code has |
16 | // been migrated into this class | 16 | // been migrated into this class |
17 | DocLnkSet &files() { return m_files; } | 17 | DocLnkSet &files() { return m_files; } |
18 | bool &scannedFiles() { return m_scannedFiles; } | 18 | bool &scannedFiles() { return m_scannedFiles; } |
19 | 19 | ||
20 | public slots: | 20 | public slots: |
21 | void scanFiles(); | 21 | void scanFiles(); |
22 | void populateView(); | 22 | void populateView(); |
23 | 23 | ||
24 | private: | 24 | private: |
25 | QString m_mimeTypePattern; | 25 | QString m_mimeTypePattern; |
26 | QString m_itemPixmapName; | 26 | QString m_itemPixmapName; |
27 | DocLnkSet m_files; | 27 | DocLnkSet m_files; |
28 | bool m_scannedFiles; | 28 | bool m_scannedFiles; |
29 | bool m_viewPopulated; | ||
29 | }; | 30 | }; |
30 | 31 | ||
31 | #endif // PLAYLISTFILEVIEW_H | 32 | #endif // PLAYLISTFILEVIEW_H |
32 | /* vim: et sw=4 ts=4 | 33 | /* vim: et sw=4 ts=4 |
33 | */ | 34 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 460a0bf..eb0606d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -122,66 +122,64 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par | |||
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 | audioPopulated=false; | ||
155 | videoPopulated=false; | ||
156 | populateSkinsMenu(); | 154 | populateSkinsMenu(); |
157 | initializeStates(); | 155 | initializeStates(); |
158 | 156 | ||
159 | cfg.setGroup("PlayList"); | 157 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
161 | loadList(DocLnk( currentPlaylist ) ); | 159 | loadList(DocLnk( currentPlaylist ) ); |
162 | } | 160 | } |
163 | 161 | ||
164 | 162 | ||
165 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
166 | delete d; | 164 | delete d; |
167 | } | 165 | } |
168 | 166 | ||
169 | 167 | ||
170 | void PlayListWidget::initializeStates() { | 168 | void PlayListWidget::initializeStates() { |
171 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
172 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
173 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
174 | d->playListFrame->show(); | 172 | d->playListFrame->show(); |
175 | } | 173 | } |
176 | 174 | ||
177 | void PlayListWidget::writeDefaultPlaylist() { | 175 | void PlayListWidget::writeDefaultPlaylist() { |
178 | 176 | ||
179 | Config config( "OpiePlayer" ); | 177 | Config config( "OpiePlayer" ); |
180 | config.setGroup( "PlayList" ); | 178 | config.setGroup( "PlayList" ); |
181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
183 | if( currentString == filename) { | 181 | if( currentString == filename) { |
184 | Om3u *m3uList; | 182 | Om3u *m3uList; |
185 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
186 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
@@ -225,158 +223,158 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , in | |||
225 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
226 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
227 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
228 | } | 226 | } |
229 | break; | 227 | break; |
230 | } | 228 | } |
231 | } | 229 | } |
232 | 230 | ||
233 | 231 | ||
234 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
235 | switch (mouse) { | 233 | switch (mouse) { |
236 | case 1: | 234 | case 1: |
237 | break; | 235 | break; |
238 | case 2: | 236 | case 2: |
239 | { | 237 | { |
240 | QPopupMenu m; | 238 | QPopupMenu m; |
241 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
242 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
243 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
244 | } | 242 | } |
245 | break; | 243 | break; |
246 | } | 244 | } |
247 | } | 245 | } |
248 | 246 | ||
249 | 247 | ||
250 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
251 | 249 | ||
252 | // QTime t; | 250 | // QTime t; |
253 | // t.start(); | 251 | // t.start(); |
254 | 252 | ||
255 | if(!audioView->scannedFiles()) { | 253 | if(!audioView->scannedFiles()) { |
256 | if(audioView->childCount() < 1) | 254 | if(audioView->childCount() < 1) |
257 | populateAudioView(); | 255 | audioView->populateView(); |
258 | } | 256 | } |
259 | 257 | ||
260 | QListViewItemIterator audioIt( audioView ); | 258 | QListViewItemIterator audioIt( audioView ); |
261 | DocLnk lnk; | 259 | DocLnk lnk; |
262 | QString filename; | 260 | QString filename; |
263 | // iterate through all items of the listview | 261 | // iterate through all items of the listview |
264 | for ( ; audioIt.current(); ++audioIt ) { | 262 | for ( ; audioIt.current(); ++audioIt ) { |
265 | filename = audioIt.current()->text(3); | 263 | filename = audioIt.current()->text(3); |
266 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 264 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
267 | lnk.setFile( filename ); //sets file name | 265 | lnk.setFile( filename ); //sets file name |
268 | d->selectedFiles->addToSelection( lnk); | 266 | d->selectedFiles->addToSelection( lnk); |
269 | } | 267 | } |
270 | 268 | ||
271 | if(!videoView->scannedFiles()) { | 269 | if(!videoView->scannedFiles()) { |
272 | if(videoView->childCount() < 1) | 270 | if(videoView->childCount() < 1) |
273 | populateVideoView(); | 271 | videoView->populateView(); |
274 | } | 272 | } |
275 | 273 | ||
276 | QListViewItemIterator videoIt( videoView ); | 274 | QListViewItemIterator videoIt( videoView ); |
277 | for ( ; videoIt.current(); ++videoIt ) { | 275 | for ( ; videoIt.current(); ++videoIt ) { |
278 | filename = videoIt.current()->text(3); | 276 | filename = videoIt.current()->text(3); |
279 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 277 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
280 | lnk.setFile( filename ); //sets file name | 278 | lnk.setFile( filename ); //sets file name |
281 | d->selectedFiles->addToSelection( lnk); | 279 | d->selectedFiles->addToSelection( lnk); |
282 | } | 280 | } |
283 | 281 | ||
284 | // d->selectedFiles->addToSelection( ); | 282 | // d->selectedFiles->addToSelection( ); |
285 | // if ( it.current()->isSelected() ) | 283 | // if ( it.current()->isSelected() ) |
286 | // lst->append( audioIt.current() ); | 284 | // lst->append( audioIt.current() ); |
287 | // } | 285 | // } |
288 | 286 | ||
289 | 287 | ||
290 | // if(!audioScan) | 288 | // if(!audioScan) |
291 | // scanForAudio(); | 289 | // scanForAudio(); |
292 | // if(!videoScan) | 290 | // if(!videoScan) |
293 | // scanForVideo(); | 291 | // scanForVideo(); |
294 | 292 | ||
295 | // DocLnkSet filesAll; | 293 | // DocLnkSet filesAll; |
296 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 294 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
297 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 295 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
298 | // for ( ; Adit.current(); ++Adit ) { | 296 | // for ( ; Adit.current(); ++Adit ) { |
299 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 297 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
300 | // d->selectedFiles->addToSelection( **Adit ); | 298 | // d->selectedFiles->addToSelection( **Adit ); |
301 | // } | 299 | // } |
302 | // } | 300 | // } |
303 | 301 | ||
304 | // qDebug("elapsed time %d", t.elapsed() ); | 302 | // qDebug("elapsed time %d", t.elapsed() ); |
305 | 303 | ||
306 | tabWidget->setCurrentPage(0); | 304 | tabWidget->setCurrentPage(0); |
307 | 305 | ||
308 | writeCurrentM3u(); | 306 | writeCurrentM3u(); |
309 | d->selectedFiles->first(); | 307 | d->selectedFiles->first(); |
310 | } | 308 | } |
311 | 309 | ||
312 | 310 | ||
313 | void PlayListWidget::addAllMusicToList() { | 311 | void PlayListWidget::addAllMusicToList() { |
314 | 312 | ||
315 | if(!audioView->scannedFiles()) { | 313 | if(!audioView->scannedFiles()) { |
316 | if(audioView->childCount() < 1) | 314 | if(audioView->childCount() < 1) |
317 | populateAudioView(); | 315 | audioView->populateView(); |
318 | } | 316 | } |
319 | 317 | ||
320 | QListViewItemIterator audioIt( audioView ); | 318 | QListViewItemIterator audioIt( audioView ); |
321 | DocLnk lnk; | 319 | DocLnk lnk; |
322 | QString filename; | 320 | QString filename; |
323 | // iterate through all items of the listview | 321 | // iterate through all items of the listview |
324 | for ( ; audioIt.current(); ++audioIt ) { | 322 | for ( ; audioIt.current(); ++audioIt ) { |
325 | filename = audioIt.current()->text(3); | 323 | filename = audioIt.current()->text(3); |
326 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 324 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
327 | lnk.setFile( filename ); //sets file name | 325 | lnk.setFile( filename ); //sets file name |
328 | d->selectedFiles->addToSelection( lnk); | 326 | d->selectedFiles->addToSelection( lnk); |
329 | } | 327 | } |
330 | 328 | ||
331 | /* if(!audioScan) | 329 | /* if(!audioScan) |
332 | scanForAudio(); | 330 | scanForAudio(); |
333 | QListIterator<DocLnk> dit( files.children() ); | 331 | QListIterator<DocLnk> dit( files.children() ); |
334 | for ( ; dit.current(); ++dit ) { | 332 | for ( ; dit.current(); ++dit ) { |
335 | if( QFileInfo(dit.current()->file() ).exists() ) { | 333 | if( QFileInfo(dit.current()->file() ).exists() ) { |
336 | d->selectedFiles->addToSelection( **dit ); | 334 | d->selectedFiles->addToSelection( **dit ); |
337 | } | 335 | } |
338 | } | 336 | } |
339 | */ | 337 | */ |
340 | tabWidget->setCurrentPage(0); | 338 | tabWidget->setCurrentPage(0); |
341 | writeCurrentM3u(); | 339 | writeCurrentM3u(); |
342 | d->selectedFiles->first(); | 340 | d->selectedFiles->first(); |
343 | } | 341 | } |
344 | 342 | ||
345 | 343 | ||
346 | void PlayListWidget::addAllVideoToList() { | 344 | void PlayListWidget::addAllVideoToList() { |
347 | 345 | ||
348 | if(!videoView->scannedFiles()) { | 346 | if(!videoView->scannedFiles()) { |
349 | if(videoView->childCount() < 1) | 347 | if(videoView->childCount() < 1) |
350 | populateVideoView(); | 348 | videoView->populateView(); |
351 | } | 349 | } |
352 | 350 | ||
353 | QListViewItemIterator videoIt( videoView ); | 351 | QListViewItemIterator videoIt( videoView ); |
354 | DocLnk lnk; | 352 | DocLnk lnk; |
355 | QString filename; | 353 | QString filename; |
356 | for ( ; videoIt.current(); ++videoIt ) { | 354 | for ( ; videoIt.current(); ++videoIt ) { |
357 | filename = videoIt.current()->text(3); | 355 | filename = videoIt.current()->text(3); |
358 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 356 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
359 | lnk.setFile( filename ); //sets file name | 357 | lnk.setFile( filename ); //sets file name |
360 | d->selectedFiles->addToSelection( lnk); | 358 | d->selectedFiles->addToSelection( lnk); |
361 | } | 359 | } |
362 | 360 | ||
363 | 361 | ||
364 | /* if(!videoScan) | 362 | /* if(!videoScan) |
365 | scanForVideo(); | 363 | scanForVideo(); |
366 | QListIterator<DocLnk> dit( vFiles.children() ); | 364 | QListIterator<DocLnk> dit( vFiles.children() ); |
367 | for ( ; dit.current(); ++dit ) { | 365 | for ( ; dit.current(); ++dit ) { |
368 | if( QFileInfo( dit.current()->file() ).exists() ) { | 366 | if( QFileInfo( dit.current()->file() ).exists() ) { |
369 | d->selectedFiles->addToSelection( **dit ); | 367 | d->selectedFiles->addToSelection( **dit ); |
370 | } | 368 | } |
371 | } | 369 | } |
372 | */ | 370 | */ |
373 | tabWidget->setCurrentPage(0); | 371 | tabWidget->setCurrentPage(0); |
374 | writeCurrentM3u(); | 372 | writeCurrentM3u(); |
375 | d->selectedFiles->first(); | 373 | d->selectedFiles->first(); |
376 | } | 374 | } |
377 | 375 | ||
378 | 376 | ||
379 | void PlayListWidget::setDocument( const QString& fileref ) { | 377 | void PlayListWidget::setDocument( const QString& fileref ) { |
380 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 378 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
381 | fromSetDocument = TRUE; | 379 | fromSetDocument = TRUE; |
382 | if ( fileref.isNull() ) { | 380 | if ( fileref.isNull() ) { |
@@ -543,146 +541,130 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
543 | QString filename; | 541 | QString filename; |
544 | 542 | ||
545 | filename=it->text(3); | 543 | filename=it->text(3); |
546 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 544 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
547 | lnk.setFile( filename ); //sets file name | 545 | lnk.setFile( filename ); //sets file name |
548 | d->selectedFiles->addToSelection( lnk); | 546 | d->selectedFiles->addToSelection( lnk); |
549 | 547 | ||
550 | writeCurrentM3u(); | 548 | writeCurrentM3u(); |
551 | tabWidget->setCurrentPage(0); | 549 | tabWidget->setCurrentPage(0); |
552 | 550 | ||
553 | } | 551 | } |
554 | } | 552 | } |
555 | 553 | ||
556 | 554 | ||
557 | void PlayListWidget::tabChanged(QWidget *) { | 555 | void PlayListWidget::tabChanged(QWidget *) { |
558 | 556 | ||
559 | d->tbPlay->setEnabled( true ); | 557 | d->tbPlay->setEnabled( true ); |
560 | 558 | ||
561 | switch ( currentTab() ) { | 559 | switch ( currentTab() ) { |
562 | case CurrentPlayList: | 560 | case CurrentPlayList: |
563 | { | 561 | { |
564 | if( !tbDeletePlaylist->isHidden() ) { | 562 | if( !tbDeletePlaylist->isHidden() ) { |
565 | tbDeletePlaylist->hide(); | 563 | tbDeletePlaylist->hide(); |
566 | } | 564 | } |
567 | d->tbRemoveFromList->setEnabled(TRUE); | 565 | d->tbRemoveFromList->setEnabled(TRUE); |
568 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
569 | 567 | ||
570 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 568 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
571 | } | 569 | } |
572 | break; | 570 | break; |
573 | case AudioFiles: | 571 | case AudioFiles: |
574 | { | 572 | { |
575 | // audioView->clear(); | 573 | audioView->populateView(); |
576 | if(!audioPopulated) populateAudioView(); | ||
577 | 574 | ||
578 | if( !tbDeletePlaylist->isHidden() ) { | 575 | if( !tbDeletePlaylist->isHidden() ) { |
579 | tbDeletePlaylist->hide(); | 576 | tbDeletePlaylist->hide(); |
580 | } | 577 | } |
581 | d->tbRemoveFromList->setEnabled(FALSE); | 578 | d->tbRemoveFromList->setEnabled(FALSE); |
582 | d->tbAddToList->setEnabled(TRUE); | 579 | d->tbAddToList->setEnabled(TRUE); |
583 | } | 580 | } |
584 | break; | 581 | break; |
585 | case VideoFiles: | 582 | case VideoFiles: |
586 | { | 583 | { |
587 | // videoView->clear(); | 584 | videoView->populateView(); |
588 | if(!videoPopulated) populateVideoView(); | ||
589 | if( !tbDeletePlaylist->isHidden() ) { | 585 | if( !tbDeletePlaylist->isHidden() ) { |
590 | tbDeletePlaylist->hide(); | 586 | tbDeletePlaylist->hide(); |
591 | } | 587 | } |
592 | d->tbRemoveFromList->setEnabled(FALSE); | 588 | d->tbRemoveFromList->setEnabled(FALSE); |
593 | d->tbAddToList->setEnabled(TRUE); | 589 | d->tbAddToList->setEnabled(TRUE); |
594 | } | 590 | } |
595 | break; | 591 | break; |
596 | case PlayLists: | 592 | case PlayLists: |
597 | { | 593 | { |
598 | if( tbDeletePlaylist->isHidden() ) { | 594 | if( tbDeletePlaylist->isHidden() ) { |
599 | tbDeletePlaylist->show(); | 595 | tbDeletePlaylist->show(); |
600 | } | 596 | } |
601 | playLists->reread(); | 597 | playLists->reread(); |
602 | d->tbAddToList->setEnabled(FALSE); | 598 | d->tbAddToList->setEnabled(FALSE); |
603 | 599 | ||
604 | d->tbPlay->setEnabled( false ); | 600 | d->tbPlay->setEnabled( false ); |
605 | } | 601 | } |
606 | break; | 602 | break; |
607 | }; | 603 | }; |
608 | } | 604 | } |
609 | 605 | ||
610 | 606 | ||
611 | void PlayListWidget::btnPlay(bool b) { | 607 | void PlayListWidget::btnPlay(bool b) { |
612 | // mediaPlayerState->setPlaying(false); | 608 | // mediaPlayerState->setPlaying(false); |
613 | mediaPlayerState.setPlaying(b); | 609 | mediaPlayerState.setPlaying(b); |
614 | insanityBool=FALSE; | 610 | insanityBool=FALSE; |
615 | } | 611 | } |
616 | 612 | ||
617 | void PlayListWidget::deletePlaylist() { | 613 | void PlayListWidget::deletePlaylist() { |
618 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 614 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
619 | (tr("You really want to delete\nthis playlist?")), | 615 | (tr("You really want to delete\nthis playlist?")), |
620 | (tr("Yes")), (tr("No")), 0 )){ | 616 | (tr("Yes")), (tr("No")), 0 )){ |
621 | case 0: // Yes clicked, | 617 | case 0: // Yes clicked, |
622 | QFile().remove(playLists->selectedDocument().file()); | 618 | QFile().remove(playLists->selectedDocument().file()); |
623 | QFile().remove(playLists->selectedDocument().linkFile()); | 619 | QFile().remove(playLists->selectedDocument().linkFile()); |
624 | playLists->reread(); | 620 | playLists->reread(); |
625 | break; | 621 | break; |
626 | case 1: // Cancel | 622 | case 1: // Cancel |
627 | break; | 623 | break; |
628 | }; | 624 | }; |
629 | } | 625 | } |
630 | 626 | ||
631 | 627 | ||
632 | void PlayListWidget::playSelected() { | 628 | void PlayListWidget::playSelected() { |
633 | btnPlay( TRUE); | 629 | btnPlay( TRUE); |
634 | } | 630 | } |
635 | 631 | ||
636 | 632 | ||
637 | void PlayListWidget::scanForAudio() { | 633 | void PlayListWidget::scanForAudio() { |
638 | audioView->scanFiles(); | 634 | audioView->scanFiles(); |
639 | audioView->scannedFiles() = true; | ||
640 | populateAudioView(); | ||
641 | } | 635 | } |
642 | 636 | ||
643 | void PlayListWidget::scanForVideo() { | 637 | void PlayListWidget::scanForVideo() { |
644 | videoView->scanFiles(); | 638 | videoView->scanFiles(); |
645 | videoView->scannedFiles() = true; | ||
646 | populateVideoView(); | ||
647 | } | ||
648 | |||
649 | void PlayListWidget::populateAudioView() { | ||
650 | audioView->populateView(); | ||
651 | audioPopulated = true; | ||
652 | } | ||
653 | |||
654 | void PlayListWidget::populateVideoView() { | ||
655 | videoView->populateView(); | ||
656 | videoPopulated=true; | ||
657 | } | 639 | } |
658 | 640 | ||
659 | QListView *PlayListWidget::currentFileListView() const | 641 | QListView *PlayListWidget::currentFileListView() const |
660 | { | 642 | { |
661 | switch ( currentTab() ) { | 643 | switch ( currentTab() ) { |
662 | case AudioFiles: return audioView; | 644 | case AudioFiles: return audioView; |
663 | case VideoFiles: return videoView; | 645 | case VideoFiles: return videoView; |
664 | default: assert( false ); | 646 | default: assert( false ); |
665 | } | 647 | } |
666 | return 0; | 648 | return 0; |
667 | } | 649 | } |
668 | 650 | ||
669 | bool PlayListWidget::inFileListMode() const | 651 | bool PlayListWidget::inFileListMode() const |
670 | { | 652 | { |
671 | TabType tab = currentTab(); | 653 | TabType tab = currentTab(); |
672 | return tab == AudioFiles || tab == VideoFiles; | 654 | return tab == AudioFiles || tab == VideoFiles; |
673 | } | 655 | } |
674 | 656 | ||
675 | void PlayListWidget::openFile() { | 657 | void PlayListWidget::openFile() { |
676 | // http://66.28.164.33:2080 | 658 | // http://66.28.164.33:2080 |
677 | // http://somafm.com/star0242.m3u | 659 | // http://somafm.com/star0242.m3u |
678 | QString filename, name; | 660 | QString filename, name; |
679 | InputDialog *fileDlg; | 661 | InputDialog *fileDlg; |
680 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 662 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
681 | fileDlg->exec(); | 663 | fileDlg->exec(); |
682 | if( fileDlg->result() == 1 ) { | 664 | if( fileDlg->result() == 1 ) { |
683 | filename = fileDlg->text(); | 665 | filename = fileDlg->text(); |
684 | qDebug( "Selected filename is " + filename ); | 666 | qDebug( "Selected filename is " + filename ); |
685 | // Om3u *m3uList; | 667 | // Om3u *m3uList; |
686 | DocLnk lnk; | 668 | DocLnk lnk; |
687 | Config cfg( "OpiePlayer" ); | 669 | Config cfg( "OpiePlayer" ); |
688 | cfg.setGroup("PlayList"); | 670 | cfg.setGroup("PlayList"); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 58efd47..8c22f17 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -65,70 +65,67 @@ public: | |||
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 | bool audioPopulated, videoPopulated; | ||
98 | void readm3u(const QString &); | 97 | void readm3u(const QString &); |
99 | void readPls(const QString &); | 98 | void readPls(const QString &); |
100 | void initializeStates(); | 99 | void initializeStates(); |
101 | void populateAudioView(); | ||
102 | void populateVideoView(); | ||
103 | 100 | ||
104 | QListView *currentFileListView() const; | 101 | QListView *currentFileListView() const; |
105 | 102 | ||
106 | bool inFileListMode() const; | 103 | bool inFileListMode() const; |
107 | 104 | ||
108 | private slots: | 105 | private slots: |
109 | void populateSkinsMenu(); | 106 | void populateSkinsMenu(); |
110 | void skinsMenuActivated(int); | 107 | void skinsMenuActivated(int); |
111 | void pmViewActivated(int); | 108 | void pmViewActivated(int); |
112 | void writem3u(); | 109 | void writem3u(); |
113 | void writeCurrentM3u(); | 110 | void writeCurrentM3u(); |
114 | void scanForAudio(); | 111 | void scanForAudio(); |
115 | void scanForVideo(); | 112 | void scanForVideo(); |
116 | void openFile(); | 113 | void openFile(); |
117 | void setDocument( const QString& fileref ); | 114 | void setDocument( const QString& fileref ); |
118 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 115 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
119 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 116 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
120 | void clearList(); | 117 | void clearList(); |
121 | void addAllToList(); | 118 | void addAllToList(); |
122 | void addAllMusicToList(); | 119 | void addAllMusicToList(); |
123 | void addAllVideoToList(); | 120 | void addAllVideoToList(); |
124 | void saveList(); // Save the playlist | 121 | void saveList(); // Save the playlist |
125 | void loadList( const DocLnk &); // Load a playlist | 122 | void loadList( const DocLnk &); // Load a playlist |
126 | void playIt( QListViewItem *); | 123 | void playIt( QListViewItem *); |
127 | void btnPlay(bool); | 124 | void btnPlay(bool); |
128 | void deletePlaylist(); | 125 | void deletePlaylist(); |
129 | void addSelected(); | 126 | void addSelected(); |
130 | void removeSelected(); | 127 | void removeSelected(); |
131 | void tabChanged(QWidget*); | 128 | void tabChanged(QWidget*); |
132 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 129 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
133 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
134 | void playSelected(); | 131 | void playSelected(); |