summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-04 11:40:01 (UTC)
committer simon <simon>2002-12-04 11:40:01 (UTC)
commit6a11cf48019e28006172cfb9a61e865816c3657e (patch) (unidiff)
tree45634eded135f17fcdba8e4cb706e87f47f6d5f0
parent84d5ca934e9cb8950d1efdb90ac3b00ce6d44e95 (diff)
downloadopie-6a11cf48019e28006172cfb9a61e865816c3657e.zip
opie-6a11cf48019e28006172cfb9a61e865816c3657e.tar.gz
opie-6a11cf48019e28006172cfb9a61e865816c3657e.tar.bz2
- move more view population logic into PlayListFileView
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp30
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
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
8PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) 8PlayListFileView::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
23PlayListFileView::~PlayListFileView() 24PlayListFileView::~PlayListFileView()
24{ 25{
25} 26}
26 27
27void PlayListFileView::scanFiles() 28void 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
37void PlayListFileView::populateView() 43void 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
8class PlayListFileView : public PlayListView 8class PlayListFileView : public PlayListView
9{ 9{
10 Q_OBJECT 10 Q_OBJECT
11public: 11public:
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
20public slots: 20public slots:
21 void scanFiles(); 21 void scanFiles();
22 void populateView(); 22 void populateView();
23 23
24private: 24private:
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
@@ -1,1047 +1,1029 @@
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
61extern MediaPlayerState *mediaPlayerState; 61extern MediaPlayerState *mediaPlayerState;
62// extern AudioWidget *audioUI; 62// extern AudioWidget *audioUI;
63// extern VideoWidget *videoUI; 63// extern VideoWidget *videoUI;
64 64
65PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 65PlayListWidget::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 this,SLOT( scanForAudio() ) );
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 this,SLOT( scanForVideo() ) );
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 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
165PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
166 delete d; 164 delete d;
167} 165}
168 166
169 167
170void PlayListWidget::initializeStates() { 168void 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
177void PlayListWidget::writeDefaultPlaylist() { 175void 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);
188 do { 186 do {
189 // qDebug(d->selectedFiles->current()->file()); 187 // qDebug(d->selectedFiles->current()->file());
190 m3uList->add( d->selectedFiles->current()->file() ); 188 m3uList->add( d->selectedFiles->current()->file() );
191 } 189 }
192 while ( d->selectedFiles->next() ); 190 while ( d->selectedFiles->next() );
193 191
194 m3uList->write(); 192 m3uList->write();
195 m3uList->close(); 193 m3uList->close();
196 if(m3uList) delete m3uList; 194 if(m3uList) delete m3uList;
197 195
198 } 196 }
199 } 197 }
200} 198}
201 199
202void PlayListWidget::addToSelection( const DocLnk& lnk ) { 200void PlayListWidget::addToSelection( const DocLnk& lnk ) {
203 d->setDocumentUsed = FALSE; 201 d->setDocumentUsed = FALSE;
204 if( QFileInfo( lnk.file() ).exists() || 202 if( QFileInfo( lnk.file() ).exists() ||
205 lnk.file().left(4) == "http" ) { 203 lnk.file().left(4) == "http" ) {
206 d->selectedFiles->addToSelection( lnk ); 204 d->selectedFiles->addToSelection( lnk );
207 } 205 }
208// writeCurrentM3u(); 206// writeCurrentM3u();
209} 207}
210 208
211 209
212void PlayListWidget::clearList() { 210void PlayListWidget::clearList() {
213 while ( first() ) { 211 while ( first() ) {
214 d->selectedFiles->removeSelected(); 212 d->selectedFiles->removeSelected();
215 } 213 }
216} 214}
217 215
218void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
219 switch (mouse) { 217 switch (mouse) {
220 case 1: 218 case 1:
221 break; 219 break;
222 case 2: 220 case 2:
223 { 221 {
224 QPopupMenu m; 222 QPopupMenu m;
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
234void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 232void 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
250void PlayListWidget::addAllToList() { 248void 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
313void PlayListWidget::addAllMusicToList() { 311void 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
346void PlayListWidget::addAllVideoToList() { 344void 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
379void PlayListWidget::setDocument( const QString& fileref ) { 377void 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() ) {
383 QMessageBox::warning( this, tr( "Invalid File" ), 381 QMessageBox::warning( this, tr( "Invalid File" ),
384 tr( "There was a problem in getting the file." ) ); 382 tr( "There was a problem in getting the file." ) );
385 return; 383 return;
386 } 384 }
387 385
388 clearList(); 386 clearList();
389 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 387 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
390 readm3u( fileref ); 388 readm3u( fileref );
391 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 389 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
392 readm3u( DocLnk( fileref).file() ); 390 readm3u( DocLnk( fileref).file() );
393 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 391 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
394 readPls( fileref ); 392 readPls( fileref );
395 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 393 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
396 readPls( DocLnk( fileref).file() ); 394 readPls( DocLnk( fileref).file() );
397 } else { 395 } else {
398 clearList(); 396 clearList();
399 addToSelection( DocLnk( fileref ) ); 397 addToSelection( DocLnk( fileref ) );
400 writeCurrentM3u(); 398 writeCurrentM3u();
401 399
402 d->setDocumentUsed = TRUE; 400 d->setDocumentUsed = TRUE;
403 mediaPlayerState.setPlaying( FALSE ); 401 mediaPlayerState.setPlaying( FALSE );
404 mediaPlayerState.setPlaying( TRUE ); 402 mediaPlayerState.setPlaying( TRUE );
405 } 403 }
406} 404}
407 405
408 406
409void PlayListWidget::useSelectedDocument() { 407void PlayListWidget::useSelectedDocument() {
410 d->setDocumentUsed = FALSE; 408 d->setDocumentUsed = FALSE;
411} 409}
412 410
413 411
414const DocLnk *PlayListWidget::current() const { // this is fugly 412const DocLnk *PlayListWidget::current() const { // this is fugly
415 assert( currentTab() == CurrentPlayList ); 413 assert( currentTab() == CurrentPlayList );
416 414
417 const DocLnk *lnk = d->selectedFiles->current(); 415 const DocLnk *lnk = d->selectedFiles->current();
418 if ( !lnk ) { 416 if ( !lnk ) {
419 d->selectedFiles->first(); 417 d->selectedFiles->first();
420 lnk = d->selectedFiles->current(); 418 lnk = d->selectedFiles->current();
421 } 419 }
422 assert( lnk ); 420 assert( lnk );
423 return lnk; 421 return lnk;
424} 422}
425 423
426 424
427bool PlayListWidget::prev() { 425bool PlayListWidget::prev() {
428 if ( mediaPlayerState.isShuffled() ) { 426 if ( mediaPlayerState.isShuffled() ) {
429 const DocLnk *cur = current(); 427 const DocLnk *cur = current();
430 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 428 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
431 for ( int i = 0; i < j; i++ ) { 429 for ( int i = 0; i < j; i++ ) {
432 if ( !d->selectedFiles->next() ) 430 if ( !d->selectedFiles->next() )
433 d->selectedFiles->first(); 431 d->selectedFiles->first();
434 } 432 }
435 if ( cur == current() ) 433 if ( cur == current() )
436 if ( !d->selectedFiles->next() ) { 434 if ( !d->selectedFiles->next() ) {
437 d->selectedFiles->first(); 435 d->selectedFiles->first();
438 } 436 }
439 return TRUE; 437 return TRUE;
440 } else { 438 } else {
441 if ( !d->selectedFiles->prev() ) { 439 if ( !d->selectedFiles->prev() ) {
442 if ( mediaPlayerState.isLooping() ) { 440 if ( mediaPlayerState.isLooping() ) {
443 return d->selectedFiles->last(); 441 return d->selectedFiles->last();
444 } else { 442 } else {
445 return FALSE; 443 return FALSE;
446 } 444 }
447 } 445 }
448 return TRUE; 446 return TRUE;
449 } 447 }
450} 448}
451 449
452 450
453bool PlayListWidget::next() { 451bool PlayListWidget::next() {
454//qDebug("<<<<<<<<<<<<next()"); 452//qDebug("<<<<<<<<<<<<next()");
455 if ( mediaPlayerState.isShuffled() ) { 453 if ( mediaPlayerState.isShuffled() ) {
456 return prev(); 454 return prev();
457 } else { 455 } else {
458 if ( !d->selectedFiles->next() ) { 456 if ( !d->selectedFiles->next() ) {
459 if ( mediaPlayerState.isLooping() ) { 457 if ( mediaPlayerState.isLooping() ) {
460 return d->selectedFiles->first(); 458 return d->selectedFiles->first();
461 } else { 459 } else {
462 return FALSE; 460 return FALSE;
463 } 461 }
464 } 462 }
465 return TRUE; 463 return TRUE;
466 } 464 }
467} 465}
468 466
469 467
470bool PlayListWidget::first() { 468bool PlayListWidget::first() {
471 return d->selectedFiles->first(); 469 return d->selectedFiles->first();
472} 470}
473 471
474 472
475bool PlayListWidget::last() { 473bool PlayListWidget::last() {
476 return d->selectedFiles->last(); 474 return d->selectedFiles->last();
477} 475}
478 476
479 477
480 void PlayListWidget::saveList() { 478 void PlayListWidget::saveList() {
481 writem3u(); 479 writem3u();
482 } 480 }
483 481
484 482
485void PlayListWidget::loadList( const DocLnk & lnk) { 483void PlayListWidget::loadList( const DocLnk & lnk) {
486 QString name = lnk.name(); 484 QString name = lnk.name();
487 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 485 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
488 486
489 if( name.length()>0) { 487 if( name.length()>0) {
490 setCaption("OpiePlayer: "+name); 488 setCaption("OpiePlayer: "+name);
491// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 489// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
492 clearList(); 490 clearList();
493 readm3u(lnk.file()); 491 readm3u(lnk.file());
494 tabWidget->setCurrentPage(0); 492 tabWidget->setCurrentPage(0);
495 } 493 }
496} 494}
497 495
498void PlayListWidget::addSelected() { 496void PlayListWidget::addSelected() {
499 assert( inFileListMode() ); 497 assert( inFileListMode() );
500 498
501 QListView *fileListView = currentFileListView(); 499 QListView *fileListView = currentFileListView();
502 QListViewItemIterator it( fileListView ); 500 QListViewItemIterator it( fileListView );
503 for ( ; it.current(); ++it ) 501 for ( ; it.current(); ++it )
504 if ( it.current()->isSelected() ) { 502 if ( it.current()->isSelected() ) {
505 QString filename = it.current()->text(3); 503 QString filename = it.current()->text(3);
506 504
507 DocLnk lnk; 505 DocLnk lnk;
508 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 506 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
509 lnk.setFile( filename ); //sets file name 507 lnk.setFile( filename ); //sets file name
510 508
511 d->selectedFiles->addToSelection( lnk ); 509 d->selectedFiles->addToSelection( lnk );
512 } 510 }
513 511
514 fileListView->clearSelection(); 512 fileListView->clearSelection();
515 513
516 tabWidget->setCurrentPage( 0 ); 514 tabWidget->setCurrentPage( 0 );
517 writeCurrentM3u(); 515 writeCurrentM3u();
518} 516}
519 517
520 518
521void PlayListWidget::removeSelected() { 519void PlayListWidget::removeSelected() {
522 d->selectedFiles->removeSelected( ); 520 d->selectedFiles->removeSelected( );
523 writeCurrentM3u(); 521 writeCurrentM3u();
524} 522}
525 523
526 524
527void PlayListWidget::playIt( QListViewItem *it) { 525void PlayListWidget::playIt( QListViewItem *it) {
528 if(!it) return; 526 if(!it) return;
529 mediaPlayerState.setPlaying(FALSE); 527 mediaPlayerState.setPlaying(FALSE);
530 mediaPlayerState.setPlaying(TRUE); 528 mediaPlayerState.setPlaying(TRUE);
531 d->selectedFiles->unSelect(); 529 d->selectedFiles->unSelect();
532} 530}
533 531
534 532
535void PlayListWidget::addToSelection( QListViewItem *it) { 533void PlayListWidget::addToSelection( QListViewItem *it) {
536 d->setDocumentUsed = FALSE; 534 d->setDocumentUsed = FALSE;
537 535
538 if(it) { 536 if(it) {
539 if ( currentTab() == CurrentPlayList ) 537 if ( currentTab() == CurrentPlayList )
540 return; 538 return;
541 // case 1: { 539 // case 1: {
542 DocLnk lnk; 540 DocLnk lnk;
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
557void PlayListWidget::tabChanged(QWidget *) { 555void 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
611void PlayListWidget::btnPlay(bool b) { 607void 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
617void PlayListWidget::deletePlaylist() { 613void 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
632void PlayListWidget::playSelected() { 628void PlayListWidget::playSelected() {
633 btnPlay( TRUE); 629 btnPlay( TRUE);
634} 630}
635 631
636 632
637void PlayListWidget::scanForAudio() { 633void PlayListWidget::scanForAudio() {
638 audioView->scanFiles(); 634 audioView->scanFiles();
639 audioView->scannedFiles() = true;
640 populateAudioView();
641} 635}
642 636
643void PlayListWidget::scanForVideo() { 637void PlayListWidget::scanForVideo() {
644 videoView->scanFiles(); 638 videoView->scanFiles();
645 videoView->scannedFiles() = true;
646 populateVideoView();
647}
648
649void PlayListWidget::populateAudioView() {
650 audioView->populateView();
651 audioPopulated = true;
652}
653
654void PlayListWidget::populateVideoView() {
655 videoView->populateView();
656 videoPopulated=true;
657} 639}
658 640
659QListView *PlayListWidget::currentFileListView() const 641QListView *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
669bool PlayListWidget::inFileListMode() const 651bool 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
675void PlayListWidget::openFile() { 657void 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");
689 671
690 if(filename.left(4) == "http") { 672 if(filename.left(4) == "http") {
691 QString m3uFile, m3uFilePath; 673 QString m3uFile, m3uFilePath;
692 if(filename.find(":",8,TRUE) != -1) { //found a port 674 if(filename.find(":",8,TRUE) != -1) { //found a port
693 m3uFile = filename.left( filename.find( ":",8,TRUE)); 675 m3uFile = filename.left( filename.find( ":",8,TRUE));
694 m3uFile = m3uFile.right( 7); 676 m3uFile = m3uFile.right( 7);
695 } else if(filename.left(4) == "http"){ 677 } else if(filename.left(4) == "http"){
696 m3uFile=filename; 678 m3uFile=filename;
697 m3uFile = m3uFile.right( m3uFile.length() - 7); 679 m3uFile = m3uFile.right( m3uFile.length() - 7);
698 } else{ 680 } else{
699 m3uFile=filename; 681 m3uFile=filename;
700 } 682 }
701 683
702// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 684// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
703 lnk.setName( filename ); //sets name 685 lnk.setName( filename ); //sets name
704 lnk.setFile( filename ); //sets file name 686 lnk.setFile( filename ); //sets file name
705 687
706// lnk.setIcon("opieplayer2/musicfile"); 688// lnk.setIcon("opieplayer2/musicfile");
707 689
708 d->selectedFiles->addToSelection( lnk ); 690 d->selectedFiles->addToSelection( lnk );
709 writeCurrentM3u(); 691 writeCurrentM3u();
710 d->selectedFiles->setSelectedItem( lnk.name()); 692 d->selectedFiles->setSelectedItem( lnk.name());
711 } 693 }
712 else if( filename.right( 3) == "m3u" ) { 694 else if( filename.right( 3) == "m3u" ) {
713 readm3u( filename ); 695 readm3u( filename );
714 696
715 } else if( filename.right(3) == "pls" ) { 697 } else if( filename.right(3) == "pls" ) {
716 readPls( filename ); 698 readPls( filename );
717 } else { 699 } else {
718 lnk.setName( QFileInfo(filename).baseName() ); //sets name 700 lnk.setName( QFileInfo(filename).baseName() ); //sets name
719 lnk.setFile( filename ); //sets file name 701 lnk.setFile( filename ); //sets file name
720 d->selectedFiles->addToSelection( lnk); 702 d->selectedFiles->addToSelection( lnk);
721 writeCurrentM3u(); 703 writeCurrentM3u();
722 d->selectedFiles->setSelectedItem( lnk.name()); 704 d->selectedFiles->setSelectedItem( lnk.name());
723 } 705 }
724 } 706 }
725 707
726 if( fileDlg ) { 708 if( fileDlg ) {
727 delete fileDlg; 709 delete fileDlg;
728 } 710 }
729} 711}
730 712
731/* 713/*
732reads m3u and shows files/urls to playlist widget */ 714reads m3u and shows files/urls to playlist widget */
733void PlayListWidget::readm3u( const QString &filename ) { 715void PlayListWidget::readm3u( const QString &filename ) {
734 qDebug( "read m3u filename " + filename ); 716 qDebug( "read m3u filename " + filename );
735 717
736 Om3u *m3uList; 718 Om3u *m3uList;
737 QString s, name; 719 QString s, name;
738 m3uList = new Om3u( filename, IO_ReadOnly ); 720 m3uList = new Om3u( filename, IO_ReadOnly );
739 m3uList->readM3u(); 721 m3uList->readM3u();
740 DocLnk lnk; 722 DocLnk lnk;
741 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 723 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
742 s = *it; 724 s = *it;
743// qDebug("reading "+ s); 725// qDebug("reading "+ s);
744 if(s.left(4)=="http") { 726 if(s.left(4)=="http") {
745 lnk.setName( s ); //sets file name 727 lnk.setName( s ); //sets file name
746 lnk.setIcon("opieplayer2/musicfile"); 728 lnk.setIcon("opieplayer2/musicfile");
747 lnk.setFile( s ); //sets file name 729 lnk.setFile( s ); //sets file name
748 730
749 } else { 731 } else {
750 // if( QFileInfo( s ).exists() ) { 732 // if( QFileInfo( s ).exists() ) {
751 lnk.setName( QFileInfo(s).baseName()); 733 lnk.setName( QFileInfo(s).baseName());
752 // if(s.right(4) == '.') {//if regular file 734 // if(s.right(4) == '.') {//if regular file
753 if(s.left(1) != "/") { 735 if(s.left(1) != "/") {
754 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 736 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
755 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 737 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
756// lnk.setIcon(MimeType(s).pixmap() ); 738// lnk.setIcon(MimeType(s).pixmap() );
757// lnk.setIcon("SoundPlayer"); 739// lnk.setIcon("SoundPlayer");
758 } else { 740 } else {
759 // qDebug("set link2 "+s); 741 // qDebug("set link2 "+s);
760 lnk.setFile( s); 742 lnk.setFile( s);
761// lnk.setIcon(MimeType(s).pixmap() ); 743// lnk.setIcon(MimeType(s).pixmap() );
762// lnk.setIcon("SoundPlayer"); 744// lnk.setIcon("SoundPlayer");
763 } 745 }
764 } 746 }
765 d->selectedFiles->addToSelection( lnk ); 747 d->selectedFiles->addToSelection( lnk );
766 } 748 }
767 Config config( "OpiePlayer" ); 749 Config config( "OpiePlayer" );
768 config.setGroup( "PlayList" ); 750 config.setGroup( "PlayList" );
769 751
770 config.writeEntry("CurrentPlaylist",filename); 752 config.writeEntry("CurrentPlaylist",filename);
771 config.write(); 753 config.write();
772 currentPlayList=filename; 754 currentPlayList=filename;
773 755
774// m3uList->write(); 756// m3uList->write();
775 m3uList->close(); 757 m3uList->close();
776 if(m3uList) delete m3uList; 758 if(m3uList) delete m3uList;
777 759
778 d->selectedFiles->setSelectedItem( s); 760 d->selectedFiles->setSelectedItem( s);
779 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 761 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
780 762
781} 763}
782 764
783/* 765/*
784reads pls and adds files/urls to playlist */ 766reads pls and adds files/urls to playlist */
785void PlayListWidget::readPls( const QString &filename ) { 767void PlayListWidget::readPls( const QString &filename ) {
786 768
787 qDebug( "pls filename is " + filename ); 769 qDebug( "pls filename is " + filename );
788 Om3u *m3uList; 770 Om3u *m3uList;
789 QString s, name; 771 QString s, name;
790 m3uList = new Om3u( filename, IO_ReadOnly ); 772 m3uList = new Om3u( filename, IO_ReadOnly );
791 m3uList->readPls(); 773 m3uList->readPls();
792 774
793 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 775 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
794 s = *it; 776 s = *it;
795 // s.replace( QRegExp( "%20" )," " ); 777 // s.replace( QRegExp( "%20" )," " );
796 DocLnk lnk( s ); 778 DocLnk lnk( s );
797 QFileInfo f( s ); 779 QFileInfo f( s );
798 QString name = f.baseName(); 780 QString name = f.baseName();
799 781
800 if( name.left( 4 ) == "http" ) { 782 if( name.left( 4 ) == "http" ) {
801 name = s.right( s.length() - 7); 783 name = s.right( s.length() - 7);
802 } else { 784 } else {
803 name = s; 785 name = s;
804 } 786 }
805 787
806 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 788 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
807 789
808 lnk.setName( name ); 790 lnk.setName( name );
809 if( s.at( s.length() - 4) == '.') {// if this is probably a file 791 if( s.at( s.length() - 4) == '.') {// if this is probably a file
810 lnk.setFile( s ); 792 lnk.setFile( s );
811 } else { //if its a url 793 } else { //if its a url
812// if( name.right( 1 ).find( '/' ) == -1) { 794// if( name.right( 1 ).find( '/' ) == -1) {
813// s += "/"; 795// s += "/";
814// } 796// }
815 lnk.setFile( s ); 797 lnk.setFile( s );
816 } 798 }
817 lnk.setType( "audio/x-mpegurl" ); 799 lnk.setType( "audio/x-mpegurl" );
818 800
819 lnk.writeLink(); 801 lnk.writeLink();
820 d->selectedFiles->addToSelection( lnk ); 802 d->selectedFiles->addToSelection( lnk );
821 } 803 }
822 804
823 m3uList->close(); 805 m3uList->close();
824 if(m3uList) delete m3uList; 806 if(m3uList) delete m3uList;
825} 807}
826 808
827/* 809/*
828 writes current playlist to current m3u file */ 810 writes current playlist to current m3u file */
829void PlayListWidget::writeCurrentM3u() { 811void PlayListWidget::writeCurrentM3u() {
830 qDebug("writing to current m3u"); 812 qDebug("writing to current m3u");
831 Config cfg( "OpiePlayer" ); 813 Config cfg( "OpiePlayer" );
832 cfg.setGroup("PlayList"); 814 cfg.setGroup("PlayList");
833 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 815 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
834 816
835 Om3u *m3uList; 817 Om3u *m3uList;
836 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 818 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
837 if( d->selectedFiles->first()) { 819 if( d->selectedFiles->first()) {
838 820
839 do { 821 do {
840 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 822 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
841 m3uList->add( d->selectedFiles->current()->file() ); 823 m3uList->add( d->selectedFiles->current()->file() );
842 } 824 }
843 while ( d->selectedFiles->next() ); 825 while ( d->selectedFiles->next() );
844 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 826 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
845 m3uList->write(); 827 m3uList->write();
846 m3uList->close(); 828 m3uList->close();
847 829
848 if(m3uList) delete m3uList; 830 if(m3uList) delete m3uList;
849 } 831 }
850 832
851} 833}
852 834
853 /* 835 /*
854 writes current playlist to m3u file */ 836 writes current playlist to m3u file */
855void PlayListWidget::writem3u() { 837void PlayListWidget::writem3u() {
856 InputDialog *fileDlg; 838 InputDialog *fileDlg;
857 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 839 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
858 fileDlg->exec(); 840 fileDlg->exec();
859 QString name, filename, list; 841 QString name, filename, list;
860 Om3u *m3uList; 842 Om3u *m3uList;
861 843
862 if( fileDlg->result() == 1 ) { 844 if( fileDlg->result() == 1 ) {
863 name = fileDlg->text(); 845 name = fileDlg->text();
864// qDebug( filename ); 846// qDebug( filename );
865 847
866 if( name.left( 1) != "/" ) { 848 if( name.left( 1) != "/" ) {
867 filename = QPEApplication::documentDir() + "/" + name; 849 filename = QPEApplication::documentDir() + "/" + name;
868 } 850 }
869 851
870 if( name.right( 3 ) != "m3u" ) { 852 if( name.right( 3 ) != "m3u" ) {
871 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 853 filename = QPEApplication::documentDir() + "/" +name+".m3u";
872 } 854 }
873 855
874 if( d->selectedFiles->first()) { 856 if( d->selectedFiles->first()) {
875 m3uList = new Om3u(filename, IO_ReadWrite); 857 m3uList = new Om3u(filename, IO_ReadWrite);
876 858
877 do { 859 do {
878 m3uList->add( d->selectedFiles->current()->file()); 860 m3uList->add( d->selectedFiles->current()->file());
879 } 861 }
880 while ( d->selectedFiles->next() ); 862 while ( d->selectedFiles->next() );
881 // qDebug( list ); 863 // qDebug( list );
882 m3uList->write(); 864 m3uList->write();
883 m3uList->close(); 865 m3uList->close();
884 if(m3uList) delete m3uList; 866 if(m3uList) delete m3uList;
885 867
886 if(fileDlg) delete fileDlg; 868 if(fileDlg) delete fileDlg;
887 869
888 DocLnk lnk; 870 DocLnk lnk;
889 lnk.setFile( filename); 871 lnk.setFile( filename);
890 lnk.setIcon("opieplayer2/playlist2"); 872 lnk.setIcon("opieplayer2/playlist2");
891 lnk.setName( name); //sets file name 873 lnk.setName( name); //sets file name
892 874
893 // qDebug(filename); 875 // qDebug(filename);
894 Config config( "OpiePlayer" ); 876 Config config( "OpiePlayer" );
895 config.setGroup( "PlayList" ); 877 config.setGroup( "PlayList" );
896 878
897 config.writeEntry("CurrentPlaylist",filename); 879 config.writeEntry("CurrentPlaylist",filename);
898 currentPlayList=filename; 880 currentPlayList=filename;
899 881
900 if(!lnk.writeLink()) { 882 if(!lnk.writeLink()) {
901 qDebug("Writing doclink did not work"); 883 qDebug("Writing doclink did not work");
902 } 884 }
903 885
904 setCaption(tr("OpiePlayer: ") + name); 886 setCaption(tr("OpiePlayer: ") + name);
905 } 887 }
906 } 888 }
907} 889}
908 890
909void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 891void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
910 switch ( e->key() ) { 892 switch ( e->key() ) {
911 ////////////////////////////// Zaurus keys 893 ////////////////////////////// Zaurus keys
912 case Key_F9: //activity 894 case Key_F9: //activity
913 // if(audioUI->isHidden()) 895 // if(audioUI->isHidden())
914 // audioUI->showMaximized(); 896 // audioUI->showMaximized();
915 break; 897 break;
916 case Key_F10: //contacts 898 case Key_F10: //contacts
917 // if( videoUI->isHidden()) 899 // if( videoUI->isHidden())
918 // videoUI->showMaximized(); 900 // videoUI->showMaximized();
919 break; 901 break;
920 case Key_F11: //menu 902 case Key_F11: //menu
921 break; 903 break;
922 case Key_F12: //home 904 case Key_F12: //home
923 // doBlank(); 905 // doBlank();
924 break; 906 break;
925 case Key_F13: //mail 907 case Key_F13: //mail
926 // doUnblank(); 908 // doUnblank();
927 break; 909 break;
928 case Key_Q: //add to playlist 910 case Key_Q: //add to playlist
929 addSelected(); 911 addSelected();
930 break; 912 break;
931 case Key_R: //remove from playlist 913 case Key_R: //remove from playlist
932 removeSelected(); 914 removeSelected();
933 break; 915 break;
934 // case Key_P: //play 916 // case Key_P: //play
935 // qDebug("Play"); 917 // qDebug("Play");
936 // playSelected(); 918 // playSelected();
937 // break; 919 // break;
938 case Key_Space: 920 case Key_Space:
939 // playSelected(); puh 921 // playSelected(); puh
940 break; 922 break;
941 case Key_1: 923 case Key_1:
942 tabWidget->setCurrentPage( 0 ); 924 tabWidget->setCurrentPage( 0 );
943 break; 925 break;
944 case Key_2: 926 case Key_2:
945 tabWidget->setCurrentPage( 1 ); 927 tabWidget->setCurrentPage( 1 );
946 break; 928 break;
947 case Key_3: 929 case Key_3:
948 tabWidget->setCurrentPage( 2 ); 930 tabWidget->setCurrentPage( 2 );
949 break; 931 break;
950 case Key_4: 932 case Key_4:
951 tabWidget->setCurrentPage( 3 ); 933 tabWidget->setCurrentPage( 3 );
952 break; 934 break;
953 case Key_Down: 935 case Key_Down:
954 if ( !d->selectedFiles->next() ) 936 if ( !d->selectedFiles->next() )
955 d->selectedFiles->first(); 937 d->selectedFiles->first();
956 break; 938 break;
957 case Key_Up: 939 case Key_Up:
958 if ( !d->selectedFiles->prev() ) 940 if ( !d->selectedFiles->prev() )
959 // d->selectedFiles->last(); 941 // d->selectedFiles->last();
960 break; 942 break;
961 } 943 }
962} 944}
963 945
964void PlayListWidget::pmViewActivated(int index) { 946void PlayListWidget::pmViewActivated(int index) {
965// qDebug("%d", index); 947// qDebug("%d", index);
966 switch(index) { 948 switch(index) {
967 case -16: 949 case -16:
968 { 950 {
969 mediaPlayerState.toggleFullscreen(); 951 mediaPlayerState.toggleFullscreen();
970 bool b=mediaPlayerState.isFullscreen(); 952 bool b=mediaPlayerState.isFullscreen();
971 pmView->setItemChecked( index, b); 953 pmView->setItemChecked( index, b);
972 Config cfg( "OpiePlayer" ); 954 Config cfg( "OpiePlayer" );
973 cfg.writeEntry( "FullScreen", b ); 955 cfg.writeEntry( "FullScreen", b );
974 } 956 }
975 break; 957 break;
976 }; 958 };
977} 959}
978 960
979void PlayListWidget::populateSkinsMenu() { 961void PlayListWidget::populateSkinsMenu() {
980 int item = 0; 962 int item = 0;
981 defaultSkinIndex = 0; 963 defaultSkinIndex = 0;
982 QString skinName; 964 QString skinName;
983 Config cfg( "OpiePlayer" ); 965 Config cfg( "OpiePlayer" );
984 cfg.setGroup("Options" ); 966 cfg.setGroup("Options" );
985 QString skin = cfg.readEntry( "Skin", "default" ); 967 QString skin = cfg.readEntry( "Skin", "default" );
986 968
987 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 969 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
988 skinsDir.setFilter( QDir::Dirs ); 970 skinsDir.setFilter( QDir::Dirs );
989 skinsDir.setSorting(QDir::Name ); 971 skinsDir.setSorting(QDir::Name );
990 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 972 const QFileInfoList *skinslist = skinsDir.entryInfoList();
991 QFileInfoListIterator it( *skinslist ); 973 QFileInfoListIterator it( *skinslist );
992 QFileInfo *fi; 974 QFileInfo *fi;
993 while ( ( fi = it.current() ) ) { 975 while ( ( fi = it.current() ) ) {
994 skinName = fi->fileName(); 976 skinName = fi->fileName();
995// qDebug( fi->fileName() ); 977// qDebug( fi->fileName() );
996 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 978 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
997 item = skinsMenu->insertItem( fi->fileName() ) ; 979 item = skinsMenu->insertItem( fi->fileName() ) ;
998 } 980 }
999 if( skinName == "default" ) { 981 if( skinName == "default" ) {
1000 defaultSkinIndex = item; 982 defaultSkinIndex = item;
1001 } 983 }
1002 if( skinName == skin ) { 984 if( skinName == skin ) {
1003 skinsMenu->setItemChecked( item, TRUE ); 985 skinsMenu->setItemChecked( item, TRUE );
1004 } 986 }
1005 ++it; 987 ++it;
1006 } 988 }
1007} 989}
1008 990
1009void PlayListWidget::skinsMenuActivated( int item ) { 991void PlayListWidget::skinsMenuActivated( int item ) {
1010 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 992 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1011 skinsMenu->setItemChecked( i, FALSE ); 993 skinsMenu->setItemChecked( i, FALSE );
1012 } 994 }
1013 skinsMenu->setItemChecked( item, TRUE ); 995 skinsMenu->setItemChecked( item, TRUE );
1014 996
1015 { 997 {
1016 Config cfg( "OpiePlayer" ); 998 Config cfg( "OpiePlayer" );
1017 cfg.setGroup("Options"); 999 cfg.setGroup("Options");
1018 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1000 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1019 } 1001 }
1020 1002
1021 emit skinSelected(); 1003 emit skinSelected();
1022} 1004}
1023 1005
1024PlayListWidget::TabType PlayListWidget::currentTab() const 1006PlayListWidget::TabType PlayListWidget::currentTab() const
1025{ 1007{
1026 static const TabType indexToTabType[ TabTypeCount ] = 1008 static const TabType indexToTabType[ TabTypeCount ] =
1027 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 1009 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
1028 1010
1029 int index = tabWidget->currentPageIndex(); 1011 int index = tabWidget->currentPageIndex();
1030 assert( index < TabTypeCount && index >= 0 ); 1012 assert( index < TabTypeCount && index >= 0 );
1031 1013
1032 return indexToTabType[ index ]; 1014 return indexToTabType[ index ];
1033} 1015}
1034 1016
1035PlayListWidget::Entry PlayListWidget::currentEntry() const 1017PlayListWidget::Entry PlayListWidget::currentEntry() const
1036{ 1018{
1037 if ( currentTab() == CurrentPlayList ) { 1019 if ( currentTab() == CurrentPlayList ) {
1038 const DocLnk *lnk = current(); 1020 const DocLnk *lnk = current();
1039 return Entry( lnk->name(), lnk->file() ); 1021 return Entry( lnk->name(), lnk->file() );
1040 } 1022 }
1041 1023
1042 return Entry( currentFileListPathName() ); 1024 return Entry( currentFileListPathName() );
1043} 1025}
1044 1026
1045QString PlayListWidget::currentFileListPathName() const { 1027QString PlayListWidget::currentFileListPathName() const {
1046 return currentFileListView()->currentItem()->text( 3 ); 1028 return currentFileListView()->currentItem()->text( 3 );
1047} 1029}
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
@@ -1,144 +1,141 @@
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;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
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
82public slots: 82public 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;
89protected: 89protected:
90 void keyReleaseEvent( QKeyEvent *e); 90 void keyReleaseEvent( QKeyEvent *e);
91 91
92signals: 92signals:
93 void skinSelected(); 93 void skinSelected();
94 94
95private: 95private:
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
108private slots: 105private 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();
135 132
136private: 133private:
137 bool fromSetDocument; 134 bool fromSetDocument;
138 bool insanityBool; 135 bool insanityBool;
139 QString setDocFileRef, currentPlayList; 136 QString setDocFileRef, currentPlayList;
140 int selected; 137 int selected;
141}; 138};
142 139
143#endif // PLAY_LIST_WIDGET_H 140#endif // PLAY_LIST_WIDGET_H
144 141