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