summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-05-31 00:24:18 (UTC)
committer llornkcor <llornkcor>2002-05-31 00:24:18 (UTC)
commit294fecd1c15c4940bdab8566e5afaee9f305abb6 (patch) (unidiff)
tree47860d13c0aeffb0b9afad96d669d8935769fe7a /core
parent706841997a5d466f3b873ed79102e4abe0d745ae (diff)
downloadopie-294fecd1c15c4940bdab8566e5afaee9f305abb6.zip
opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.gz
opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.bz2
sped up startup time, and fixed segfault on exit
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayer.h2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp70
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h3
3 files changed, 53 insertions, 22 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h
index cf9daea..8f9a0ee 100644
--- a/core/multimedia/opieplayer/mediaplayer.h
+++ b/core/multimedia/opieplayer/mediaplayer.h
@@ -1,61 +1,61 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MEDIA_PLAYER_H 20#ifndef MEDIA_PLAYER_H
21#define MEDIA_PLAYER_H 21#define MEDIA_PLAYER_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qpe/qlibrary.h> 25#include <qpe/qlibrary.h>
26#include <qpe/mediaplayerplugininterface.h> 26#include <qpe/mediaplayerplugininterface.h>
27 27
28 28
29class DocLnk; 29class DocLnk;
30 30
31 31
32class MediaPlayer : public QObject { 32class MediaPlayer : public QObject {
33 Q_OBJECT 33 Q_OBJECT
34public: 34public:
35 MediaPlayer( QObject *parent, const char *name ); 35 MediaPlayer( QObject *parent, const char *name );
36 ~MediaPlayer(); 36 ~MediaPlayer();
37 37
38private slots: 38private slots:
39 void setPlaying( bool ); 39 void setPlaying( bool );
40 void pauseCheck( bool ); 40 void pauseCheck( bool );
41 void play(); 41 void play();
42 void next(); 42 void next();
43 void prev(); 43 void prev();
44 void startIncreasingVolume(); 44 void startIncreasingVolume();
45 void startDecreasingVolume(); 45 void startDecreasingVolume();
46 void stopChangingVolume(); 46 void stopChangingVolume();
47 void cleanUp();
47 48
48protected: 49protected:
49 void timerEvent( QTimerEvent *e ); 50 void timerEvent( QTimerEvent *e );
50 void keyReleaseEvent( QKeyEvent *e); 51 void keyReleaseEvent( QKeyEvent *e);
51 void doBlank(); 52 void doBlank();
52 void doUnblank(); 53 void doUnblank();
53 void cleanUp();
54private: 54private:
55 int volumeDirection; 55 int volumeDirection;
56 const DocLnk *currentFile; 56 const DocLnk *currentFile;
57}; 57};
58 58
59 59
60#endif // MEDIA_PLAYER_H 60#endif // MEDIA_PLAYER_H
61 61
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 7a79be1..78c2822 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,83 +1,82 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35
36#include <qaction.h> 35#include <qaction.h>
37#include <qcursor.h> 36#include <qcursor.h>
38#include <qimage.h> 37#include <qimage.h>
39#include <qfile.h> 38#include <qfile.h>
40#include <qdir.h> 39#include <qdir.h>
41#include <qlayout.h> 40#include <qlayout.h>
42#include <qlabel.h> 41#include <qlabel.h>
43#include <qlist.h> 42#include <qlist.h>
44#include <qlistbox.h> 43#include <qlistbox.h>
45#include <qmainwindow.h> 44#include <qmainwindow.h>
46#include <qmessagebox.h> 45#include <qmessagebox.h>
47#include <qtoolbutton.h> 46#include <qtoolbutton.h>
48#include <qtabwidget.h> 47#include <qtabwidget.h>
49#include <qlistview.h> 48#include <qlistview.h>
50#include <qpoint.h> 49#include <qpoint.h>
51#include <qlineedit.h> 50#include <qlineedit.h>
52#include <qpushbutton.h> 51#include <qpushbutton.h>
53#include <qregexp.h> 52#include <qregexp.h>
54#include <qtextstream.h> 53#include <qtextstream.h>
55 54
56//#include <qtimer.h> 55//#include <qtimer.h>
57 56
58#include "playlistselection.h" 57#include "playlistselection.h"
59#include "playlistwidget.h" 58#include "playlistwidget.h"
60#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
61 60
62#include "inputDialog.h" 61#include "inputDialog.h"
63 62
64#include <stdlib.h> 63#include <stdlib.h>
65#include "audiowidget.h" 64#include "audiowidget.h"
66#include "videowidget.h" 65#include "videowidget.h"
67 66
68#include <unistd.h> 67#include <unistd.h>
69#include <sys/file.h> 68#include <sys/file.h>
70#include <sys/ioctl.h> 69#include <sys/ioctl.h>
71#include <sys/soundcard.h> 70#include <sys/soundcard.h>
72 71
73// for setBacklight() 72// for setBacklight()
74#include <linux/fb.h> 73#include <linux/fb.h>
75#include <sys/types.h> 74#include <sys/types.h>
76#include <sys/stat.h> 75#include <sys/stat.h>
77#include <stdlib.h> 76#include <stdlib.h>
78 77
79#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
80#define SIDE_BUTTONS 79#define SIDE_BUTTONS
81#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
82 81
83extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
@@ -86,257 +85,261 @@ extern MediaPlayerState *mediaPlayerState;
86 85
87// class myFileSelector { 86// class myFileSelector {
88 87
89// }; 88// };
90class PlayListWidgetPrivate { 89class PlayListWidgetPrivate {
91public: 90public:
92 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 91 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
93 QFrame *playListFrame; 92 QFrame *playListFrame;
94 FileSelector *files; 93 FileSelector *files;
95 PlayListSelection *selectedFiles; 94 PlayListSelection *selectedFiles;
96 bool setDocumentUsed; 95 bool setDocumentUsed;
97 DocLnk *current; 96 DocLnk *current;
98}; 97};
99 98
100 99
101class ToolButton : public QToolButton { 100class ToolButton : public QToolButton {
102public: 101public:
103 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
104 : QToolButton( parent, name ) { 103 : QToolButton( parent, name ) {
105 setTextLabel( name ); 104 setTextLabel( name );
106 setPixmap( Resource::loadPixmap( icon ) ); 105 setPixmap( Resource::loadPixmap( icon ) );
107 setAutoRaise( TRUE ); 106 setAutoRaise( TRUE );
108 setFocusPolicy( QWidget::NoFocus ); 107 setFocusPolicy( QWidget::NoFocus );
109 setToggleButton( t ); 108 setToggleButton( t );
110 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
111 QPEMenuToolFocusManager::manager()->addWidget( this ); 110 QPEMenuToolFocusManager::manager()->addWidget( this );
112 } 111 }
113}; 112};
114 113
115 114
116class MenuItem : public QAction { 115class MenuItem : public QAction {
117public: 116public:
118 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
119 : QAction( text, QString::null, 0, 0 ) { 118 : QAction( text, QString::null, 0, 0 ) {
120 connect( this, SIGNAL( activated() ), handler, slot ); 119 connect( this, SIGNAL( activated() ), handler, slot );
121 addTo( parent ); 120 addTo( parent );
122 } 121 }
123}; 122};
124 123
125 124
126PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
127 : QMainWindow( parent, name, fl ) { 126 : QMainWindow( parent, name, fl ) {
128 127
129 d = new PlayListWidgetPrivate; 128 d = new PlayListWidgetPrivate;
130 d->setDocumentUsed = FALSE; 129 d->setDocumentUsed = FALSE;
131 d->current = NULL; 130 d->current = NULL;
132 fromSetDocument = FALSE; 131 fromSetDocument = FALSE;
133 insanityBool=FALSE; 132 insanityBool=FALSE;
133 audioScan = FALSE;
134 videoScan = FALSE;
134// menuTimer = new QTimer( this ,"menu timer"), 135// menuTimer = new QTimer( this ,"menu timer"),
135// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 136// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
136 137
137 setBackgroundMode( PaletteButton ); 138 setBackgroundMode( PaletteButton );
138 139
139 setCaption( tr("OpiePlayer") ); 140 setCaption( tr("OpiePlayer") );
140 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 141 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
141 142
142 setToolBarsMovable( FALSE ); 143 setToolBarsMovable( FALSE );
143 144
144 // Create Toolbar 145 // Create Toolbar
145 QPEToolBar *toolbar = new QPEToolBar( this ); 146 QPEToolBar *toolbar = new QPEToolBar( this );
146 toolbar->setHorizontalStretchable( TRUE ); 147 toolbar->setHorizontalStretchable( TRUE );
147 148
148 // Create Menubar 149 // Create Menubar
149 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 150 QPEMenuBar *menu = new QPEMenuBar( toolbar );
150 menu->setMargin( 0 ); 151 menu->setMargin( 0 );
151 152
152 QPEToolBar *bar = new QPEToolBar( this ); 153 QPEToolBar *bar = new QPEToolBar( this );
153 bar->setLabel( tr( "Play Operations" ) ); 154 bar->setLabel( tr( "Play Operations" ) );
154// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 155// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
155// this , SLOT( addSelected()) ); 156// this , SLOT( addSelected()) );
156 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 157 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
157 tbDeletePlaylist->setFlat(TRUE); 158 tbDeletePlaylist->setFlat(TRUE);
158 tbDeletePlaylist->setFixedSize(20,20); 159 tbDeletePlaylist->setFixedSize(20,20);
159 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 160 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
160 161
161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
162 this , SLOT(addSelected()) ); 163 this , SLOT(addSelected()) );
163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
164 this , SLOT(removeSelected()) ); 165 this , SLOT(removeSelected()) );
165// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
166 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
167 this , SLOT( btnPlay(bool) ), TRUE ); 168 this , SLOT( btnPlay(bool) ), TRUE );
168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
171 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 172 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
172 tbDeletePlaylist->hide(); 173 tbDeletePlaylist->hide();
173 174
174 QPopupMenu *pmPlayList = new QPopupMenu( this ); 175 QPopupMenu *pmPlayList = new QPopupMenu( this );
175 menu->insertItem( tr( "File" ), pmPlayList ); 176 menu->insertItem( tr( "File" ), pmPlayList );
176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180// pmPlayList->insertSeparator(-1); 181// pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 pmPlayList->insertSeparator(-1); 183 pmPlayList->insertSeparator(-1);
183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
185 pmPlayList->insertSeparator(-1);
186 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
187 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
184 188
185 QPopupMenu *pmView = new QPopupMenu( this ); 189 QPopupMenu *pmView = new QPopupMenu( this );
186 menu->insertItem( tr( "View" ), pmView ); 190 menu->insertItem( tr( "View" ), pmView );
187 191
188 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 192 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
189 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 193 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
190 fullScreenButton->addTo(pmView); 194 fullScreenButton->addTo(pmView);
191 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 195 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
192 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 196 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
193 scaleButton->addTo(pmView); 197 scaleButton->addTo(pmView);
194 198
195 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 199 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
196 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 200 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
197 201
198 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 202 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
199 203
200 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 204 tabWidget = new QTabWidget( hbox6, "tabWidget" );
201 tabWidget->setTabShape(QTabWidget::Triangular); 205 tabWidget->setTabShape(QTabWidget::Triangular);
202 206
203 QWidget *pTab; 207 QWidget *pTab;
204 pTab = new QWidget( tabWidget, "pTab" ); 208 pTab = new QWidget( tabWidget, "pTab" );
205// playlistView = new QListView( pTab, "playlistview" ); 209// playlistView = new QListView( pTab, "playlistview" );
206// playlistView->setMinimumSize(236,260); 210// playlistView->setMinimumSize(236,260);
207 tabWidget->insertTab( pTab,"Playlist"); 211 tabWidget->insertTab( pTab,"Playlist");
208 212
209 213
210 // Add the playlist area 214 // Add the playlist area
211 215
212 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 216 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
213 d->playListFrame = vbox3; 217 d->playListFrame = vbox3;
214 d->playListFrame ->setMinimumSize(235,260); 218 d->playListFrame ->setMinimumSize(235,260);
215 219
216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 220 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
217 221
218 d->selectedFiles = new PlayListSelection( hbox2); 222 d->selectedFiles = new PlayListSelection( hbox2);
219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 223 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
220 224
221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 225 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
222 226
223 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 227 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
224 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 228 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
225 229
226 230
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 231 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 232 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 233 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 234 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 235 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 236
233 QWidget *aTab; 237 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 238 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 239 audioView = new QListView( aTab, "Audioview" );
236 audioView->setMinimumSize(233,260); 240 audioView->setMinimumSize(233,260);
237 audioView->addColumn( tr("Title"),140); 241 audioView->addColumn( tr("Title"),140);
238 audioView->addColumn(tr("Size"), -1); 242 audioView->addColumn(tr("Size"), -1);
239 audioView->addColumn(tr("Media"),-1); 243 audioView->addColumn(tr("Media"),-1);
240 audioView->setColumnAlignment(1, Qt::AlignRight); 244 audioView->setColumnAlignment(1, Qt::AlignRight);
241 audioView->setColumnAlignment(2, Qt::AlignRight); 245 audioView->setColumnAlignment(2, Qt::AlignRight);
242 audioView->setAllColumnsShowFocus(TRUE); 246 audioView->setAllColumnsShowFocus(TRUE);
243 247
244 audioView->setMultiSelection( TRUE ); 248 audioView->setMultiSelection( TRUE );
245 audioView->setSelectionMode( QListView::Extended); 249 audioView->setSelectionMode( QListView::Extended);
246 250
247 tabWidget->insertTab(aTab,tr("Audio")); 251 tabWidget->insertTab(aTab,tr("Audio"));
248 252
249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 253 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
250 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 254 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
251 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 255 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
252 256
253 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 257 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
254 this,SLOT( playIt( QListViewItem *)) ); 258 this,SLOT( playIt( QListViewItem *)) );
255 259
256// audioView 260// audioView
257 populateAudioView(); 261// populateAudioView();
258// videowidget 262// videowidget
259 263
260 QWidget *vTab; 264 QWidget *vTab;
261 vTab = new QWidget( tabWidget, "vTab" ); 265 vTab = new QWidget( tabWidget, "vTab" );
262 videoView = new QListView( vTab, "Videoview" ); 266 videoView = new QListView( vTab, "Videoview" );
263 videoView->setMinimumSize(233,260); 267 videoView->setMinimumSize(233,260);
264 268
265 videoView->addColumn(tr("Title"),140); 269 videoView->addColumn(tr("Title"),140);
266 videoView->addColumn(tr("Size"),-1); 270 videoView->addColumn(tr("Size"),-1);
267 videoView->addColumn(tr("Media"),-1); 271 videoView->addColumn(tr("Media"),-1);
268 videoView->setColumnAlignment(1, Qt::AlignRight); 272 videoView->setColumnAlignment(1, Qt::AlignRight);
269 videoView->setColumnAlignment(2, Qt::AlignRight); 273 videoView->setColumnAlignment(2, Qt::AlignRight);
270 videoView->setAllColumnsShowFocus(TRUE); 274 videoView->setAllColumnsShowFocus(TRUE);
271 videoView->setMultiSelection( TRUE ); 275 videoView->setMultiSelection( TRUE );
272 videoView->setSelectionMode( QListView::Extended); 276 videoView->setSelectionMode( QListView::Extended);
273 277
274 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 278 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
275 279
276 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 280 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
277 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 281 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
278 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 282 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
279 this,SLOT( playIt( QListViewItem *)) ); 283 this,SLOT( playIt( QListViewItem *)) );
280 284
281 tabWidget->insertTab( vTab,tr("Video")); 285 tabWidget->insertTab( vTab,tr("Video"));
282populateVideoView(); 286// populateVideoView();
283 287
284//playlists list 288//playlists list
285 QWidget *LTab; 289 QWidget *LTab;
286 LTab = new QWidget( tabWidget, "LTab" ); 290 LTab = new QWidget( tabWidget, "LTab" );
287 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 291 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
288 playLists->setMinimumSize(233,260);; 292 playLists->setMinimumSize(233,260);
289 tabWidget->insertTab(LTab,tr("Lists")); 293 tabWidget->insertTab(LTab,tr("Lists"));
290 294
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 295 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 296// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
293 297
294
295// add the library area 298// add the library area
296 299
297// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 300// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
298// this, SLOT( fauxPlay( QListViewItem *) ) ); 301// this, SLOT( fauxPlay( QListViewItem *) ) );
299// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 302// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
300// this, SLOT( fauxPlay( QListViewItem *)) ); 303// this, SLOT( fauxPlay( QListViewItem *)) );
301 304
302// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 305// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
303// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 306// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
304 307
305 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 308 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
306 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 309 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
307 310
308 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 311 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
309 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 312 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
310 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 313 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
311 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 314 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
312 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 315 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
313 316
314 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 317 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
315// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 318// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
316 319
317 setCentralWidget( vbox5 ); 320 setCentralWidget( vbox5 );
318 321
319 Config cfg( "OpiePlayer" ); 322 Config cfg( "OpiePlayer" );
320 readConfig( cfg ); 323 readConfig( cfg );
321 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 324 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
322// qDebug("currentList is "+currentPlaylist); 325// qDebug("currentList is "+currentPlaylist);
323 loadList(DocLnk( currentPlaylist)); 326 loadList(DocLnk( currentPlaylist));
324 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 327 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
325 328
326 initializeStates(); 329 initializeStates();
327} 330}
328 331
329 332
330PlayListWidget::~PlayListWidget() { 333PlayListWidget::~PlayListWidget() {
331 Config cfg( "OpiePlayer" ); 334 Config cfg( "OpiePlayer" );
332 writeConfig( cfg ); 335 writeConfig( cfg );
333 336
334 337
335 if ( d->current ) 338 if ( d->current )
336 delete d->current; 339 delete d->current;
337 delete d; 340 delete d;
338} 341}
339 342
340 343
341void PlayListWidget::initializeStates() { 344void PlayListWidget::initializeStates() {
342 345
@@ -388,205 +391,201 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
388 // next time... 391 // next time...
389 if ( !QFile::exists( lnk->linkFile() ) ) { 392 if ( !QFile::exists( lnk->linkFile() ) ) {
390 // the way writing lnks doesn't really check for out 393 // the way writing lnks doesn't really check for out
391 // of disk space, but check it anyway. 394 // of disk space, but check it anyway.
392 if ( !lnk->writeLink() ) { 395 if ( !lnk->writeLink() ) {
393 QMessageBox::critical( 0, tr("Out of space"), 396 QMessageBox::critical( 0, tr("Out of space"),
394 tr( "There was a problem saving " 397 tr( "There was a problem saving "
395 "the playlist.\n" 398 "the playlist.\n"
396 "Your playlist " 399 "Your playlist "
397 "may be missing some entries\n" 400 "may be missing some entries\n"
398 "the next time you start it." ) 401 "the next time you start it." )
399 ); 402 );
400 } 403 }
401 } 404 }
402 noOfFiles++; 405 noOfFiles++;
403 } 406 }
404 } 407 }
405 while ( d->selectedFiles->next() ); 408 while ( d->selectedFiles->next() );
406 cfg.writeEntry("NumberOfFiles", noOfFiles ); 409 cfg.writeEntry("NumberOfFiles", noOfFiles );
407} 410}
408 411
409 412
410void PlayListWidget::addToSelection( const DocLnk& lnk ) { 413void PlayListWidget::addToSelection( const DocLnk& lnk ) {
411// qDebug("add"); 414// qDebug("add");
412 d->setDocumentUsed = FALSE; 415 d->setDocumentUsed = FALSE;
413 if ( mediaPlayerState->playlist() ) 416 if ( mediaPlayerState->playlist() )
414 d->selectedFiles->addToSelection( lnk ); 417 d->selectedFiles->addToSelection( lnk );
415 else 418 else
416 mediaPlayerState->setPlaying( TRUE ); 419 mediaPlayerState->setPlaying( TRUE );
417} 420}
418 421
419 422
420void PlayListWidget::clearList() { 423void PlayListWidget::clearList() {
421 while ( first() ) 424 while ( first() )
422 d->selectedFiles->removeSelected(); 425 d->selectedFiles->removeSelected();
423} 426}
424 427
425 428
426void PlayListWidget::addAllToList() { 429void PlayListWidget::addAllToList() {
427 DocLnkSet filesAll; 430 DocLnkSet filesAll;
428 Global::findDocuments(&filesAll, "video/*;audio/*"); 431 Global::findDocuments(&filesAll, "video/*;audio/*");
429 QListIterator<DocLnk> Adit( filesAll.children() ); 432 QListIterator<DocLnk> Adit( filesAll.children() );
430 for ( ; Adit.current(); ++Adit ) 433 for ( ; Adit.current(); ++Adit )
431 d->selectedFiles->addToSelection( **Adit ); 434 d->selectedFiles->addToSelection( **Adit );
432} 435}
433 436
434 437
435void PlayListWidget::addAllMusicToList() { 438void PlayListWidget::addAllMusicToList() {
436// DocLnkSet files;
437// Global::findDocuments(&files, "audio/*");
438 QListIterator<DocLnk> dit( files.children() ); 439 QListIterator<DocLnk> dit( files.children() );
439 for ( ; dit.current(); ++dit ) 440 for ( ; dit.current(); ++dit )
440 d->selectedFiles->addToSelection( **dit ); 441 d->selectedFiles->addToSelection( **dit );
441} 442}
442 443
443 444
444void PlayListWidget::addAllVideoToList() { 445void PlayListWidget::addAllVideoToList() {
445 QListIterator<DocLnk> dit( vFiles.children() ); 446 QListIterator<DocLnk> dit( vFiles.children() );
446 for ( ; dit.current(); ++dit ) 447 for ( ; dit.current(); ++dit )
447 d->selectedFiles->addToSelection( **dit ); 448 d->selectedFiles->addToSelection( **dit );
448} 449}
449 450
450 451
451void PlayListWidget::setDocument(const QString& fileref) { 452void PlayListWidget::setDocument(const QString& fileref) {
452 qDebug(fileref); 453 qDebug(fileref);
453 fromSetDocument = TRUE; 454 fromSetDocument = TRUE;
454 if ( fileref.isNull() ) { 455 if ( fileref.isNull() ) {
455 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 456 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
456 return; 457 return;
457 } 458 }
458// qDebug("setDocument "+fileref); 459// qDebug("setDocument "+fileref);
459// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 460// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
460// clearList(); 461// clearList();
461// addToSelection( DocLnk( fileref ) ); 462// addToSelection( DocLnk( fileref ) );
462// d->setDocumentUsed = TRUE; 463// d->setDocumentUsed = TRUE;
463// d->selectedFiles->first(); 464// d->selectedFiles->first();
464// qApp->processEvents(); 465// qApp->processEvents();
465// } 466// }
466// else 467// else
467 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 468 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
468 clearList(); 469 clearList();
469 loadList(DocLnk(fileref)); 470 loadList(DocLnk(fileref));
470 d->selectedFiles->first(); 471 d->selectedFiles->first();
471 } else { 472 } else {
472 clearList(); 473 clearList();
473 addToSelection( DocLnk( fileref ) ); 474 addToSelection( DocLnk( fileref ) );
474 d->setDocumentUsed = TRUE; 475 d->setDocumentUsed = TRUE;
475 mediaPlayerState->setPlaying( FALSE ); 476 mediaPlayerState->setPlaying( FALSE );
476 qApp->processEvents(); 477 qApp->processEvents();
477 mediaPlayerState->setPlaying( TRUE ); 478 mediaPlayerState->setPlaying( TRUE );
478 qApp->processEvents(); 479 qApp->processEvents();
479 setCaption(tr("OpiePlayer")); 480 setCaption(tr("OpiePlayer"));
480 } 481 }
481} 482}
482 483
483 484
484void PlayListWidget::setActiveWindow() { 485void PlayListWidget::setActiveWindow() {
485 // When we get raised we need to ensure that it switches views 486 // When we get raised we need to ensure that it switches views
486 char origView = mediaPlayerState->view(); 487 char origView = mediaPlayerState->view();
487 mediaPlayerState->setView( 'l' ); // invalidate 488 mediaPlayerState->setView( 'l' ); // invalidate
488 mediaPlayerState->setView( origView ); // now switch back 489 mediaPlayerState->setView( origView ); // now switch back
489} 490}
490 491
491 492
492void PlayListWidget::useSelectedDocument() { 493void PlayListWidget::useSelectedDocument() {
493 d->setDocumentUsed = FALSE; 494 d->setDocumentUsed = FALSE;
494} 495}
495 496
496 497
497const DocLnk *PlayListWidget::current() { // this is fugly 498const DocLnk *PlayListWidget::current() { // this is fugly
498 499
499// if( fromSetDocument) { 500// if( fromSetDocument) {
500// qDebug("from setDoc"); 501// qDebug("from setDoc");
501// DocLnkSet files; 502// DocLnkSet files;
502// Global::findDocuments(&files, "video/*;audio/*"); 503// Global::findDocuments(&files, "video/*;audio/*");
503// QListIterator<DocLnk> dit( files.children() ); 504// QListIterator<DocLnk> dit( files.children() );
504// for ( ; dit.current(); ++dit ) { 505// for ( ; dit.current(); ++dit ) {
505// if(dit.current()->linkFile() == setDocFileRef) { 506// if(dit.current()->linkFile() == setDocFileRef) {
506// qDebug(setDocFileRef); 507// qDebug(setDocFileRef);
507// return dit; 508// return dit;
508// } 509// }
509// } 510// }
510// } else 511// } else
511 512
512 513
513 switch (tabWidget->currentPageIndex()) { 514 switch (tabWidget->currentPageIndex()) {
514 case 0: //playlist 515 case 0: //playlist
515 { 516 {
516 qDebug("playlist"); 517 qDebug("playlist");
517 if ( mediaPlayerState->playlist() ) { 518 if ( mediaPlayerState->playlist() ) {
518 return d->selectedFiles->current(); 519 return d->selectedFiles->current();
519 } 520 }
520 else if ( d->setDocumentUsed && d->current ) { 521 else if ( d->setDocumentUsed && d->current ) {
521 return d->current; 522 return d->current;
522 } else { 523 } else {
523 return d->files->selected(); 524 return d->files->selected();
524 } 525 }
525 } 526 }
526 break; 527 break;
527 case 1://audio 528 case 1://audio
528 { 529 {
529 qDebug("audioView"); 530 qDebug("audioView");
530// Global::findDocuments(&files, "audio/*");
531 QListIterator<DocLnk> dit( files.children() ); 531 QListIterator<DocLnk> dit( files.children() );
532 for ( ; dit.current(); ++dit ) { 532 for ( ; dit.current(); ++dit ) {
533 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 533 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
534 qDebug("here"); 534 qDebug("here");
535 insanityBool=TRUE; 535 insanityBool=TRUE;
536 return dit; 536 return dit;
537 } 537 }
538 } 538 }
539 } 539 }
540 break; 540 break;
541 case 2: // video 541 case 2: // video
542 { 542 {
543 qDebug("videoView"); 543 qDebug("videoView");
544// Global::findDocuments(&vFiles, "video/*");
545 QListIterator<DocLnk> Vdit( vFiles.children() ); 544 QListIterator<DocLnk> Vdit( vFiles.children() );
546 for ( ; Vdit.current(); ++Vdit ) { 545 for ( ; Vdit.current(); ++Vdit ) {
547 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 546 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
548 insanityBool=TRUE; 547 insanityBool=TRUE;
549 return Vdit; 548 return Vdit;
550 } 549 }
551 } 550 }
552 } 551 }
553 break; 552 break;
554 }; 553 };
555 return 0; 554 return 0;
556} 555}
557 556
558bool PlayListWidget::prev() { 557bool PlayListWidget::prev() {
559 if ( mediaPlayerState->playlist() ) { 558 if ( mediaPlayerState->playlist() ) {
560 if ( mediaPlayerState->shuffled() ) { 559 if ( mediaPlayerState->shuffled() ) {
561 const DocLnk *cur = current(); 560 const DocLnk *cur = current();
562 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 561 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
563 for ( int i = 0; i < j; i++ ) { 562 for ( int i = 0; i < j; i++ ) {
564 if ( !d->selectedFiles->next() ) 563 if ( !d->selectedFiles->next() )
565 d->selectedFiles->first(); 564 d->selectedFiles->first();
566 } 565 }
567 if ( cur == current() ) 566 if ( cur == current() )
568 if ( !d->selectedFiles->next() ) 567 if ( !d->selectedFiles->next() )
569 d->selectedFiles->first(); 568 d->selectedFiles->first();
570 return TRUE; 569 return TRUE;
571 } else { 570 } else {
572 if ( !d->selectedFiles->prev() ) { 571 if ( !d->selectedFiles->prev() ) {
573 if ( mediaPlayerState->looping() ) { 572 if ( mediaPlayerState->looping() ) {
574 return d->selectedFiles->last(); 573 return d->selectedFiles->last();
575 } else { 574 } else {
576 return FALSE; 575 return FALSE;
577 } 576 }
578 } 577 }
579 return TRUE; 578 return TRUE;
580 } 579 }
581 } else { 580 } else {
582 return mediaPlayerState->looping(); 581 return mediaPlayerState->looping();
583 } 582 }
584} 583}
585 584
586 585
587bool PlayListWidget::next() { 586bool PlayListWidget::next() {
588 if ( mediaPlayerState->playlist() ) { 587 if ( mediaPlayerState->playlist() ) {
589 if ( mediaPlayerState->shuffled() ) { 588 if ( mediaPlayerState->shuffled() ) {
590 return prev(); 589 return prev();
591 } else { 590 } else {
592 if ( !d->selectedFiles->next() ) { 591 if ( !d->selectedFiles->next() ) {
@@ -758,389 +757,417 @@ void PlayListWidget::playIt( QListViewItem *it) {
758 mediaPlayerState->setPlaying(FALSE); 757 mediaPlayerState->setPlaying(FALSE);
759 mediaPlayerState->setPlaying(TRUE); 758 mediaPlayerState->setPlaying(TRUE);
760 d->selectedFiles->unSelect(); 759 d->selectedFiles->unSelect();
761} 760}
762 761
763void PlayListWidget::addToSelection( QListViewItem *it) { 762void PlayListWidget::addToSelection( QListViewItem *it) {
764 d->setDocumentUsed = FALSE; 763 d->setDocumentUsed = FALSE;
765 764
766 if(it) { 765 if(it) {
767 switch (tabWidget->currentPageIndex()) { 766 switch (tabWidget->currentPageIndex()) {
768 case 1: { 767 case 1: {
769 QListIterator<DocLnk> dit( files.children() ); 768 QListIterator<DocLnk> dit( files.children() );
770 for ( ; dit.current(); ++dit ) { 769 for ( ; dit.current(); ++dit ) {
771 if( dit.current()->name() == it->text(0)) { 770 if( dit.current()->name() == it->text(0)) {
772 d->selectedFiles->addToSelection( **dit ); 771 d->selectedFiles->addToSelection( **dit );
773 } 772 }
774 } 773 }
775 } 774 }
776 break; 775 break;
777 case 2: { 776 case 2: {
778 QListIterator<DocLnk> dit( vFiles.children() ); 777 QListIterator<DocLnk> dit( vFiles.children() );
779 for ( ; dit.current(); ++dit ) { 778 for ( ; dit.current(); ++dit ) {
780 if( dit.current()->name() == it->text(0)) { 779 if( dit.current()->name() == it->text(0)) {
781 d->selectedFiles->addToSelection( **dit ); 780 d->selectedFiles->addToSelection( **dit );
782 } 781 }
783 } 782 }
784 } 783 }
785 break; 784 break;
786 case 0: 785 case 0:
787 break; 786 break;
788 }; 787 };
789 tabWidget->setCurrentPage(0); 788 tabWidget->setCurrentPage(0);
790 } 789 }
791} 790}
792 791
793void PlayListWidget::tabChanged(QWidget *widg) { 792void PlayListWidget::tabChanged(QWidget *widg) {
794 793
795 switch ( tabWidget->currentPageIndex()) { 794 switch ( tabWidget->currentPageIndex()) {
796 case 0: 795 case 0:
797 { 796 {
798 if( !tbDeletePlaylist->isHidden()) 797 if( !tbDeletePlaylist->isHidden())
799 tbDeletePlaylist->hide(); 798 tbDeletePlaylist->hide();
800 d->tbRemoveFromList->setEnabled(TRUE); 799 d->tbRemoveFromList->setEnabled(TRUE);
801 d->tbAddToList->setEnabled(FALSE); 800 d->tbAddToList->setEnabled(FALSE);
802 } 801 }
803 break; 802 break;
804 case 1: 803 case 1:
805 { 804 {
805 audioView->clear();
806 populateAudioView();
807
806 if( !tbDeletePlaylist->isHidden()) 808 if( !tbDeletePlaylist->isHidden())
807 tbDeletePlaylist->hide(); 809 tbDeletePlaylist->hide();
808 d->tbRemoveFromList->setEnabled(FALSE); 810 d->tbRemoveFromList->setEnabled(FALSE);
809 d->tbAddToList->setEnabled(TRUE); 811 d->tbAddToList->setEnabled(TRUE);
810 } 812 }
811 break; 813 break;
812 case 2: 814 case 2:
813 { 815 {
816 videoView->clear();
817 populateVideoView();
814 if( !tbDeletePlaylist->isHidden()) 818 if( !tbDeletePlaylist->isHidden())
815 tbDeletePlaylist->hide(); 819 tbDeletePlaylist->hide();
816 d->tbRemoveFromList->setEnabled(FALSE); 820 d->tbRemoveFromList->setEnabled(FALSE);
817 d->tbAddToList->setEnabled(TRUE); 821 d->tbAddToList->setEnabled(TRUE);
818 } 822 }
819 break; 823 break;
820 case 3: 824 case 3:
821 { 825 {
822 if( tbDeletePlaylist->isHidden()) 826 if( tbDeletePlaylist->isHidden())
823 tbDeletePlaylist->show(); 827 tbDeletePlaylist->show();
824 playLists->reread(); 828 playLists->reread();
825 } 829 }
826 break; 830 break;
827 }; 831 };
828} 832}
829 833
830
831
832void PlayListWidget::btnPlay(bool b) { 834void PlayListWidget::btnPlay(bool b) {
833 835
834// mediaPlayerState->setPlaying(b); 836// mediaPlayerState->setPlaying(b);
835 switch ( tabWidget->currentPageIndex()) { 837 switch ( tabWidget->currentPageIndex()) {
836 case 0: 838 case 0:
837 { 839 {
838 mediaPlayerState->setPlaying(b); 840 mediaPlayerState->setPlaying(b);
839 } 841 }
840 break; 842 break;
841 case 1: 843 case 1:
842 { 844 {
843// if(audioView->selectedItem()) { 845// if(audioView->selectedItem()) {
844 addToSelection( audioView->selectedItem() ); 846 addToSelection( audioView->selectedItem() );
845 mediaPlayerState->setPlaying(b); 847 mediaPlayerState->setPlaying(b);
846 d->selectedFiles->removeSelected( ); 848 d->selectedFiles->removeSelected( );
847 tabWidget->setCurrentPage(1); 849 tabWidget->setCurrentPage(1);
848 d->selectedFiles->unSelect(); 850 d->selectedFiles->unSelect();
849 insanityBool=FALSE; 851 insanityBool=FALSE;
850// audioView->clearSelection(); 852// audioView->clearSelection();
851// } 853// }
852 } 854 }
853 break; 855 break;
854 case 2: 856 case 2:
855 { 857 {
856// if(videoView->selectedItem() ) { 858// if(videoView->selectedItem() ) {
857 addToSelection( videoView->selectedItem() ); 859 addToSelection( videoView->selectedItem() );
858 mediaPlayerState->setPlaying(b); 860 mediaPlayerState->setPlaying(b);
859 qApp->processEvents(); 861 qApp->processEvents();
860 d->selectedFiles->removeSelected( ); 862 d->selectedFiles->removeSelected( );
861 tabWidget->setCurrentPage(2); 863 tabWidget->setCurrentPage(2);
862 d->selectedFiles->unSelect(); 864 d->selectedFiles->unSelect();
863 insanityBool=FALSE; 865 insanityBool=FALSE;
864// videoView->clearSelection(); 866// videoView->clearSelection();
865// } 867// }
866 } 868 }
867 break; 869 break;
868 }; 870 };
869} 871}
870 872
871void PlayListWidget::deletePlaylist() { 873void PlayListWidget::deletePlaylist() {
872 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 874 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
873 (tr("You really want to delete\nthis playlist?")), 875 (tr("You really want to delete\nthis playlist?")),
874 (tr("Yes")), (tr("No")), 0 )){ 876 (tr("Yes")), (tr("No")), 0 )){
875 case 0: // Yes clicked, 877 case 0: // Yes clicked,
876 QFile().remove(playLists->selected()->file()); 878 QFile().remove(playLists->selected()->file());
877 QFile().remove(playLists->selected()->linkFile()); 879 QFile().remove(playLists->selected()->linkFile());
878 playLists->reread(); 880 playLists->reread();
879 break; 881 break;
880 case 1: // Cancel 882 case 1: // Cancel
881 break; 883 break;
882 }; 884 };
883
884} 885}
885 886
886void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 887void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
887{ 888{
888 switch (mouse) { 889 switch (mouse) {
889 case 1: 890 case 1:
890 break; 891 break;
891 case 2:{ 892 case 2:{
892 QPopupMenu m; 893 QPopupMenu m;
893 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 894 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
894 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 895 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
895 m.insertSeparator(); 896 m.insertSeparator();
896 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 897 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
897 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 898 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
898 899
899 m.exec( QCursor::pos() ); 900 m.exec( QCursor::pos() );
900 } 901 }
901 break; 902 break;
902 }; 903 };
903} 904}
904 905
905void PlayListWidget::playSelected() 906void PlayListWidget::playSelected()
906{ 907{
907 btnPlay( TRUE); 908 btnPlay( TRUE);
908// d->selectedFiles->unSelect(); 909// d->selectedFiles->unSelect();
909} 910}
910 911
911void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 912void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
912{ 913{
913 switch (mouse) { 914 switch (mouse) {
914 case 1: 915 case 1:
915 916
916 break; 917 break;
917 case 2:{ 918 case 2:{
918 QPopupMenu m; 919 QPopupMenu m;
919 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 920 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
920 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 921 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
921// m.insertSeparator(); 922// m.insertSeparator();
922// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 923// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
923 m.exec( QCursor::pos() ); 924 m.exec( QCursor::pos() );
924 } 925 }
925 break; 926 break;
926 }; 927 };
927 928
928} 929}
929 930
930void PlayListWidget::listDelete() { 931void PlayListWidget::listDelete() {
931 Config cfg( "OpiePlayer" ); 932 Config cfg( "OpiePlayer" );
932 cfg.setGroup("PlayList"); 933 cfg.setGroup("PlayList");
933 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 934 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
934 QString file; 935 QString file;
935 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 936 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
936 switch ( tabWidget->currentPageIndex()) { 937 switch ( tabWidget->currentPageIndex()) {
937 case 0: 938 case 0:
938 break; 939 break;
939 case 1: 940 case 1:
940 { 941 {
941 file = audioView->selectedItem()->text(0); 942 file = audioView->selectedItem()->text(0);
942// Global::findDocuments(&files, "audio/*"); 943// Global::findDocuments(&files, "audio/*");
943// AppLnkSet appFiles; 944// AppLnkSet appFiles;
944 QListIterator<DocLnk> dit( files.children() ); 945 QListIterator<DocLnk> dit( files.children() );
945 for ( ; dit.current(); ++dit ) { 946 for ( ; dit.current(); ++dit ) {
946 if( dit.current()->name() == file) { 947 if( dit.current()->name() == file) {
947// qDebug(file); 948// qDebug(file);
948 LnkProperties prop( dit.current() ); 949 LnkProperties prop( dit.current() );
949// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 950// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
950 prop.showMaximized(); 951 prop.showMaximized();
951 prop.exec(); 952 prop.exec();
952 } 953 }
953 } 954 }
954 populateAudioView(); 955 populateAudioView();
955 } 956 }
956 break; 957 break;
957 case 2: 958 case 2:
958 { 959 {
959// file = videoView->selectedItem()->text(0); 960// file = videoView->selectedItem()->text(0);
960// for ( int i = 0; i < noOfFiles; i++ ) { 961// for ( int i = 0; i < noOfFiles; i++ ) {
961// QString entryName; 962// QString entryName;
962// entryName.sprintf( "File%i", i + 1 ); 963// entryName.sprintf( "File%i", i + 1 );
963// QString linkFile = cfg.readEntry( entryName ); 964// QString linkFile = cfg.readEntry( entryName );
964// AppLnk lnk( AppLnk(linkFile)); 965// AppLnk lnk( AppLnk(linkFile));
965// if( lnk.name() == file ) { 966// if( lnk.name() == file ) {
966// LnkProperties prop( &lnk); 967// LnkProperties prop( &lnk);
967// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 968// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
968// prop.showMaximized(); 969// prop.showMaximized();
969// prop.exec(); 970// prop.exec();
970// } 971// }
971// } 972// }
972 } 973 }
973 break; 974 break;
974 }; 975 };
975} 976}
976 977
978void PlayListWidget::scanForAudio() {
979 qDebug("scan for audio");
980 files.detachChildren();
981 QListIterator<DocLnk> sdit( files.children() );
982 for ( ; sdit.current(); ++sdit ) {
983 delete sdit.current();
984 }
985 Global::findDocuments(&files, "audio/*");
986 audioScan = TRUE;
987}
988void PlayListWidget::scanForVideo() {
989 qDebug("scan for video");
990 vFiles.detachChildren();
991 QListIterator<DocLnk> sdit( vFiles.children() );
992 for ( ; sdit.current(); ++sdit ) {
993 delete sdit.current();
994 }
995 Global::findDocuments(&vFiles, "video/*");
996 videoScan = TRUE;
997}
998
977void PlayListWidget::populateAudioView() { 999void PlayListWidget::populateAudioView() {
978// if(files) 1000
979// files.~DocLnkSet(); 1001 audioView->clear();
980 StorageInfo storageInfo; 1002 StorageInfo storageInfo;
981 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1003 const QList<FileSystem> &fs = storageInfo.fileSystems();
1004 if(!audioScan) scanForAudio();
982 1005
983 Global::findDocuments(&files, "audio/*");
984 QListIterator<DocLnk> dit( files.children() ); 1006 QListIterator<DocLnk> dit( files.children() );
985 QListIterator<FileSystem> it ( fs ); 1007 QListIterator<FileSystem> it ( fs );
986 audioView->clear(); 1008
987 QString storage; 1009 QString storage;
988 for ( ; dit.current(); ++dit ) { 1010 for ( ; dit.current(); ++dit ) {
989 for( ; it.current(); ++it ){ 1011 for( ; it.current(); ++it ){
990 const QString name = (*it)->name(); 1012 const QString name = (*it)->name();
991 const QString path = (*it)->path(); 1013 const QString path = (*it)->path();
992 if(dit.current()->file().find(path) != -1 ) storage=name; 1014 if(dit.current()->file().find(path) != -1 ) storage=name;
993 } 1015 }
994 1016
995 QListViewItem * newItem; 1017 QListViewItem * newItem;
996 if ( QFile( dit.current()->file()).exists() ) { 1018 if ( QFile( dit.current()->file()).exists() ) {
997 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 1019// qDebug(dit.current()->name());
1020 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1021 QString::number( QFile( dit.current()->file()).size() ), storage);
998 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1022 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
999 } 1023 }
1000 } 1024 }
1001 1025
1002} 1026}
1003 1027
1004void PlayListWidget::populateVideoView() { 1028void PlayListWidget::populateVideoView() {
1029 videoView->clear();
1005 StorageInfo storageInfo; 1030 StorageInfo storageInfo;
1006 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1031 const QList<FileSystem> &fs = storageInfo.fileSystems();
1007 1032
1008 Global::findDocuments(&vFiles, "video/*"); 1033 if(!videoScan ) scanForVideo();
1034
1009 QListIterator<DocLnk> Vdit( vFiles.children() ); 1035 QListIterator<DocLnk> Vdit( vFiles.children() );
1010 QListIterator<FileSystem> it ( fs ); 1036 QListIterator<FileSystem> it ( fs );
1011 videoView->clear(); 1037 videoView->clear();
1012 QString storage; 1038 QString storage;
1013 for ( ; Vdit.current(); ++Vdit ) { 1039 for ( ; Vdit.current(); ++Vdit ) {
1014 for( ; it.current(); ++it ){ 1040 for( ; it.current(); ++it ){
1015 const QString name = (*it)->name(); 1041 const QString name = (*it)->name();
1016 const QString path = (*it)->path(); 1042 const QString path = (*it)->path();
1017 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1043 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1018 } 1044 }
1019 1045
1020 QListViewItem * newItem; 1046 QListViewItem * newItem;
1021 if ( QFile( Vdit.current()->file()).exists() ) { 1047 if ( QFile( Vdit.current()->file()).exists() ) {
1022 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 1048 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1049 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1023 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1050 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1024 } 1051 }
1025 } 1052 }
1026} 1053}
1027 1054
1028void PlayListWidget::openFile() { 1055void PlayListWidget::openFile() {
1029 QString filename, name; 1056 QString filename, name;
1030 InputDialog *fileDlg; 1057 InputDialog *fileDlg;
1031 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1058 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1032 fileDlg->exec(); 1059 fileDlg->exec();
1033 if( fileDlg->result() == 1 ) { 1060 if( fileDlg->result() == 1 ) {
1034 filename = fileDlg->LineEdit1->text(); 1061 filename = fileDlg->LineEdit1->text();
1035// http://205.188.234.129:8030 1062// http://205.188.234.129:8030
1036// http://66.28.68.70:8000 1063// http://66.28.68.70:8000
1037 qDebug("Selected filename is "+filename); 1064 qDebug("Selected filename is "+filename);
1038 if(filename.right(3) == "m3u") 1065 if(filename.right(3) == "m3u")
1039 readm3u( filename); 1066 readm3u( filename);
1040 else if(filename.right(3) == "pls") 1067 else if(filename.right(3) == "pls")
1041 readPls( filename); 1068 readPls( filename);
1042 else { 1069 else {
1043 DocLnk lnk; 1070 DocLnk lnk;
1044 1071
1045 lnk.setName(filename); //sets file name 1072 lnk.setName(filename); //sets file name
1046 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1073 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1047 filename += "/"; 1074 filename += "/";
1048 lnk.setFile(filename); //sets File property 1075 lnk.setFile(filename); //sets File property
1049 1076
1050 lnk.setType("audio/x-mpegurl"); 1077 lnk.setType("audio/x-mpegurl");
1051 lnk.setExec("opieplayer"); 1078 lnk.setExec("opieplayer");
1052 lnk.setIcon("opieplayer/MPEGPlayer"); 1079 lnk.setIcon("opieplayer/MPEGPlayer");
1053 1080
1054 if(!lnk.writeLink()) 1081 if(!lnk.writeLink())
1055 qDebug("Writing doclink did not work"); 1082 qDebug("Writing doclink did not work");
1056 d->selectedFiles->addToSelection( lnk); 1083 d->selectedFiles->addToSelection( lnk);
1057// if(fileDlg2) 1084// if(fileDlg2)
1058// delete fileDlg2; 1085// delete fileDlg2;
1059 } 1086 }
1060 } 1087 }
1061 if(fileDlg) 1088 if(fileDlg)
1062 delete fileDlg; 1089 delete fileDlg;
1063} 1090}
1064 1091
1065void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1092void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1066{ 1093{
1067 switch ( e->key() ) { 1094 switch ( e->key() ) {
1068////////////////////////////// Zaurus keys 1095////////////////////////////// Zaurus keys
1069 case Key_F9: //activity 1096 case Key_F9: //activity
1070// if(audioUI->isHidden()) 1097// if(audioUI->isHidden())
1071// audioUI->showMaximized(); 1098// audioUI->showMaximized();
1072 break; 1099 break;
1073 case Key_F10: //contacts 1100 case Key_F10: //contacts
1074// if( videoUI->isHidden()) 1101// if( videoUI->isHidden())
1075// videoUI->showMaximized(); 1102// videoUI->showMaximized();
1076 break; 1103 break;
1077 case Key_F11: //menu 1104 case Key_F11: //menu
1078 break; 1105 break;
1079 case Key_F12: //home 1106 case Key_F12: //home
1080// doBlank(); 1107// doBlank();
1081 break; 1108 break;
1082 case Key_F13: //mail 1109 case Key_F13: //mail
1083// doUnblank(); 1110// doUnblank();
1084 break; 1111 break;
1085 case Key_Q: //add to playlist 1112 case Key_Q: //add to playlist
1086 qDebug("Add"); 1113 qDebug("Add");
1087 addSelected(); 1114 addSelected();
1088 break; 1115 break;
1089 case Key_R: //remove from playlist 1116 case Key_R: //remove from playlist
1090 removeSelected(); 1117 removeSelected();
1091 break; 1118 break;
1092// case Key_P: //play 1119// case Key_P: //play
1093// qDebug("Play"); 1120// qDebug("Play");
1094// playSelected(); 1121// playSelected();
1095// break; 1122// break;
1096 case Key_Space: 1123 case Key_Space:
1097 qDebug("Play"); 1124 qDebug("Play");
1098 playSelected(); 1125// playSelected(); puh
1099 break; 1126 break;
1100 case Key_1: 1127 case Key_1:
1101 tabWidget->setCurrentPage(0); 1128 tabWidget->setCurrentPage(0);
1102 break; 1129 break;
1103 case Key_2: 1130 case Key_2:
1104 tabWidget->setCurrentPage(1); 1131 tabWidget->setCurrentPage(1);
1105 break; 1132 break;
1106 case Key_3: 1133 case Key_3:
1107 tabWidget->setCurrentPage(2); 1134 tabWidget->setCurrentPage(2);
1108 break; 1135 break;
1109 case Key_4: 1136 case Key_4:
1110 tabWidget->setCurrentPage(3); 1137 tabWidget->setCurrentPage(3);
1111 break; 1138 break;
1112 } 1139 }
1113} 1140}
1114 1141
1115void PlayListWidget::keyPressEvent( QKeyEvent *e) 1142void PlayListWidget::keyPressEvent( QKeyEvent *e)
1116{ 1143{
1117// qDebug("Key press"); 1144// qDebug("Key press");
1118// switch ( e->key() ) { 1145// switch ( e->key() ) {
1119// ////////////////////////////// Zaurus keys 1146// ////////////////////////////// Zaurus keys
1120// case Key_A: //add to playlist 1147// case Key_A: //add to playlist
1121// qDebug("Add"); 1148// qDebug("Add");
1122// addSelected(); 1149// addSelected();
1123// break; 1150// break;
1124// case Key_R: //remove from playlist 1151// case Key_R: //remove from playlist
1125// removeSelected(); 1152// removeSelected();
1126// break; 1153// break;
1127// case Key_P: //play 1154// case Key_P: //play
1128// qDebug("Play"); 1155// qDebug("Play");
1129// playSelected(); 1156// playSelected();
1130// break; 1157// break;
1131// case Key_Space: 1158// case Key_Space:
1132// qDebug("Play"); 1159// qDebug("Play");
1133// playSelected(); 1160// playSelected();
1134// break; 1161// break;
1135// } 1162// }
1136} 1163}
1137 1164
1138void PlayListWidget::doBlank() { 1165void PlayListWidget::doBlank() {
1139 qDebug("do blanking"); 1166 qDebug("do blanking");
1140 fd=open("/dev/fb0",O_RDWR); 1167 fd=open("/dev/fb0",O_RDWR);
1141 if (fd != -1) { 1168 if (fd != -1) {
1142 ioctl(fd,FBIOBLANK,1); 1169 ioctl(fd,FBIOBLANK,1);
1143// close(fd); 1170// close(fd);
1144 } 1171 }
1145} 1172}
1146 1173
@@ -1188,48 +1215,49 @@ void PlayListWidget::readm3u(const QString &filename) {
1188 QString name = s.right( s.length() - 7); 1215 QString name = s.right( s.length() - 7);
1189// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1216// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1190 lnk.setName(name); 1217 lnk.setName(name);
1191 lnk.setFile( s+"/"); 1218 lnk.setFile( s+"/");
1192// lnk.setFile( filename); 1219// lnk.setFile( filename);
1193// lnk.setComment( s+"/"); 1220// lnk.setComment( s+"/");
1194 lnk.setType("audio/x-mpegurl"); 1221 lnk.setType("audio/x-mpegurl");
1195// lnk.setIcon( "opieplayer/MPEGPlayer"); 1222// lnk.setIcon( "opieplayer/MPEGPlayer");
1196// qDebug("add "+s); 1223// qDebug("add "+s);
1197 d->selectedFiles->addToSelection( lnk); 1224 d->selectedFiles->addToSelection( lnk);
1198 } 1225 }
1199 i++; 1226 i++;
1200 } 1227 }
1201 } 1228 }
1202 } 1229 }
1203 } 1230 }
1204} 1231}
1205 1232
1206void PlayListWidget::writem3u(const QString &filename) { 1233void PlayListWidget::writem3u(const QString &filename) {
1207 1234
1208} 1235}
1209 1236
1210void PlayListWidget::readPls(const QString &filename) { 1237void PlayListWidget::readPls(const QString &filename) {
1211 1238
1212 qDebug("playlist filename is "+filename); 1239 qDebug("playlist filename is "+filename);
1213 QFile f(filename); 1240 QFile f(filename);
1214 1241
1215 if(f.open(IO_ReadOnly)) { 1242 if(f.open(IO_ReadOnly)) {
1216 QTextStream t(&f); 1243 QTextStream t(&f);
1217 QString s;//, first, second; 1244 QString s;//, first, second;
1218 int i=0; 1245 int i=0;
1219 while ( !t.atEnd()) { 1246 while ( !t.atEnd()) {
1220// Lview->insertLine(t.readLine(),-1); 1247// Lview->insertLine(t.readLine(),-1);
1221// s=t.readLine(); 1248// s=t.readLine();
1222// s=s.right(s.length()-2); 1249// s=s.right(s.length()-2);
1223// DocLnk lnk( s ); 1250// DocLnk lnk( s );
1224// QFileInfo f(s); 1251// QFileInfo f(s);
1225// QString name = f.baseName(); 1252// QString name = f.baseName();
1226// // name = name.left(name.length()-4); 1253// // name = name.left(name.length()-4);
1227// name = name.right(name.findRev("/",0,TRUE)); 1254// name = name.right(name.findRev("/",0,TRUE));
1228// lnk.setName( name); 1255// lnk.setName( name);
1229// lnk.setFile( s); 1256// lnk.setFile( s);
1230// qDebug("add "+name); 1257// qDebug("add "+name);
1231// d->selectedFiles->addToSelection( lnk); 1258// d->selectedFiles->addToSelection( lnk);
1232 } 1259 }
1233 i++; 1260 i++;
1234 } 1261 }
1235} 1262}
1263
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 778e3ee..6569f35 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -26,97 +26,100 @@
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29/* #include <qtimer.h> */ 29/* #include <qtimer.h> */
30 30
31 31
32class PlayListWidgetPrivate; 32class PlayListWidgetPrivate;
33class Config; 33class Config;
34class QListViewItem; 34class QListViewItem;
35class QListView; 35class QListView;
36class QPoint; 36class QPoint;
37class QAction; 37class QAction;
38class QLabel; 38class QLabel;
39 39
40class PlayListWidget : public QMainWindow { 40class PlayListWidget : public QMainWindow {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 44 ~PlayListWidget();
45 QTabWidget * tabWidget; 45 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 46 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 47 DocLnkSet files;
48 DocLnkSet vFiles; 48 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 49 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 50 QLabel *libString;
51 bool fromSetDocument; 51 bool fromSetDocument;
52 bool insanityBool; 52 bool insanityBool;
53 QString setDocFileRef; 53 QString setDocFileRef;
54 // retrieve the current playlist entry (media file link) 54 // retrieve the current playlist entry (media file link)
55 const DocLnk *current(); 55 const DocLnk *current();
56 void useSelectedDocument(); 56 void useSelectedDocument();
57/* QTimer * menuTimer; */ 57/* QTimer * menuTimer; */
58 FileSelector* playLists; 58 FileSelector* playLists;
59 QPushButton *tbDeletePlaylist; 59 QPushButton *tbDeletePlaylist;
60 int fd; 60 int fd;
61public slots: 61public slots:
62 bool first(); 62 bool first();
63 bool last(); 63 bool last();
64 bool next(); 64 bool next();
65 bool prev(); 65 bool prev();
66/* void setFullScreen(); */ 66/* void setFullScreen(); */
67/* void setScaled(); */ 67/* void setScaled(); */
68protected: 68protected:
69/* void contentsMousePressEvent( QMouseEvent * e ); */ 69/* void contentsMousePressEvent( QMouseEvent * e ); */
70/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 70/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
71void keyReleaseEvent( QKeyEvent *e); 71void keyReleaseEvent( QKeyEvent *e);
72void keyPressEvent( QKeyEvent *e); 72void keyPressEvent( QKeyEvent *e);
73private: 73private:
74 bool audioScan, videoScan;
74 void doBlank(); 75 void doBlank();
75 void doUnblank(); 76 void doUnblank();
76 void readm3u(const QString &); 77 void readm3u(const QString &);
77 void writem3u(const QString &); 78 void writem3u(const QString &);
78 void readPls(const QString &); 79 void readPls(const QString &);
79 80
80 81
81 void initializeStates(); 82 void initializeStates();
82 void readConfig( Config& cfg ); 83 void readConfig( Config& cfg );
83 void writeConfig( Config& cfg ) const; 84 void writeConfig( Config& cfg ) const;
84 PlayListWidgetPrivate *d; // Private implementation data 85 PlayListWidgetPrivate *d; // Private implementation data
85 void populateAudioView(); 86 void populateAudioView();
86 void populateVideoView(); 87 void populateVideoView();
87private slots: 88private slots:
89 void scanForAudio();
90 void scanForVideo();
88 void openFile(); 91 void openFile();
89 void setDocument( const QString& fileref ); 92 void setDocument( const QString& fileref );
90 void addToSelection( const DocLnk& ); // Add a media file to the playlist 93 void addToSelection( const DocLnk& ); // Add a media file to the playlist
91 void addToSelection( QListViewItem* ); // Add a media file to the playlist 94 void addToSelection( QListViewItem* ); // Add a media file to the playlist
92 void setActiveWindow(); // need to handle this to show the right view 95 void setActiveWindow(); // need to handle this to show the right view
93 void setPlaylist( bool ); // Show/Hide the playlist 96 void setPlaylist( bool ); // Show/Hide the playlist
94 void setView( char ); 97 void setView( char );
95 void clearList(); 98 void clearList();
96 void addAllToList(); 99 void addAllToList();
97 void addAllMusicToList(); 100 void addAllMusicToList();
98 void addAllVideoToList(); 101 void addAllVideoToList();
99 void saveList(); // Save the playlist 102 void saveList(); // Save the playlist
100 void loadList( const DocLnk &); // Load a playlist 103 void loadList( const DocLnk &); // Load a playlist
101 void playIt( QListViewItem *); 104 void playIt( QListViewItem *);
102 105
103 void btnPlay(bool); 106 void btnPlay(bool);
104 void deletePlaylist(); 107 void deletePlaylist();
105 void addSelected(); 108 void addSelected();
106 void removeSelected(); 109 void removeSelected();
107 void tabChanged(QWidget*); 110 void tabChanged(QWidget*);
108 void viewPressed( int, QListViewItem *, const QPoint&, int); 111 void viewPressed( int, QListViewItem *, const QPoint&, int);
109 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 112 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
110 void playSelected(); 113 void playSelected();
111 void listDelete(); 114 void listDelete();
112 115
113protected slots: 116protected slots:
114/* void cancelMenuTimer(); */ 117/* void cancelMenuTimer(); */
115/* void showFileMenu(); */ 118/* void showFileMenu(); */
116 119
117 120
118}; 121};
119 122
120 123
121#endif // PLAY_LIST_WIDGET_H 124#endif // PLAY_LIST_WIDGET_H
122 125