summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index efb5df3..3609f5d 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1457 +1,1457 @@
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 22
23#include <qtoolbar.h> 23#include <qtoolbar.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/lnkproperties.h> 25#include <qpe/lnkproperties.h>
26 26
27#include <qaction.h> 27#include <qaction.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30 30
31//#include <qtimer.h> 31//#include <qtimer.h>
32 32
33#include "playlistselection.h" 33#include "playlistselection.h"
34#include "playlistwidget.h" 34#include "playlistwidget.h"
35#include "mediaplayerstate.h" 35#include "mediaplayerstate.h"
36 36
37#include "inputDialog.h" 37#include "inputDialog.h"
38 38
39#include <stdlib.h> 39#include <stdlib.h>
40#include "audiowidget.h" 40#include "audiowidget.h"
41#include "videowidget.h" 41#include "videowidget.h"
42 42
43#include <unistd.h> 43#include <unistd.h>
44#include <sys/file.h> 44#include <sys/file.h>
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46#include <sys/soundcard.h> 46#include <sys/soundcard.h>
47 47
48// for setBacklight() 48// for setBacklight()
49#include <linux/fb.h> 49#include <linux/fb.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/stat.h> 51#include <sys/stat.h>
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#define BUTTONS_ON_TOOLBAR 54#define BUTTONS_ON_TOOLBAR
55#define SIDE_BUTTONS 55#define SIDE_BUTTONS
56#define CAN_SAVE_LOAD_PLAYLISTS 56#define CAN_SAVE_LOAD_PLAYLISTS
57 57
58extern AudioWidget *audioUI; 58extern AudioWidget *audioUI;
59extern VideoWidget *videoUI; 59extern VideoWidget *videoUI;
60extern MediaPlayerState *mediaPlayerState; 60extern MediaPlayerState *mediaPlayerState;
61 61
62static inline QString fullBaseName ( const QFileInfo &fi ) 62static inline QString fullBaseName ( const QFileInfo &fi )
63{ 63{
64 QString str = fi. fileName ( ); 64 QString str = fi. fileName ( );
65 return str. left ( str. findRev ( '.' )); 65 return str. left ( str. findRev ( '.' ));
66} 66}
67 67
68 68
69QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; 69QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
70// class myFileSelector { 70// class myFileSelector {
71 71
72// }; 72// };
73class PlayListWidgetPrivate { 73class PlayListWidgetPrivate {
74public: 74public:
75 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 75 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
76 QFrame *playListFrame; 76 QFrame *playListFrame;
77 FileSelector *files; 77 FileSelector *files;
78 PlayListSelection *selectedFiles; 78 PlayListSelection *selectedFiles;
79 bool setDocumentUsed; 79 bool setDocumentUsed;
80 DocLnk *current; 80 DocLnk *current;
81}; 81};
82 82
83 83
84class ToolButton : public QToolButton { 84class ToolButton : public QToolButton {
85public: 85public:
86 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 86 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
87 : QToolButton( parent, name ) { 87 : QToolButton( parent, name ) {
88 setTextLabel( name ); 88 setTextLabel( name );
89 setPixmap( Resource::loadPixmap( icon ) ); 89 setPixmap( Resource::loadPixmap( icon ) );
90 setAutoRaise( TRUE ); 90 setAutoRaise( TRUE );
91 setFocusPolicy( QWidget::NoFocus ); 91 setFocusPolicy( QWidget::NoFocus );
92 setToggleButton( t ); 92 setToggleButton( t );
93 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 93 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
94 QPEMenuToolFocusManager::manager()->addWidget( this ); 94 QPEMenuToolFocusManager::manager()->addWidget( this );
95 } 95 }
96}; 96};
97 97
98 98
99class MenuItem : public QAction { 99class MenuItem : public QAction {
100public: 100public:
101 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 101 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
102 : QAction( text, QString::null, 0, 0 ) { 102 : QAction( text, QString::null, 0, 0 ) {
103 connect( this, SIGNAL( activated() ), handler, slot ); 103 connect( this, SIGNAL( activated() ), handler, slot );
104 addTo( parent ); 104 addTo( parent );
105 } 105 }
106}; 106};
107 107
108 108
109PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 109PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
110 : QMainWindow( parent, name, fl ) { 110 : QMainWindow( parent, name, fl ) {
111 111
112 d = new PlayListWidgetPrivate; 112 d = new PlayListWidgetPrivate;
113 d->setDocumentUsed = FALSE; 113 d->setDocumentUsed = FALSE;
114 d->current = NULL; 114 d->current = NULL;
115 fromSetDocument = FALSE; 115 fromSetDocument = FALSE;
116 insanityBool=FALSE; 116 insanityBool=FALSE;
117 audioScan = FALSE; 117 audioScan = FALSE;
118 videoScan = FALSE; 118 videoScan = FALSE;
119// menuTimer = new QTimer( this ,"menu timer"), 119// menuTimer = new QTimer( this ,"menu timer"),
120// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 120// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
121 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 121 channel = new QCopChannel( "QPE/Application/opieplayer", this );
122 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 122 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
123 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 123 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
124 124
125 setBackgroundMode( PaletteButton ); 125 setBackgroundMode( PaletteButton );
126 126
127 setCaption( tr("OpiePlayer") ); 127 setCaption( tr("OpiePlayer") );
128 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 128 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
129 129
130 setToolBarsMovable( FALSE ); 130 setToolBarsMovable( FALSE );
131 131
132 // Create Toolbar 132 // Create Toolbar
133 QToolBar *toolbar = new QToolBar( this ); 133 QToolBar *toolbar = new QToolBar( this );
134 toolbar->setHorizontalStretchable( TRUE ); 134 toolbar->setHorizontalStretchable( TRUE );
135 135
136 // Create Menubar 136 // Create Menubar
137 QMenuBar *menu = new QMenuBar( toolbar ); 137 QMenuBar *menu = new QMenuBar( toolbar );
138 menu->setMargin( 0 ); 138 menu->setMargin( 0 );
139 139
140 QToolBar *bar = new QToolBar( this ); 140 QToolBar *bar = new QToolBar( this );
141 bar->setLabel( tr( "Play Operations" ) ); 141 bar->setLabel( tr( "Play Operations" ) );
142// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 142// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
143// this , SLOT( addSelected()) ); 143// this , SLOT( addSelected()) );
144 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 144 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
145 tbDeletePlaylist->setFlat(TRUE); 145 tbDeletePlaylist->setFlat(TRUE);
146 146
147 tbDeletePlaylist->setFixedSize(20,20); 147 tbDeletePlaylist->setFixedSize(20,20);
148 148
149 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 149 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
150 this , SLOT(addSelected()) ); 150 this , SLOT(addSelected()) );
151 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 151 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
152 this , SLOT(removeSelected()) ); 152 this , SLOT(removeSelected()) );
153// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); 153// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE );
154 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 154 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
155 this , SLOT( btnPlay(bool) ), TRUE ); 155 this , SLOT( btnPlay(bool) ), TRUE );
156 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 156 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
157 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 157 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
158 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 158 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
159 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 159 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
160 tbDeletePlaylist->hide(); 160 tbDeletePlaylist->hide();
161 161
162 QPopupMenu *pmPlayList = new QPopupMenu( this ); 162 QPopupMenu *pmPlayList = new QPopupMenu( this );
163 menu->insertItem( tr( "File" ), pmPlayList ); 163 menu->insertItem( tr( "File" ), pmPlayList );
164 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 164 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
165 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 165 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
166 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 166 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
167 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 167 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
168 pmPlayList->insertSeparator(-1); 168 pmPlayList->insertSeparator(-1);
169 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 169 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
170 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 170 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
171 pmPlayList->insertSeparator(-1); 171 pmPlayList->insertSeparator(-1);
172 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 172 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
173 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 173 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
174 174
175 QPopupMenu *pmView = new QPopupMenu( this ); 175 QPopupMenu *pmView = new QPopupMenu( this );
176 menu->insertItem( tr( "View" ), pmView ); 176 menu->insertItem( tr( "View" ), pmView );
177 177
178 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 178 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
179 fullScreenButton->addTo(pmView); 179 fullScreenButton->addTo(pmView);
180 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 180 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
181 scaleButton->addTo(pmView); 181 scaleButton->addTo(pmView);
182 182
183 183
184 skinsMenu = new QPopupMenu( this ); 184 skinsMenu = new QPopupMenu( this );
185 menu->insertItem( tr( "Skins" ), skinsMenu ); 185 menu->insertItem( tr( "Skins" ), skinsMenu );
186 skinsMenu->isCheckable(); 186 skinsMenu->isCheckable();
187 connect( skinsMenu, SIGNAL( activated(int) ) , 187 connect( skinsMenu, SIGNAL( activated(int) ) ,
188 this, SLOT( skinsMenuActivated(int) ) ); 188 this, SLOT( skinsMenuActivated(int) ) );
189 populateSkinsMenu(); 189 populateSkinsMenu();
190 190
191 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 191 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
192 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 192 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
193 193
194 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 194 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
195 195
196 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 196 tabWidget = new QTabWidget( hbox6, "tabWidget" );
197// tabWidget->setTabShape(QTabWidget::Triangular); 197// tabWidget->setTabShape(QTabWidget::Triangular);
198 198
199 QWidget *pTab; 199 QWidget *pTab;
200 pTab = new QWidget( tabWidget, "pTab" ); 200 pTab = new QWidget( tabWidget, "pTab" );
201// playlistView = new QListView( pTab, "playlistview" ); 201// playlistView = new QListView( pTab, "playlistview" );
202// playlistView->setMinimumSize(236,260); 202// playlistView->setMinimumSize(236,260);
203 tabWidget->insertTab( pTab,"Playlist"); 203 tabWidget->insertTab( pTab,"Playlist");
204 204
205 205
206 // Add the playlist area 206 // Add the playlist area
207 207
208 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 208 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
209 d->playListFrame = vbox3; 209 d->playListFrame = vbox3;
210 210
211 QGridLayout *layoutF = new QGridLayout( pTab ); 211 QGridLayout *layoutF = new QGridLayout( pTab );
212 layoutF->setSpacing( 2); 212 layoutF->setSpacing( 2);
213 layoutF->setMargin( 2); 213 layoutF->setMargin( 2);
214 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 214 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
215 215
216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 216 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
217 217
218 d->selectedFiles = new PlayListSelection( hbox2); 218 d->selectedFiles = new PlayListSelection( hbox2);
219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 219 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
220 220
221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 221 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
222 222
223 223
224 224
225 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 225 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
226 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 226 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
227 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 227 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
228 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 228 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
229 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 229 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
230 230
231 QWidget *aTab; 231 QWidget *aTab;
232 aTab = new QWidget( tabWidget, "aTab" ); 232 aTab = new QWidget( tabWidget, "aTab" );
233 audioView = new QListView( aTab, "Audioview" ); 233 audioView = new QListView( aTab, "Audioview" );
234 234
235 QGridLayout *layoutA = new QGridLayout( aTab ); 235 QGridLayout *layoutA = new QGridLayout( aTab );
236 layoutA->setSpacing( 2); 236 layoutA->setSpacing( 2);
237 layoutA->setMargin( 2); 237 layoutA->setMargin( 2);
238 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 238 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 );
239 239
240 audioView->addColumn( tr("Title"),-1); 240 audioView->addColumn( tr("Title"),-1);
241 audioView->addColumn(tr("Size"), -1); 241 audioView->addColumn(tr("Size"), -1);
242 audioView->addColumn(tr("Media"),-1); 242 audioView->addColumn(tr("Media"),-1);
243 audioView->addColumn( tr( "Path" ), -1 ); 243 audioView->addColumn( tr( "Path" ), -1 );
244 244
245 audioView->setColumnAlignment(1, Qt::AlignRight); 245 audioView->setColumnAlignment(1, Qt::AlignRight);
246 audioView->setColumnAlignment(2, Qt::AlignRight); 246 audioView->setColumnAlignment(2, Qt::AlignRight);
247 audioView->setAllColumnsShowFocus(TRUE); 247 audioView->setAllColumnsShowFocus(TRUE);
248 248
249 audioView->setMultiSelection( TRUE ); 249 audioView->setMultiSelection( TRUE );
250 audioView->setSelectionMode( QListView::Extended); 250 audioView->setSelectionMode( QListView::Extended);
251 audioView->setSorting( 3, TRUE ); 251 audioView->setSorting( 3, TRUE );
252 252
253 tabWidget->insertTab(aTab,tr("Audio")); 253 tabWidget->insertTab(aTab,tr("Audio"));
254 254
255 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
256 256
257// audioView 257// audioView
258// populateAudioView(); 258// populateAudioView();
259// videowidget 259// videowidget
260 260
261 QWidget *vTab; 261 QWidget *vTab;
262 vTab = new QWidget( tabWidget, "vTab" ); 262 vTab = new QWidget( tabWidget, "vTab" );
263 videoView = new QListView( vTab, "Videoview" ); 263 videoView = new QListView( vTab, "Videoview" );
264 264
265 QGridLayout *layoutV = new QGridLayout( vTab ); 265 QGridLayout *layoutV = new QGridLayout( vTab );
266 layoutV->setSpacing( 2); 266 layoutV->setSpacing( 2);
267 layoutV->setMargin( 2); 267 layoutV->setMargin( 2);
268 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 268 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
269 269
270 videoView->addColumn(tr("Title"),-1); 270 videoView->addColumn(tr("Title"),-1);
271 videoView->addColumn(tr("Size"),-1); 271 videoView->addColumn(tr("Size"),-1);
272 videoView->addColumn(tr("Media"),-1); 272 videoView->addColumn(tr("Media"),-1);
273 videoView->addColumn(tr( "Path" ), -1 ); 273 videoView->addColumn(tr( "Path" ), -1 );
274 videoView->setColumnAlignment(1, Qt::AlignRight); 274 videoView->setColumnAlignment(1, Qt::AlignRight);
275 videoView->setColumnAlignment(2, Qt::AlignRight); 275 videoView->setColumnAlignment(2, Qt::AlignRight);
276 videoView->setAllColumnsShowFocus(TRUE); 276 videoView->setAllColumnsShowFocus(TRUE);
277 videoView->setMultiSelection( TRUE ); 277 videoView->setMultiSelection( TRUE );
278 videoView->setSelectionMode( QListView::Extended); 278 videoView->setSelectionMode( QListView::Extended);
279 279
280 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 280 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
281 281
282 tabWidget->insertTab( vTab,tr("Video")); 282 tabWidget->insertTab( vTab,tr("Video"));
283 283
284 QWidget *LTab; 284 QWidget *LTab;
285 LTab = new QWidget( tabWidget, "LTab" ); 285 LTab = new QWidget( tabWidget, "LTab" );
286 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); 286 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE);
287 287
288 QGridLayout *layoutL = new QGridLayout( LTab ); 288 QGridLayout *layoutL = new QGridLayout( LTab );
289 layoutL->setSpacing( 2); 289 layoutL->setSpacing( 2);
290 layoutL->setMargin( 2); 290 layoutL->setMargin( 2);
291 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 291 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
292 292
293 tabWidget->insertTab(LTab,tr("Lists")); 293 tabWidget->insertTab(LTab,tr("Lists"));
294 294
295 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 295 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
296 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 296 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
297 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 297 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
298 298
299 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 299 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
300 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); 300 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) );
301 301
302 302
303///audioView 303///audioView
304 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 304 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
305 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 305 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
306 306
307 connect( audioView, SIGNAL( returnPressed(QListViewItem*)), 307 connect( audioView, SIGNAL( returnPressed(QListViewItem*)),
308 this,SLOT( playIt(QListViewItem*)) ); 308 this,SLOT( playIt(QListViewItem*)) );
309 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 309 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
310 310
311 311
312//videoView 312//videoView
313 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 313 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
314 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 314 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
315 connect( videoView, SIGNAL( returnPressed(QListViewItem*)), 315 connect( videoView, SIGNAL( returnPressed(QListViewItem*)),
316 this,SLOT( playIt(QListViewItem*)) ); 316 this,SLOT( playIt(QListViewItem*)) );
317 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 317 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
318 318
319//playlists 319//playlists
320 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); 320 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) );
321 321
322 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 322 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
323 323
324 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); 324 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) );
325 325
326 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); 326 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) );
327 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); 327 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) );
328 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); 328 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) );
329 329
330 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); 330 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) );
331 331
332 setCentralWidget( vbox5 ); 332 setCentralWidget( vbox5 );
333 333
334 Config cfg( "OpiePlayer" ); 334 Config cfg( "OpiePlayer" );
335 readConfig( cfg ); 335 readConfig( cfg );
336 336
337 currentPlayList = cfg.readEntry("CurrentPlaylist","default"); 337 currentPlayList = cfg.readEntry("CurrentPlaylist","default");
338 loadList(DocLnk( currentPlayList)); 338 loadList(DocLnk( currentPlayList));
339 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); 339 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
340 340
341 initializeStates(); 341 initializeStates();
342} 342}
343 343
344 344
345PlayListWidget::~PlayListWidget() { 345PlayListWidget::~PlayListWidget() {
346 Config cfg( "OpiePlayer" ); 346 Config cfg( "OpiePlayer" );
347 writeConfig( cfg ); 347 writeConfig( cfg );
348 348
349 if ( d->current ) 349 if ( d->current )
350 delete d->current; 350 delete d->current;
351 if(d) delete d; 351 if(d) delete d;
352} 352}
353 353
354 354
355void PlayListWidget::initializeStates() { 355void PlayListWidget::initializeStates() {
356 356
357 d->tbPlay->setOn( mediaPlayerState->playing() ); 357 d->tbPlay->setOn( mediaPlayerState->playing() );
358 d->tbLoop->setOn( mediaPlayerState->looping() ); 358 d->tbLoop->setOn( mediaPlayerState->looping() );
359 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 359 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
360 setPlaylist( true); 360 setPlaylist( true);
361} 361}
362 362
363 363
364void PlayListWidget::readConfig( Config& cfg ) { 364void PlayListWidget::readConfig( Config& cfg ) {
365 cfg.setGroup("PlayList"); 365 cfg.setGroup("PlayList");
366 QString currentString = cfg.readEntry("current", "" ); 366 QString currentString = cfg.readEntry("current", "" );
367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
368 for ( int i = 0; i < noOfFiles; i++ ) { 368 for ( int i = 0; i < noOfFiles; i++ ) {
369 QString entryName; 369 QString entryName;
370 entryName.sprintf( "File%i", i + 1 ); 370 entryName.sprintf( "File%i", i + 1 );
371 QString linkFile = cfg.readEntry( entryName ); 371 QString linkFile = cfg.readEntry( entryName );
372 DocLnk lnk( linkFile ); 372 DocLnk lnk( linkFile );
373 if ( lnk.isValid() ) { 373 if ( lnk.isValid() ) {
374 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
375 } 375 }
376 } 376 }
377 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
378} 378}
379 379
380 380
381void PlayListWidget::writeConfig( Config& cfg ) const { 381void PlayListWidget::writeConfig( Config& cfg ) const {
382 382
383 d->selectedFiles->writeCurrent( cfg); 383 d->selectedFiles->writeCurrent( cfg);
384 cfg.setGroup("PlayList"); 384 cfg.setGroup("PlayList");
385 int noOfFiles = 0; 385 int noOfFiles = 0;
386 d->selectedFiles->first(); 386 d->selectedFiles->first();
387 do { 387 do {
388 const DocLnk *lnk = d->selectedFiles->current(); 388 const DocLnk *lnk = d->selectedFiles->current();
389 if ( lnk ) { 389 if ( lnk ) {
390 QString entryName; 390 QString entryName;
391 entryName.sprintf( "File%i", noOfFiles + 1 ); 391 entryName.sprintf( "File%i", noOfFiles + 1 );
392// qDebug(entryName); 392// qDebug(entryName);
393 cfg.writeEntry( entryName, lnk->linkFile() ); 393 cfg.writeEntry( entryName, lnk->linkFile() );
394 // if this link does exist, add it so we have the file 394 // if this link does exist, add it so we have the file
395 // next time... 395 // next time...
396 if ( !QFile::exists( lnk->linkFile() ) ) { 396 if ( !QFile::exists( lnk->linkFile() ) ) {
397 // the way writing lnks doesn't really check for out 397 // the way writing lnks doesn't really check for out
398 // of disk space, but check it anyway. 398 // of disk space, but check it anyway.
399// if ( !lnk->writeLink() ) { 399// if ( !lnk->writeLink() ) {
400// QMessageBox::critical( 0, tr("Out of space"), 400// QMessageBox::critical( 0, tr("Out of space"),
401// tr( "There was a problem saving " 401// tr( "There was a problem saving "
402// "the playlist.\n" 402// "the playlist.\n"
403// "Your playlist " 403// "Your playlist "
404// "may be missing some entries\n" 404// "may be missing some entries\n"
405// "the next time you start it." ) 405// "the next time you start it." )
406// ); 406// );
407// } 407// }
408 408
409 } 409 }
410 noOfFiles++; 410 noOfFiles++;
411 } 411 }
412 } 412 }
413 while ( d->selectedFiles->next() ); 413 while ( d->selectedFiles->next() );
414 cfg.writeEntry("NumberOfFiles", noOfFiles ); 414 cfg.writeEntry("NumberOfFiles", noOfFiles );
415} 415}
416 416
417 417
418void PlayListWidget::addToSelection( const DocLnk& lnk ) { 418void PlayListWidget::addToSelection( const DocLnk& lnk ) {
419 d->setDocumentUsed = false; 419 d->setDocumentUsed = false;
420 if ( mediaPlayerState->playlist() ) { 420 if ( mediaPlayerState->playlist() ) {
421 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 421 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
422 d->selectedFiles->addToSelection( lnk ); 422 d->selectedFiles->addToSelection( lnk );
423 } 423 }
424 else 424 else
425 mediaPlayerState->setPlaying( true); 425 mediaPlayerState->setPlaying( true);
426 426
427} 427}
428 428
429 429
430void PlayListWidget::clearList() { 430void PlayListWidget::clearList() {
431 while ( first() ) 431 while ( first() )
432 d->selectedFiles->removeSelected(); 432 d->selectedFiles->removeSelected();
433 Config cfg( "OpiePlayer" ); 433 Config cfg( "OpiePlayer" );
434 cfg.setGroup("PlayList"); 434 cfg.setGroup("PlayList");
435 cfg.writeEntry("CurrentPlaylist",""); 435 cfg.writeEntry("CurrentPlaylist","");
436 currentPlayList=""; 436 currentPlayList="";
437 437
438} 438}
439 439
440 440
441void PlayListWidget::addAllToList() { 441void PlayListWidget::addAllToList() {
442 DocLnkSet filesAll; 442 DocLnkSet filesAll;
443 Global::findDocuments(&filesAll, "video/*;audio/*"); 443 Global::findDocuments(&filesAll, "video/*;audio/*");
444 QListIterator<DocLnk> Adit( filesAll.children() ); 444 QListIterator<DocLnk> Adit( filesAll.children() );
445 for ( ; Adit.current(); ++Adit ) 445 for ( ; Adit.current(); ++Adit )
446 if(QFileInfo(Adit.current()->file()).exists()) 446 if(QFileInfo(Adit.current()->file()).exists())
447 d->selectedFiles->addToSelection( **Adit ); 447 d->selectedFiles->addToSelection( **Adit );
448 tabWidget->setCurrentPage(0); 448 tabWidget->setCurrentPage(0);
449 449
450 writeCurrentM3u(); 450 writeCurrentM3u();
451 d->selectedFiles->first(); 451 d->selectedFiles->first();
452} 452}
453 453
454 454
455void PlayListWidget::addAllMusicToList() { 455void PlayListWidget::addAllMusicToList() {
456 QListIterator<DocLnk> dit( files.children() ); 456 QListIterator<DocLnk> dit( files.children() );
457 for ( ; dit.current(); ++dit ) 457 for ( ; dit.current(); ++dit )
458 if(QFileInfo(dit.current()->file()).exists()) 458 if(QFileInfo(dit.current()->file()).exists())
459 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
460 tabWidget->setCurrentPage(0); 460 tabWidget->setCurrentPage(0);
461 461
462 writeCurrentM3u(); 462 writeCurrentM3u();
463 d->selectedFiles->first(); 463 d->selectedFiles->first();
464} 464}
465 465
466 466
467void PlayListWidget::addAllVideoToList() { 467void PlayListWidget::addAllVideoToList() {
468 QListIterator<DocLnk> dit( vFiles.children() ); 468 QListIterator<DocLnk> dit( vFiles.children() );
469 for ( ; dit.current(); ++dit ) 469 for ( ; dit.current(); ++dit )
470 if(QFileInfo( dit.current()->file()).exists()) 470 if(QFileInfo( dit.current()->file()).exists())
471 d->selectedFiles->addToSelection( **dit ); 471 d->selectedFiles->addToSelection( **dit );
472 tabWidget->setCurrentPage(0); 472 tabWidget->setCurrentPage(0);
473 473
474 writeCurrentM3u(); 474 writeCurrentM3u();
475 d->selectedFiles->first(); 475 d->selectedFiles->first();
476} 476}
477 477
478 478
479void PlayListWidget::setDocument(const QString& fileref) { 479void PlayListWidget::setDocument(const QString& fileref) {
480 fromSetDocument = true; 480 fromSetDocument = true;
481 d->setDocumentUsed = TRUE; 481 d->setDocumentUsed = TRUE;
482 setDocumentEx(fileref); 482 setDocumentEx(fileref);
483} 483}
484 484
485void PlayListWidget::setDocumentEx(const QString& fileref) { 485void PlayListWidget::setDocumentEx(const QString& fileref) {
486 qDebug("opieplayer receive "+fileref); 486 qDebug("opieplayer receive "+fileref);
487 clearList(); 487 clearList();
488 DocLnk lnk; 488 DocLnk lnk;
489 QFileInfo fileInfo(fileref); 489 QFileInfo fileInfo(fileref);
490 if ( !fileInfo.exists() ) { 490 if ( !fileInfo.exists() ) {
491 QMessageBox::critical( 0, tr( "Invalid File" ), 491 QMessageBox::critical( 0, tr( "Invalid File" ),
492 tr( "There was a problem in getting the file." ) ); 492 tr( "There was a problem in getting the file." ) );
493 return; 493 return;
494 } 494 }
495 // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); 495 // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref);
496 QString extension = fileInfo.extension(false); 496 QString extension = fileInfo.extension(false);
497 if( extension.find( "m3u", 0, false) != -1) { //is m3u 497 if( extension.find( "m3u", 0, false) != -1) { //is m3u
498 readm3u( fileref); 498 readm3u( fileref);
499 } 499 }
500 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 500 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
501 readPls( fileref); 501 readPls( fileref);
502 } 502 }
503 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 503 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
504 clearList(); 504 clearList();
505 lnk.setName( fileInfo.baseName() ); //sets name 505 lnk.setName( fileInfo.baseName() ); //sets name
506 lnk.setFile( fileref ); //sets file name 506 lnk.setFile( fileref ); //sets file name
507 lnk.setIcon("Sound"); 507 lnk.setIcon("Sound");
508 //addToSelection( lnk ); 508 //addToSelection( lnk );
509 509
510 loadList( lnk); 510 loadList( lnk);
511 d->selectedFiles->first(); 511 d->selectedFiles->first();
512 } else { 512 } else {
513 if( fileref.find(".desktop",0,TRUE) != -1) { 513 if( fileref.find(".desktop",0,TRUE) != -1) {
514 lnk = DocLnk(fileref); 514 lnk = DocLnk(fileref);
515 } else { 515 } else {
516 lnk.setName( fileInfo.baseName() ); //sets name 516 lnk.setName( fileInfo.baseName() ); //sets name
517 lnk.setFile( fileref ); //sets file name 517 lnk.setFile( fileref ); //sets file name
518 lnk.setIcon("Sound"); 518 lnk.setIcon("Sound");
519 } 519 }
520 520
521 addToSelection( lnk ); 521 addToSelection( lnk );
522 // addToSelection( DocLnk( fileref ) ); 522 // addToSelection( DocLnk( fileref ) );
523 lnk.removeLinkFile(); 523 lnk.removeLinkFile();
524 // qApp->processEvents(); 524 // qApp->processEvents();
525 } 525 }
526 setCaption(tr("OpiePlayer")); 526 setCaption(tr("OpiePlayer"));
527 d->setDocumentUsed = TRUE; 527 d->setDocumentUsed = TRUE;
528 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); 528 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
529 mediaPlayerState->setPlaying( FALSE ); 529 mediaPlayerState->setPlaying( FALSE );
530 qApp->processEvents(); 530 qApp->processEvents();
531 mediaPlayerState->setPlaying( TRUE ); 531 mediaPlayerState->setPlaying( TRUE );
532 532
533} 533}
534 534
535 535
536void PlayListWidget::setActiveWindow() { 536void PlayListWidget::setActiveWindow() {
537 // qDebug("SETTING active window"); 537 // qDebug("SETTING active window");
538 // When we get raised we need to ensure that it switches views 538 // When we get raised we need to ensure that it switches views
539 char origView = mediaPlayerState->view(); 539 char origView = mediaPlayerState->view();
540 mediaPlayerState->setView( 'l' ); // invalidate 540 mediaPlayerState->setView( 'l' ); // invalidate
541 mediaPlayerState->setView( origView ); // now switch back 541 mediaPlayerState->setView( origView ); // now switch back
542} 542}
543 543
544 544
545void PlayListWidget::useSelectedDocument() { 545void PlayListWidget::useSelectedDocument() {
546 d->setDocumentUsed = FALSE; 546 d->setDocumentUsed = FALSE;
547} 547}
548 548
549 549
550const DocLnk *PlayListWidget::current() { // this is fugly 550const DocLnk *PlayListWidget::current() { // this is fugly
551 switch (tabWidget->currentPageIndex()) { 551 switch (tabWidget->currentPageIndex()) {
552 case 0: //playlist 552 case 0: //playlist
553 { 553 {
554 // qDebug("playlist"); 554 // qDebug("playlist");
555 if ( mediaPlayerState->playlist() ) { 555 if ( mediaPlayerState->playlist() ) {
556 return d->selectedFiles->current(); 556 return d->selectedFiles->current();
557 } 557 }
558 else if ( d->setDocumentUsed && d->current ) { 558 else if ( d->setDocumentUsed && d->current ) {
559 return d->current; 559 return d->current;
560 } else { 560 } else {
561 return &(d->files->selectedDocument()); 561 return &(d->files->selectedDocument());
562 } 562 }
563 } 563 }
564 break; 564 break;
565 case 1://audio 565 case 1://audio
566 { 566 {
567 // qDebug("audioView"); 567 // qDebug("audioView");
568 QListIterator<DocLnk> dit( files.children() ); 568 QListIterator<DocLnk> dit( files.children() );
569 for ( ; dit.current(); ++dit ) { 569 for ( ; dit.current(); ++dit ) {
570 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 570 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
571 insanityBool=TRUE; 571 insanityBool=TRUE;
572 return dit; 572 return dit;
573 } 573 }
574 } 574 }
575 } 575 }
576 break; 576 break;
577 case 2: // video 577 case 2: // video
578 { 578 {
579 QListIterator<DocLnk> Vdit( vFiles.children() ); 579 QListIterator<DocLnk> Vdit( vFiles.children() );
580 for ( ; Vdit.current(); ++Vdit ) { 580 for ( ; Vdit.current(); ++Vdit ) {
581 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 581 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
582 insanityBool=TRUE; 582 insanityBool=TRUE;
583 return Vdit; 583 return Vdit;
584 } 584 }
585 } 585 }
586 } 586 }
587 break; 587 break;
588 }; 588 };
589 return 0; 589 return 0;
590} 590}
591 591
592bool PlayListWidget::prev() { 592bool PlayListWidget::prev() {
593 if ( mediaPlayerState->playlist() ) { 593 if ( mediaPlayerState->playlist() ) {
594 if ( mediaPlayerState->shuffled() ) { 594 if ( mediaPlayerState->shuffled() ) {
595 const DocLnk *cur = current(); 595 const DocLnk *cur = current();
596 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 596 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
597 for ( int i = 0; i < j; i++ ) { 597 for ( int i = 0; i < j; i++ ) {
598 if ( !d->selectedFiles->next() ) 598 if ( !d->selectedFiles->next() )
599 d->selectedFiles->first(); 599 d->selectedFiles->first();
600 } 600 }
601 if ( cur == current() ) 601 if ( cur == current() )
602 if ( !d->selectedFiles->next() ) 602 if ( !d->selectedFiles->next() )
603 d->selectedFiles->first(); 603 d->selectedFiles->first();
604 return TRUE; 604 return TRUE;
605 } else { 605 } else {
606 if ( !d->selectedFiles->prev() ) { 606 if ( !d->selectedFiles->prev() ) {
607 if ( mediaPlayerState->looping() ) { 607 if ( mediaPlayerState->looping() ) {
608 return d->selectedFiles->last(); 608 return d->selectedFiles->last();
609 } else { 609 } else {
610 return FALSE; 610 return FALSE;
611 } 611 }
612 } 612 }
613 return TRUE; 613 return TRUE;
614 } 614 }
615 } else { 615 } else {
616 return mediaPlayerState->looping(); 616 return mediaPlayerState->looping();
617 } 617 }
618} 618}
619 619
620 620
621bool PlayListWidget::next() { 621bool PlayListWidget::next() {
622 if ( mediaPlayerState->playlist() ) { 622 if ( mediaPlayerState->playlist() ) {
623 if ( mediaPlayerState->shuffled() ) { 623 if ( mediaPlayerState->shuffled() ) {
624 return prev(); 624 return prev();
625 } else { 625 } else {
626 if ( !d->selectedFiles->next() ) { 626 if ( !d->selectedFiles->next() ) {
627 if ( mediaPlayerState->looping() ) { 627 if ( mediaPlayerState->looping() ) {
628 return d->selectedFiles->first(); 628 return d->selectedFiles->first();
629 } else { 629 } else {
630 return FALSE; 630 return FALSE;
631 } 631 }
632 } 632 }
633 return TRUE; 633 return TRUE;
634 } 634 }
635 } else { 635 } else {
636 return mediaPlayerState->looping(); 636 return mediaPlayerState->looping();
637 } 637 }
638} 638}
639 639
640 640
641bool PlayListWidget::first() { 641bool PlayListWidget::first() {
642 if ( mediaPlayerState->playlist() ) 642 if ( mediaPlayerState->playlist() )
643 return d->selectedFiles->first(); 643 return d->selectedFiles->first();
644 else 644 else
645 return mediaPlayerState->looping(); 645 return mediaPlayerState->looping();
646} 646}
647 647
648 648
649bool PlayListWidget::last() { 649bool PlayListWidget::last() {
650 if ( mediaPlayerState->playlist() ) 650 if ( mediaPlayerState->playlist() )
651 return d->selectedFiles->last(); 651 return d->selectedFiles->last();
652 else 652 else
653 return mediaPlayerState->looping(); 653 return mediaPlayerState->looping();
654} 654}
655 655
656 656
657void PlayListWidget::saveList() { 657void PlayListWidget::saveList() {
658 writem3u(); 658 writem3u();
659} 659}
660 660
661void PlayListWidget::loadList( const DocLnk & lnk) { 661void PlayListWidget::loadList( const DocLnk & lnk) {
662 QString name = lnk.name(); 662 QString name = lnk.name();
663 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 663 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
664 664
665 if( name.length()>0) { 665 if( name.length()>0) {
666 setCaption("OpiePlayer: "+name); 666 setCaption("OpiePlayer: "+name);
667 // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 667 // qDebug("<<<<<<<<<<<<load list "+ lnk.file());
668 clearList(); 668 clearList();
669 readm3u(lnk.file()); 669 readm3u(lnk.file());
670 tabWidget->setCurrentPage(0); 670 tabWidget->setCurrentPage(0);
671 } 671 }
672} 672}
673 673
674void PlayListWidget::setPlaylist( bool shown ) { 674void PlayListWidget::setPlaylist( bool shown ) {
675 if ( shown ) 675 if ( shown )
676 d->playListFrame->show(); 676 d->playListFrame->show();
677 else 677 else
678 d->playListFrame->hide(); 678 d->playListFrame->hide();
679} 679}
680 680
681void PlayListWidget::setView( char view ) { 681void PlayListWidget::setView( char view ) {
682 if ( view == 'l' ) 682 if ( view == 'l' )
683 QPEApplication::showWidget( this ); 683 QPEApplication::showWidget( this );
684 else 684 else
685 hide(); 685 hide();
686} 686}
687 687
688void PlayListWidget::addSelected() { 688void PlayListWidget::addSelected() {
689 DocLnk lnk; 689 DocLnk lnk;
690 QString filename; 690 QString filename;
691 switch (tabWidget->currentPageIndex()) { 691 switch (tabWidget->currentPageIndex()) {
692 692
693 case 0: //playlist 693 case 0: //playlist
694 return; 694 return;
695 break; 695 break;
696 case 1: { //audio 696 case 1: { //audio
697 QListViewItemIterator it( audioView ); 697 QListViewItemIterator it( audioView );
698 for ( ; it.current(); ++it ) { 698 for ( ; it.current(); ++it ) {
699 if ( it.current()->isSelected() ) { 699 if ( it.current()->isSelected() ) {
700 filename = it.current()->text(3); 700 filename = it.current()->text(3);
701 lnk.setName( QFileInfo(filename).baseName() ); //sets name 701 lnk.setName( QFileInfo(filename).baseName() ); //sets name
702 lnk.setFile( filename ); //sets file name 702 lnk.setFile( filename ); //sets file name
703 d->selectedFiles->addToSelection( lnk); 703 d->selectedFiles->addToSelection( lnk);
704 } 704 }
705 } 705 }
706 audioView->clearSelection(); 706 audioView->clearSelection();
707 // d->selectedFiles->next(); 707 // d->selectedFiles->next();
708 } 708 }
709 break; 709 break;
710 710
711 case 2: { // video 711 case 2: { // video
712 QListViewItemIterator it( videoView ); 712 QListViewItemIterator it( videoView );
713 for ( ; it.current(); ++it ) { 713 for ( ; it.current(); ++it ) {
714 if ( it.current()->isSelected() ) { 714 if ( it.current()->isSelected() ) {
715 715
716 filename = it.current()->text(3); 716 filename = it.current()->text(3);
717 lnk.setName( QFileInfo(filename).baseName() ); //sets name 717 lnk.setName( QFileInfo(filename).baseName() ); //sets name
718 lnk.setFile( filename ); //sets file name 718 lnk.setFile( filename ); //sets file name
719 d->selectedFiles->addToSelection( lnk); 719 d->selectedFiles->addToSelection( lnk);
720 } 720 }
721 } 721 }
722 videoView->clearSelection(); 722 videoView->clearSelection();
723 } 723 }
724 break; 724 break;
725 }; 725 };
726 // tabWidget->setCurrentPage(0); 726 // tabWidget->setCurrentPage(0);
727 writeCurrentM3u(); 727 writeCurrentM3u();
728 728
729} 729}
730 730
731void PlayListWidget::removeSelected() { 731void PlayListWidget::removeSelected() {
732 d->selectedFiles->removeSelected( ); 732 d->selectedFiles->removeSelected( );
733} 733}
734 734
735void PlayListWidget::playIt( QListViewItem *) { 735void PlayListWidget::playIt( QListViewItem *) {
736 // d->setDocumentUsed = FALSE; 736 // d->setDocumentUsed = FALSE;
737 // mediaPlayerState->curPosition =0; 737 // mediaPlayerState->curPosition =0;
738 // mediaPlayerState->setPlaying(FALSE); 738 // mediaPlayerState->setPlaying(FALSE);
739 mediaPlayerState->setPlaying(TRUE); 739 mediaPlayerState->setPlaying(TRUE);
740 d->selectedFiles->unSelect(); 740 d->selectedFiles->unSelect();
741} 741}
742 742
743void PlayListWidget::addToSelection( QListViewItem *it) { 743void PlayListWidget::addToSelection( QListViewItem *it) {
744 d->setDocumentUsed = FALSE; 744 d->setDocumentUsed = FALSE;
745 745
746 if(it) { 746 if(it) {
747 switch ( tabWidget->currentPageIndex()) { 747 switch ( tabWidget->currentPageIndex()) {
748 case 0: //playlist 748 case 0: //playlist
749 return; 749 return;
750 break; 750 break;
751 }; 751 };
752 // case 1: { 752 // case 1: {
753 DocLnk lnk; 753 DocLnk lnk;
754 QString filename; 754 QString filename;
755 755
756 filename=it->text(3); 756 filename=it->text(3);
757 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 757 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
758 lnk.setFile( filename ); //sets file name 758 lnk.setFile( filename ); //sets file name
759 d->selectedFiles->addToSelection( lnk); 759 d->selectedFiles->addToSelection( lnk);
760 760
761 if(tabWidget->currentPageIndex() == 0) 761 if(tabWidget->currentPageIndex() == 0)
762 writeCurrentM3u(); 762 writeCurrentM3u();
763 // tabWidget->setCurrentPage(0); 763 // tabWidget->setCurrentPage(0);
764 764
765 } 765 }
766} 766}
767 767
768void PlayListWidget::tabChanged(QWidget *) { 768void PlayListWidget::tabChanged(QWidget *) {
769 769
770 switch ( tabWidget->currentPageIndex()) { 770 switch ( tabWidget->currentPageIndex()) {
771 case 0: 771 case 0:
772 { 772 {
773 if( !tbDeletePlaylist->isHidden()) 773 if( !tbDeletePlaylist->isHidden())
774 tbDeletePlaylist->hide(); 774 tbDeletePlaylist->hide();
775 d->tbRemoveFromList->setEnabled(TRUE); 775 d->tbRemoveFromList->setEnabled(TRUE);
776 d->tbAddToList->setEnabled(FALSE); 776 d->tbAddToList->setEnabled(FALSE);
777 } 777 }
778 break; 778 break;
779 case 1: 779 case 1:
780 { 780 {
781 audioView->clear(); 781 audioView->clear();
782 populateAudioView(); 782 populateAudioView();
783 783
784 if( !tbDeletePlaylist->isHidden()) 784 if( !tbDeletePlaylist->isHidden())
785 tbDeletePlaylist->hide(); 785 tbDeletePlaylist->hide();
786 d->tbRemoveFromList->setEnabled(FALSE); 786 d->tbRemoveFromList->setEnabled(FALSE);
787 d->tbAddToList->setEnabled(TRUE); 787 d->tbAddToList->setEnabled(TRUE);
788 } 788 }
789 break; 789 break;
790 case 2: 790 case 2:
791 { 791 {
792 videoView->clear(); 792 videoView->clear();
793 populateVideoView(); 793 populateVideoView();
794 if( !tbDeletePlaylist->isHidden()) 794 if( !tbDeletePlaylist->isHidden())
795 tbDeletePlaylist->hide(); 795 tbDeletePlaylist->hide();
796 d->tbRemoveFromList->setEnabled(FALSE); 796 d->tbRemoveFromList->setEnabled(FALSE);
797 d->tbAddToList->setEnabled(TRUE); 797 d->tbAddToList->setEnabled(TRUE);
798 } 798 }
799 break; 799 break;
800 case 3: 800 case 3:
801 { 801 {
802 if( tbDeletePlaylist->isHidden()) 802 if( tbDeletePlaylist->isHidden())
803 tbDeletePlaylist->show(); 803 tbDeletePlaylist->show();
804 playLists->reread(); 804 playLists->reread();
805 } 805 }
806 break; 806 break;
807 }; 807 };
808} 808}
809 809
810void PlayListWidget::btnPlay(bool b) { 810void PlayListWidget::btnPlay(bool b) {
811 // mediaPlayerState->setPlaying(b); 811 // mediaPlayerState->setPlaying(b);
812 switch ( tabWidget->currentPageIndex()) { 812 switch ( tabWidget->currentPageIndex()) {
813 case 0: 813 case 0:
814 { 814 {
815 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 815 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
816 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 816 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
817 // QMessageBox::message("Note","You are trying to play\na malformed url."); 817 // QMessageBox::message("Note","You are trying to play\na malformed url.");
818 // } else { 818 // } else {
819 mediaPlayerState->setPlaying(b); 819 mediaPlayerState->setPlaying(b);
820 insanityBool=FALSE; 820 insanityBool=FALSE;
821 qDebug("insanity"); 821 qDebug("insanity");
822 // } 822 // }
823 } 823 }
824 break; 824 break;
825 case 1: 825 case 1:
826 { 826 {
827 // d->selectedFiles->unSelect(); 827 // d->selectedFiles->unSelect();
828 addToSelection( audioView->currentItem() ); 828 addToSelection( audioView->currentItem() );
829 mediaPlayerState->setPlaying( b); 829 mediaPlayerState->setPlaying( b);
830 d->selectedFiles->removeSelected( ); 830 d->selectedFiles->removeSelected( );
831 d->selectedFiles->unSelect(); 831 d->selectedFiles->unSelect();
832 tabWidget->setCurrentPage(1); 832 tabWidget->setCurrentPage(1);
833 insanityBool=FALSE; 833 insanityBool=FALSE;
834 }// audioView->clearSelection(); 834 }// audioView->clearSelection();
835 break; 835 break;
836 case 2: 836 case 2:
837 { 837 {
838 838
839 addToSelection( videoView->currentItem() ); 839 addToSelection( videoView->currentItem() );
840 mediaPlayerState->setPlaying( b); 840 mediaPlayerState->setPlaying( b);
841 // qApp->processEvents(); 841 // qApp->processEvents();
842 d->selectedFiles->removeSelected( ); 842 d->selectedFiles->removeSelected( );
843 d->selectedFiles->unSelect(); 843 d->selectedFiles->unSelect();
844 tabWidget->setCurrentPage(2); 844 tabWidget->setCurrentPage(2);
845 insanityBool=FALSE; 845 insanityBool=FALSE;
846 }// videoView->clearSelection(); 846 }// videoView->clearSelection();
847 break; 847 break;
848 }; 848 };
849 849
850} 850}
851 851
852void PlayListWidget::deletePlaylist() { 852void PlayListWidget::deletePlaylist() {
853 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 853 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
854 (tr("You really want to delete\nthis playlist?")), 854 (tr("You really want to delete\nthis playlist?")),
855 (tr("Yes")), (tr("No")), 0 )){ 855 (tr("Yes")), (tr("No")), 0 )){
856 case 0: // Yes clicked, 856 case 0: // Yes clicked,
857 QFile().remove(playLists->selectedDocument().file()); 857 QFile().remove(playLists->selectedDocument().file());
858 QFile().remove(playLists->selectedDocument().linkFile()); 858 QFile().remove(playLists->selectedDocument().linkFile());
859 playLists->reread(); 859 playLists->reread();
860 break; 860 break;
861 case 1: // Cancel 861 case 1: // Cancel
862 break; 862 break;
863 }; 863 };
864} 864}
865 865
866void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 866void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
867{ 867{
868 switch (mouse) { 868 switch (mouse) {
869 case 1: 869 case 1:
870 break; 870 break;
871 case 2:{ 871 case 2:{
872 872
873 QPopupMenu m; 873 QPopupMenu m;
874 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 874 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
875 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 875 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
876 m.insertSeparator(); 876 m.insertSeparator();
877 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 877 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
878 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 878 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
879 879
880 m.exec( QCursor::pos() ); 880 m.exec( QCursor::pos() );
881 } 881 }
882 break; 882 break;
883 }; 883 };
884} 884}
885 885
886void PlayListWidget::playSelected() 886void PlayListWidget::playSelected()
887{ 887{
888 btnPlay( true); 888 btnPlay( true);
889// d->selectedFiles->unSelect(); 889// d->selectedFiles->unSelect();
890} 890}
891 891
892void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 892void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
893{ 893{
894 switch (mouse) { 894 switch (mouse) {
895 case 1: 895 case 1:
896 896
897 break; 897 break;
898 case 2:{ 898 case 2:{
899 QPopupMenu m; 899 QPopupMenu m;
900 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 900 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
901 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 901 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
902 // m.insertSeparator(); 902 // m.insertSeparator();
903 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 903 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
904 m.exec( QCursor::pos() ); 904 m.exec( QCursor::pos() );
905 } 905 }
906 break; 906 break;
907 }; 907 };
908 908
909} 909}
910 910
911void PlayListWidget::listDelete() { 911void PlayListWidget::listDelete() {
912 Config cfg( "OpiePlayer" ); 912 Config cfg( "OpiePlayer" );
913 cfg.setGroup("PlayList"); 913 cfg.setGroup("PlayList");
914 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 914 currentPlayList = cfg.readEntry("CurrentPlaylist","");
915 QString file; 915 QString file;
916 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 916 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
917 switch ( tabWidget->currentPageIndex()) { 917 switch ( tabWidget->currentPageIndex()) {
918 case 0: 918 case 0:
919 break; 919 break;
920 case 1: 920 case 1:
921 { 921 {
922 file = audioView->currentItem()->text(0); 922 file = audioView->currentItem()->text(0);
923 QListIterator<DocLnk> Pdit( files.children() ); 923 QListIterator<DocLnk> Pdit( files.children() );
924 for ( ; Pdit.current(); ++Pdit ) { 924 for ( ; Pdit.current(); ++Pdit ) {
925 if( Pdit.current()->name() == file) { 925 if( Pdit.current()->name() == file) {
926 LnkProperties prop( Pdit.current() ); 926 LnkProperties prop( Pdit.current() );
927 QPEApplication::execDialog( &prop ); 927 QPEApplication::execDialog( &prop );
928 } 928 }
929 } 929 }
930 populateAudioView(); 930 populateAudioView();
931 } 931 }
932 break; 932 break;
933 case 2: 933 case 2:
934 { 934 {
935 // file = videoView->selectedItem()->text(0); 935 // file = videoView->selectedItem()->text(0);
936 // for ( int i = 0; i < noOfFiles; i++ ) { 936 // for ( int i = 0; i < noOfFiles; i++ ) {
937 // QString entryName; 937 // QString entryName;
938 // entryName.sprintf( "File%i", i + 1 ); 938 // entryName.sprintf( "File%i", i + 1 );
939 // QString linkFile = cfg.readEntry( entryName ); 939 // QString linkFile = cfg.readEntry( entryName );
940 // AppLnk lnk( AppLnk(linkFile)); 940 // AppLnk lnk( AppLnk(linkFile));
941 // if( lnk.name() == file ) { 941 // if( lnk.name() == file ) {
942 // LnkProperties prop( &lnk); 942 // LnkProperties prop( &lnk);
943 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); 943 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*)));
944 // prop.showMaximized(); 944 // prop.showMaximized();
945 // prop.exec(); 945 // prop.exec();
946 // } 946 // }
947 // } 947 // }
948 } 948 }
949 break; 949 break;
950 }; 950 };
951} 951}
952 952
953void PlayListWidget::scanForAudio() { 953void PlayListWidget::scanForAudio() {
954 // qDebug("scan for audio"); 954 // qDebug("scan for audio");
955 files.detachChildren(); 955 files.detachChildren();
956 QListIterator<DocLnk> sdit( files.children() ); 956 QListIterator<DocLnk> sdit( files.children() );
957 for ( ; sdit.current(); ++sdit ) { 957 for ( ; sdit.current(); ++sdit ) {
958 delete sdit.current(); 958 delete sdit.current();
959 } 959 }
960 Global::findDocuments( &files, audioMimes); 960 Global::findDocuments( &files, audioMimes);
961 audioScan = true; 961 audioScan = true;
962} 962}
963void PlayListWidget::scanForVideo() { 963void PlayListWidget::scanForVideo() {
964 // qDebug("scan for video"); 964 // qDebug("scan for video");
965 vFiles.detachChildren(); 965 vFiles.detachChildren();
966 QListIterator<DocLnk> sdit( vFiles.children() ); 966 QListIterator<DocLnk> sdit( vFiles.children() );
967 for ( ; sdit.current(); ++sdit ) { 967 for ( ; sdit.current(); ++sdit ) {
968 delete sdit.current(); 968 delete sdit.current();
969 } 969 }
970 Global::findDocuments(&vFiles, "video/*"); 970 Global::findDocuments(&vFiles, "video/*");
971 videoScan = true; 971 videoScan = true;
972} 972}
973 973
974void PlayListWidget::populateAudioView() { 974void PlayListWidget::populateAudioView() {
975 975
976 audioView->clear(); 976 audioView->clear();
977 StorageInfo storageInfo; 977 StorageInfo storageInfo;
978 const QList<FileSystem> &fs = storageInfo.fileSystems(); 978 const QList<FileSystem> &fs = storageInfo.fileSystems();
979 if(!audioScan) scanForAudio(); 979 if(!audioScan) scanForAudio();
980 980
981 QListIterator<DocLnk> dit( files.children() ); 981 QListIterator<DocLnk> dit( files.children() );
982 QListIterator<FileSystem> it ( fs ); 982 QListIterator<FileSystem> it ( fs );
983 983
984 QString storage; 984 QString storage;
985 for ( ; dit.current(); ++dit ) { 985 for ( ; dit.current(); ++dit ) {
986 for( ; it.current(); ++it ){ 986 for( ; it.current(); ++it ){
987 const QString name = (*it)->name(); 987 const QString name = (*it)->name();
988 const QString path = (*it)->path(); 988 const QString path = (*it)->path();
989 if(dit.current()->file().find(path) != -1 ) storage=name; 989 if(dit.current()->file().find(path) != -1 ) storage=name;
990 } 990 }
991 991
992 QListViewItem * newItem; 992 QListViewItem * newItem;
993 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 993 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
994 long size; 994 long size;
995 if( dit.current()->file().left(4) == "http" ) 995 if( dit.current()->file().left(4) == "http" )
996 size=0; 996 size=0;
997 else 997 else
998 size = QFile( dit.current()->file() ).size(); 998 size = QFile( dit.current()->file() ).size();
999 // qDebug(dit.current()->name()); 999 // qDebug(dit.current()->name());
1000 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1000 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1001 QString::number(size ), storage, dit.current()->file()); 1001 QString::number(size ), storage, dit.current()->file());
1002 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1002 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1003 } 1003 }
1004 } 1004 }
1005 1005
1006} 1006}
1007 1007
1008void PlayListWidget::populateVideoView() { 1008void PlayListWidget::populateVideoView() {
1009 videoView->clear(); 1009 videoView->clear();
1010 StorageInfo storageInfo; 1010 StorageInfo storageInfo;
1011 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1011 const QList<FileSystem> &fs = storageInfo.fileSystems();
1012 1012
1013 if(!videoScan ) scanForVideo(); 1013 if(!videoScan ) scanForVideo();
1014 1014
1015 QListIterator<DocLnk> Vdit( vFiles.children() ); 1015 QListIterator<DocLnk> Vdit( vFiles.children() );
1016 QListIterator<FileSystem> it ( fs ); 1016 QListIterator<FileSystem> it ( fs );
1017 videoView->clear(); 1017 videoView->clear();
1018 QString storage; 1018 QString storage;
1019 for ( ; Vdit.current(); ++Vdit ) { 1019 for ( ; Vdit.current(); ++Vdit ) {
1020 for( ; it.current(); ++it ){ 1020 for( ; it.current(); ++it ){
1021 const QString name = (*it)->name(); 1021 const QString name = (*it)->name();
1022 const QString path = (*it)->path(); 1022 const QString path = (*it)->path();
1023 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1023 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1024 } 1024 }
1025 1025
1026 QListViewItem * newItem; 1026 QListViewItem * newItem;
1027 if ( QFile( Vdit.current()->file()).exists() ) { 1027 if ( QFile( Vdit.current()->file()).exists() ) {
1028 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1028 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1029 QString::number( QFile( Vdit.current()->file() ).size() ), 1029 QString::number( QFile( Vdit.current()->file() ).size() ),
1030 storage, Vdit.current()->file()); 1030 storage, Vdit.current()->file());
1031 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1031 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1032 } 1032 }
1033 } 1033 }
1034} 1034}
1035 1035
1036void PlayListWidget::openFile() { 1036void PlayListWidget::openFile() {
1037 QString filename, name; 1037 QString filename, name;
1038 InputDialog *fileDlg; 1038 InputDialog *fileDlg;
1039 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1039 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1040 fileDlg->exec(); 1040 fileDlg->exec();
1041 if( fileDlg->result() == 1 ) { 1041 if( fileDlg->result() == 1 ) {
1042 filename = fileDlg->text(); 1042 filename = fileDlg->text();
1043 // qDebug( "Selected filename is " + filename ); 1043 // qDebug( "Selected filename is " + filename );
1044 DocLnk lnk; 1044 DocLnk lnk;
1045 Config cfg( "OpiePlayer" ); 1045 Config cfg( "OpiePlayer" );
1046 cfg.setGroup("PlayList"); 1046 cfg.setGroup("PlayList");
1047 1047
1048 QString m3uFile; 1048 QString m3uFile;
1049 m3uFile = filename; 1049 m3uFile = filename;
1050 if(filename.left(4) == "http") { 1050 if(filename.left(4) == "http") {
1051 if(filename.find(":",8,TRUE) != -1) { //found a port 1051 if(filename.find(":",8,TRUE) != -1) { //found a port
1052 1052
1053 m3uFile = filename; 1053 m3uFile = filename;
1054 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1054 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1055 m3uFile += "/"; 1055 m3uFile += "/";
1056 } 1056 }
1057 filename = m3uFile; 1057 filename = m3uFile;
1058 } 1058 }
1059 lnk.setName( m3uFile ); //sets name 1059 lnk.setName( m3uFile ); //sets name
1060 lnk.setFile( filename ); //sets file name 1060 lnk.setFile( filename ); //sets file name
1061 lnk.setIcon("opieplayer2/musicfile"); 1061 lnk.setIcon("opieplayer2/musicfile");
1062 d->selectedFiles->addToSelection( lnk ); 1062 d->selectedFiles->addToSelection( lnk );
1063 writeCurrentM3u(); 1063 writeCurrentM3u();
1064 } 1064 }
1065 else if( filename.right( 3) == "m3u" ) { 1065 else if( filename.right( 3) == "m3u" ) {
1066 readm3u( filename ); 1066 readm3u( filename );
1067 1067
1068 } else if( filename.right(3) == "pls" ) { 1068 } else if( filename.right(3) == "pls" ) {
1069 readPls( filename ); 1069 readPls( filename );
1070 } else { 1070 } else {
1071 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1071 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1072 lnk.setFile( filename ); //sets file name 1072 lnk.setFile( filename ); //sets file name
1073 d->selectedFiles->addToSelection( lnk); 1073 d->selectedFiles->addToSelection( lnk);
1074 lnk.removeLinkFile(); 1074 lnk.removeLinkFile();
1075 writeCurrentM3u(); 1075 writeCurrentM3u();
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 if( fileDlg ) { 1079 if( fileDlg ) {
1080 delete fileDlg; 1080 delete fileDlg;
1081 } 1081 }
1082} 1082}
1083 1083
1084 1084
1085/* 1085/*
1086reads m3u and shows files/urls to playlist widget */ 1086reads m3u and shows files/urls to playlist widget */
1087void PlayListWidget::readm3u( const QString &filename ) { 1087void PlayListWidget::readm3u( const QString &filename ) {
1088 // qDebug( "read m3u filename " + filename ); 1088 // qDebug( "read m3u filename " + filename );
1089 1089
1090 Om3u *m3uList; 1090 Om3u *m3uList;
1091 QString s, name; 1091 QString s, name;
1092 m3uList = new Om3u( filename, IO_ReadOnly ); 1092 m3uList = new Om3u( filename, IO_ReadOnly );
1093 m3uList->readM3u(); 1093 m3uList->readM3u();
1094 DocLnk lnk; 1094 DocLnk lnk;
1095 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1095 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1096 s = *it; 1096 s = *it;
1097 // qDebug("reading "+ s); 1097 // qDebug("reading "+ s);
1098 if(s.left(4)=="http") { 1098 if(s.left(4)=="http") {
1099 lnk.setName( s ); //sets file name 1099 lnk.setName( s ); //sets file name
1100 lnk.setIcon("opieplayer2/musicfile"); 1100 lnk.setIcon("opieplayer2/musicfile");
1101 1101
1102 // if(s.right(4) != '.' || s.right(5) != '.') 1102 // if(s.right(4) != '.' || s.right(5) != '.')
1103 if(s.right(4) != '.' || s.right(5) != '.' ) 1103 if(s.right(4) != '.' || s.right(5) != '.' )
1104 if( s.right(1) != "/") 1104 if( s.right(1) != "/")
1105 lnk.setFile( s+"/"); //if url with no extension 1105 lnk.setFile( s+"/"); //if url with no extension
1106 else 1106 else
1107 lnk.setFile( s ); //sets file name 1107 lnk.setFile( s ); //sets file name
1108 1108
1109 } else { 1109 } else {
1110 // if( QFileInfo( s ).exists() ) { 1110 // if( QFileInfo( s ).exists() ) {
1111 lnk.setName( fullBaseName ( QFileInfo(s))); 1111 lnk.setName( fullBaseName ( QFileInfo(s)));
1112 // if(s.right(4) == '.') {//if regular file 1112 // if(s.right(4) == '.') {//if regular file
1113 if(s.left(1) != "/") { 1113 if(s.left(1) != "/") {
1114 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1114 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1115 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1115 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1116 lnk.setIcon("SoundPlayer"); 1116 lnk.setIcon("SoundPlayer");
1117 } else { 1117 } else {
1118 // qDebug("set link2 "+s); 1118 // qDebug("set link2 "+s);
1119 lnk.setFile( s); 1119 lnk.setFile( s);
1120 lnk.setIcon("SoundPlayer"); 1120 lnk.setIcon("SoundPlayer");
1121 } 1121 }
1122 } 1122 }
1123 d->selectedFiles->addToSelection( lnk ); 1123 d->selectedFiles->addToSelection( lnk );
1124 } 1124 }
1125 Config config( "OpiePlayer" ); 1125 Config config( "OpiePlayer" );
1126 config.setGroup( "PlayList" ); 1126 config.setGroup( "PlayList" );
1127 1127
1128 config.writeEntry("CurrentPlaylist",filename); 1128 config.writeEntry("CurrentPlaylist",filename);
1129 config.write(); 1129 config.write();
1130 currentPlayList=filename; 1130 currentPlayList=filename;
1131 1131
1132// m3uList->write(); 1132// m3uList->write();
1133 m3uList->close(); 1133 m3uList->close();
1134 if(m3uList) delete m3uList; 1134 if(m3uList) delete m3uList;
1135 1135
1136 d->selectedFiles->setSelectedItem( s); 1136 d->selectedFiles->setSelectedItem( s);
1137 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1137 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1138 1138
1139} 1139}
1140 1140
1141/* 1141/*
1142reads pls and adds files/urls to playlist */ 1142reads pls and adds files/urls to playlist */
1143void PlayListWidget::readPls( const QString &filename ) { 1143void PlayListWidget::readPls( const QString &filename ) {
1144 1144
1145 // qDebug( "pls filename is " + filename ); 1145 // qDebug( "pls filename is " + filename );
1146 Om3u *m3uList; 1146 Om3u *m3uList;
1147 QString s, name; 1147 QString s, name;
1148 m3uList = new Om3u( filename, IO_ReadOnly ); 1148 m3uList = new Om3u( filename, IO_ReadOnly );
1149 m3uList->readPls(); 1149 m3uList->readPls();
1150 1150
1151 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1151 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1152 s = *it; 1152 s = *it;
1153 // s.replace( QRegExp( "%20" )," " ); 1153 // s.replace( QRegExp( "%20" )," " );
1154 DocLnk lnk( s ); 1154 DocLnk lnk( s );
1155 QFileInfo f( s ); 1155 QFileInfo f( s );
1156 QString name = fullBaseName ( f); 1156 QString name = fullBaseName ( f);
1157 1157
1158 if( name.left( 4 ) == "http" ) { 1158 if( name.left( 4 ) == "http" ) {
1159 name = s.right( s.length() - 7); 1159 name = s.right( s.length() - 7);
1160 } else { 1160 } else {
1161 name = s; 1161 name = s;
1162 } 1162 }
1163 1163
1164 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1164 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1165 1165
1166 lnk.setName( name ); 1166 lnk.setName( name );
1167 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1167 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1168 lnk.setFile( s ); 1168 lnk.setFile( s );
1169 } else { //if its a url 1169 } else { //if its a url
1170 if( name.right( 1 ).find( '/' ) == -1) { 1170 if( name.right( 1 ).find( '/' ) == -1) {
1171 s += "/"; 1171 s += "/";
1172 } 1172 }
1173 lnk.setFile( s ); 1173 lnk.setFile( s );
1174 } 1174 }
1175 lnk.setType( "audio/x-mpegurl" ); 1175 lnk.setType( "audio/x-mpegurl" );
1176 1176
1177 lnk.writeLink(); 1177 lnk.writeLink();
1178 d->selectedFiles->addToSelection( lnk ); 1178 d->selectedFiles->addToSelection( lnk );
1179 } 1179 }
1180 1180
1181 m3uList->close(); 1181 m3uList->close();
1182 if(m3uList) delete m3uList; 1182 if(m3uList) delete m3uList;
1183} 1183}
1184 1184
1185/* 1185/*
1186 writes current playlist to current m3u file */ 1186 writes current playlist to current m3u file */
1187void PlayListWidget::writeCurrentM3u() { 1187void PlayListWidget::writeCurrentM3u() {
1188 // qDebug("writing to current m3u"); 1188 // qDebug("writing to current m3u");
1189 Config cfg( "OpiePlayer" ); 1189 Config cfg( "OpiePlayer" );
1190 cfg.setGroup("PlayList"); 1190 cfg.setGroup("PlayList");
1191 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 1191 currentPlayList = cfg.readEntry("CurrentPlaylist","");
1192 Om3u *m3uList; 1192 Om3u *m3uList;
1193 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); 1193 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
1194 1194
1195 if( d->selectedFiles->first()) { 1195 if( d->selectedFiles->first()) {
1196 do { 1196 do {
1197 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1197 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1198 m3uList->add( d->selectedFiles->current()->file() ); 1198 m3uList->add( d->selectedFiles->current()->file() );
1199 } 1199 }
1200 while ( d->selectedFiles->next() ); 1200 while ( d->selectedFiles->next() );
1201 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1201 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1202 m3uList->write(); 1202 m3uList->write();
1203 m3uList->close(); 1203 m3uList->close();
1204 1204
1205 if(m3uList) delete m3uList; 1205 if(m3uList) delete m3uList;
1206 } 1206 }
1207} 1207}
1208 1208
1209 /* 1209 /*
1210 writes current playlist to m3u file */ 1210 writes current playlist to m3u file */
1211void PlayListWidget::writem3u() { 1211void PlayListWidget::writem3u() {
1212 InputDialog *fileDlg; 1212 InputDialog *fileDlg;
1213 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1213 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1214 fileDlg->exec(); 1214 fileDlg->exec();
1215 QString name, filename, list; 1215 QString name, filename, list;
1216 Om3u *m3uList; 1216 Om3u *m3uList;
1217 1217
1218 if( fileDlg->result() == 1 ) { 1218 if( fileDlg->result() == 1 ) {
1219 name = fileDlg->text(); 1219 name = fileDlg->text();
1220 // qDebug( filename ); 1220 // qDebug( filename );
1221 if( name.find("/",0,true) != -1) {// assume they specify a file path 1221 if( name.find("/",0,true) != -1) {// assume they specify a file path
1222 filename = name; 1222 filename = name;
1223 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1223 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1224 } 1224 }
1225 else //otherwise dump it somewhere noticable 1225 else //otherwise dump it somewhere noticable
1226 filename = QPEApplication::documentDir() + "/" + name; 1226 filename = QPEApplication::documentDir() + "/" + name;
1227 1227
1228 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1228 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1229 filename += ".m3u"; 1229 filename += ".m3u";
1230 1230
1231 if( d->selectedFiles->first()) { 1231 if( d->selectedFiles->first()) {
1232 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 1232 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
1233 1233
1234 do { 1234 do {
1235 m3uList->add( d->selectedFiles->current()->file()); 1235 m3uList->add( d->selectedFiles->current()->file());
1236 } 1236 }
1237 while ( d->selectedFiles->next() ); 1237 while ( d->selectedFiles->next() );
1238 // qDebug( list ); 1238 // qDebug( list );
1239 m3uList->write(); 1239 m3uList->write();
1240 m3uList->close(); 1240 m3uList->close();
1241 if(m3uList) delete m3uList; 1241 if(m3uList) delete m3uList;
1242 1242
1243 if(fileDlg) delete fileDlg; 1243 if(fileDlg) delete fileDlg;
1244 1244
1245 DocLnk lnk; 1245 DocLnk lnk;
1246 lnk.setFile( filename); 1246 lnk.setFile( filename);
1247 lnk.setIcon("opieplayer2/playlist2"); 1247 lnk.setIcon("opieplayer2/playlist2");
1248 lnk.setName( name); //sets file name 1248 lnk.setName( name); //sets file name
1249 1249
1250 // qDebug(filename); 1250 // qDebug(filename);
1251 Config config( "OpiePlayer" ); 1251 Config config( "OpiePlayer" );
1252 config.setGroup( "PlayList" ); 1252 config.setGroup( "PlayList" );
1253 1253
1254 config.writeEntry("CurrentPlaylist",filename); 1254 config.writeEntry("CurrentPlaylist",filename);
1255 currentPlayList=filename; 1255 currentPlayList=filename;
1256 1256
1257 if(!lnk.writeLink()) { 1257 if(!lnk.writeLink()) {
1258 // qDebug("Writing doclink did not work"); 1258 // qDebug("Writing doclink did not work");
1259 } 1259 }
1260 1260
1261 setCaption(tr("OpiePlayer: ") + name); 1261 setCaption(tr("OpiePlayer: ") + name);
1262 } 1262 }
1263 } 1263 }
1264} 1264}
1265 1265
1266 1266
1267void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1267void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1268{ 1268{
1269 switch ( e->key() ) { 1269 switch ( e->key() ) {
1270////////////////////////////// Zaurus keys 1270////////////////////////////// Zaurus keys
1271 case Key_F9: //activity 1271 case Key_F9: //activity
1272// if(audioUI->isHidden()) 1272// if(audioUI->isHidden())
1273// audioUI->showMaximized(); 1273// audioUI->showMaximized();
1274 break; 1274 break;
1275 case Key_F10: //contacts 1275 case Key_F10: //contacts
1276// if( videoUI->isHidden()) 1276// if( videoUI->isHidden())
1277// videoUI->showMaximized(); 1277// videoUI->showMaximized();
1278 break; 1278 break;
1279 case Key_F11: //menu 1279 case Key_F11: //menu
1280 break; 1280 break;
1281 case Key_F12: //home 1281 case Key_F12: //home
1282// doBlank(); 1282// doBlank();
1283 break; 1283 break;
1284 case Key_F13: //mail 1284 case Key_F13: //mail
1285// doUnblank(); 1285// doUnblank();
1286 break; 1286 break;
1287 case Key_Q: //add to playlist 1287 case Key_Q: //add to playlist
1288 addSelected(); 1288 addSelected();
1289 break; 1289 break;
1290 case Key_R: //remove from playlist 1290 case Key_R: //remove from playlist
1291 removeSelected(); 1291 removeSelected();
1292 break; 1292 break;
1293// case Key_P: //play 1293// case Key_P: //play
1294// qDebug("Play"); 1294// qDebug("Play");
1295// playSelected(); 1295// playSelected();
1296// break; 1296// break;
1297 case Key_Space: 1297 case Key_Space:
1298// playSelected(); puh 1298// playSelected(); puh
1299 break; 1299 break;
1300 case Key_1: 1300 case Key_1:
1301 tabWidget->setCurrentPage(0); 1301 tabWidget->setCurrentPage(0);
1302 break; 1302 break;
1303 case Key_2: 1303 case Key_2:
1304 tabWidget->setCurrentPage(1); 1304 tabWidget->setCurrentPage(1);
1305 break; 1305 break;
1306 case Key_3: 1306 case Key_3:
1307 tabWidget->setCurrentPage(2); 1307 tabWidget->setCurrentPage(2);
1308 break; 1308 break;
1309 case Key_4: 1309 case Key_4:
1310 tabWidget->setCurrentPage(3); 1310 tabWidget->setCurrentPage(3);
1311 break; 1311 break;
1312 case Key_Down: 1312 case Key_Down:
1313 if ( !d->selectedFiles->next() ) 1313 if ( !d->selectedFiles->next() )
1314 d->selectedFiles->first(); 1314 d->selectedFiles->first();
1315 1315
1316 break; 1316 break;
1317 case Key_Up: 1317 case Key_Up:
1318 if ( !d->selectedFiles->prev() ) 1318 if ( !d->selectedFiles->prev() )
1319 // d->selectedFiles->last(); 1319 // d->selectedFiles->last();
1320 1320
1321 break; 1321 break;
1322 1322
1323 } 1323 }
1324} 1324}
1325 1325
1326void PlayListWidget::keyPressEvent( QKeyEvent *) 1326void PlayListWidget::keyPressEvent( QKeyEvent *)
1327{ 1327{
1328// qDebug("Key press"); 1328// qDebug("Key press");
1329// switch ( e->key() ) { 1329// switch ( e->key() ) {
1330// ////////////////////////////// Zaurus keys 1330// ////////////////////////////// Zaurus keys
1331// case Key_A: //add to playlist 1331// case Key_A: //add to playlist
1332// qDebug("Add"); 1332// qDebug("Add");
1333// addSelected(); 1333// addSelected();
1334// break; 1334// break;
1335// case Key_R: //remove from playlist 1335// case Key_R: //remove from playlist
1336// removeSelected(); 1336// removeSelected();
1337// break; 1337// break;
1338// case Key_P: //play 1338// case Key_P: //play
1339// qDebug("Play"); 1339// qDebug("Play");
1340// playSelected(); 1340// playSelected();
1341// break; 1341// break;
1342// case Key_Space: 1342// case Key_Space:
1343// qDebug("Play"); 1343// qDebug("Play");
1344// playSelected(); 1344// playSelected();
1345// break; 1345// break;
1346// } 1346// }
1347} 1347}
1348 1348
1349void PlayListWidget::doBlank() { 1349void PlayListWidget::doBlank() {
1350 // qDebug("do blanking"); 1350 // qDebug("do blanking");
1351#ifdef QT_QWS_DEVFS 1351#ifdef QT_QWS_DEVFS
1352 fd=open("/dev/fb/0",O_RDWR); 1352 fd=open("/dev/fb/0",O_RDWR);
1353#else 1353#else
1354 fd=open("/dev/fb0",O_RDWR); 1354 fd=open("/dev/fb0",O_RDWR);
1355#endif 1355#endif
1356 if (fd != -1) { 1356 if (fd != -1) {
1357 ioctl(fd,FBIOBLANK,1); 1357 ioctl(fd,FBIOBLANK,1);
1358 // close(fd); 1358 // close(fd);
1359 } 1359 }
1360} 1360}
1361 1361
1362void PlayListWidget::doUnblank() { 1362void PlayListWidget::doUnblank() {
1363 // this crashes opieplayer with a segfault 1363 // this crashes opieplayer with a segfault
1364 // int fd; 1364 // int fd;
1365 // fd=open("/dev/fb0",O_RDWR); 1365 // fd=open("/dev/fb0",O_RDWR);
1366 // qDebug("do unblanking"); 1366 // qDebug("do unblanking");
1367 if (fd != -1) { 1367 if (fd != -1) {
1368 ioctl(fd,FBIOBLANK,0); 1368 ioctl(fd,FBIOBLANK,0);
1369 close(fd); 1369 close(fd);
1370 } 1370 }
1371 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1371 QCopEnvelope h("QPE/System", "setBacklight(int)");
1372 h <<-3;// v[1]; // -3 Force on 1372 h <<-3;// v[1]; // -3 Force on
1373} 1373}
1374 1374
1375void PlayListWidget::populateSkinsMenu() { 1375void PlayListWidget::populateSkinsMenu() {
1376 int item = 0; 1376 int item = 0;
1377 defaultSkinIndex = 0; 1377 defaultSkinIndex = 0;
1378 QString skinName; 1378 QString skinName;
1379 Config cfg( "OpiePlayer" ); 1379 Config cfg( "OpiePlayer" );
1380 cfg.setGroup("Options" ); 1380 cfg.setGroup("Options" );
1381 QString skin = cfg.readEntry( "Skin", "default" ); 1381 QString skin = cfg.readEntry( "Skin", "default" );
1382 1382
1383 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1383 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1384 skinsDir.setFilter( QDir::Dirs ); 1384 skinsDir.setFilter( QDir::Dirs );
1385 skinsDir.setSorting(QDir::Name ); 1385 skinsDir.setSorting(QDir::Name );
1386 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1386 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1387 QFileInfoListIterator it( *skinslist ); 1387 QFileInfoListIterator it( *skinslist );
1388 QFileInfo *fi; 1388 QFileInfo *fi;
1389 while ( ( fi = it.current() ) ) { 1389 while ( ( fi = it.current() ) ) {
1390 skinName = fi->fileName(); 1390 skinName = fi->fileName();
1391 // qDebug( fi->fileName() ); 1391 // qDebug( fi->fileName() );
1392 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1392 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1393 item = skinsMenu->insertItem( fi->fileName() ) ; 1393 item = skinsMenu->insertItem( fi->fileName() ) ;
1394 } 1394 }
1395 if( skinName == "default" ) { 1395 if( skinName == "default" ) {
1396 defaultSkinIndex = item; 1396 defaultSkinIndex = item;
1397 } 1397 }
1398 if( skinName == skin ) { 1398 if( skinName == skin ) {
1399 skinsMenu->setItemChecked( item, TRUE ); 1399 skinsMenu->setItemChecked( item, TRUE );
1400 } 1400 }
1401 ++it; 1401 ++it;
1402 } 1402 }
1403} 1403}
1404 1404
1405void PlayListWidget::skinsMenuActivated( int item ) { 1405void PlayListWidget::skinsMenuActivated( int item ) {
1406 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1406 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1407 skinsMenu->setItemChecked( i, FALSE ); 1407 skinsMenu->setItemChecked( i, FALSE );
1408 } 1408 }
1409 skinsMenu->setItemChecked( item, TRUE ); 1409 skinsMenu->setItemChecked( item, TRUE );
1410 1410
1411 Config cfg( "OpiePlayer" ); 1411 Config cfg( "OpiePlayer" );
1412 cfg.setGroup("Options"); 1412 cfg.setGroup("Options");
1413 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1413 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1414} 1414}
1415 1415
1416void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1416void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1417 // qDebug("qcop message "+msg ); 1417 // qDebug("qcop message "+msg );
1418 QDataStream stream ( data, IO_ReadOnly ); 1418 QDataStream stream ( data, IO_ReadOnly );
1419 if ( msg == "play()" ) { //plays current selection 1419 if ( msg == "play()" ) { //plays current selection
1420 btnPlay( true); 1420 btnPlay( true);
1421 } else if ( msg == "stop()" ) { 1421 } else if ( msg == "stop()" ) {
1422 mediaPlayerState->setPlaying( false); 1422 mediaPlayerState->setPlaying( false);
1423 } else if ( msg == "togglePause()" ) { 1423 } else if ( msg == "togglePause()" ) {
1424 mediaPlayerState->togglePaused(); 1424 mediaPlayerState->togglePaused();
1425 } else if ( msg == "next()" ) { //select next in lis 1425 } else if ( msg == "next()" ) { //select next in lis
1426 mediaPlayerState->setNext(); 1426 mediaPlayerState->setNext();
1427 } else if ( msg == "prev()" ) { //select previous in list 1427 } else if ( msg == "prev()" ) { //select previous in list
1428 mediaPlayerState->setPrev(); 1428 mediaPlayerState->setPrev();
1429 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1429 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1430 mediaPlayerState->toggleLooping(); 1430 mediaPlayerState->toggleLooping();
1431 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1431 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1432 mediaPlayerState->toggleShuffled(); 1432 mediaPlayerState->toggleShuffled();
1433 } else if ( msg == "volUp()" ) { //volume more 1433 } else if ( msg == "volUp()" ) { //volume more
1434 // emit moreClicked(); 1434 // emit moreClicked();
1435 // emit moreReleased(); 1435 // emit moreReleased();
1436 } else if ( msg == "volDown()" ) { //volume less 1436 } else if ( msg == "volDown()" ) { //volume less
1437 // emit lessClicked(); 1437 // emit lessClicked();
1438 // emit lessReleased(); 1438 // emit lessReleased();
1439 } else if ( msg == "play(QString)" ) { //play this now 1439 } else if ( msg == "play(QString)" ) { //play this now
1440 QString file; 1440 QString file;
1441 stream >> file; 1441 stream >> file;
1442 setDocumentEx( (const QString &) file); 1442 setDocumentEx( (const QString &) file);
1443 } else if ( msg == "add(QString)" ) { //add to playlist 1443 } else if ( msg == "add(QString)" ) { //add to playlist
1444 QString file; 1444 QString file;
1445 stream >> file; 1445 stream >> file;
1446 QFileInfo fileInfo(file); 1446 QFileInfo fileInfo(file);
1447 DocLnk lnk; 1447 DocLnk lnk;
1448 lnk.setName( fileInfo.baseName() ); //sets name 1448 lnk.setName( fileInfo.baseName() ); //sets name
1449 lnk.setFile( file ); //sets file name 1449 lnk.setFile( file ); //sets file name
1450 addToSelection( lnk ); 1450 addToSelection( lnk );
1451 } else if ( msg == "rem(QString)" ) { //remove from playlist 1451 } else if ( msg == "rem(QString)" ) { //remove from playlist
1452 QString file; 1452 QString file;
1453 stream >> file; 1453 stream >> file;
1454 } else if ( msg == "setDocument(QString)" ) { //loop or not loop 1454 } else if ( msg == "setDocument(QString)" ) { //loop or not loop
1455 QCopEnvelope h("QPE/Application/opieplayer", "raise()"); 1455 QCopEnvelope h("QPE/Application/opieplayer", "raise()");
1456 } 1456 }
1457} 1457}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 1a5e474..4460833 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1043 +1,1043 @@
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,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 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 <qtoolbar.h> 34#include <qtoolbar.h>
35 35
36#include <opie2/ofiledialog.h> 36#include <opie2/ofiledialog.h>
37 37
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39 39
40#include "playlistselection.h" 40#include "playlistselection.h"
41#include "playlistwidget.h" 41#include "playlistwidget.h"
42#include "mediaplayer.h" 42#include "mediaplayer.h"
43#include "inputDialog.h" 43#include "inputDialog.h"
44#include "om3u.h" 44#include "om3u.h"
45#include "playlistfileview.h" 45#include "playlistfileview.h"
46 46
47//only needed for the random play 47//only needed for the random play
48#include <assert.h> 48#include <assert.h>
49 49
50using namespace Opie::Ui; 50using namespace Opie::Ui;
51PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 51PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
52 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 52 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
53{ 53{
54 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 54 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
55 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 55 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
56 56
57 57
58 58
59 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 59 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
60 "opieplayer2/add_to_playlist", 60 "opieplayer2/add_to_playlist",
61 this , SLOT(addSelected() ) ); 61 this , SLOT(addSelected() ) );
62 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 62 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
63 "opieplayer2/remove_from_playlist", 63 "opieplayer2/remove_from_playlist",
64 this , SLOT(removeSelected() ) ); 64 this , SLOT(removeSelected() ) );
65 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 65 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
66 this , SLOT( btnPlay(bool) ), TRUE ); 66 this , SLOT( btnPlay(bool) ), TRUE );
67 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 67 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
68 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 68 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
69 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 69 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
70 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 70 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
71 71
72 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 72 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
73 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 73 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
74 this, SLOT( addAllMusicToList() ) ); 74 this, SLOT( addAllMusicToList() ) );
75 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 75 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
76 this, SLOT( addAllVideoToList() ) ); 76 this, SLOT( addAllVideoToList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
78 this, SLOT( addAllToList() ) ); 78 this, SLOT( addAllToList() ) );
79 pmPlayList->insertSeparator(-1); 79 pmPlayList->insertSeparator(-1);
80 (void)new MenuItem( pmPlayList, tr( "Add File" ), 80 (void)new MenuItem( pmPlayList, tr( "Add File" ),
81 this,SLOT( openFile() ) ); 81 this,SLOT( openFile() ) );
82 (void)new MenuItem( pmPlayList, tr("Add URL"), 82 (void)new MenuItem( pmPlayList, tr("Add URL"),
83 this,SLOT( openURL() ) ); 83 this,SLOT( openURL() ) );
84 pmPlayList->insertSeparator(-1); 84 pmPlayList->insertSeparator(-1);
85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
86 this, SLOT(writem3u() ) ); 86 this, SLOT(writem3u() ) );
87 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
88 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 88 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
89 audioView, SLOT( scanFiles() ) ); 89 audioView, SLOT( scanFiles() ) );
90 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 90 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
91 videoView, SLOT( scanFiles() ) ); 91 videoView, SLOT( scanFiles() ) );
92 92
93 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 93 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
94 mediaPlayerState, SLOT( toggleFullscreen() ) ); 94 mediaPlayerState, SLOT( toggleFullscreen() ) );
95 95
96 Config cfg( "OpiePlayer" ); 96 Config cfg( "OpiePlayer" );
97 bool b= cfg.readBoolEntry("FullScreen", 0); 97 bool b= cfg.readBoolEntry("FullScreen", 0);
98 mediaPlayerState->setFullscreen( b ); 98 mediaPlayerState->setFullscreen( b );
99 pmView->setItemChecked( -16, b ); 99 pmView->setItemChecked( -16, b );
100 100
101 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 101 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
102 d->selectedFiles, SLOT(moveSelectedUp() ) ); 102 d->selectedFiles, SLOT(moveSelectedUp() ) );
103 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 103 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
104 d->selectedFiles, SLOT(removeSelected() ) ); 104 d->selectedFiles, SLOT(removeSelected() ) );
105 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 105 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
106 d->selectedFiles, SLOT(moveSelectedDown() ) ); 106 d->selectedFiles, SLOT(moveSelectedDown() ) );
107 QVBox *stretch2 = new QVBox( vbox1 ); 107 QVBox *stretch2 = new QVBox( vbox1 );
108 108
109 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 109 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
110 SLOT( deletePlaylist() ) ); 110 SLOT( deletePlaylist() ) );
111 connect( pmView, SIGNAL( activated(int) ), 111 connect( pmView, SIGNAL( activated(int) ),
112 this, SLOT( pmViewActivated(int) ) ); 112 this, SLOT( pmViewActivated(int) ) );
113 connect( skinsMenu, SIGNAL( activated(int) ) , 113 connect( skinsMenu, SIGNAL( activated(int) ) ,
114 this, SLOT( skinsMenuActivated(int) ) ); 114 this, SLOT( skinsMenuActivated(int) ) );
115 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 115 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
116 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 116 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
117 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 117 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
118 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 118 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
119 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 119 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
120 this,SLOT( playIt(QListViewItem*) ) ); 120 this,SLOT( playIt(QListViewItem*) ) );
121 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 121 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
122 this, SLOT( addToSelection(QListViewItem*) ) ); 122 this, SLOT( addToSelection(QListViewItem*) ) );
123 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 123 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
125 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 125 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
126 this,SLOT( playIt(QListViewItem*) ) ); 126 this,SLOT( playIt(QListViewItem*) ) );
127 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 127 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
128 this, SLOT( addToSelection(QListViewItem*) ) ); 128 this, SLOT( addToSelection(QListViewItem*) ) );
129 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 129 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
130 this, SLOT( loadList(const DocLnk&) ) ); 130 this, SLOT( loadList(const DocLnk&) ) );
131 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 131 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
132 this, SLOT( tabChanged(QWidget*) ) ); 132 this, SLOT( tabChanged(QWidget*) ) );
133 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 133 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
134 d->tbPlay, SLOT( setOn(bool) ) ); 134 d->tbPlay, SLOT( setOn(bool) ) );
135 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 135 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
136 d->tbLoop, SLOT( setOn(bool) ) ); 136 d->tbLoop, SLOT( setOn(bool) ) );
137 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 137 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
138 d->tbShuffle, SLOT( setOn(bool) ) ); 138 d->tbShuffle, SLOT( setOn(bool) ) );
139 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 139 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
140 this, SLOT( playIt(QListViewItem*) ) ); 140 this, SLOT( playIt(QListViewItem*) ) );
141 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 141 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
142 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 142 mediaPlayerState, SLOT( setVideoGamma(int) ) );
143 143
144 connect( this, SIGNAL(skinSelected() ), 144 connect( this, SIGNAL(skinSelected() ),
145 m_mp, SLOT( reloadSkins() ) ); 145 m_mp, SLOT( reloadSkins() ) );
146 146
147 // see which skins are installed 147 // see which skins are installed
148 populateSkinsMenu(); 148 populateSkinsMenu();
149 initializeStates(); 149 initializeStates();
150 150
151 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 151 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
152 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 152 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
153 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 153 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
154 154
155 155
156 cfg.setGroup("PlayList"); 156 cfg.setGroup("PlayList");
157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
158 loadList(DocLnk( currentPlaylist ) ); 158 loadList(DocLnk( currentPlaylist ) );
159 159
160 tabWidget->showPage( playListTab ); 160 tabWidget->showPage( playListTab );
161} 161}
162 162
163 163
164PlayListWidget::~PlayListWidget() { 164PlayListWidget::~PlayListWidget() {
165 delete d; 165 delete d;
166 delete m_mp; 166 delete m_mp;
167} 167}
168 168
169 169
170void PlayListWidget::initializeStates() { 170void PlayListWidget::initializeStates() {
171 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 171 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
172 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 172 d->tbLoop->setOn( mediaPlayerState->isLooping() );
173 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 173 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
174 d->playListFrame->show(); 174 d->playListFrame->show();
175} 175}
176 176
177void PlayListWidget::writeDefaultPlaylist() { 177void PlayListWidget::writeDefaultPlaylist() {
178 178
179 Config config( "OpiePlayer" ); 179 Config config( "OpiePlayer" );
180 config.setGroup( "PlayList" ); 180 config.setGroup( "PlayList" );
181 QString filename=QPEApplication::documentDir() + "/default.m3u"; 181 QString filename=QPEApplication::documentDir() + "/default.m3u";
182 QString currentString = config.readEntry( "CurrentPlaylist", filename); 182 QString currentString = config.readEntry( "CurrentPlaylist", filename);
183 if( currentString == filename) { 183 if( currentString == filename) {
184 Om3u *m3uList; 184 Om3u *m3uList;
185 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 185 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
186 if( d->selectedFiles->first() ) { 186 if( d->selectedFiles->first() ) {
187 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 187 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
188 do { 188 do {
189 // qDebug(d->selectedFiles->current()->file()); 189 // qDebug(d->selectedFiles->current()->file());
190 m3uList->add( d->selectedFiles->current()->file() ); 190 m3uList->add( d->selectedFiles->current()->file() );
191 } 191 }
192 while ( d->selectedFiles->next() ); 192 while ( d->selectedFiles->next() );
193 193
194 m3uList->write(); 194 m3uList->write();
195 m3uList->close(); 195 m3uList->close();
196 delete m3uList; 196 delete m3uList;
197 197
198 } 198 }
199 } 199 }
200} 200}
201 201
202void PlayListWidget::addToSelection( const DocLnk& lnk ) { 202void PlayListWidget::addToSelection( const DocLnk& lnk ) {
203 d->setDocumentUsed = FALSE; 203 d->setDocumentUsed = FALSE;
204 if( QFileInfo( lnk.file() ).exists() || 204 if( QFileInfo( lnk.file() ).exists() ||
205 lnk.file().left(4) == "http" ) { 205 lnk.file().left(4) == "http" ) {
206 d->selectedFiles->addToSelection( lnk ); 206 d->selectedFiles->addToSelection( lnk );
207 } 207 }
208// writeCurrentM3u(); 208// writeCurrentM3u();
209} 209}
210 210
211 211
212void PlayListWidget::clearList() { 212void PlayListWidget::clearList() {
213 while ( first() ) { 213 while ( first() ) {
214 d->selectedFiles->removeSelected(); 214 d->selectedFiles->removeSelected();
215 } 215 }
216 Config cfg( "OpiePlayer" ); 216 Config cfg( "OpiePlayer" );
217 cfg.setGroup("PlayList"); 217 cfg.setGroup("PlayList");
218 cfg.writeEntry("CurrentPlaylist","default"); 218 cfg.writeEntry("CurrentPlaylist","default");
219 setCaption("OpiePlayer"); 219 setCaption("OpiePlayer");
220} 220}
221 221
222void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 222void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
223 switch (mouse) { 223 switch (mouse) {
224 case LeftButton: 224 case LeftButton:
225 break; 225 break;
226 case RightButton: 226 case RightButton:
227 { 227 {
228 QPopupMenu m; 228 QPopupMenu m;
229 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 229 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
230 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 230 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
231 m.exec( QCursor::pos() ); 231 m.exec( QCursor::pos() );
232 } 232 }
233 break; 233 break;
234 } 234 }
235} 235}
236 236
237 237
238void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 238void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
239 switch (mouse) { 239 switch (mouse) {
240 case LeftButton: 240 case LeftButton:
241 break; 241 break;
242 case RightButton: 242 case RightButton:
243 { 243 {
244 QPopupMenu m; 244 QPopupMenu m;
245 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 245 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
246 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 246 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
247 m.exec( QCursor::pos() ); 247 m.exec( QCursor::pos() );
248 } 248 }
249 break; 249 break;
250 } 250 }
251} 251}
252 252
253 253
254void PlayListWidget::addAllToList() { 254void PlayListWidget::addAllToList() {
255 255
256 256
257 audioView->populateView(); 257 audioView->populateView();
258 258
259 QListViewItemIterator audioIt( audioView ); 259 QListViewItemIterator audioIt( audioView );
260 DocLnk lnk; 260 DocLnk lnk;
261 QString filename; 261 QString filename;
262 // iterate through all items of the listview 262 // iterate through all items of the listview
263 for ( ; audioIt.current(); ++audioIt ) { 263 for ( ; audioIt.current(); ++audioIt ) {
264 filename = audioIt.current()->text(3); 264 filename = audioIt.current()->text(3);
265 lnk.setName( QFileInfo(filename).baseName() ); //sets name 265 lnk.setName( QFileInfo(filename).baseName() ); //sets name
266 lnk.setFile( filename ); //sets file name 266 lnk.setFile( filename ); //sets file name
267 d->selectedFiles->addToSelection( lnk); 267 d->selectedFiles->addToSelection( lnk);
268 } 268 }
269 269
270 videoView->populateView(); 270 videoView->populateView();
271 271
272 QListViewItemIterator videoIt( videoView ); 272 QListViewItemIterator videoIt( videoView );
273 for ( ; videoIt.current(); ++videoIt ) { 273 for ( ; videoIt.current(); ++videoIt ) {
274 filename = videoIt.current()->text(3); 274 filename = videoIt.current()->text(3);
275 lnk.setName( QFileInfo(filename).baseName() ); //sets name 275 lnk.setName( QFileInfo(filename).baseName() ); //sets name
276 lnk.setFile( filename ); //sets file name 276 lnk.setFile( filename ); //sets file name
277 d->selectedFiles->addToSelection( lnk); 277 d->selectedFiles->addToSelection( lnk);
278 } 278 }
279 279
280 tabWidget->setCurrentPage(0); 280 tabWidget->setCurrentPage(0);
281 281
282 writeCurrentM3u(); 282 writeCurrentM3u();
283 d->selectedFiles->first(); 283 d->selectedFiles->first();
284} 284}
285 285
286 286
287void PlayListWidget::addAllMusicToList() { 287void PlayListWidget::addAllMusicToList() {
288 288
289 audioView->populateView(); 289 audioView->populateView();
290 290
291 QListViewItemIterator audioIt( audioView ); 291 QListViewItemIterator audioIt( audioView );
292 DocLnk lnk; 292 DocLnk lnk;
293 QString filename; 293 QString filename;
294 // iterate through all items of the listview 294 // iterate through all items of the listview
295 for ( ; audioIt.current(); ++audioIt ) { 295 for ( ; audioIt.current(); ++audioIt ) {
296 filename = audioIt.current()->text(3); 296 filename = audioIt.current()->text(3);
297 lnk.setName( QFileInfo(filename).baseName() ); //sets name 297 lnk.setName( QFileInfo(filename).baseName() ); //sets name
298 lnk.setFile( filename ); //sets file name 298 lnk.setFile( filename ); //sets file name
299 d->selectedFiles->addToSelection( lnk); 299 d->selectedFiles->addToSelection( lnk);
300 } 300 }
301 301
302 tabWidget->setCurrentPage(0); 302 tabWidget->setCurrentPage(0);
303 writeCurrentM3u(); 303 writeCurrentM3u();
304 d->selectedFiles->first(); 304 d->selectedFiles->first();
305} 305}
306 306
307 307
308void PlayListWidget::addAllVideoToList() { 308void PlayListWidget::addAllVideoToList() {
309 309
310 videoView->populateView(); 310 videoView->populateView();
311 311
312 QListViewItemIterator videoIt( videoView ); 312 QListViewItemIterator videoIt( videoView );
313 DocLnk lnk; 313 DocLnk lnk;
314 QString filename; 314 QString filename;
315 for ( ; videoIt.current(); ++videoIt ) { 315 for ( ; videoIt.current(); ++videoIt ) {
316 filename = videoIt.current()->text(3); 316 filename = videoIt.current()->text(3);
317 lnk.setName( QFileInfo(filename).baseName() ); //sets name 317 lnk.setName( QFileInfo(filename).baseName() ); //sets name
318 lnk.setFile( filename ); //sets file name 318 lnk.setFile( filename ); //sets file name
319 d->selectedFiles->addToSelection( lnk); 319 d->selectedFiles->addToSelection( lnk);
320 } 320 }
321 tabWidget->setCurrentPage(0); 321 tabWidget->setCurrentPage(0);
322 writeCurrentM3u(); 322 writeCurrentM3u();
323 d->selectedFiles->first(); 323 d->selectedFiles->first();
324} 324}
325 325
326 326
327void PlayListWidget::setDocument( const QString& fileref ) { 327void PlayListWidget::setDocument( const QString& fileref ) {
328 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 328 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
329 fromSetDocument = TRUE; 329 fromSetDocument = TRUE;
330 QFileInfo fileInfo(fileref); 330 QFileInfo fileInfo(fileref);
331 331
332 if ( !fileInfo.exists() ) { 332 if ( !fileInfo.exists() ) {
333 QMessageBox::warning( this, tr( "Invalid File" ), 333 QMessageBox::warning( this, tr( "Invalid File" ),
334 tr( "There was a problem in getting the file." ) ); 334 tr( "There was a problem in getting the file." ) );
335 return; 335 return;
336 } 336 }
337 337
338 clearList(); 338 clearList();
339 QString extension = fileInfo.extension(false); 339 QString extension = fileInfo.extension(false);
340 340
341 if( extension.find( "m3u", 0, false) != -1 341 if( extension.find( "m3u", 0, false) != -1
342 || extension.find( "pls", 0, false) != -1 ) { 342 || extension.find( "pls", 0, false) != -1 ) {
343 readListFromFile( fileref ); 343 readListFromFile( fileref );
344 } else { 344 } else {
345 clearList(); 345 clearList();
346 DocLnk lnk; 346 DocLnk lnk;
347 lnk.setName( fileInfo.baseName() ); //sets name 347 lnk.setName( fileInfo.baseName() ); //sets name
348 lnk.setFile( fileref ); //sets file name 348 lnk.setFile( fileref ); //sets file name
349 addToSelection( lnk ); 349 addToSelection( lnk );
350 writeCurrentM3u(); 350 writeCurrentM3u();
351 351
352 d->setDocumentUsed = TRUE; 352 d->setDocumentUsed = TRUE;
353 mediaPlayerState->setPlaying( FALSE ); 353 mediaPlayerState->setPlaying( FALSE );
354 mediaPlayerState->setPlaying( TRUE ); 354 mediaPlayerState->setPlaying( TRUE );
355 } 355 }
356} 356}
357 357
358 358
359void PlayListWidget::useSelectedDocument() { 359void PlayListWidget::useSelectedDocument() {
360 d->setDocumentUsed = FALSE; 360 d->setDocumentUsed = FALSE;
361} 361}
362 362
363 363
364const DocLnk *PlayListWidget::current() const { // this is fugly 364const DocLnk *PlayListWidget::current() const { // this is fugly
365 assert( currentTab() == CurrentPlayList ); 365 assert( currentTab() == CurrentPlayList );
366 366
367 const DocLnk *lnk = d->selectedFiles->current(); 367 const DocLnk *lnk = d->selectedFiles->current();
368 if ( !lnk ) { 368 if ( !lnk ) {
369 d->selectedFiles->first(); 369 d->selectedFiles->first();
370 lnk = d->selectedFiles->current(); 370 lnk = d->selectedFiles->current();
371 } 371 }
372 assert( lnk ); 372 assert( lnk );
373 return lnk; 373 return lnk;
374} 374}
375 375
376 376
377bool PlayListWidget::prev() { 377bool PlayListWidget::prev() {
378 if ( mediaPlayerState->isShuffled() ) { 378 if ( mediaPlayerState->isShuffled() ) {
379 const DocLnk *cur = current(); 379 const DocLnk *cur = current();
380 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 380 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
381 for ( int i = 0; i < j; i++ ) { 381 for ( int i = 0; i < j; i++ ) {
382 if ( !d->selectedFiles->next() ) 382 if ( !d->selectedFiles->next() )
383 d->selectedFiles->first(); 383 d->selectedFiles->first();
384 } 384 }
385 if ( cur == current() ) 385 if ( cur == current() )
386 if ( !d->selectedFiles->next() ) { 386 if ( !d->selectedFiles->next() ) {
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388 } 388 }
389 return TRUE; 389 return TRUE;
390 } else { 390 } else {
391 if ( !d->selectedFiles->prev() ) { 391 if ( !d->selectedFiles->prev() ) {
392 if ( mediaPlayerState->isLooping() ) { 392 if ( mediaPlayerState->isLooping() ) {
393 return d->selectedFiles->last(); 393 return d->selectedFiles->last();
394 } else { 394 } else {
395 return FALSE; 395 return FALSE;
396 } 396 }
397 } 397 }
398 return TRUE; 398 return TRUE;
399 } 399 }
400} 400}
401 401
402 402
403bool PlayListWidget::next() { 403bool PlayListWidget::next() {
404//qDebug("<<<<<<<<<<<<next()"); 404//qDebug("<<<<<<<<<<<<next()");
405 if ( mediaPlayerState->isShuffled() ) { 405 if ( mediaPlayerState->isShuffled() ) {
406 return prev(); 406 return prev();
407 } else { 407 } else {
408 if ( !d->selectedFiles->next() ) { 408 if ( !d->selectedFiles->next() ) {
409 if ( mediaPlayerState->isLooping() ) { 409 if ( mediaPlayerState->isLooping() ) {
410 return d->selectedFiles->first(); 410 return d->selectedFiles->first();
411 } else { 411 } else {
412 return FALSE; 412 return FALSE;
413 } 413 }
414 } 414 }
415 return TRUE; 415 return TRUE;
416 } 416 }
417} 417}
418 418
419 419
420bool PlayListWidget::first() { 420bool PlayListWidget::first() {
421 return d->selectedFiles->first(); 421 return d->selectedFiles->first();
422} 422}
423 423
424 424
425bool PlayListWidget::last() { 425bool PlayListWidget::last() {
426 return d->selectedFiles->last(); 426 return d->selectedFiles->last();
427} 427}
428 428
429 429
430 void PlayListWidget::saveList() { 430 void PlayListWidget::saveList() {
431 writem3u(); 431 writem3u();
432 } 432 }
433 433
434 434
435void PlayListWidget::loadList( const DocLnk & lnk) { 435void PlayListWidget::loadList( const DocLnk & lnk) {
436 QString name = lnk.name(); 436 QString name = lnk.name();
437 437
438 if( name.length()>0) { 438 if( name.length()>0) {
439 setCaption("OpiePlayer: "+name); 439 setCaption("OpiePlayer: "+name);
440 clearList(); 440 clearList();
441 readListFromFile(lnk.file()); 441 readListFromFile(lnk.file());
442 tabWidget->setCurrentPage(0); 442 tabWidget->setCurrentPage(0);
443 } 443 }
444} 444}
445 445
446void PlayListWidget::addSelected() { 446void PlayListWidget::addSelected() {
447 assert( inFileListMode() ); 447 assert( inFileListMode() );
448 448
449 QListViewItemIterator it( currentFileListView ); 449 QListViewItemIterator it( currentFileListView );
450 for ( ; it.current(); ++it ) 450 for ( ; it.current(); ++it )
451 if ( it.current()->isSelected() ) { 451 if ( it.current()->isSelected() ) {
452 QString filename = it.current()->text(3); 452 QString filename = it.current()->text(3);
453 453
454 DocLnk lnk; 454 DocLnk lnk;
455 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 455 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
456 lnk.setFile( filename ); //sets file name 456 lnk.setFile( filename ); //sets file name
457 457
458 d->selectedFiles->addToSelection( lnk ); 458 d->selectedFiles->addToSelection( lnk );
459 } 459 }
460 460
461 currentFileListView->clearSelection(); 461 currentFileListView->clearSelection();
462 462
463 writeCurrentM3u(); 463 writeCurrentM3u();
464} 464}
465 465
466 466
467void PlayListWidget::removeSelected() { 467void PlayListWidget::removeSelected() {
468 d->selectedFiles->removeSelected( ); 468 d->selectedFiles->removeSelected( );
469 writeCurrentM3u(); 469 writeCurrentM3u();
470} 470}
471 471
472 472
473void PlayListWidget::playIt( QListViewItem *it) { 473void PlayListWidget::playIt( QListViewItem *it) {
474 if(!it) return; 474 if(!it) return;
475 mediaPlayerState->setPlaying(FALSE); 475 mediaPlayerState->setPlaying(FALSE);
476 mediaPlayerState->setPlaying(TRUE); 476 mediaPlayerState->setPlaying(TRUE);
477 d->selectedFiles->unSelect(); 477 d->selectedFiles->unSelect();
478} 478}
479 479
480 480
481void PlayListWidget::addToSelection( QListViewItem *it) { 481void PlayListWidget::addToSelection( QListViewItem *it) {
482 d->setDocumentUsed = FALSE; 482 d->setDocumentUsed = FALSE;
483 483
484 if(it) { 484 if(it) {
485 if ( currentTab() == CurrentPlayList ) 485 if ( currentTab() == CurrentPlayList )
486 return; 486 return;
487 DocLnk lnk; 487 DocLnk lnk;
488 QString filename; 488 QString filename;
489 489
490 filename=it->text(3); 490 filename=it->text(3);
491 lnk.setName( QFileInfo(filename).baseName() ); //sets name 491 lnk.setName( QFileInfo(filename).baseName() ); //sets name
492 lnk.setFile( filename ); //sets file name 492 lnk.setFile( filename ); //sets file name
493 d->selectedFiles->addToSelection( lnk); 493 d->selectedFiles->addToSelection( lnk);
494 494
495 writeCurrentM3u(); 495 writeCurrentM3u();
496// tabWidget->setCurrentPage(0); 496// tabWidget->setCurrentPage(0);
497 497
498 } 498 }
499} 499}
500 500
501 501
502void PlayListWidget::tabChanged(QWidget *) { 502void PlayListWidget::tabChanged(QWidget *) {
503 503
504 d->tbPlay->setEnabled( true ); 504 d->tbPlay->setEnabled( true );
505 505
506 disconnect( audioView, SIGNAL( itemsSelected(bool) ), 506 disconnect( audioView, SIGNAL( itemsSelected(bool) ),
507 d->tbPlay, SLOT( setEnabled(bool) ) ); 507 d->tbPlay, SLOT( setEnabled(bool) ) );
508 disconnect( videoView, SIGNAL( itemsSelected(bool) ), 508 disconnect( videoView, SIGNAL( itemsSelected(bool) ),
509 d->tbPlay, SLOT( setEnabled(bool) ) ); 509 d->tbPlay, SLOT( setEnabled(bool) ) );
510 510
511 currentFileListView = 0; 511 currentFileListView = 0;
512 512
513 switch ( currentTab() ) { 513 switch ( currentTab() ) {
514 case CurrentPlayList: 514 case CurrentPlayList:
515 { 515 {
516 if( !tbDeletePlaylist->isHidden() ) { 516 if( !tbDeletePlaylist->isHidden() ) {
517 tbDeletePlaylist->hide(); 517 tbDeletePlaylist->hide();
518 } 518 }
519 d->tbRemoveFromList->setEnabled(TRUE); 519 d->tbRemoveFromList->setEnabled(TRUE);
520 d->tbAddToList->setEnabled(FALSE); 520 d->tbAddToList->setEnabled(FALSE);
521 521
522 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 522 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
523 } 523 }
524 break; 524 break;
525 case AudioFiles: 525 case AudioFiles:
526 { 526 {
527 audioView->populateView(); 527 audioView->populateView();
528 528
529 if( !tbDeletePlaylist->isHidden() ) { 529 if( !tbDeletePlaylist->isHidden() ) {
530 tbDeletePlaylist->hide(); 530 tbDeletePlaylist->hide();
531 } 531 }
532 d->tbRemoveFromList->setEnabled(FALSE); 532 d->tbRemoveFromList->setEnabled(FALSE);
533 d->tbAddToList->setEnabled(TRUE); 533 d->tbAddToList->setEnabled(TRUE);
534 534
535 connect( audioView, SIGNAL( itemsSelected(bool) ), 535 connect( audioView, SIGNAL( itemsSelected(bool) ),
536 d->tbPlay, SLOT( setEnabled(bool) ) ); 536 d->tbPlay, SLOT( setEnabled(bool) ) );
537 537
538 d->tbPlay->setEnabled( audioView->hasSelection() ); 538 d->tbPlay->setEnabled( audioView->hasSelection() );
539 539
540 currentFileListView = audioView; 540 currentFileListView = audioView;
541 } 541 }
542 break; 542 break;
543 case VideoFiles: 543 case VideoFiles:
544 { 544 {
545 videoView->populateView(); 545 videoView->populateView();
546 if( !tbDeletePlaylist->isHidden() ) { 546 if( !tbDeletePlaylist->isHidden() ) {
547 tbDeletePlaylist->hide(); 547 tbDeletePlaylist->hide();
548 } 548 }
549 d->tbRemoveFromList->setEnabled(FALSE); 549 d->tbRemoveFromList->setEnabled(FALSE);
550 d->tbAddToList->setEnabled(TRUE); 550 d->tbAddToList->setEnabled(TRUE);
551 551
552 connect( videoView, SIGNAL( itemsSelected(bool) ), 552 connect( videoView, SIGNAL( itemsSelected(bool) ),
553 d->tbPlay, SLOT( setEnabled(bool) ) ); 553 d->tbPlay, SLOT( setEnabled(bool) ) );
554 554
555 d->tbPlay->setEnabled( videoView->hasSelection() ); 555 d->tbPlay->setEnabled( videoView->hasSelection() );
556 556
557 currentFileListView = videoView; 557 currentFileListView = videoView;
558 } 558 }
559 break; 559 break;
560 case PlayLists: 560 case PlayLists:
561 { 561 {
562 if( tbDeletePlaylist->isHidden() ) { 562 if( tbDeletePlaylist->isHidden() ) {
563 tbDeletePlaylist->show(); 563 tbDeletePlaylist->show();
564 } 564 }
565 playLists->reread(); 565 playLists->reread();
566 d->tbAddToList->setEnabled(FALSE); 566 d->tbAddToList->setEnabled(FALSE);
567 567
568 d->tbPlay->setEnabled( false ); 568 d->tbPlay->setEnabled( false );
569 } 569 }
570 break; 570 break;
571 }; 571 };
572} 572}
573 573
574 574
575void PlayListWidget::btnPlay(bool b) { 575void PlayListWidget::btnPlay(bool b) {
576// mediaPlayerState->setPlaying(false); 576// mediaPlayerState->setPlaying(false);
577 mediaPlayerState->setPlaying(b); 577 mediaPlayerState->setPlaying(b);
578 insanityBool=FALSE; 578 insanityBool=FALSE;
579} 579}
580 580
581void PlayListWidget::deletePlaylist() { 581void PlayListWidget::deletePlaylist() {
582 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 582 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
583 (tr("You really want to delete\nthis playlist?")), 583 (tr("You really want to delete\nthis playlist?")),
584 (tr("Yes")), (tr("No")), 0 )){ 584 (tr("Yes")), (tr("No")), 0 )){
585 case 0: // Yes clicked, 585 case 0: // Yes clicked,
586 QFile().remove(playLists->selectedDocument().file()); 586 QFile().remove(playLists->selectedDocument().file());
587 QFile().remove(playLists->selectedDocument().linkFile()); 587 QFile().remove(playLists->selectedDocument().linkFile());
588 playLists->reread(); 588 playLists->reread();
589 break; 589 break;
590 case 1: // Cancel 590 case 1: // Cancel
591 break; 591 break;
592 }; 592 };
593} 593}
594 594
595 595
596void PlayListWidget::playSelected() { 596void PlayListWidget::playSelected() {
597 btnPlay( TRUE); 597 btnPlay( TRUE);
598} 598}
599 599
600bool PlayListWidget::inFileListMode() const 600bool PlayListWidget::inFileListMode() const
601{ 601{
602 TabType tab = currentTab(); 602 TabType tab = currentTab();
603 return tab == AudioFiles || tab == VideoFiles; 603 return tab == AudioFiles || tab == VideoFiles;
604} 604}
605 605
606void PlayListWidget::openURL() { 606void PlayListWidget::openURL() {
607 // http://66.28.164.33:2080 607 // http://66.28.164.33:2080
608 // http://somafm.com/star0242.m3u 608 // http://somafm.com/star0242.m3u
609 QString filename, name; 609 QString filename, name;
610 InputDialog *fileDlg; 610 InputDialog *fileDlg;
611 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 611 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
612 fileDlg->exec(); 612 fileDlg->exec();
613 if( fileDlg->result() == 1 ) { 613 if( fileDlg->result() == 1 ) {
614 filename = fileDlg->text(); 614 filename = fileDlg->text();
615 qDebug( "Selected filename is " + filename ); 615 qDebug( "Selected filename is " + filename );
616 // Om3u *m3uList; 616 // Om3u *m3uList;
617 DocLnk lnk; 617 DocLnk lnk;
618 Config cfg( "OpiePlayer" ); 618 Config cfg( "OpiePlayer" );
619 cfg.setGroup("PlayList"); 619 cfg.setGroup("PlayList");
620 620
621 if(filename.left(4) == "http") { 621 if(filename.left(4) == "http") {
622 QString m3uFile, m3uFilePath; 622 QString m3uFile, m3uFilePath;
623 if(filename.find(":",8,TRUE) != -1) { //found a port 623 if(filename.find(":",8,TRUE) != -1) { //found a port
624 m3uFile = filename.left( filename.find( ":",8,TRUE)); 624 m3uFile = filename.left( filename.find( ":",8,TRUE));
625 m3uFile = m3uFile.right( 7); 625 m3uFile = m3uFile.right( 7);
626 } else if(filename.left(4) == "http"){ 626 } else if(filename.left(4) == "http"){
627 m3uFile=filename; 627 m3uFile=filename;
628 m3uFile = m3uFile.right( m3uFile.length() - 7); 628 m3uFile = m3uFile.right( m3uFile.length() - 7);
629 } else{ 629 } else{
630 m3uFile=filename; 630 m3uFile=filename;
631 } 631 }
632 632
633 lnk.setName( filename ); //sets name 633 lnk.setName( filename ); //sets name
634 lnk.setFile( filename ); //sets file name 634 lnk.setFile( filename ); //sets file name
635 635
636// lnk.setIcon("opieplayer2/musicfile"); 636// lnk.setIcon("opieplayer2/musicfile");
637 637
638 d->selectedFiles->addToSelection( lnk ); 638 d->selectedFiles->addToSelection( lnk );
639 writeCurrentM3u(); 639 writeCurrentM3u();
640 d->selectedFiles->setSelectedItem( lnk.name()); 640 d->selectedFiles->setSelectedItem( lnk.name());
641 } 641 }
642 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 642 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
643 readListFromFile( filename ); 643 readListFromFile( filename );
644 } else { 644 } else {
645 lnk.setName( QFileInfo(filename).baseName() ); //sets name 645 lnk.setName( QFileInfo(filename).baseName() ); //sets name
646 lnk.setFile( filename ); //sets file name 646 lnk.setFile( filename ); //sets file name
647 d->selectedFiles->addToSelection( lnk); 647 d->selectedFiles->addToSelection( lnk);
648 writeCurrentM3u(); 648 writeCurrentM3u();
649 d->selectedFiles->setSelectedItem( lnk.name()); 649 d->selectedFiles->setSelectedItem( lnk.name());
650 } 650 }
651 } 651 }
652 652
653 653
654 delete fileDlg; 654 delete fileDlg;
655} 655}
656 656
657 657
658void PlayListWidget::openFile() { 658void PlayListWidget::openFile() {
659 659
660 QString filename, name; 660 QString filename, name;
661 661
662 Config cfg( "OpiePlayer" ); 662 Config cfg( "OpiePlayer" );
663 cfg.setGroup("Dialog"); 663 cfg.setGroup("Dialog");
664 MimeTypes types; 664 MimeTypes types;
665 QStringList audio, video, all; 665 QStringList audio, video, all;
666 audio << "audio/*"; 666 audio << "audio/*";
667 audio << "playlist/plain"; 667 audio << "playlist/plain";
668 audio << "application/ogg"; 668 audio << "audio/x-ogg";
669 audio << "audio/x-mpegurl"; 669 audio << "audio/x-mpegurl";
670 670
671 video << "video/*"; 671 video << "video/*";
672 video << "playlist/plain"; 672 video << "playlist/plain";
673 673
674 all += audio; 674 all += audio;
675 all += video; 675 all += video;
676 types.insert("All Media Files", all ); 676 types.insert("All Media Files", all );
677 types.insert("Audio", audio ); 677 types.insert("Audio", audio );
678 types.insert("Video", video ); 678 types.insert("Video", video );
679 679
680 QString str = OFileDialog::getOpenFileName( 1, 680 QString str = OFileDialog::getOpenFileName( 1,
681 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 681 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
682 types, 0 ); 682 types, 0 );
683 683
684 if(str.left(2) == "//") { 684 if(str.left(2) == "//") {
685 str=str.right(str.length()-1); 685 str=str.right(str.length()-1);
686 } 686 }
687 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); 687 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
688 688
689 if( !str.isEmpty() ) { 689 if( !str.isEmpty() ) {
690 690
691 qDebug( "Selected filename is " + str ); 691 qDebug( "Selected filename is " + str );
692 filename = str; 692 filename = str;
693 DocLnk lnk; 693 DocLnk lnk;
694 694
695 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 695 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
696 readListFromFile( filename ); 696 readListFromFile( filename );
697 } else { 697 } else {
698 lnk.setName( QFileInfo(filename).baseName() ); //sets name 698 lnk.setName( QFileInfo(filename).baseName() ); //sets name
699 lnk.setFile( filename ); //sets file name 699 lnk.setFile( filename ); //sets file name
700 d->selectedFiles->addToSelection( lnk ); 700 d->selectedFiles->addToSelection( lnk );
701 writeCurrentM3u(); 701 writeCurrentM3u();
702 d->selectedFiles->setSelectedItem( lnk.name() ); 702 d->selectedFiles->setSelectedItem( lnk.name() );
703 } 703 }
704 } 704 }
705} 705}
706 706
707 707
708void PlayListWidget::readListFromFile( const QString &filename ) { 708void PlayListWidget::readListFromFile( const QString &filename ) {
709 qDebug( "read list filename " + filename ); 709 qDebug( "read list filename " + filename );
710 QFileInfo fi(filename); 710 QFileInfo fi(filename);
711 Om3u *m3uList; 711 Om3u *m3uList;
712 QString s, name; 712 QString s, name;
713 m3uList = new Om3u( filename, IO_ReadOnly ); 713 m3uList = new Om3u( filename, IO_ReadOnly );
714 if(fi.extension(false).find("m3u",0,false) != -1 ) 714 if(fi.extension(false).find("m3u",0,false) != -1 )
715 m3uList->readM3u(); 715 m3uList->readM3u();
716 else if(fi.extension(false).find("pls",0,false) != -1 ) 716 else if(fi.extension(false).find("pls",0,false) != -1 )
717 m3uList->readPls(); 717 m3uList->readPls();
718 718
719 DocLnk lnk; 719 DocLnk lnk;
720 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 720 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
721 s = *it; 721 s = *it;
722 // qDebug(s); 722 // qDebug(s);
723 if(s.left(4)=="http") { 723 if(s.left(4)=="http") {
724 lnk.setName( s ); //sets file name 724 lnk.setName( s ); //sets file name
725 lnk.setIcon("opieplayer2/musicfile"); 725 lnk.setIcon("opieplayer2/musicfile");
726 lnk.setFile( s ); //sets file name 726 lnk.setFile( s ); //sets file name
727 727
728 } else { //is file 728 } else { //is file
729 lnk.setName( QFileInfo(s).baseName()); 729 lnk.setName( QFileInfo(s).baseName());
730 if(s.left(1) != "/") { 730 if(s.left(1) != "/") {
731 731
732 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 732 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
733 } else { 733 } else {
734 lnk.setFile( s); 734 lnk.setFile( s);
735 } 735 }
736 } 736 }
737 d->selectedFiles->addToSelection( lnk ); 737 d->selectedFiles->addToSelection( lnk );
738 } 738 }
739 Config config( "OpiePlayer" ); 739 Config config( "OpiePlayer" );
740 config.setGroup( "PlayList" ); 740 config.setGroup( "PlayList" );
741 741
742 config.writeEntry("CurrentPlaylist",filename); 742 config.writeEntry("CurrentPlaylist",filename);
743 config.write(); 743 config.write();
744 currentPlayList=filename; 744 currentPlayList=filename;
745 745
746 m3uList->close(); 746 m3uList->close();
747 delete m3uList; 747 delete m3uList;
748 748
749 d->selectedFiles->setSelectedItem( s); 749 d->selectedFiles->setSelectedItem( s);
750 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 750 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
751 751
752} 752}
753 753
754// writes current playlist to current m3u file */ 754// writes current playlist to current m3u file */
755 void PlayListWidget::writeCurrentM3u() { 755 void PlayListWidget::writeCurrentM3u() {
756 qDebug("writing to current m3u"); 756 qDebug("writing to current m3u");
757 Config cfg( "OpiePlayer" ); 757 Config cfg( "OpiePlayer" );
758 cfg.setGroup("PlayList"); 758 cfg.setGroup("PlayList");
759 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 759 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
760 760
761 Om3u *m3uList; 761 Om3u *m3uList;
762 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 762 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
763 if( d->selectedFiles->first()) { 763 if( d->selectedFiles->first()) {
764 764
765 do { 765 do {
766 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 766 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
767 m3uList->add( d->selectedFiles->current()->file() ); 767 m3uList->add( d->selectedFiles->current()->file() );
768 } 768 }
769 while ( d->selectedFiles->next() ); 769 while ( d->selectedFiles->next() );
770 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 770 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
771 m3uList->write(); 771 m3uList->write();
772 m3uList->close(); 772 m3uList->close();
773 } 773 }
774 delete m3uList; 774 delete m3uList;
775 775
776 } 776 }
777 777
778 /* 778 /*
779 writes current playlist to m3u file */ 779 writes current playlist to m3u file */
780void PlayListWidget::writem3u() { 780void PlayListWidget::writem3u() {
781 //InputDilog *fileDlg; 781 //InputDilog *fileDlg;
782 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 782 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
783 //fileDlg->exec(); 783 //fileDlg->exec();
784 784
785 Config cfg( "OpiePlayer" ); 785 Config cfg( "OpiePlayer" );
786 cfg.setGroup("Dialog"); 786 cfg.setGroup("Dialog");
787 MimeTypes types; 787 MimeTypes types;
788 QStringList audio, video, all; 788 QStringList audio, video, all;
789 audio << "audio/*"; 789 audio << "audio/*";
790 audio << "playlist/plain"; 790 audio << "playlist/plain";
791 audio << "audio/x-mpegurl"; 791 audio << "audio/x-mpegurl";
792 792
793 video << "video/*"; 793 video << "video/*";
794 video << "playlist/plain"; 794 video << "playlist/plain";
795 795
796 all += audio; 796 all += audio;
797 all += video; 797 all += video;
798 types.insert("All Media Files", all ); 798 types.insert("All Media Files", all );
799 types.insert("Audio", audio ); 799 types.insert("Audio", audio );
800 types.insert("Video", video ); 800 types.insert("Video", video );
801 801
802 QString str = OFileDialog::getOpenFileName( 1, 802 QString str = OFileDialog::getOpenFileName( 1,
803 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 803 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
804 types, 0 ); 804 types, 0 );
805 if(str.left(2) == "//") str=str.right(str.length()-1); 805 if(str.left(2) == "//") str=str.right(str.length()-1);
806 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); 806 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
807 807
808 808
809 QString name, filename, list; 809 QString name, filename, list;
810 Om3u *m3uList; 810 Om3u *m3uList;
811 811
812 if( !str.isEmpty() ) { 812 if( !str.isEmpty() ) {
813 name = str; 813 name = str;
814 // name = fileDlg->text(); 814 // name = fileDlg->text();
815// qDebug( filename ); 815// qDebug( filename );
816 if( name.find("/",0,true) != -1) {// assume they specify a file path 816 if( name.find("/",0,true) != -1) {// assume they specify a file path
817 filename = name; 817 filename = name;
818 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 818 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
819 } 819 }
820 else //otherwise dump it somewhere noticable 820 else //otherwise dump it somewhere noticable
821 filename = QPEApplication::documentDir() + "/" + name; 821 filename = QPEApplication::documentDir() + "/" + name;
822 822
823 if( filename.right( 3 ) != "m3u" ) //needs filename extension 823 if( filename.right( 3 ) != "m3u" ) //needs filename extension
824 filename += ".m3u"; 824 filename += ".m3u";
825 825
826 if( d->selectedFiles->first()) { //ramble through playlist view 826 if( d->selectedFiles->first()) { //ramble through playlist view
827 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 827 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
828 828
829 do { 829 do {
830 m3uList->add( d->selectedFiles->current()->file()); 830 m3uList->add( d->selectedFiles->current()->file());
831 } 831 }
832 while ( d->selectedFiles->next() ); 832 while ( d->selectedFiles->next() );
833 // qDebug( list ); 833 // qDebug( list );
834 m3uList->write(); 834 m3uList->write();
835 m3uList->close(); 835 m3uList->close();
836 delete m3uList; 836 delete m3uList;
837 837
838 //delete fileDlg; 838 //delete fileDlg;
839 839
840 DocLnk lnk; 840 DocLnk lnk;
841 lnk.setFile( filename); 841 lnk.setFile( filename);
842 lnk.setIcon("opieplayer2/playlist2"); 842 lnk.setIcon("opieplayer2/playlist2");
843 lnk.setName( name); //sets file name 843 lnk.setName( name); //sets file name
844 844
845 // qDebug(filename); 845 // qDebug(filename);
846 Config config( "OpiePlayer" ); 846 Config config( "OpiePlayer" );
847 config.setGroup( "PlayList" ); 847 config.setGroup( "PlayList" );
848 848
849 config.writeEntry("CurrentPlaylist",filename); 849 config.writeEntry("CurrentPlaylist",filename);
850 currentPlayList=filename; 850 currentPlayList=filename;
851 851
852 if(!lnk.writeLink()) { 852 if(!lnk.writeLink()) {
853 qDebug("Writing doclink did not work"); 853 qDebug("Writing doclink did not work");
854 } 854 }
855 855
856 setCaption(tr("OpiePlayer: ") + name); 856 setCaption(tr("OpiePlayer: ") + name);
857 } 857 }
858 } 858 }
859} 859}
860 860
861void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 861void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
862 switch ( e->key() ) { 862 switch ( e->key() ) {
863 ////////////////////////////// Zaurus keys 863 ////////////////////////////// Zaurus keys
864 case Key_F9: //activity 864 case Key_F9: //activity
865 // if(audioUI->isHidden()) 865 // if(audioUI->isHidden())
866 // audioUI->showMaximized(); 866 // audioUI->showMaximized();
867 break; 867 break;
868 case Key_F10: //contacts 868 case Key_F10: //contacts
869 // if( videoUI->isHidden()) 869 // if( videoUI->isHidden())
870 // videoUI->showMaximized(); 870 // videoUI->showMaximized();
871 break; 871 break;
872 case Key_F11: //menu 872 case Key_F11: //menu
873 break; 873 break;
874 case Key_F12: //home 874 case Key_F12: //home
875 // doBlank(); 875 // doBlank();
876 break; 876 break;
877 case Key_F13: //mail 877 case Key_F13: //mail
878 // doUnblank(); 878 // doUnblank();
879 break; 879 break;
880 case Key_Q: //add to playlist 880 case Key_Q: //add to playlist
881 addSelected(); 881 addSelected();
882 break; 882 break;
883 case Key_R: //remove from playlist 883 case Key_R: //remove from playlist
884 removeSelected(); 884 removeSelected();
885 break; 885 break;
886 // case Key_P: //play 886 // case Key_P: //play
887 // qDebug("Play"); 887 // qDebug("Play");
888 // playSelected(); 888 // playSelected();
889 // break; 889 // break;
890 case Key_Space: 890 case Key_Space:
891 // playSelected(); puh 891 // playSelected(); puh
892 break; 892 break;
893 case Key_1: 893 case Key_1:
894 tabWidget->setCurrentPage( 0 ); 894 tabWidget->setCurrentPage( 0 );
895 break; 895 break;
896 case Key_2: 896 case Key_2:
897 tabWidget->setCurrentPage( 1 ); 897 tabWidget->setCurrentPage( 1 );
898 break; 898 break;
899 case Key_3: 899 case Key_3:
900 tabWidget->setCurrentPage( 2 ); 900 tabWidget->setCurrentPage( 2 );
901 break; 901 break;
902 case Key_4: 902 case Key_4:
903 tabWidget->setCurrentPage( 3 ); 903 tabWidget->setCurrentPage( 3 );
904 break; 904 break;
905 case Key_Down: 905 case Key_Down:
906 if ( !d->selectedFiles->next() ) 906 if ( !d->selectedFiles->next() )
907 d->selectedFiles->first(); 907 d->selectedFiles->first();
908 break; 908 break;
909 case Key_Up: 909 case Key_Up:
910 if ( !d->selectedFiles->prev() ) 910 if ( !d->selectedFiles->prev() )
911 // d->selectedFiles->last(); 911 // d->selectedFiles->last();
912 break; 912 break;
913 } 913 }
914} 914}
915 915
916void PlayListWidget::pmViewActivated(int index) { 916void PlayListWidget::pmViewActivated(int index) {
917// qDebug("%d", index); 917// qDebug("%d", index);
918 switch(index) { 918 switch(index) {
919 case -16: 919 case -16:
920 { 920 {
921 mediaPlayerState->toggleFullscreen(); 921 mediaPlayerState->toggleFullscreen();
922 bool b=mediaPlayerState->isFullscreen(); 922 bool b=mediaPlayerState->isFullscreen();
923 pmView->setItemChecked( index, b); 923 pmView->setItemChecked( index, b);
924 Config cfg( "OpiePlayer" ); 924 Config cfg( "OpiePlayer" );
925 cfg.writeEntry( "FullScreen", b ); 925 cfg.writeEntry( "FullScreen", b );
926 } 926 }
927 break; 927 break;
928 }; 928 };
929} 929}
930 930
931void PlayListWidget::populateSkinsMenu() { 931void PlayListWidget::populateSkinsMenu() {
932 int item = 0; 932 int item = 0;
933 defaultSkinIndex = 0; 933 defaultSkinIndex = 0;
934 QString skinName; 934 QString skinName;
935 Config cfg( "OpiePlayer" ); 935 Config cfg( "OpiePlayer" );
936 cfg.setGroup("Options" ); 936 cfg.setGroup("Options" );
937 QString skin = cfg.readEntry( "Skin", "default" ); 937 QString skin = cfg.readEntry( "Skin", "default" );
938 938
939 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 939 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
940 skinsDir.setFilter( QDir::Dirs ); 940 skinsDir.setFilter( QDir::Dirs );
941 skinsDir.setSorting(QDir::Name ); 941 skinsDir.setSorting(QDir::Name );
942 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 942 const QFileInfoList *skinslist = skinsDir.entryInfoList();
943 QFileInfoListIterator it( *skinslist ); 943 QFileInfoListIterator it( *skinslist );
944 QFileInfo *fi; 944 QFileInfo *fi;
945 while ( ( fi = it.current() ) ) { 945 while ( ( fi = it.current() ) ) {
946 skinName = fi->fileName(); 946 skinName = fi->fileName();
947// qDebug( fi->fileName() ); 947// qDebug( fi->fileName() );
948 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 948 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
949 item = skinsMenu->insertItem( fi->fileName() ) ; 949 item = skinsMenu->insertItem( fi->fileName() ) ;
950 } 950 }
951 if( skinName == "default" ) { 951 if( skinName == "default" ) {
952 defaultSkinIndex = item; 952 defaultSkinIndex = item;
953 } 953 }
954 if( skinName == skin ) { 954 if( skinName == skin ) {
955 skinsMenu->setItemChecked( item, TRUE ); 955 skinsMenu->setItemChecked( item, TRUE );
956 } 956 }
957 ++it; 957 ++it;
958 } 958 }
959} 959}
960 960
961void PlayListWidget::skinsMenuActivated( int item ) { 961void PlayListWidget::skinsMenuActivated( int item ) {
962 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 962 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
963 skinsMenu->setItemChecked( i, FALSE ); 963 skinsMenu->setItemChecked( i, FALSE );
964 } 964 }
965 skinsMenu->setItemChecked( item, TRUE ); 965 skinsMenu->setItemChecked( item, TRUE );
966 966
967 { 967 {
968 Config cfg( "OpiePlayer" ); 968 Config cfg( "OpiePlayer" );
969 cfg.setGroup("Options"); 969 cfg.setGroup("Options");
970 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 970 cfg.writeEntry("Skin", skinsMenu->text( item ) );
971 } 971 }
972 972
973 emit skinSelected(); 973 emit skinSelected();
974} 974}
975 975
976PlayListWidget::TabType PlayListWidget::currentTab() const 976PlayListWidget::TabType PlayListWidget::currentTab() const
977{ 977{
978 static const TabType indexToTabType[ TabTypeCount ] = 978 static const TabType indexToTabType[ TabTypeCount ] =
979 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 979 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
980 980
981 int index = tabWidget->currentPageIndex(); 981 int index = tabWidget->currentPageIndex();
982 assert( index < TabTypeCount && index >= 0 ); 982 assert( index < TabTypeCount && index >= 0 );
983 983
984 return indexToTabType[ index ]; 984 return indexToTabType[ index ];
985} 985}
986 986
987PlayListWidget::Entry PlayListWidget::currentEntry() const 987PlayListWidget::Entry PlayListWidget::currentEntry() const
988{ 988{
989 if ( currentTab() == CurrentPlayList ) { 989 if ( currentTab() == CurrentPlayList ) {
990 const DocLnk *lnk = current(); 990 const DocLnk *lnk = current();
991 return Entry( lnk->name(), lnk->file() ); 991 return Entry( lnk->name(), lnk->file() );
992 } 992 }
993 993
994 return Entry( currentFileListPathName() ); 994 return Entry( currentFileListPathName() );
995} 995}
996 996
997QString PlayListWidget::currentFileListPathName() const { 997QString PlayListWidget::currentFileListPathName() const {
998 return currentFileListView->currentItem()->text( 3 ); 998 return currentFileListView->currentItem()->text( 3 );
999} 999}
1000 1000
1001 1001
1002void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1002void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1003 qDebug("qcop message "+msg ); 1003 qDebug("qcop message "+msg );
1004 QDataStream stream ( data, IO_ReadOnly ); 1004 QDataStream stream ( data, IO_ReadOnly );
1005 if ( msg == "play()" ) { //plays current selection 1005 if ( msg == "play()" ) { //plays current selection
1006 btnPlay( true); 1006 btnPlay( true);
1007 } else if ( msg == "stop()" ) { 1007 } else if ( msg == "stop()" ) {
1008 mediaPlayerState->setPlaying( false); 1008 mediaPlayerState->setPlaying( false);
1009 } else if ( msg == "togglePause()" ) { 1009 } else if ( msg == "togglePause()" ) {
1010 mediaPlayerState->togglePaused(); 1010 mediaPlayerState->togglePaused();
1011 } else if ( msg == "next()" ) { //select next in list 1011 } else if ( msg == "next()" ) { //select next in list
1012 mediaPlayerState->setNext(); 1012 mediaPlayerState->setNext();
1013 } else if ( msg == "prev()" ) { //select previous in list 1013 } else if ( msg == "prev()" ) { //select previous in list
1014 mediaPlayerState->setPrev(); 1014 mediaPlayerState->setPrev();
1015 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1015 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1016 mediaPlayerState->toggleLooping(); 1016 mediaPlayerState->toggleLooping();
1017 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1017 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1018 mediaPlayerState->toggleShuffled(); 1018 mediaPlayerState->toggleShuffled();
1019 } else if ( msg == "volUp()" ) { //volume more 1019 } else if ( msg == "volUp()" ) { //volume more
1020// emit moreClicked(); 1020// emit moreClicked();
1021// emit moreReleased(); 1021// emit moreReleased();
1022 } else if ( msg == "volDown()" ) { //volume less 1022 } else if ( msg == "volDown()" ) { //volume less
1023// emit lessClicked(); 1023// emit lessClicked();
1024// emit lessReleased(); 1024// emit lessReleased();
1025 } else if ( msg == "play(QString)" ) { //play this now 1025 } else if ( msg == "play(QString)" ) { //play this now
1026 QString file; 1026 QString file;
1027 stream >> file; 1027 stream >> file;
1028 setDocument( (const QString &) file); 1028 setDocument( (const QString &) file);
1029 } else if ( msg == "add(QString)" ) { //add to playlist 1029 } else if ( msg == "add(QString)" ) { //add to playlist
1030 QString file; 1030 QString file;
1031 stream >> file; 1031 stream >> file;
1032 QFileInfo fileInfo(file); 1032 QFileInfo fileInfo(file);
1033 DocLnk lnk; 1033 DocLnk lnk;
1034 lnk.setName( fileInfo.baseName() ); //sets name 1034 lnk.setName( fileInfo.baseName() ); //sets name
1035 lnk.setFile( file ); //sets file name 1035 lnk.setFile( file ); //sets file name
1036 addToSelection( lnk ); 1036 addToSelection( lnk );
1037 } else if ( msg == "rem(QString)" ) { //remove from playlist 1037 } else if ( msg == "rem(QString)" ) { //remove from playlist
1038 QString file; 1038 QString file;
1039 stream >> file; 1039 stream >> file;
1040 1040
1041 } 1041 }
1042 1042
1043} 1043}