summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-04 11:03:26 (UTC)
committer simon <simon>2002-12-04 11:03:26 (UTC)
commit9b30090fddf1cc2e8ffbff70b164213118106167 (patch) (unidiff)
treea328c893928233cd0f17f1842d150ecf87530efe
parent63541c46776721ef5ae63903e5b40838c1c49a43 (diff)
downloadopie-9b30090fddf1cc2e8ffbff70b164213118106167.zip
opie-9b30090fddf1cc2e8ffbff70b164213118106167.tar.gz
opie-9b30090fddf1cc2e8ffbff70b164213118106167.tar.bz2
- moving videoScan and audioScan into PlayListFileView
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.h4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp18
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
4 files changed, 14 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp
index 2726296..1e2ef89 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.cpp
+++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp
@@ -1,36 +1,36 @@
1 1
2#include "playlistfileview.h" 2#include "playlistfileview.h"
3 3
4#include <qpe/global.h> 4#include <qpe/global.h>
5 5
6PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name ) 6PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name )
7 : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ) 7 : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_scannedFiles( false )
8{ 8{
9 addColumn( tr( "Title" ), 140); 9 addColumn( tr( "Title" ), 140);
10 addColumn( tr( "Size" ), -1 ); 10 addColumn( tr( "Size" ), -1 );
11 addColumn(tr( "Media" ), 0 ); 11 addColumn(tr( "Media" ), 0 );
12 addColumn(tr( "Path" ), -1 ); 12 addColumn(tr( "Path" ), -1 );
13 setColumnAlignment( 1, Qt::AlignRight ); 13 setColumnAlignment( 1, Qt::AlignRight );
14 setColumnAlignment( 2, Qt::AlignRight ); 14 setColumnAlignment( 2, Qt::AlignRight );
15 setAllColumnsShowFocus( TRUE ); 15 setAllColumnsShowFocus( TRUE );
16 setSorting( 3, TRUE ); 16 setSorting( 3, TRUE );
17 setMultiSelection( TRUE ); 17 setMultiSelection( TRUE );
18 setSelectionMode( QListView::Extended ); 18 setSelectionMode( QListView::Extended );
19} 19}
20 20
21PlayListFileView::~PlayListFileView() 21PlayListFileView::~PlayListFileView()
22{ 22{
23} 23}
24 24
25void PlayListFileView::scanFiles() 25void PlayListFileView::scanFiles()
26{ 26{
27 m_files.detachChildren(); 27 m_files.detachChildren();
28 QListIterator<DocLnk> sdit( m_files.children() ); 28 QListIterator<DocLnk> sdit( m_files.children() );
29 for ( ; sdit.current(); ++sdit ) 29 for ( ; sdit.current(); ++sdit )
30 delete sdit.current(); 30 delete sdit.current();
31 31
32 Global::findDocuments( &m_files, m_mimeTypePattern ); 32 Global::findDocuments( &m_files, m_mimeTypePattern );
33} 33}
34 34
35/* vim: et sw=4 ts=4 35/* vim: et sw=4 ts=4
36 */ 36 */
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h
index 08db929..4e17966 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.h
+++ b/noncore/multimedia/opieplayer2/playlistfileview.h
@@ -1,27 +1,31 @@
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, QWidget *parent, const char *name = 0 ); 12 PlayListFileView( const QString &mimeTypePattern, 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
16 // been migrated into this class
15 DocLnkSet &files() { return m_files; } 17 DocLnkSet &files() { return m_files; }
18 bool &scannedFiles() { return m_scannedFiles; }
16 19
17public slots: 20public slots:
18 void scanFiles(); 21 void scanFiles();
19 22
20private: 23private:
21 QString m_mimeTypePattern; 24 QString m_mimeTypePattern;
22 DocLnkSet m_files; 25 DocLnkSet m_files;
26 bool m_scannedFiles;
23}; 27};
24 28
25#endif // PLAYLISTFILEVIEW_H 29#endif // PLAYLISTFILEVIEW_H
26/* vim: et sw=4 ts=4 30/* vim: et sw=4 ts=4
27 */ 31 */
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 93e7919..12b8a71 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1082 +1,1080 @@
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 videoScan=false;
155 audioScan=false;
156 audioPopulated=false; 154 audioPopulated=false;
157 videoPopulated=false; 155 videoPopulated=false;
158 populateSkinsMenu(); 156 populateSkinsMenu();
159 initializeStates(); 157 initializeStates();
160 158
161 cfg.setGroup("PlayList"); 159 cfg.setGroup("PlayList");
162 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
163 loadList(DocLnk( currentPlaylist ) ); 161 loadList(DocLnk( currentPlaylist ) );
164} 162}
165 163
166 164
167PlayListWidget::~PlayListWidget() { 165PlayListWidget::~PlayListWidget() {
168 delete d; 166 delete d;
169} 167}
170 168
171 169
172void PlayListWidget::initializeStates() { 170void PlayListWidget::initializeStates() {
173 d->tbPlay->setOn( mediaPlayerState.isPlaying() ); 171 d->tbPlay->setOn( mediaPlayerState.isPlaying() );
174 d->tbLoop->setOn( mediaPlayerState.isLooping() ); 172 d->tbLoop->setOn( mediaPlayerState.isLooping() );
175 d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); 173 d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
176 d->playListFrame->show(); 174 d->playListFrame->show();
177} 175}
178 176
179void PlayListWidget::writeDefaultPlaylist() { 177void PlayListWidget::writeDefaultPlaylist() {
180 178
181 Config config( "OpiePlayer" ); 179 Config config( "OpiePlayer" );
182 config.setGroup( "PlayList" ); 180 config.setGroup( "PlayList" );
183 QString filename=QPEApplication::documentDir() + "/default.m3u"; 181 QString filename=QPEApplication::documentDir() + "/default.m3u";
184 QString currentString = config.readEntry( "CurrentPlaylist", filename); 182 QString currentString = config.readEntry( "CurrentPlaylist", filename);
185 if( currentString == filename) { 183 if( currentString == filename) {
186 Om3u *m3uList; 184 Om3u *m3uList;
187 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 185 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
188 if( d->selectedFiles->first() ) { 186 if( d->selectedFiles->first() ) {
189 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 187 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
190 do { 188 do {
191 // qDebug(d->selectedFiles->current()->file()); 189 // qDebug(d->selectedFiles->current()->file());
192 m3uList->add( d->selectedFiles->current()->file() ); 190 m3uList->add( d->selectedFiles->current()->file() );
193 } 191 }
194 while ( d->selectedFiles->next() ); 192 while ( d->selectedFiles->next() );
195 193
196 m3uList->write(); 194 m3uList->write();
197 m3uList->close(); 195 m3uList->close();
198 if(m3uList) delete m3uList; 196 if(m3uList) delete m3uList;
199 197
200 } 198 }
201 } 199 }
202} 200}
203 201
204void PlayListWidget::addToSelection( const DocLnk& lnk ) { 202void PlayListWidget::addToSelection( const DocLnk& lnk ) {
205 d->setDocumentUsed = FALSE; 203 d->setDocumentUsed = FALSE;
206 if( QFileInfo( lnk.file() ).exists() || 204 if( QFileInfo( lnk.file() ).exists() ||
207 lnk.file().left(4) == "http" ) { 205 lnk.file().left(4) == "http" ) {
208 d->selectedFiles->addToSelection( lnk ); 206 d->selectedFiles->addToSelection( lnk );
209 } 207 }
210// writeCurrentM3u(); 208// writeCurrentM3u();
211} 209}
212 210
213 211
214void PlayListWidget::clearList() { 212void PlayListWidget::clearList() {
215 while ( first() ) { 213 while ( first() ) {
216 d->selectedFiles->removeSelected(); 214 d->selectedFiles->removeSelected();
217 } 215 }
218} 216}
219 217
220void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 218void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
221 switch (mouse) { 219 switch (mouse) {
222 case 1: 220 case 1:
223 break; 221 break;
224 case 2: 222 case 2:
225 { 223 {
226 QPopupMenu m; 224 QPopupMenu m;
227 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 225 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
228 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 226 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
229 m.exec( QCursor::pos() ); 227 m.exec( QCursor::pos() );
230 } 228 }
231 break; 229 break;
232 } 230 }
233} 231}
234 232
235 233
236void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 234void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
237 switch (mouse) { 235 switch (mouse) {
238 case 1: 236 case 1:
239 break; 237 break;
240 case 2: 238 case 2:
241 { 239 {
242 QPopupMenu m; 240 QPopupMenu m;
243 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 241 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
244 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 242 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
245 m.exec( QCursor::pos() ); 243 m.exec( QCursor::pos() );
246 } 244 }
247 break; 245 break;
248 } 246 }
249} 247}
250 248
251 249
252void PlayListWidget::addAllToList() { 250void PlayListWidget::addAllToList() {
253 251
254// QTime t; 252// QTime t;
255// t.start(); 253// t.start();
256 254
257 if(!audioScan) { 255 if(!audioView->scannedFiles()) {
258 if(audioView->childCount() < 1) 256 if(audioView->childCount() < 1)
259 populateAudioView(); 257 populateAudioView();
260 } 258 }
261 259
262 QListViewItemIterator audioIt( audioView ); 260 QListViewItemIterator audioIt( audioView );
263 DocLnk lnk; 261 DocLnk lnk;
264 QString filename; 262 QString filename;
265 // iterate through all items of the listview 263 // iterate through all items of the listview
266 for ( ; audioIt.current(); ++audioIt ) { 264 for ( ; audioIt.current(); ++audioIt ) {
267 filename = audioIt.current()->text(3); 265 filename = audioIt.current()->text(3);
268 lnk.setName( QFileInfo(filename).baseName() ); //sets name 266 lnk.setName( QFileInfo(filename).baseName() ); //sets name
269 lnk.setFile( filename ); //sets file name 267 lnk.setFile( filename ); //sets file name
270 d->selectedFiles->addToSelection( lnk); 268 d->selectedFiles->addToSelection( lnk);
271 } 269 }
272 270
273 if(!videoScan) { 271 if(!videoView->scannedFiles()) {
274 if(videoView->childCount() < 1) 272 if(videoView->childCount() < 1)
275 populateVideoView(); 273 populateVideoView();
276 } 274 }
277 275
278 QListViewItemIterator videoIt( videoView ); 276 QListViewItemIterator videoIt( videoView );
279 for ( ; videoIt.current(); ++videoIt ) { 277 for ( ; videoIt.current(); ++videoIt ) {
280 filename = videoIt.current()->text(3); 278 filename = videoIt.current()->text(3);
281 lnk.setName( QFileInfo(filename).baseName() ); //sets name 279 lnk.setName( QFileInfo(filename).baseName() ); //sets name
282 lnk.setFile( filename ); //sets file name 280 lnk.setFile( filename ); //sets file name
283 d->selectedFiles->addToSelection( lnk); 281 d->selectedFiles->addToSelection( lnk);
284 } 282 }
285 283
286 // d->selectedFiles->addToSelection( ); 284 // d->selectedFiles->addToSelection( );
287 // if ( it.current()->isSelected() ) 285 // if ( it.current()->isSelected() )
288 // lst->append( audioIt.current() ); 286 // lst->append( audioIt.current() );
289 // } 287 // }
290 288
291 289
292// if(!audioScan) 290// if(!audioScan)
293// scanForAudio(); 291// scanForAudio();
294// if(!videoScan) 292// if(!videoScan)
295// scanForVideo(); 293// scanForVideo();
296 294
297// DocLnkSet filesAll; 295// DocLnkSet filesAll;
298// Global::findDocuments(&filesAll, "video/*;"+audioMimes); 296// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
299// QListIterator<DocLnk> Adit( filesAll.children() ); 297// QListIterator<DocLnk> Adit( filesAll.children() );
300// for ( ; Adit.current(); ++Adit ) { 298// for ( ; Adit.current(); ++Adit ) {
301// if( QFileInfo( Adit.current()->file() ).exists() ) { 299// if( QFileInfo( Adit.current()->file() ).exists() ) {
302// d->selectedFiles->addToSelection( **Adit ); 300// d->selectedFiles->addToSelection( **Adit );
303// } 301// }
304// } 302// }
305 303
306 // qDebug("elapsed time %d", t.elapsed() ); 304 // qDebug("elapsed time %d", t.elapsed() );
307 305
308 tabWidget->setCurrentPage(0); 306 tabWidget->setCurrentPage(0);
309 307
310 writeCurrentM3u(); 308 writeCurrentM3u();
311 d->selectedFiles->first(); 309 d->selectedFiles->first();
312} 310}
313 311
314 312
315void PlayListWidget::addAllMusicToList() { 313void PlayListWidget::addAllMusicToList() {
316 314
317 if(!audioScan) { 315 if(!audioView->scannedFiles()) {
318 if(audioView->childCount() < 1) 316 if(audioView->childCount() < 1)
319 populateAudioView(); 317 populateAudioView();
320 } 318 }
321 319
322 QListViewItemIterator audioIt( audioView ); 320 QListViewItemIterator audioIt( audioView );
323 DocLnk lnk; 321 DocLnk lnk;
324 QString filename; 322 QString filename;
325 // iterate through all items of the listview 323 // iterate through all items of the listview
326 for ( ; audioIt.current(); ++audioIt ) { 324 for ( ; audioIt.current(); ++audioIt ) {
327 filename = audioIt.current()->text(3); 325 filename = audioIt.current()->text(3);
328 lnk.setName( QFileInfo(filename).baseName() ); //sets name 326 lnk.setName( QFileInfo(filename).baseName() ); //sets name
329 lnk.setFile( filename ); //sets file name 327 lnk.setFile( filename ); //sets file name
330 d->selectedFiles->addToSelection( lnk); 328 d->selectedFiles->addToSelection( lnk);
331 } 329 }
332 330
333 /* if(!audioScan) 331 /* if(!audioScan)
334 scanForAudio(); 332 scanForAudio();
335 QListIterator<DocLnk> dit( files.children() ); 333 QListIterator<DocLnk> dit( files.children() );
336 for ( ; dit.current(); ++dit ) { 334 for ( ; dit.current(); ++dit ) {
337 if( QFileInfo(dit.current()->file() ).exists() ) { 335 if( QFileInfo(dit.current()->file() ).exists() ) {
338 d->selectedFiles->addToSelection( **dit ); 336 d->selectedFiles->addToSelection( **dit );
339 } 337 }
340 } 338 }
341 */ 339 */
342 tabWidget->setCurrentPage(0); 340 tabWidget->setCurrentPage(0);
343 writeCurrentM3u(); 341 writeCurrentM3u();
344 d->selectedFiles->first(); 342 d->selectedFiles->first();
345} 343}
346 344
347 345
348void PlayListWidget::addAllVideoToList() { 346void PlayListWidget::addAllVideoToList() {
349 347
350 if(!videoScan) { 348 if(!videoView->scannedFiles()) {
351 if(videoView->childCount() < 1) 349 if(videoView->childCount() < 1)
352 populateVideoView(); 350 populateVideoView();
353 } 351 }
354 352
355 QListViewItemIterator videoIt( videoView ); 353 QListViewItemIterator videoIt( videoView );
356 DocLnk lnk; 354 DocLnk lnk;
357 QString filename; 355 QString filename;
358 for ( ; videoIt.current(); ++videoIt ) { 356 for ( ; videoIt.current(); ++videoIt ) {
359 filename = videoIt.current()->text(3); 357 filename = videoIt.current()->text(3);
360 lnk.setName( QFileInfo(filename).baseName() ); //sets name 358 lnk.setName( QFileInfo(filename).baseName() ); //sets name
361 lnk.setFile( filename ); //sets file name 359 lnk.setFile( filename ); //sets file name
362 d->selectedFiles->addToSelection( lnk); 360 d->selectedFiles->addToSelection( lnk);
363 } 361 }
364 362
365 363
366 /* if(!videoScan) 364 /* if(!videoScan)
367 scanForVideo(); 365 scanForVideo();
368 QListIterator<DocLnk> dit( vFiles.children() ); 366 QListIterator<DocLnk> dit( vFiles.children() );
369 for ( ; dit.current(); ++dit ) { 367 for ( ; dit.current(); ++dit ) {
370 if( QFileInfo( dit.current()->file() ).exists() ) { 368 if( QFileInfo( dit.current()->file() ).exists() ) {
371 d->selectedFiles->addToSelection( **dit ); 369 d->selectedFiles->addToSelection( **dit );
372 } 370 }
373 } 371 }
374*/ 372*/
375 tabWidget->setCurrentPage(0); 373 tabWidget->setCurrentPage(0);
376 writeCurrentM3u(); 374 writeCurrentM3u();
377 d->selectedFiles->first(); 375 d->selectedFiles->first();
378} 376}
379 377
380 378
381void PlayListWidget::setDocument( const QString& fileref ) { 379void PlayListWidget::setDocument( const QString& fileref ) {
382 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 380 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
383 fromSetDocument = TRUE; 381 fromSetDocument = TRUE;
384 if ( fileref.isNull() ) { 382 if ( fileref.isNull() ) {
385 QMessageBox::warning( this, tr( "Invalid File" ), 383 QMessageBox::warning( this, tr( "Invalid File" ),
386 tr( "There was a problem in getting the file." ) ); 384 tr( "There was a problem in getting the file." ) );
387 return; 385 return;
388 } 386 }
389 387
390 clearList(); 388 clearList();
391 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 389 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
392 readm3u( fileref ); 390 readm3u( fileref );
393 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 391 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
394 readm3u( DocLnk( fileref).file() ); 392 readm3u( DocLnk( fileref).file() );
395 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 393 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
396 readPls( fileref ); 394 readPls( fileref );
397 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 395 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
398 readPls( DocLnk( fileref).file() ); 396 readPls( DocLnk( fileref).file() );
399 } else { 397 } else {
400 clearList(); 398 clearList();
401 addToSelection( DocLnk( fileref ) ); 399 addToSelection( DocLnk( fileref ) );
402 writeCurrentM3u(); 400 writeCurrentM3u();
403 401
404 d->setDocumentUsed = TRUE; 402 d->setDocumentUsed = TRUE;
405 mediaPlayerState.setPlaying( FALSE ); 403 mediaPlayerState.setPlaying( FALSE );
406 mediaPlayerState.setPlaying( TRUE ); 404 mediaPlayerState.setPlaying( TRUE );
407 } 405 }
408} 406}
409 407
410 408
411void PlayListWidget::useSelectedDocument() { 409void PlayListWidget::useSelectedDocument() {
412 d->setDocumentUsed = FALSE; 410 d->setDocumentUsed = FALSE;
413} 411}
414 412
415 413
416const DocLnk *PlayListWidget::current() const { // this is fugly 414const DocLnk *PlayListWidget::current() const { // this is fugly
417 assert( currentTab() == CurrentPlayList ); 415 assert( currentTab() == CurrentPlayList );
418 416
419 const DocLnk *lnk = d->selectedFiles->current(); 417 const DocLnk *lnk = d->selectedFiles->current();
420 if ( !lnk ) { 418 if ( !lnk ) {
421 d->selectedFiles->first(); 419 d->selectedFiles->first();
422 lnk = d->selectedFiles->current(); 420 lnk = d->selectedFiles->current();
423 } 421 }
424 assert( lnk ); 422 assert( lnk );
425 return lnk; 423 return lnk;
426} 424}
427 425
428 426
429bool PlayListWidget::prev() { 427bool PlayListWidget::prev() {
430 if ( mediaPlayerState.isShuffled() ) { 428 if ( mediaPlayerState.isShuffled() ) {
431 const DocLnk *cur = current(); 429 const DocLnk *cur = current();
432 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 430 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
433 for ( int i = 0; i < j; i++ ) { 431 for ( int i = 0; i < j; i++ ) {
434 if ( !d->selectedFiles->next() ) 432 if ( !d->selectedFiles->next() )
435 d->selectedFiles->first(); 433 d->selectedFiles->first();
436 } 434 }
437 if ( cur == current() ) 435 if ( cur == current() )
438 if ( !d->selectedFiles->next() ) { 436 if ( !d->selectedFiles->next() ) {
439 d->selectedFiles->first(); 437 d->selectedFiles->first();
440 } 438 }
441 return TRUE; 439 return TRUE;
442 } else { 440 } else {
443 if ( !d->selectedFiles->prev() ) { 441 if ( !d->selectedFiles->prev() ) {
444 if ( mediaPlayerState.isLooping() ) { 442 if ( mediaPlayerState.isLooping() ) {
445 return d->selectedFiles->last(); 443 return d->selectedFiles->last();
446 } else { 444 } else {
447 return FALSE; 445 return FALSE;
448 } 446 }
449 } 447 }
450 return TRUE; 448 return TRUE;
451 } 449 }
452} 450}
453 451
454 452
455bool PlayListWidget::next() { 453bool PlayListWidget::next() {
456//qDebug("<<<<<<<<<<<<next()"); 454//qDebug("<<<<<<<<<<<<next()");
457 if ( mediaPlayerState.isShuffled() ) { 455 if ( mediaPlayerState.isShuffled() ) {
458 return prev(); 456 return prev();
459 } else { 457 } else {
460 if ( !d->selectedFiles->next() ) { 458 if ( !d->selectedFiles->next() ) {
461 if ( mediaPlayerState.isLooping() ) { 459 if ( mediaPlayerState.isLooping() ) {
462 return d->selectedFiles->first(); 460 return d->selectedFiles->first();
463 } else { 461 } else {
464 return FALSE; 462 return FALSE;
465 } 463 }
466 } 464 }
467 return TRUE; 465 return TRUE;
468 } 466 }
469} 467}
470 468
471 469
472bool PlayListWidget::first() { 470bool PlayListWidget::first() {
473 return d->selectedFiles->first(); 471 return d->selectedFiles->first();
474} 472}
475 473
476 474
477bool PlayListWidget::last() { 475bool PlayListWidget::last() {
478 return d->selectedFiles->last(); 476 return d->selectedFiles->last();
479} 477}
480 478
481 479
482 void PlayListWidget::saveList() { 480 void PlayListWidget::saveList() {
483 writem3u(); 481 writem3u();
484 } 482 }
485 483
486 484
487void PlayListWidget::loadList( const DocLnk & lnk) { 485void PlayListWidget::loadList( const DocLnk & lnk) {
488 QString name = lnk.name(); 486 QString name = lnk.name();
489 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 487 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
490 488
491 if( name.length()>0) { 489 if( name.length()>0) {
492 setCaption("OpiePlayer: "+name); 490 setCaption("OpiePlayer: "+name);
493// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 491// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
494 clearList(); 492 clearList();
495 readm3u(lnk.file()); 493 readm3u(lnk.file());
496 tabWidget->setCurrentPage(0); 494 tabWidget->setCurrentPage(0);
497 } 495 }
498} 496}
499 497
500void PlayListWidget::addSelected() { 498void PlayListWidget::addSelected() {
501 assert( inFileListMode() ); 499 assert( inFileListMode() );
502 500
503 QListView *fileListView = currentFileListView(); 501 QListView *fileListView = currentFileListView();
504 QListViewItemIterator it( fileListView ); 502 QListViewItemIterator it( fileListView );
505 for ( ; it.current(); ++it ) 503 for ( ; it.current(); ++it )
506 if ( it.current()->isSelected() ) { 504 if ( it.current()->isSelected() ) {
507 QString filename = it.current()->text(3); 505 QString filename = it.current()->text(3);
508 506
509 DocLnk lnk; 507 DocLnk lnk;
510 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 508 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
511 lnk.setFile( filename ); //sets file name 509 lnk.setFile( filename ); //sets file name
512 510
513 d->selectedFiles->addToSelection( lnk ); 511 d->selectedFiles->addToSelection( lnk );
514 } 512 }
515 513
516 fileListView->clearSelection(); 514 fileListView->clearSelection();
517 515
518 tabWidget->setCurrentPage( 0 ); 516 tabWidget->setCurrentPage( 0 );
519 writeCurrentM3u(); 517 writeCurrentM3u();
520} 518}
521 519
522 520
523void PlayListWidget::removeSelected() { 521void PlayListWidget::removeSelected() {
524 d->selectedFiles->removeSelected( ); 522 d->selectedFiles->removeSelected( );
525 writeCurrentM3u(); 523 writeCurrentM3u();
526} 524}
527 525
528 526
529void PlayListWidget::playIt( QListViewItem *it) { 527void PlayListWidget::playIt( QListViewItem *it) {
530 if(!it) return; 528 if(!it) return;
531 mediaPlayerState.setPlaying(FALSE); 529 mediaPlayerState.setPlaying(FALSE);
532 mediaPlayerState.setPlaying(TRUE); 530 mediaPlayerState.setPlaying(TRUE);
533 d->selectedFiles->unSelect(); 531 d->selectedFiles->unSelect();
534} 532}
535 533
536 534
537void PlayListWidget::addToSelection( QListViewItem *it) { 535void PlayListWidget::addToSelection( QListViewItem *it) {
538 d->setDocumentUsed = FALSE; 536 d->setDocumentUsed = FALSE;
539 537
540 if(it) { 538 if(it) {
541 if ( currentTab() == CurrentPlayList ) 539 if ( currentTab() == CurrentPlayList )
542 return; 540 return;
543 // case 1: { 541 // case 1: {
544 DocLnk lnk; 542 DocLnk lnk;
545 QString filename; 543 QString filename;
546 544
547 filename=it->text(3); 545 filename=it->text(3);
548 lnk.setName( QFileInfo(filename).baseName() ); //sets name 546 lnk.setName( QFileInfo(filename).baseName() ); //sets name
549 lnk.setFile( filename ); //sets file name 547 lnk.setFile( filename ); //sets file name
550 d->selectedFiles->addToSelection( lnk); 548 d->selectedFiles->addToSelection( lnk);
551 549
552 writeCurrentM3u(); 550 writeCurrentM3u();
553 tabWidget->setCurrentPage(0); 551 tabWidget->setCurrentPage(0);
554 552
555 } 553 }
556} 554}
557 555
558 556
559void PlayListWidget::tabChanged(QWidget *) { 557void PlayListWidget::tabChanged(QWidget *) {
560 558
561 d->tbPlay->setEnabled( true ); 559 d->tbPlay->setEnabled( true );
562 560
563 switch ( currentTab() ) { 561 switch ( currentTab() ) {
564 case CurrentPlayList: 562 case CurrentPlayList:
565 { 563 {
566 if( !tbDeletePlaylist->isHidden() ) { 564 if( !tbDeletePlaylist->isHidden() ) {
567 tbDeletePlaylist->hide(); 565 tbDeletePlaylist->hide();
568 } 566 }
569 d->tbRemoveFromList->setEnabled(TRUE); 567 d->tbRemoveFromList->setEnabled(TRUE);
570 d->tbAddToList->setEnabled(FALSE); 568 d->tbAddToList->setEnabled(FALSE);
571 569
572 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 570 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
573 } 571 }
574 break; 572 break;
575 case AudioFiles: 573 case AudioFiles:
576 { 574 {
577 // audioView->clear(); 575 // audioView->clear();
578 if(!audioPopulated) populateAudioView(); 576 if(!audioPopulated) populateAudioView();
579 577
580 if( !tbDeletePlaylist->isHidden() ) { 578 if( !tbDeletePlaylist->isHidden() ) {
581 tbDeletePlaylist->hide(); 579 tbDeletePlaylist->hide();
582 } 580 }
583 d->tbRemoveFromList->setEnabled(FALSE); 581 d->tbRemoveFromList->setEnabled(FALSE);
584 d->tbAddToList->setEnabled(TRUE); 582 d->tbAddToList->setEnabled(TRUE);
585 } 583 }
586 break; 584 break;
587 case VideoFiles: 585 case VideoFiles:
588 { 586 {
589 // videoView->clear(); 587 // videoView->clear();
590 if(!videoPopulated) populateVideoView(); 588 if(!videoPopulated) populateVideoView();
591 if( !tbDeletePlaylist->isHidden() ) { 589 if( !tbDeletePlaylist->isHidden() ) {
592 tbDeletePlaylist->hide(); 590 tbDeletePlaylist->hide();
593 } 591 }
594 d->tbRemoveFromList->setEnabled(FALSE); 592 d->tbRemoveFromList->setEnabled(FALSE);
595 d->tbAddToList->setEnabled(TRUE); 593 d->tbAddToList->setEnabled(TRUE);
596 } 594 }
597 break; 595 break;
598 case PlayLists: 596 case PlayLists:
599 { 597 {
600 if( tbDeletePlaylist->isHidden() ) { 598 if( tbDeletePlaylist->isHidden() ) {
601 tbDeletePlaylist->show(); 599 tbDeletePlaylist->show();
602 } 600 }
603 playLists->reread(); 601 playLists->reread();
604 d->tbAddToList->setEnabled(FALSE); 602 d->tbAddToList->setEnabled(FALSE);
605 603
606 d->tbPlay->setEnabled( false ); 604 d->tbPlay->setEnabled( false );
607 } 605 }
608 break; 606 break;
609 }; 607 };
610} 608}
611 609
612 610
613void PlayListWidget::btnPlay(bool b) { 611void PlayListWidget::btnPlay(bool b) {
614// mediaPlayerState->setPlaying(false); 612// mediaPlayerState->setPlaying(false);
615 mediaPlayerState.setPlaying(b); 613 mediaPlayerState.setPlaying(b);
616 insanityBool=FALSE; 614 insanityBool=FALSE;
617} 615}
618 616
619void PlayListWidget::deletePlaylist() { 617void PlayListWidget::deletePlaylist() {
620 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 618 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
621 (tr("You really want to delete\nthis playlist?")), 619 (tr("You really want to delete\nthis playlist?")),
622 (tr("Yes")), (tr("No")), 0 )){ 620 (tr("Yes")), (tr("No")), 0 )){
623 case 0: // Yes clicked, 621 case 0: // Yes clicked,
624 QFile().remove(playLists->selectedDocument().file()); 622 QFile().remove(playLists->selectedDocument().file());
625 QFile().remove(playLists->selectedDocument().linkFile()); 623 QFile().remove(playLists->selectedDocument().linkFile());
626 playLists->reread(); 624 playLists->reread();
627 break; 625 break;
628 case 1: // Cancel 626 case 1: // Cancel
629 break; 627 break;
630 }; 628 };
631} 629}
632 630
633 631
634void PlayListWidget::playSelected() { 632void PlayListWidget::playSelected() {
635 btnPlay( TRUE); 633 btnPlay( TRUE);
636} 634}
637 635
638 636
639void PlayListWidget::scanForAudio() { 637void PlayListWidget::scanForAudio() {
640 audioView->scanFiles(); 638 audioView->scanFiles();
641 audioScan = true; 639 audioView->scannedFiles() = true;
642 populateAudioView(); 640 populateAudioView();
643} 641}
644 642
645void PlayListWidget::scanForVideo() { 643void PlayListWidget::scanForVideo() {
646 videoView->scanFiles(); 644 videoView->scanFiles();
647 videoScan = true; 645 videoView->scannedFiles() = true;
648 populateVideoView(); 646 populateVideoView();
649} 647}
650 648
651void PlayListWidget::populateAudioView() { 649void PlayListWidget::populateAudioView() {
652 audioView->clear(); 650 audioView->clear();
653 StorageInfo storageInfo; 651 StorageInfo storageInfo;
654 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 652 // const QList<FileSystem> &fs = storageInfo.fileSystems();
655 if(!audioScan) { 653 if(!audioView->scannedFiles()) {
656 scanForAudio(); 654 scanForAudio();
657 } 655 }
658 656
659 QListIterator<DocLnk> dit( audioView->files().children() ); 657 QListIterator<DocLnk> dit( audioView->files().children() );
660 // QListIterator<FileSystem> it ( fs ); 658 // QListIterator<FileSystem> it ( fs );
661 audioView->clear(); 659 audioView->clear();
662 660
663 QString storage; 661 QString storage;
664 for ( ; dit.current(); ++dit ) { 662 for ( ; dit.current(); ++dit ) {
665// // for( ; it.current(); ++it ){ 663// // for( ; it.current(); ++it ){
666// const QString name = (*dit)->name(); 664// const QString name = (*dit)->name();
667// const QString path = (*dit)->path(); 665// const QString path = (*dit)->path();
668// if(dit.current()->file().find(path) != -1 ) { 666// if(dit.current()->file().find(path) != -1 ) {
669// storage = name; 667// storage = name;
670// // } 668// // }
671// } 669// }
672 670
673 QListViewItem * newItem; 671 QListViewItem * newItem;
674 if ( QFile( dit.current()->file()).exists() || 672 if ( QFile( dit.current()->file()).exists() ||
675 dit.current()->file().left(4) == "http" ) { 673 dit.current()->file().left(4) == "http" ) {
676 long size; 674 long size;
677 if( dit.current()->file().left(4) == "http" ) 675 if( dit.current()->file().left(4) == "http" )
678 size=0; 676 size=0;
679 else 677 else
680 size = QFile( dit.current()->file() ).size(); 678 size = QFile( dit.current()->file() ).size();
681 679
682 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 680 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
683 QString::number(size ), "" /*storage*/, 681 QString::number(size ), "" /*storage*/,
684 dit.current()->file() ); 682 dit.current()->file() );
685 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 683 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
686// qDebug("<<<< "+dit.current()->file()); 684// qDebug("<<<< "+dit.current()->file());
687 } 685 }
688 } 686 }
689 audioPopulated=true; 687 audioPopulated=true;
690} 688}
691 689
692 690
693void PlayListWidget::populateVideoView() { 691void PlayListWidget::populateVideoView() {
694 videoView->clear(); 692 videoView->clear();
695 StorageInfo storageInfo; 693 StorageInfo storageInfo;
696 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 694 // const QList<FileSystem> &fs = storageInfo.fileSystems();
697 695
698 if(!videoScan ) { 696 if(!videoView->scannedFiles()) {
699 scanForVideo(); 697 scanForVideo();
700 } 698 }
701 699
702 QListIterator<DocLnk> Vdit( videoView->files().children() ); 700 QListIterator<DocLnk> Vdit( videoView->files().children() );
703// QListIterator<FileSystem> it ( fs ); 701// QListIterator<FileSystem> it ( fs );
704 videoView->clear(); 702 videoView->clear();
705 QString storage, pathName; 703 QString storage, pathName;
706 for ( ; Vdit.current(); ++Vdit ) { 704 for ( ; Vdit.current(); ++Vdit ) {
707// // for( ; it.current(); ++it ) { 705// // for( ; it.current(); ++it ) {
708// const QString name = (*Vdit)->name(); 706// const QString name = (*Vdit)->name();
709// const QString path = (*Vdit)->path(); 707// const QString path = (*Vdit)->path();
710// if( Vdit.current()->file().find(path) != -1 ) { 708// if( Vdit.current()->file().find(path) != -1 ) {
711// storage=name; 709// storage=name;
712// pathName=path; 710// pathName=path;
713// // } 711// // }
714// } 712// }
715 713
716 QListViewItem * newItem; 714 QListViewItem * newItem;
717 if ( QFile( Vdit.current()->file() ).exists() ) { 715 if ( QFile( Vdit.current()->file() ).exists() ) {
718 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 716 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
719 QString::number( QFile( Vdit.current()->file() ).size() ), 717 QString::number( QFile( Vdit.current()->file() ).size() ),
720 ""/*storage*/, Vdit.current()->file()); 718 ""/*storage*/, Vdit.current()->file());
721 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 719 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
722 } 720 }
723 } 721 }
724 videoPopulated=true; 722 videoPopulated=true;
725} 723}
726 724
727QListView *PlayListWidget::currentFileListView() const 725QListView *PlayListWidget::currentFileListView() const
728{ 726{
729 switch ( currentTab() ) { 727 switch ( currentTab() ) {
730 case AudioFiles: return audioView; 728 case AudioFiles: return audioView;
731 case VideoFiles: return videoView; 729 case VideoFiles: return videoView;
732 default: assert( false ); 730 default: assert( false );
733 } 731 }
734 return 0; 732 return 0;
735} 733}
736 734
737bool PlayListWidget::inFileListMode() const 735bool PlayListWidget::inFileListMode() const
738{ 736{
739 TabType tab = currentTab(); 737 TabType tab = currentTab();
740 return tab == AudioFiles || tab == VideoFiles; 738 return tab == AudioFiles || tab == VideoFiles;
741} 739}
742 740
743void PlayListWidget::openFile() { 741void PlayListWidget::openFile() {
744 // http://66.28.164.33:2080 742 // http://66.28.164.33:2080
745 // http://somafm.com/star0242.m3u 743 // http://somafm.com/star0242.m3u
746 QString filename, name; 744 QString filename, name;
747 InputDialog *fileDlg; 745 InputDialog *fileDlg;
748 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 746 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
749 fileDlg->exec(); 747 fileDlg->exec();
750 if( fileDlg->result() == 1 ) { 748 if( fileDlg->result() == 1 ) {
751 filename = fileDlg->text(); 749 filename = fileDlg->text();
752 qDebug( "Selected filename is " + filename ); 750 qDebug( "Selected filename is " + filename );
753 // Om3u *m3uList; 751 // Om3u *m3uList;
754 DocLnk lnk; 752 DocLnk lnk;
755 Config cfg( "OpiePlayer" ); 753 Config cfg( "OpiePlayer" );
756 cfg.setGroup("PlayList"); 754 cfg.setGroup("PlayList");
757 755
758 if(filename.left(4) == "http") { 756 if(filename.left(4) == "http") {
759 QString m3uFile, m3uFilePath; 757 QString m3uFile, m3uFilePath;
760 if(filename.find(":",8,TRUE) != -1) { //found a port 758 if(filename.find(":",8,TRUE) != -1) { //found a port
761 m3uFile = filename.left( filename.find( ":",8,TRUE)); 759 m3uFile = filename.left( filename.find( ":",8,TRUE));
762 m3uFile = m3uFile.right( 7); 760 m3uFile = m3uFile.right( 7);
763 } else if(filename.left(4) == "http"){ 761 } else if(filename.left(4) == "http"){
764 m3uFile=filename; 762 m3uFile=filename;
765 m3uFile = m3uFile.right( m3uFile.length() - 7); 763 m3uFile = m3uFile.right( m3uFile.length() - 7);
766 } else{ 764 } else{
767 m3uFile=filename; 765 m3uFile=filename;
768 } 766 }
769 767
770// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 768// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
771 lnk.setName( filename ); //sets name 769 lnk.setName( filename ); //sets name
772 lnk.setFile( filename ); //sets file name 770 lnk.setFile( filename ); //sets file name
773 771
774// lnk.setIcon("opieplayer2/musicfile"); 772// lnk.setIcon("opieplayer2/musicfile");
775 773
776 d->selectedFiles->addToSelection( lnk ); 774 d->selectedFiles->addToSelection( lnk );
777 writeCurrentM3u(); 775 writeCurrentM3u();
778 d->selectedFiles->setSelectedItem( lnk.name()); 776 d->selectedFiles->setSelectedItem( lnk.name());
779 } 777 }
780 else if( filename.right( 3) == "m3u" ) { 778 else if( filename.right( 3) == "m3u" ) {
781 readm3u( filename ); 779 readm3u( filename );
782 780
783 } else if( filename.right(3) == "pls" ) { 781 } else if( filename.right(3) == "pls" ) {
784 readPls( filename ); 782 readPls( filename );
785 } else { 783 } else {
786 lnk.setName( QFileInfo(filename).baseName() ); //sets name 784 lnk.setName( QFileInfo(filename).baseName() ); //sets name
787 lnk.setFile( filename ); //sets file name 785 lnk.setFile( filename ); //sets file name
788 d->selectedFiles->addToSelection( lnk); 786 d->selectedFiles->addToSelection( lnk);
789 writeCurrentM3u(); 787 writeCurrentM3u();
790 d->selectedFiles->setSelectedItem( lnk.name()); 788 d->selectedFiles->setSelectedItem( lnk.name());
791 } 789 }
792 } 790 }
793 791
794 if( fileDlg ) { 792 if( fileDlg ) {
795 delete fileDlg; 793 delete fileDlg;
796 } 794 }
797} 795}
798 796
799/* 797/*
800reads m3u and shows files/urls to playlist widget */ 798reads m3u and shows files/urls to playlist widget */
801void PlayListWidget::readm3u( const QString &filename ) { 799void PlayListWidget::readm3u( const QString &filename ) {
802 qDebug( "read m3u filename " + filename ); 800 qDebug( "read m3u filename " + filename );
803 801
804 Om3u *m3uList; 802 Om3u *m3uList;
805 QString s, name; 803 QString s, name;
806 m3uList = new Om3u( filename, IO_ReadOnly ); 804 m3uList = new Om3u( filename, IO_ReadOnly );
807 m3uList->readM3u(); 805 m3uList->readM3u();
808 DocLnk lnk; 806 DocLnk lnk;
809 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 807 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
810 s = *it; 808 s = *it;
811// qDebug("reading "+ s); 809// qDebug("reading "+ s);
812 if(s.left(4)=="http") { 810 if(s.left(4)=="http") {
813 lnk.setName( s ); //sets file name 811 lnk.setName( s ); //sets file name
814 lnk.setIcon("opieplayer2/musicfile"); 812 lnk.setIcon("opieplayer2/musicfile");
815 lnk.setFile( s ); //sets file name 813 lnk.setFile( s ); //sets file name
816 814
817 } else { 815 } else {
818 // if( QFileInfo( s ).exists() ) { 816 // if( QFileInfo( s ).exists() ) {
819 lnk.setName( QFileInfo(s).baseName()); 817 lnk.setName( QFileInfo(s).baseName());
820 // if(s.right(4) == '.') {//if regular file 818 // if(s.right(4) == '.') {//if regular file
821 if(s.left(1) != "/") { 819 if(s.left(1) != "/") {
822 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 820 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
823 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 821 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
824// lnk.setIcon(MimeType(s).pixmap() ); 822// lnk.setIcon(MimeType(s).pixmap() );
825// lnk.setIcon("SoundPlayer"); 823// lnk.setIcon("SoundPlayer");
826 } else { 824 } else {
827 // qDebug("set link2 "+s); 825 // qDebug("set link2 "+s);
828 lnk.setFile( s); 826 lnk.setFile( s);
829// lnk.setIcon(MimeType(s).pixmap() ); 827// lnk.setIcon(MimeType(s).pixmap() );
830// lnk.setIcon("SoundPlayer"); 828// lnk.setIcon("SoundPlayer");
831 } 829 }
832 } 830 }
833 d->selectedFiles->addToSelection( lnk ); 831 d->selectedFiles->addToSelection( lnk );
834 } 832 }
835 Config config( "OpiePlayer" ); 833 Config config( "OpiePlayer" );
836 config.setGroup( "PlayList" ); 834 config.setGroup( "PlayList" );
837 835
838 config.writeEntry("CurrentPlaylist",filename); 836 config.writeEntry("CurrentPlaylist",filename);
839 config.write(); 837 config.write();
840 currentPlayList=filename; 838 currentPlayList=filename;
841 839
842// m3uList->write(); 840// m3uList->write();
843 m3uList->close(); 841 m3uList->close();
844 if(m3uList) delete m3uList; 842 if(m3uList) delete m3uList;
845 843
846 d->selectedFiles->setSelectedItem( s); 844 d->selectedFiles->setSelectedItem( s);
847 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 845 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
848 846
849} 847}
850 848
851/* 849/*
852reads pls and adds files/urls to playlist */ 850reads pls and adds files/urls to playlist */
853void PlayListWidget::readPls( const QString &filename ) { 851void PlayListWidget::readPls( const QString &filename ) {
854 852
855 qDebug( "pls filename is " + filename ); 853 qDebug( "pls filename is " + filename );
856 Om3u *m3uList; 854 Om3u *m3uList;
857 QString s, name; 855 QString s, name;
858 m3uList = new Om3u( filename, IO_ReadOnly ); 856 m3uList = new Om3u( filename, IO_ReadOnly );
859 m3uList->readPls(); 857 m3uList->readPls();
860 858
861 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 859 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
862 s = *it; 860 s = *it;
863 // s.replace( QRegExp( "%20" )," " ); 861 // s.replace( QRegExp( "%20" )," " );
864 DocLnk lnk( s ); 862 DocLnk lnk( s );
865 QFileInfo f( s ); 863 QFileInfo f( s );
866 QString name = f.baseName(); 864 QString name = f.baseName();
867 865
868 if( name.left( 4 ) == "http" ) { 866 if( name.left( 4 ) == "http" ) {
869 name = s.right( s.length() - 7); 867 name = s.right( s.length() - 7);
870 } else { 868 } else {
871 name = s; 869 name = s;
872 } 870 }
873 871
874 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 872 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
875 873
876 lnk.setName( name ); 874 lnk.setName( name );
877 if( s.at( s.length() - 4) == '.') {// if this is probably a file 875 if( s.at( s.length() - 4) == '.') {// if this is probably a file
878 lnk.setFile( s ); 876 lnk.setFile( s );
879 } else { //if its a url 877 } else { //if its a url
880// if( name.right( 1 ).find( '/' ) == -1) { 878// if( name.right( 1 ).find( '/' ) == -1) {
881// s += "/"; 879// s += "/";
882// } 880// }
883 lnk.setFile( s ); 881 lnk.setFile( s );
884 } 882 }
885 lnk.setType( "audio/x-mpegurl" ); 883 lnk.setType( "audio/x-mpegurl" );
886 884
887 lnk.writeLink(); 885 lnk.writeLink();
888 d->selectedFiles->addToSelection( lnk ); 886 d->selectedFiles->addToSelection( lnk );
889 } 887 }
890 888
891 m3uList->close(); 889 m3uList->close();
892 if(m3uList) delete m3uList; 890 if(m3uList) delete m3uList;
893} 891}
894 892
895/* 893/*
896 writes current playlist to current m3u file */ 894 writes current playlist to current m3u file */
897void PlayListWidget::writeCurrentM3u() { 895void PlayListWidget::writeCurrentM3u() {
898 qDebug("writing to current m3u"); 896 qDebug("writing to current m3u");
899 Config cfg( "OpiePlayer" ); 897 Config cfg( "OpiePlayer" );
900 cfg.setGroup("PlayList"); 898 cfg.setGroup("PlayList");
901 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 899 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
902 900
903 Om3u *m3uList; 901 Om3u *m3uList;
904 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 902 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
905 if( d->selectedFiles->first()) { 903 if( d->selectedFiles->first()) {
906 904
907 do { 905 do {
908 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 906 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
909 m3uList->add( d->selectedFiles->current()->file() ); 907 m3uList->add( d->selectedFiles->current()->file() );
910 } 908 }
911 while ( d->selectedFiles->next() ); 909 while ( d->selectedFiles->next() );
912 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 910 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
913 m3uList->write(); 911 m3uList->write();
914 m3uList->close(); 912 m3uList->close();
915 913
916 if(m3uList) delete m3uList; 914 if(m3uList) delete m3uList;
917 } 915 }
918 916
919} 917}
920 918
921 /* 919 /*
922 writes current playlist to m3u file */ 920 writes current playlist to m3u file */
923void PlayListWidget::writem3u() { 921void PlayListWidget::writem3u() {
924 InputDialog *fileDlg; 922 InputDialog *fileDlg;
925 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 923 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
926 fileDlg->exec(); 924 fileDlg->exec();
927 QString name, filename, list; 925 QString name, filename, list;
928 Om3u *m3uList; 926 Om3u *m3uList;
929 927
930 if( fileDlg->result() == 1 ) { 928 if( fileDlg->result() == 1 ) {
931 name = fileDlg->text(); 929 name = fileDlg->text();
932// qDebug( filename ); 930// qDebug( filename );
933 931
934 if( name.left( 1) != "/" ) { 932 if( name.left( 1) != "/" ) {
935 filename = QPEApplication::documentDir() + "/" + name; 933 filename = QPEApplication::documentDir() + "/" + name;
936 } 934 }
937 935
938 if( name.right( 3 ) != "m3u" ) { 936 if( name.right( 3 ) != "m3u" ) {
939 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 937 filename = QPEApplication::documentDir() + "/" +name+".m3u";
940 } 938 }
941 939
942 if( d->selectedFiles->first()) { 940 if( d->selectedFiles->first()) {
943 m3uList = new Om3u(filename, IO_ReadWrite); 941 m3uList = new Om3u(filename, IO_ReadWrite);
944 942
945 do { 943 do {
946 m3uList->add( d->selectedFiles->current()->file()); 944 m3uList->add( d->selectedFiles->current()->file());
947 } 945 }
948 while ( d->selectedFiles->next() ); 946 while ( d->selectedFiles->next() );
949 // qDebug( list ); 947 // qDebug( list );
950 m3uList->write(); 948 m3uList->write();
951 m3uList->close(); 949 m3uList->close();
952 if(m3uList) delete m3uList; 950 if(m3uList) delete m3uList;
953 951
954 if(fileDlg) delete fileDlg; 952 if(fileDlg) delete fileDlg;
955 953
956 DocLnk lnk; 954 DocLnk lnk;
957 lnk.setFile( filename); 955 lnk.setFile( filename);
958 lnk.setIcon("opieplayer2/playlist2"); 956 lnk.setIcon("opieplayer2/playlist2");
959 lnk.setName( name); //sets file name 957 lnk.setName( name); //sets file name
960 958
961 // qDebug(filename); 959 // qDebug(filename);
962 Config config( "OpiePlayer" ); 960 Config config( "OpiePlayer" );
963 config.setGroup( "PlayList" ); 961 config.setGroup( "PlayList" );
964 962
965 config.writeEntry("CurrentPlaylist",filename); 963 config.writeEntry("CurrentPlaylist",filename);
966 currentPlayList=filename; 964 currentPlayList=filename;
967 965
968 if(!lnk.writeLink()) { 966 if(!lnk.writeLink()) {
969 qDebug("Writing doclink did not work"); 967 qDebug("Writing doclink did not work");
970 } 968 }
971 969
972 setCaption(tr("OpiePlayer: ") + name); 970 setCaption(tr("OpiePlayer: ") + name);
973 } 971 }
974 } 972 }
975} 973}
976 974
977void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 975void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
978 switch ( e->key() ) { 976 switch ( e->key() ) {
979 ////////////////////////////// Zaurus keys 977 ////////////////////////////// Zaurus keys
980 case Key_F9: //activity 978 case Key_F9: //activity
981 // if(audioUI->isHidden()) 979 // if(audioUI->isHidden())
982 // audioUI->showMaximized(); 980 // audioUI->showMaximized();
983 break; 981 break;
984 case Key_F10: //contacts 982 case Key_F10: //contacts
985 // if( videoUI->isHidden()) 983 // if( videoUI->isHidden())
986 // videoUI->showMaximized(); 984 // videoUI->showMaximized();
987 break; 985 break;
988 case Key_F11: //menu 986 case Key_F11: //menu
989 break; 987 break;
990 case Key_F12: //home 988 case Key_F12: //home
991 // doBlank(); 989 // doBlank();
992 break; 990 break;
993 case Key_F13: //mail 991 case Key_F13: //mail
994 // doUnblank(); 992 // doUnblank();
995 break; 993 break;
996 case Key_Q: //add to playlist 994 case Key_Q: //add to playlist
997 addSelected(); 995 addSelected();
998 break; 996 break;
999 case Key_R: //remove from playlist 997 case Key_R: //remove from playlist
1000 removeSelected(); 998 removeSelected();
1001 break; 999 break;
1002 // case Key_P: //play 1000 // case Key_P: //play
1003 // qDebug("Play"); 1001 // qDebug("Play");
1004 // playSelected(); 1002 // playSelected();
1005 // break; 1003 // break;
1006 case Key_Space: 1004 case Key_Space:
1007 // playSelected(); puh 1005 // playSelected(); puh
1008 break; 1006 break;
1009 case Key_1: 1007 case Key_1:
1010 tabWidget->setCurrentPage( 0 ); 1008 tabWidget->setCurrentPage( 0 );
1011 break; 1009 break;
1012 case Key_2: 1010 case Key_2:
1013 tabWidget->setCurrentPage( 1 ); 1011 tabWidget->setCurrentPage( 1 );
1014 break; 1012 break;
1015 case Key_3: 1013 case Key_3:
1016 tabWidget->setCurrentPage( 2 ); 1014 tabWidget->setCurrentPage( 2 );
1017 break; 1015 break;
1018 case Key_4: 1016 case Key_4:
1019 tabWidget->setCurrentPage( 3 ); 1017 tabWidget->setCurrentPage( 3 );
1020 break; 1018 break;
1021 case Key_Down: 1019 case Key_Down:
1022 if ( !d->selectedFiles->next() ) 1020 if ( !d->selectedFiles->next() )
1023 d->selectedFiles->first(); 1021 d->selectedFiles->first();
1024 break; 1022 break;
1025 case Key_Up: 1023 case Key_Up:
1026 if ( !d->selectedFiles->prev() ) 1024 if ( !d->selectedFiles->prev() )
1027 // d->selectedFiles->last(); 1025 // d->selectedFiles->last();
1028 break; 1026 break;
1029 } 1027 }
1030} 1028}
1031 1029
1032void PlayListWidget::pmViewActivated(int index) { 1030void PlayListWidget::pmViewActivated(int index) {
1033// qDebug("%d", index); 1031// qDebug("%d", index);
1034 switch(index) { 1032 switch(index) {
1035 case -16: 1033 case -16:
1036 { 1034 {
1037 mediaPlayerState.toggleFullscreen(); 1035 mediaPlayerState.toggleFullscreen();
1038 bool b=mediaPlayerState.isFullscreen(); 1036 bool b=mediaPlayerState.isFullscreen();
1039 pmView->setItemChecked( index, b); 1037 pmView->setItemChecked( index, b);
1040 Config cfg( "OpiePlayer" ); 1038 Config cfg( "OpiePlayer" );
1041 cfg.writeEntry( "FullScreen", b ); 1039 cfg.writeEntry( "FullScreen", b );
1042 } 1040 }
1043 break; 1041 break;
1044 }; 1042 };
1045} 1043}
1046 1044
1047void PlayListWidget::populateSkinsMenu() { 1045void PlayListWidget::populateSkinsMenu() {
1048 int item = 0; 1046 int item = 0;
1049 defaultSkinIndex = 0; 1047 defaultSkinIndex = 0;
1050 QString skinName; 1048 QString skinName;
1051 Config cfg( "OpiePlayer" ); 1049 Config cfg( "OpiePlayer" );
1052 cfg.setGroup("Options" ); 1050 cfg.setGroup("Options" );
1053 QString skin = cfg.readEntry( "Skin", "default" ); 1051 QString skin = cfg.readEntry( "Skin", "default" );
1054 1052
1055 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1053 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1056 skinsDir.setFilter( QDir::Dirs ); 1054 skinsDir.setFilter( QDir::Dirs );
1057 skinsDir.setSorting(QDir::Name ); 1055 skinsDir.setSorting(QDir::Name );
1058 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1056 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1059 QFileInfoListIterator it( *skinslist ); 1057 QFileInfoListIterator it( *skinslist );
1060 QFileInfo *fi; 1058 QFileInfo *fi;
1061 while ( ( fi = it.current() ) ) { 1059 while ( ( fi = it.current() ) ) {
1062 skinName = fi->fileName(); 1060 skinName = fi->fileName();
1063// qDebug( fi->fileName() ); 1061// qDebug( fi->fileName() );
1064 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1062 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1065 item = skinsMenu->insertItem( fi->fileName() ) ; 1063 item = skinsMenu->insertItem( fi->fileName() ) ;
1066 } 1064 }
1067 if( skinName == "default" ) { 1065 if( skinName == "default" ) {
1068 defaultSkinIndex = item; 1066 defaultSkinIndex = item;
1069 } 1067 }
1070 if( skinName == skin ) { 1068 if( skinName == skin ) {
1071 skinsMenu->setItemChecked( item, TRUE ); 1069 skinsMenu->setItemChecked( item, TRUE );
1072 } 1070 }
1073 ++it; 1071 ++it;
1074 } 1072 }
1075} 1073}
1076 1074
1077void PlayListWidget::skinsMenuActivated( int item ) { 1075void PlayListWidget::skinsMenuActivated( int item ) {
1078 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1076 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1079 skinsMenu->setItemChecked( i, FALSE ); 1077 skinsMenu->setItemChecked( i, FALSE );
1080 } 1078 }
1081 skinsMenu->setItemChecked( item, TRUE ); 1079 skinsMenu->setItemChecked( item, TRUE );
1082 1080
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index e81ef3c..58efd47 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,144 +1,144 @@
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 audioScan, videoScan, audioPopulated, videoPopulated; 97 bool audioPopulated, videoPopulated;
98 void readm3u(const QString &); 98 void readm3u(const QString &);
99 void readPls(const QString &); 99 void readPls(const QString &);
100 void initializeStates(); 100 void initializeStates();
101 void populateAudioView(); 101 void populateAudioView();
102 void populateVideoView(); 102 void populateVideoView();
103 103
104 QListView *currentFileListView() const; 104 QListView *currentFileListView() const;
105 105
106 bool inFileListMode() const; 106 bool inFileListMode() const;
107 107
108private slots: 108private slots:
109 void populateSkinsMenu(); 109 void populateSkinsMenu();
110 void skinsMenuActivated(int); 110 void skinsMenuActivated(int);
111 void pmViewActivated(int); 111 void pmViewActivated(int);
112 void writem3u(); 112 void writem3u();
113 void writeCurrentM3u(); 113 void writeCurrentM3u();
114 void scanForAudio(); 114 void scanForAudio();
115 void scanForVideo(); 115 void scanForVideo();
116 void openFile(); 116 void openFile();
117 void setDocument( const QString& fileref ); 117 void setDocument( const QString& fileref );
118 void addToSelection( const DocLnk& ); // Add a media file to the playlist 118 void addToSelection( const DocLnk& ); // Add a media file to the playlist
119 void addToSelection( QListViewItem* ); // Add a media file to the playlist 119 void addToSelection( QListViewItem* ); // Add a media file to the playlist
120 void clearList(); 120 void clearList();
121 void addAllToList(); 121 void addAllToList();
122 void addAllMusicToList(); 122 void addAllMusicToList();
123 void addAllVideoToList(); 123 void addAllVideoToList();
124 void saveList(); // Save the playlist 124 void saveList(); // Save the playlist
125 void loadList( const DocLnk &); // Load a playlist 125 void loadList( const DocLnk &); // Load a playlist
126 void playIt( QListViewItem *); 126 void playIt( QListViewItem *);
127 void btnPlay(bool); 127 void btnPlay(bool);
128 void deletePlaylist(); 128 void deletePlaylist();
129 void addSelected(); 129 void addSelected();
130 void removeSelected(); 130 void removeSelected();
131 void tabChanged(QWidget*); 131 void tabChanged(QWidget*);
132 void viewPressed( int, QListViewItem *, const QPoint&, int); 132 void viewPressed( int, QListViewItem *, const QPoint&, int);
133 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 133 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
134 void playSelected(); 134 void playSelected();
135 135
136private: 136private:
137 bool fromSetDocument; 137 bool fromSetDocument;
138 bool insanityBool; 138 bool insanityBool;
139 QString setDocFileRef, currentPlayList; 139 QString setDocFileRef, currentPlayList;
140 int selected; 140 int selected;
141}; 141};
142 142
143#endif // PLAY_LIST_WIDGET_H 143#endif // PLAY_LIST_WIDGET_H
144 144