summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-16 00:48:49 (UTC)
committer llornkcor <llornkcor>2002-08-16 00:48:49 (UTC)
commitf25db7780ff234b2770ac13d8c02887b79a57a26 (patch) (unidiff)
tree534b91999f3f713ee4869bd53ffbc45840338d96
parent47e3b3c20e17b257fb2d3d56bace2a89a8f0d28b (diff)
downloadopie-f25db7780ff234b2770ac13d8c02887b79a57a26.zip
opie-f25db7780ff234b2770ac13d8c02887b79a57a26.tar.gz
opie-f25db7780ff234b2770ac13d8c02887b79a57a26.tar.bz2
spaces thing crept back in I think
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 26103c3..65dc5fb 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1366 +1,1357 @@
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
86// class myFileSelector { 86// class myFileSelector {
87 87
88// }; 88// };
89class PlayListWidgetPrivate { 89class PlayListWidgetPrivate {
90public: 90public:
91 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 91 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
92 QFrame *playListFrame; 92 QFrame *playListFrame;
93 FileSelector *files; 93 FileSelector *files;
94 PlayListSelection *selectedFiles; 94 PlayListSelection *selectedFiles;
95 bool setDocumentUsed; 95 bool setDocumentUsed;
96 DocLnk *current; 96 DocLnk *current;
97}; 97};
98 98
99 99
100class ToolButton : public QToolButton { 100class ToolButton : public QToolButton {
101public: 101public:
102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 102 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
103 : QToolButton( parent, name ) { 103 : QToolButton( parent, name ) {
104 setTextLabel( name ); 104 setTextLabel( name );
105 setPixmap( Resource::loadPixmap( icon ) ); 105 setPixmap( Resource::loadPixmap( icon ) );
106 setAutoRaise( TRUE ); 106 setAutoRaise( TRUE );
107 setFocusPolicy( QWidget::NoFocus ); 107 setFocusPolicy( QWidget::NoFocus );
108 setToggleButton( t ); 108 setToggleButton( t );
109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 109 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
110 QPEMenuToolFocusManager::manager()->addWidget( this ); 110 QPEMenuToolFocusManager::manager()->addWidget( this );
111 } 111 }
112}; 112};
113 113
114 114
115class MenuItem : public QAction { 115class MenuItem : public QAction {
116public: 116public:
117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 117 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
118 : QAction( text, QString::null, 0, 0 ) { 118 : QAction( text, QString::null, 0, 0 ) {
119 connect( this, SIGNAL( activated() ), handler, slot ); 119 connect( this, SIGNAL( activated() ), handler, slot );
120 addTo( parent ); 120 addTo( parent );
121 } 121 }
122}; 122};
123 123
124 124
125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
126 : QMainWindow( parent, name, fl ) { 126 : QMainWindow( parent, name, fl ) {
127 127
128 d = new PlayListWidgetPrivate; 128 d = new PlayListWidgetPrivate;
129 d->setDocumentUsed = FALSE; 129 d->setDocumentUsed = FALSE;
130 d->current = NULL; 130 d->current = NULL;
131 fromSetDocument = FALSE; 131 fromSetDocument = FALSE;
132 insanityBool=FALSE; 132 insanityBool=FALSE;
133 audioScan = FALSE; 133 audioScan = FALSE;
134 videoScan = FALSE; 134 videoScan = FALSE;
135// menuTimer = new QTimer( this ,"menu timer"), 135// menuTimer = new QTimer( this ,"menu timer"),
136// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 136// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
137 137
138 setBackgroundMode( PaletteButton ); 138 setBackgroundMode( PaletteButton );
139 139
140 setCaption( tr("OpiePlayer") ); 140 setCaption( tr("OpiePlayer") );
141 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 141 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
142 142
143 setToolBarsMovable( FALSE ); 143 setToolBarsMovable( FALSE );
144 144
145 // Create Toolbar 145 // Create Toolbar
146 QPEToolBar *toolbar = new QPEToolBar( this ); 146 QPEToolBar *toolbar = new QPEToolBar( this );
147 toolbar->setHorizontalStretchable( TRUE ); 147 toolbar->setHorizontalStretchable( TRUE );
148 148
149 // Create Menubar 149 // Create Menubar
150 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 150 QPEMenuBar *menu = new QPEMenuBar( toolbar );
151 menu->setMargin( 0 ); 151 menu->setMargin( 0 );
152 152
153 QPEToolBar *bar = new QPEToolBar( this ); 153 QPEToolBar *bar = new QPEToolBar( this );
154 bar->setLabel( tr( "Play Operations" ) ); 154 bar->setLabel( tr( "Play Operations" ) );
155// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 155// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
156// this , SLOT( addSelected()) ); 156// this , SLOT( addSelected()) );
157 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 157 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
158 tbDeletePlaylist->setFlat(TRUE); 158 tbDeletePlaylist->setFlat(TRUE);
159 tbDeletePlaylist->setFixedSize(20,20); 159 tbDeletePlaylist->setFixedSize(20,20);
160 160
161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
162 this , SLOT(addSelected()) ); 162 this , SLOT(addSelected()) );
163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
164 this , SLOT(removeSelected()) ); 164 this , SLOT(removeSelected()) );
165// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 165// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
166 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 166 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
167 this , SLOT( btnPlay(bool) ), TRUE ); 167 this , SLOT( btnPlay(bool) ), TRUE );
168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
171 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 171 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
172 tbDeletePlaylist->hide(); 172 tbDeletePlaylist->hide();
173 173
174 QPopupMenu *pmPlayList = new QPopupMenu( this ); 174 QPopupMenu *pmPlayList = new QPopupMenu( this );
175 menu->insertItem( tr( "File" ), pmPlayList ); 175 menu->insertItem( tr( "File" ), pmPlayList );
176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180 pmPlayList->insertSeparator(-1); 180 pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
183 pmPlayList->insertSeparator(-1); 183 pmPlayList->insertSeparator(-1);
184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
185 pmPlayList->insertSeparator(-1); 185 pmPlayList->insertSeparator(-1);
186 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 186 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
187 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 187 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
188 188
189 QPopupMenu *pmView = new QPopupMenu( this ); 189 QPopupMenu *pmView = new QPopupMenu( this );
190 menu->insertItem( tr( "View" ), pmView ); 190 menu->insertItem( tr( "View" ), pmView );
191 191
192 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 192 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
193 fullScreenButton->addTo(pmView); 193 fullScreenButton->addTo(pmView);
194 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 194 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
195 scaleButton->addTo(pmView); 195 scaleButton->addTo(pmView);
196 196
197 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 197 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
198 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 198 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
199 199
200 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 200 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
201 201
202 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 202 tabWidget = new QTabWidget( hbox6, "tabWidget" );
203 tabWidget->setTabShape(QTabWidget::Triangular); 203 tabWidget->setTabShape(QTabWidget::Triangular);
204 204
205 QWidget *pTab; 205 QWidget *pTab;
206 pTab = new QWidget( tabWidget, "pTab" ); 206 pTab = new QWidget( tabWidget, "pTab" );
207// playlistView = new QListView( pTab, "playlistview" ); 207// playlistView = new QListView( pTab, "playlistview" );
208// playlistView->setMinimumSize(236,260); 208// playlistView->setMinimumSize(236,260);
209 tabWidget->insertTab( pTab,"Playlist"); 209 tabWidget->insertTab( pTab,"Playlist");
210 210
211 211
212 // Add the playlist area 212 // Add the playlist area
213 213
214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
215 d->playListFrame = vbox3; 215 d->playListFrame = vbox3;
216 d->playListFrame ->setMinimumSize(235,260); 216 d->playListFrame ->setMinimumSize(235,260);
217 217
218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
219 219
220 d->selectedFiles = new PlayListSelection( hbox2); 220 d->selectedFiles = new PlayListSelection( hbox2);
221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
222 222
223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
224 224
225 225
226 226
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 232
233 QWidget *aTab; 233 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 234 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 235 audioView = new QListView( aTab, "Audioview" );
236 audioView->setMinimumSize(233,260); 236 audioView->setMinimumSize(233,260);
237 audioView->addColumn( tr("Title"),140); 237 audioView->addColumn( tr("Title"),140);
238 audioView->addColumn(tr("Size"), -1); 238 audioView->addColumn(tr("Size"), -1);
239 audioView->addColumn(tr("Media"),-1); 239 audioView->addColumn(tr("Media"),-1);
240 audioView->setColumnAlignment(1, Qt::AlignRight); 240 audioView->setColumnAlignment(1, Qt::AlignRight);
241 audioView->setColumnAlignment(2, Qt::AlignRight); 241 audioView->setColumnAlignment(2, Qt::AlignRight);
242 audioView->setAllColumnsShowFocus(TRUE); 242 audioView->setAllColumnsShowFocus(TRUE);
243 243
244 audioView->setMultiSelection( TRUE ); 244 audioView->setMultiSelection( TRUE );
245 audioView->setSelectionMode( QListView::Extended); 245 audioView->setSelectionMode( QListView::Extended);
246 246
247 tabWidget->insertTab(aTab,tr("Audio")); 247 tabWidget->insertTab(aTab,tr("Audio"));
248 248
249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
250 250
251// audioView 251// audioView
252// populateAudioView(); 252// populateAudioView();
253// videowidget 253// videowidget
254 254
255 QWidget *vTab; 255 QWidget *vTab;
256 vTab = new QWidget( tabWidget, "vTab" ); 256 vTab = new QWidget( tabWidget, "vTab" );
257 videoView = new QListView( vTab, "Videoview" ); 257 videoView = new QListView( vTab, "Videoview" );
258 videoView->setMinimumSize(233,260); 258 videoView->setMinimumSize(233,260);
259 259
260 videoView->addColumn(tr("Title"),140); 260 videoView->addColumn(tr("Title"),140);
261 videoView->addColumn(tr("Size"),-1); 261 videoView->addColumn(tr("Size"),-1);
262 videoView->addColumn(tr("Media"),-1); 262 videoView->addColumn(tr("Media"),-1);
263 videoView->setColumnAlignment(1, Qt::AlignRight); 263 videoView->setColumnAlignment(1, Qt::AlignRight);
264 videoView->setColumnAlignment(2, Qt::AlignRight); 264 videoView->setColumnAlignment(2, Qt::AlignRight);
265 videoView->setAllColumnsShowFocus(TRUE); 265 videoView->setAllColumnsShowFocus(TRUE);
266 videoView->setMultiSelection( TRUE ); 266 videoView->setMultiSelection( TRUE );
267 videoView->setSelectionMode( QListView::Extended); 267 videoView->setSelectionMode( QListView::Extended);
268 268
269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
270 270
271 tabWidget->insertTab( vTab,tr("Video")); 271 tabWidget->insertTab( vTab,tr("Video"));
272// populateVideoView(); 272// populateVideoView();
273 273
274//playlists list 274//playlists list
275 QWidget *LTab; 275 QWidget *LTab;
276 LTab = new QWidget( tabWidget, "LTab" ); 276 LTab = new QWidget( tabWidget, "LTab" );
277 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 277 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
278 playLists->setMinimumSize(233,260); 278 playLists->setMinimumSize(233,260);
279 tabWidget->insertTab(LTab,tr("Lists")); 279 tabWidget->insertTab(LTab,tr("Lists"));
280 280
281// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 281// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
282 282
283// add the library area 283// add the library area
284 284
285// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 285// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
286// this, SLOT( fauxPlay( QListViewItem *) ) ); 286// this, SLOT( fauxPlay( QListViewItem *) ) );
287// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 287// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
288// this, SLOT( fauxPlay( QListViewItem *)) ); 288// this, SLOT( fauxPlay( QListViewItem *)) );
289 289
290// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 290// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
291// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 291// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
292 292
293 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 293 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
298 298
299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
301 301
302 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 302 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
303 this,SLOT( playIt( QListViewItem *)) ); 303 this,SLOT( playIt( QListViewItem *)) );
304 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 304 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
305 305
306 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 306 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
309 this,SLOT( playIt( QListViewItem *)) ); 309 this,SLOT( playIt( QListViewItem *)) );
310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
311 311
312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
313 313
314 314
315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
316 316
317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
321 321
322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
324 324
325 setCentralWidget( vbox5 ); 325 setCentralWidget( vbox5 );
326 326
327 Config cfg( "OpiePlayer" ); 327 Config cfg( "OpiePlayer" );
328 readConfig( cfg ); 328 readConfig( cfg );
329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
330// qDebug("currentList is "+currentPlaylist); 330// qDebug("currentList is "+currentPlaylist);
331 loadList(DocLnk( currentPlaylist)); 331 loadList(DocLnk( currentPlaylist));
332 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 332 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
333 333
334 initializeStates(); 334 initializeStates();
335} 335}
336 336
337 337
338PlayListWidget::~PlayListWidget() { 338PlayListWidget::~PlayListWidget() {
339 Config cfg( "OpiePlayer" ); 339 Config cfg( "OpiePlayer" );
340 writeConfig( cfg ); 340 writeConfig( cfg );
341 341
342 342
343 if ( d->current ) 343 if ( d->current )
344 delete d->current; 344 delete d->current;
345 delete d; 345 delete d;
346} 346}
347 347
348 348
349void PlayListWidget::initializeStates() { 349void PlayListWidget::initializeStates() {
350 350
351 d->tbPlay->setOn( mediaPlayerState->playing() ); 351 d->tbPlay->setOn( mediaPlayerState->playing() );
352 d->tbLoop->setOn( mediaPlayerState->looping() ); 352 d->tbLoop->setOn( mediaPlayerState->looping() );
353 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 353 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
354// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 354// d->tbFull->setOn( mediaPlayerState->fullscreen() );
355// d->tbScale->setOn( mediaPlayerState->scaled() ); 355// d->tbScale->setOn( mediaPlayerState->scaled() );
356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
357// setPlaylist( mediaPlayerState->playlist() ); 357// setPlaylist( mediaPlayerState->playlist() );
358 setPlaylist( true); 358 setPlaylist( true);
359// d->selectedFiles->first(); 359// d->selectedFiles->first();
360 360
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// d->selectedFiles->setSelectedItem( (const QString &)currentString); 378// d->selectedFiles->setSelectedItem( (const QString &)currentString);
379} 379}
380 380
381 381
382void PlayListWidget::writeConfig( Config& cfg ) const { 382void PlayListWidget::writeConfig( Config& cfg ) const {
383 383
384 d->selectedFiles->writeCurrent( cfg); 384 d->selectedFiles->writeCurrent( cfg);
385 cfg.setGroup("PlayList"); 385 cfg.setGroup("PlayList");
386 int noOfFiles = 0; 386 int noOfFiles = 0;
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388 do { 388 do {
389 const DocLnk *lnk = d->selectedFiles->current(); 389 const DocLnk *lnk = d->selectedFiles->current();
390 if ( lnk ) { 390 if ( lnk ) {
391 QString entryName; 391 QString entryName;
392 entryName.sprintf( "File%i", noOfFiles + 1 ); 392 entryName.sprintf( "File%i", noOfFiles + 1 );
393// qDebug(entryName); 393// qDebug(entryName);
394 cfg.writeEntry( entryName, lnk->linkFile() ); 394 cfg.writeEntry( entryName, lnk->linkFile() );
395 // if this link does exist, add it so we have the file 395 // if this link does exist, add it so we have the file
396 // next time... 396 // next time...
397 if ( !QFile::exists( lnk->linkFile() ) ) { 397 if ( !QFile::exists( lnk->linkFile() ) ) {
398 // the way writing lnks doesn't really check for out 398 // the way writing lnks doesn't really check for out
399 // of disk space, but check it anyway. 399 // of disk space, but check it anyway.
400 if ( !lnk->writeLink() ) { 400 if ( !lnk->writeLink() ) {
401 QMessageBox::critical( 0, tr("Out of space"), 401 QMessageBox::critical( 0, tr("Out of space"),
402 tr( "There was a problem saving " 402 tr( "There was a problem saving "
403 "the playlist.\n" 403 "the playlist.\n"
404 "Your playlist " 404 "Your playlist "
405 "may be missing some entries\n" 405 "may be missing some entries\n"
406 "the next time you start it." ) 406 "the next time you start it." )
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// qDebug("add"); 419// qDebug("add");
420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { 420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
421// QMessageBox::message("Note","You are trying to play\na malformed url."); 421// QMessageBox::message("Note","You are trying to play\na malformed url.");
422 422
423// } else { 423// } else {
424 424
425 d->setDocumentUsed = FALSE; 425 d->setDocumentUsed = FALSE;
426 if ( mediaPlayerState->playlist() ) { 426 if ( mediaPlayerState->playlist() ) {
427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
428 d->selectedFiles->addToSelection( lnk ); 428 d->selectedFiles->addToSelection( lnk );
429 } 429 }
430 else 430 else
431 mediaPlayerState->setPlaying( TRUE ); 431 mediaPlayerState->setPlaying( TRUE );
432// } 432// }
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} 449}
450 450
451 451
452void PlayListWidget::addAllMusicToList() { 452void PlayListWidget::addAllMusicToList() {
453 QListIterator<DocLnk> dit( files.children() ); 453 QListIterator<DocLnk> dit( files.children() );
454 for ( ; dit.current(); ++dit ) 454 for ( ; dit.current(); ++dit )
455 if(QFileInfo(dit.current()->file()).exists()) 455 if(QFileInfo(dit.current()->file()).exists())
456 d->selectedFiles->addToSelection( **dit ); 456 d->selectedFiles->addToSelection( **dit );
457} 457}
458 458
459 459
460void PlayListWidget::addAllVideoToList() { 460void PlayListWidget::addAllVideoToList() {
461 QListIterator<DocLnk> dit( vFiles.children() ); 461 QListIterator<DocLnk> dit( vFiles.children() );
462 for ( ; dit.current(); ++dit ) 462 for ( ; dit.current(); ++dit )
463 if(QFileInfo( dit.current()->file()).exists()) 463 if(QFileInfo( dit.current()->file()).exists())
464 d->selectedFiles->addToSelection( **dit ); 464 d->selectedFiles->addToSelection( **dit );
465} 465}
466 466
467 467
468void PlayListWidget::setDocument(const QString& fileref) { 468void PlayListWidget::setDocument(const QString& fileref) {
469 qDebug(fileref); 469 qDebug(fileref);
470 fromSetDocument = TRUE; 470 fromSetDocument = TRUE;
471 if ( fileref.isNull() ) { 471 if ( fileref.isNull() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
473 return; 473 return;
474 } 474 }
475// qDebug("setDocument "+fileref); 475// qDebug("setDocument "+fileref);
476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
477 readm3u( fileref); 477 readm3u( fileref);
478 } 478 }
479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
480 readPls( fileref); 480 readPls( fileref);
481 } 481 }
482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
483 clearList(); 483 clearList();
484 loadList(DocLnk(fileref)); 484 loadList(DocLnk(fileref));
485 d->selectedFiles->first(); 485 d->selectedFiles->first();
486 } else { 486 } else {
487 clearList(); 487 clearList();
488 addToSelection( DocLnk( fileref ) ); 488 addToSelection( DocLnk( fileref ) );
489 d->setDocumentUsed = TRUE; 489 d->setDocumentUsed = TRUE;
490 mediaPlayerState->setPlaying( FALSE ); 490 mediaPlayerState->setPlaying( FALSE );
491 qApp->processEvents(); 491 qApp->processEvents();
492 mediaPlayerState->setPlaying( TRUE ); 492 mediaPlayerState->setPlaying( TRUE );
493 qApp->processEvents(); 493 qApp->processEvents();
494 setCaption(tr("OpiePlayer")); 494 setCaption(tr("OpiePlayer"));
495 } 495 }
496} 496}
497 497
498 498
499void PlayListWidget::setActiveWindow() { 499void PlayListWidget::setActiveWindow() {
500 qDebug("SETTING active window");
501
500 // When we get raised we need to ensure that it switches views 502 // When we get raised we need to ensure that it switches views
501 char origView = mediaPlayerState->view(); 503 char origView = mediaPlayerState->view();
502 mediaPlayerState->setView( 'l' ); // invalidate 504 mediaPlayerState->setView( 'l' ); // invalidate
503 mediaPlayerState->setView( origView ); // now switch back 505 mediaPlayerState->setView( origView ); // now switch back
504} 506}
505 507
506 508
507void PlayListWidget::useSelectedDocument() { 509void PlayListWidget::useSelectedDocument() {
508 d->setDocumentUsed = FALSE; 510 d->setDocumentUsed = FALSE;
509} 511}
510 512
511 513
512const DocLnk *PlayListWidget::current() { // this is fugly 514const DocLnk *PlayListWidget::current() { // this is fugly
513 515
514// if( fromSetDocument) { 516// if( fromSetDocument) {
515// qDebug("from setDoc"); 517// qDebug("from setDoc");
516// DocLnkSet files; 518// DocLnkSet files;
517// Global::findDocuments(&files, "video/*;audio/*"); 519// Global::findDocuments(&files, "video/*;audio/*");
518// QListIterator<DocLnk> dit( files.children() ); 520// QListIterator<DocLnk> dit( files.children() );
519// for ( ; dit.current(); ++dit ) { 521// for ( ; dit.current(); ++dit ) {
520// if(dit.current()->linkFile() == setDocFileRef) { 522// if(dit.current()->linkFile() == setDocFileRef) {
521// qDebug(setDocFileRef); 523// qDebug(setDocFileRef);
522// return dit; 524// return dit;
523// } 525// }
524// } 526// }
525// } else 527// } else
526 528
527 529
528 switch (tabWidget->currentPageIndex()) { 530 switch (tabWidget->currentPageIndex()) {
529 case 0: //playlist 531 case 0: //playlist
530 { 532 {
531 qDebug("playlist"); 533 qDebug("playlist");
532 if ( mediaPlayerState->playlist() ) { 534 if ( mediaPlayerState->playlist() ) {
533 return d->selectedFiles->current(); 535 return d->selectedFiles->current();
534 } 536 }
535 else if ( d->setDocumentUsed && d->current ) { 537 else if ( d->setDocumentUsed && d->current ) {
536 return d->current; 538 return d->current;
537 } else { 539 } else {
538 return d->files->selected(); 540 return d->files->selected();
539 } 541 }
540 } 542 }
541 break; 543 break;
542 case 1://audio 544 case 1://audio
543 { 545 {
544 qDebug("audioView"); 546 qDebug("audioView");
545 QListIterator<DocLnk> dit( files.children() ); 547 QListIterator<DocLnk> dit( files.children() );
546 for ( ; dit.current(); ++dit ) { 548 for ( ; dit.current(); ++dit ) {
547 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 549 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
548 qDebug("here"); 550 qDebug("here");
549 insanityBool=TRUE; 551 insanityBool=TRUE;
550 return dit; 552 return dit;
551 } 553 }
552 } 554 }
553 } 555 }
554 break; 556 break;
555 case 2: // video 557 case 2: // video
556 { 558 {
557 qDebug("videoView"); 559 qDebug("videoView");
558 QListIterator<DocLnk> Vdit( vFiles.children() ); 560 QListIterator<DocLnk> Vdit( vFiles.children() );
559 for ( ; Vdit.current(); ++Vdit ) { 561 for ( ; Vdit.current(); ++Vdit ) {
560 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 562 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
561 insanityBool=TRUE; 563 insanityBool=TRUE;
562 return Vdit; 564 return Vdit;
563 } 565 }
564 } 566 }
565 } 567 }
566 break; 568 break;
567 }; 569 };
568 return 0; 570 return 0;
569} 571}
570 572
571bool PlayListWidget::prev() { 573bool PlayListWidget::prev() {
572 if ( mediaPlayerState->playlist() ) { 574 if ( mediaPlayerState->playlist() ) {
573 if ( mediaPlayerState->shuffled() ) { 575 if ( mediaPlayerState->shuffled() ) {
574 const DocLnk *cur = current(); 576 const DocLnk *cur = current();
575 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 577 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
576 for ( int i = 0; i < j; i++ ) { 578 for ( int i = 0; i < j; i++ ) {
577 if ( !d->selectedFiles->next() ) 579 if ( !d->selectedFiles->next() )
578 d->selectedFiles->first(); 580 d->selectedFiles->first();
579 } 581 }
580 if ( cur == current() ) 582 if ( cur == current() )
581 if ( !d->selectedFiles->next() ) 583 if ( !d->selectedFiles->next() )
582 d->selectedFiles->first(); 584 d->selectedFiles->first();
583 return TRUE; 585 return TRUE;
584 } else { 586 } else {
585 if ( !d->selectedFiles->prev() ) { 587 if ( !d->selectedFiles->prev() ) {
586 if ( mediaPlayerState->looping() ) { 588 if ( mediaPlayerState->looping() ) {
587 return d->selectedFiles->last(); 589 return d->selectedFiles->last();
588 } else { 590 } else {
589 return FALSE; 591 return FALSE;
590 } 592 }
591 } 593 }
592 return TRUE; 594 return TRUE;
593 } 595 }
594 } else { 596 } else {
595 return mediaPlayerState->looping(); 597 return mediaPlayerState->looping();
596 } 598 }
597} 599}
598 600
599 601
600bool PlayListWidget::next() { 602bool PlayListWidget::next() {
601 if ( mediaPlayerState->playlist() ) { 603 if ( mediaPlayerState->playlist() ) {
602 if ( mediaPlayerState->shuffled() ) { 604 if ( mediaPlayerState->shuffled() ) {
603 return prev(); 605 return prev();
604 } else { 606 } else {
605 if ( !d->selectedFiles->next() ) { 607 if ( !d->selectedFiles->next() ) {
606 if ( mediaPlayerState->looping() ) { 608 if ( mediaPlayerState->looping() ) {
607 return d->selectedFiles->first(); 609 return d->selectedFiles->first();
608 } else { 610 } else {
609 return FALSE; 611 return FALSE;
610 } 612 }
611 } 613 }
612 return TRUE; 614 return TRUE;
613 } 615 }
614 } else { 616 } else {
615 return mediaPlayerState->looping(); 617 return mediaPlayerState->looping();
616 } 618 }
617} 619}
618 620
619 621
620bool PlayListWidget::first() { 622bool PlayListWidget::first() {
621 if ( mediaPlayerState->playlist() ) 623 if ( mediaPlayerState->playlist() )
622 return d->selectedFiles->first(); 624 return d->selectedFiles->first();
623 else 625 else
624 return mediaPlayerState->looping(); 626 return mediaPlayerState->looping();
625} 627}
626 628
627 629
628bool PlayListWidget::last() { 630bool PlayListWidget::last() {
629 if ( mediaPlayerState->playlist() ) 631 if ( mediaPlayerState->playlist() )
630 return d->selectedFiles->last(); 632 return d->selectedFiles->last();
631 else 633 else
632 return mediaPlayerState->looping(); 634 return mediaPlayerState->looping();
633} 635}
634 636
635 637
636void PlayListWidget::saveList() { 638void PlayListWidget::saveList() {
637 639
638 QString filename; 640 QString filename;
639 InputDialog *fileDlg; 641 InputDialog *fileDlg;
640 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 642 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
641 fileDlg->exec(); 643 fileDlg->exec();
642 if( fileDlg->result() == 1 ) { 644 if( fileDlg->result() == 1 ) {
643 if ( d->current ) 645 if ( d->current )
644 delete d->current; 646 delete d->current;
645 filename = fileDlg->LineEdit1->text();//+".playlist"; 647 filename = fileDlg->LineEdit1->text();//+".playlist";
646// qDebug("saving playlist "+filename+".playlist"); 648// qDebug("saving playlist "+filename+".playlist");
647 Config cfg( filename +".playlist"); 649 Config cfg( filename +".playlist");
648 writeConfig( cfg ); 650 writeConfig( cfg );
649 651
650 DocLnk lnk; 652 DocLnk lnk;
651// lnk.setComment( ""); 653// lnk.setComment( "");
652 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 654 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
653 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 655 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
654 lnk.setIcon("opieplayer/playlist2"); 656 lnk.setIcon("opieplayer/playlist2");
655 lnk.setName( filename); //sets file name 657 lnk.setName( filename); //sets file name
656// qDebug(filename); 658// qDebug(filename);
657 if(!lnk.writeLink()) 659 if(!lnk.writeLink())
658 qDebug("Writing doclink did not work"); 660 qDebug("Writing doclink did not work");
659 } 661 }
660 Config config( "OpiePlayer" ); 662 Config config( "OpiePlayer" );
661 config.writeEntry("CurrentPlaylist",filename); 663 config.writeEntry("CurrentPlaylist",filename);
662 setCaption(tr("OpiePlayer: ")+filename); 664 setCaption(tr("OpiePlayer: ")+filename);
663 d->selectedFiles->first(); 665 d->selectedFiles->first();
664 if(fileDlg) 666 if(fileDlg)
665 delete fileDlg; 667 delete fileDlg;
666} 668}
667 669
668void PlayListWidget::loadList( const DocLnk & lnk) { 670void PlayListWidget::loadList( const DocLnk & lnk) {
669 QString name= lnk.name(); 671 QString name= lnk.name();
670// qDebug("currentList is "+name); 672// qDebug("currentList is "+name);
671 if( name.length()>1) { 673 if( name.length()>1) {
672 setCaption("OpiePlayer: "+name); 674 setCaption("OpiePlayer: "+name);
673// qDebug("load list "+ name+".playlist"); 675// qDebug("load list "+ name+".playlist");
674 clearList(); 676 clearList();
675 Config cfg( name+".playlist"); 677 Config cfg( name+".playlist");
676 readConfig(cfg); 678 readConfig(cfg);
677 679
678 tabWidget->setCurrentPage(0); 680 tabWidget->setCurrentPage(0);
679 681
680 Config config( "OpiePlayer" ); 682 Config config( "OpiePlayer" );
681 config.writeEntry("CurrentPlaylist", name); 683 config.writeEntry("CurrentPlaylist", name);
682// d->selectedFiles->first(); 684// d->selectedFiles->first();
683 } 685 }
684 686
685} 687}
686 688
687void PlayListWidget::setPlaylist( bool shown ) { 689void PlayListWidget::setPlaylist( bool shown ) {
688 if ( shown ) 690 if ( shown )
689 d->playListFrame->show(); 691 d->playListFrame->show();
690 else 692 else
691 d->playListFrame->hide(); 693 d->playListFrame->hide();
692} 694}
693 695
694void PlayListWidget::setView( char view ) { 696void PlayListWidget::setView( char view ) {
695 if ( view == 'l' ) 697 if ( view == 'l' )
696 showMaximized(); 698 showMaximized();
697 else 699 else
698 hide(); 700 hide();
699} 701}
700 702
701void PlayListWidget::addSelected() { 703void PlayListWidget::addSelected() {
702 704
703 Config cfg( "OpiePlayer" ); 705 Config cfg( "OpiePlayer" );
704 cfg.setGroup("PlayList"); 706 cfg.setGroup("PlayList");
705 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 707 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
706 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 708 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
707 709
708 switch (tabWidget->currentPageIndex()) { 710 switch (tabWidget->currentPageIndex()) {
709 case 0: //playlist 711 case 0: //playlist
710 break; 712 break;
711 case 1: { //audio 713 case 1: { //audio
712// QString entryName; 714// QString entryName;
713// entryName.sprintf( "File%i", i + 1 ); 715// entryName.sprintf( "File%i", i + 1 );
714// QString linkFile = cfg.readEntry( entryName ); 716// QString linkFile = cfg.readEntry( entryName );
715 QListViewItemIterator it( audioView ); 717 QListViewItemIterator it( audioView );
716 // iterate through all items of the listview 718 // iterate through all items of the listview
717 for ( ; it.current(); ++it ) { 719 for ( ; it.current(); ++it ) {
718 if ( it.current()->isSelected() ) { 720 if ( it.current()->isSelected() ) {
719 QListIterator<DocLnk> dit( files.children() ); 721 QListIterator<DocLnk> dit( files.children() );
720 for ( ; dit.current(); ++dit ) { 722 for ( ; dit.current(); ++dit ) {
721 if( dit.current()->name() == it.current()->text(0) ) { 723 if( dit.current()->name() == it.current()->text(0) ) {
722 d->selectedFiles->addToSelection( **dit ); 724 d->selectedFiles->addToSelection( **dit );
723 } 725 }
724 } 726 }
725 audioView->setSelected( it.current(),FALSE); 727 audioView->setSelected( it.current(),FALSE);
726 } 728 }
727 } 729 }
728 tabWidget->setCurrentPage(0); 730 tabWidget->setCurrentPage(0);
729 } 731 }
730 break; 732 break;
731 case 2: { // video 733 case 2: { // video
732 QListViewItemIterator it( videoView ); 734 QListViewItemIterator it( videoView );
733 // iterate through all items of the listview 735 // iterate through all items of the listview
734 for ( ; it.current(); ++it ) { 736 for ( ; it.current(); ++it ) {
735 if ( it.current()->isSelected() ) { 737 if ( it.current()->isSelected() ) {
736 QListIterator<DocLnk> dit( vFiles.children() ); 738 QListIterator<DocLnk> dit( vFiles.children() );
737 for ( ; dit.current(); ++dit ) { 739 for ( ; dit.current(); ++dit ) {
738 if( dit.current()->name() == it.current()->text(0) ) { 740 if( dit.current()->name() == it.current()->text(0) ) {
739 d->selectedFiles->addToSelection( **dit ); 741 d->selectedFiles->addToSelection( **dit );
740 } 742 }
741 } 743 }
742 744
743 videoView->setSelected( it.current(),FALSE); 745 videoView->setSelected( it.current(),FALSE);
744 } 746 }
745 } 747 }
746// for ( int i = 0; i < noOfFiles; i++ ) { 748// for ( int i = 0; i < noOfFiles; i++ ) {
747// QString entryName; 749// QString entryName;
748// entryName.sprintf( "File%i", i + 1 ); 750// entryName.sprintf( "File%i", i + 1 );
749// QString linkFile = cfg.readEntry( entryName ); 751// QString linkFile = cfg.readEntry( entryName );
750// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 752// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
751// int result= QMessageBox::warning(this,tr("OpiePlayer"), 753// int result= QMessageBox::warning(this,tr("OpiePlayer"),
752// tr("This is all ready in your playlist.\nContinue?"), 754// tr("This is all ready in your playlist.\nContinue?"),
753// tr("Yes"),tr("No"),0,0,1); 755// tr("Yes"),tr("No"),0,0,1);
754// if (result !=0) 756// if (result !=0)
755// return; 757// return;
756// } 758// }
757// } 759// }
758// addToSelection( videoView->selectedItem() ); 760// addToSelection( videoView->selectedItem() );
759 tabWidget->setCurrentPage(0); 761 tabWidget->setCurrentPage(0);
760 } 762 }
761 break; 763 break;
762 }; 764 };
763} 765}
764 766
765void PlayListWidget::removeSelected() { 767void PlayListWidget::removeSelected() {
766 d->selectedFiles->removeSelected( ); 768 d->selectedFiles->removeSelected( );
767} 769}
768 770
769void PlayListWidget::playIt( QListViewItem *it) { 771void PlayListWidget::playIt( QListViewItem *it) {
770// d->setDocumentUsed = FALSE; 772// d->setDocumentUsed = FALSE;
771// mediaPlayerState->curPosition =0; 773// mediaPlayerState->curPosition =0;
772 qDebug("playIt"); 774 qDebug("playIt");
773 mediaPlayerState->setPlaying(FALSE); 775 mediaPlayerState->setPlaying(FALSE);
774 mediaPlayerState->setPlaying(TRUE); 776 mediaPlayerState->setPlaying(TRUE);
775 d->selectedFiles->unSelect(); 777 d->selectedFiles->unSelect();
776} 778}
777 779
778void PlayListWidget::addToSelection( QListViewItem *it) { 780void PlayListWidget::addToSelection( QListViewItem *it) {
779 d->setDocumentUsed = FALSE; 781 d->setDocumentUsed = FALSE;
780 782
781 if(it) { 783 if(it) {
782 switch (tabWidget->currentPageIndex()) { 784 switch (tabWidget->currentPageIndex()) {
783 case 1: { 785 case 1: {
784 QListIterator<DocLnk> dit( files.children() ); 786 QListIterator<DocLnk> dit( files.children() );
785 for ( ; dit.current(); ++dit ) { 787 for ( ; dit.current(); ++dit ) {
786 if( dit.current()->name() == it->text(0)) { 788 if( dit.current()->name() == it->text(0)) {
787 d->selectedFiles->addToSelection( **dit ); 789 d->selectedFiles->addToSelection( **dit );
788 } 790 }
789 } 791 }
790 } 792 }
791 break; 793 break;
792 case 2: { 794 case 2: {
793 QListIterator<DocLnk> dit( vFiles.children() ); 795 QListIterator<DocLnk> dit( vFiles.children() );
794 for ( ; dit.current(); ++dit ) { 796 for ( ; dit.current(); ++dit ) {
795 if( dit.current()->name() == it->text(0)) { 797 if( dit.current()->name() == it->text(0)) {
796 d->selectedFiles->addToSelection( **dit ); 798 d->selectedFiles->addToSelection( **dit );
797 } 799 }
798 } 800 }
799 } 801 }
800 break; 802 break;
801 case 0: 803 case 0:
802 break; 804 break;
803 }; 805 };
804 tabWidget->setCurrentPage(0); 806 tabWidget->setCurrentPage(0);
805 } 807 }
806} 808}
807 809
808void PlayListWidget::tabChanged(QWidget *widg) { 810void PlayListWidget::tabChanged(QWidget *widg) {
809 811
810 switch ( tabWidget->currentPageIndex()) { 812 switch ( tabWidget->currentPageIndex()) {
811 case 0: 813 case 0:
812 { 814 {
813 if( !tbDeletePlaylist->isHidden()) 815 if( !tbDeletePlaylist->isHidden())
814 tbDeletePlaylist->hide(); 816 tbDeletePlaylist->hide();
815 d->tbRemoveFromList->setEnabled(TRUE); 817 d->tbRemoveFromList->setEnabled(TRUE);
816 d->tbAddToList->setEnabled(FALSE); 818 d->tbAddToList->setEnabled(FALSE);
817 } 819 }
818 break; 820 break;
819 case 1: 821 case 1:
820 { 822 {
821 audioView->clear(); 823 audioView->clear();
822 populateAudioView(); 824 populateAudioView();
823 825
824 if( !tbDeletePlaylist->isHidden()) 826 if( !tbDeletePlaylist->isHidden())
825 tbDeletePlaylist->hide(); 827 tbDeletePlaylist->hide();
826 d->tbRemoveFromList->setEnabled(FALSE); 828 d->tbRemoveFromList->setEnabled(FALSE);
827 d->tbAddToList->setEnabled(TRUE); 829 d->tbAddToList->setEnabled(TRUE);
828 } 830 }
829 break; 831 break;
830 case 2: 832 case 2:
831 { 833 {
832 videoView->clear(); 834 videoView->clear();
833 populateVideoView(); 835 populateVideoView();
834 if( !tbDeletePlaylist->isHidden()) 836 if( !tbDeletePlaylist->isHidden())
835 tbDeletePlaylist->hide(); 837 tbDeletePlaylist->hide();
836 d->tbRemoveFromList->setEnabled(FALSE); 838 d->tbRemoveFromList->setEnabled(FALSE);
837 d->tbAddToList->setEnabled(TRUE); 839 d->tbAddToList->setEnabled(TRUE);
838 } 840 }
839 break; 841 break;
840 case 3: 842 case 3:
841 { 843 {
842 if( tbDeletePlaylist->isHidden()) 844 if( tbDeletePlaylist->isHidden())
843 tbDeletePlaylist->show(); 845 tbDeletePlaylist->show();
844 playLists->reread(); 846 playLists->reread();
845 } 847 }
846 break; 848 break;
847 }; 849 };
848} 850}
849 851
850void PlayListWidget::btnPlay(bool b) { 852void PlayListWidget::btnPlay(bool b) {
851 853
852// mediaPlayerState->setPlaying(b); 854// mediaPlayerState->setPlaying(b);
853 switch ( tabWidget->currentPageIndex()) { 855 switch ( tabWidget->currentPageIndex()) {
854 case 0: 856 case 0:
855 { 857 {
856// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
857// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
858// QMessageBox::message("Note","You are trying to play\na malformed url."); 860// QMessageBox::message("Note","You are trying to play\na malformed url.");
859// } else { 861// } else {
860 mediaPlayerState->setPlaying(b); 862 mediaPlayerState->setPlaying(b);
861// } 863// }
862 } 864 }
863 break; 865 break;
864 case 1: 866 case 1:
865 { 867 {
866 addToSelection( audioView->currentItem() ); 868 addToSelection( audioView->currentItem() );
867 mediaPlayerState->setPlaying(b); 869 mediaPlayerState->setPlaying(b);
868 d->selectedFiles->removeSelected( ); 870 d->selectedFiles->removeSelected( );
869 tabWidget->setCurrentPage(1); 871 tabWidget->setCurrentPage(1);
870 d->selectedFiles->unSelect(); 872 d->selectedFiles->unSelect();
871 insanityBool=FALSE; 873 insanityBool=FALSE;
872 }// audioView->clearSelection(); 874 }// audioView->clearSelection();
873 break; 875 break;
874 case 2: 876 case 2:
875 { 877 {
876 addToSelection( videoView->currentItem() ); 878 addToSelection( videoView->currentItem() );
877 mediaPlayerState->setPlaying(b); 879 mediaPlayerState->setPlaying(b);
878 qApp->processEvents(); 880 qApp->processEvents();
879 d->selectedFiles->removeSelected( ); 881 d->selectedFiles->removeSelected( );
880 tabWidget->setCurrentPage(2); 882 tabWidget->setCurrentPage(2);
881 d->selectedFiles->unSelect(); 883 d->selectedFiles->unSelect();
882 insanityBool=FALSE; 884 insanityBool=FALSE;
883 }// videoView->clearSelection(); 885 }// videoView->clearSelection();
884 break; 886 break;
885 }; 887 };
886 888
887} 889}
888 890
889void PlayListWidget::deletePlaylist() { 891void PlayListWidget::deletePlaylist() {
890 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 892 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
891 (tr("You really want to delete\nthis playlist?")), 893 (tr("You really want to delete\nthis playlist?")),
892 (tr("Yes")), (tr("No")), 0 )){ 894 (tr("Yes")), (tr("No")), 0 )){
893 case 0: // Yes clicked, 895 case 0: // Yes clicked,
894 QFile().remove(playLists->selected()->file()); 896 QFile().remove(playLists->selected()->file());
895 QFile().remove(playLists->selected()->linkFile()); 897 QFile().remove(playLists->selected()->linkFile());
896 playLists->reread(); 898 playLists->reread();
897 break; 899 break;
898 case 1: // Cancel 900 case 1: // Cancel
899 break; 901 break;
900 }; 902 };
901} 903}
902 904
903void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
904{ 906{
905 switch (mouse) { 907 switch (mouse) {
906 case 1: 908 case 1:
907 break; 909 break;
908 case 2:{ 910 case 2:{
909 911
910 QPopupMenu m; 912 QPopupMenu m;
911 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
912 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
913 m.insertSeparator(); 915 m.insertSeparator();
914 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
915 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
916 918
917 m.exec( QCursor::pos() ); 919 m.exec( QCursor::pos() );
918 } 920 }
919 break; 921 break;
920 }; 922 };
921} 923}
922 924
923void PlayListWidget::playSelected() 925void PlayListWidget::playSelected()
924{ 926{
925 btnPlay( TRUE); 927 btnPlay( TRUE);
926// d->selectedFiles->unSelect(); 928// d->selectedFiles->unSelect();
927} 929}
928 930
929void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
930{ 932{
931 switch (mouse) { 933 switch (mouse) {
932 case 1: 934 case 1:
933 935
934 break; 936 break;
935 case 2:{ 937 case 2:{
936 QPopupMenu m; 938 QPopupMenu m;
937 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
938 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
939// m.insertSeparator(); 941// m.insertSeparator();
940// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
941 m.exec( QCursor::pos() ); 943 m.exec( QCursor::pos() );
942 } 944 }
943 break; 945 break;
944 }; 946 };
945 947
946} 948}
947 949
948void PlayListWidget::listDelete() { 950void PlayListWidget::listDelete() {
949 Config cfg( "OpiePlayer" ); 951 Config cfg( "OpiePlayer" );
950 cfg.setGroup("PlayList"); 952 cfg.setGroup("PlayList");
951 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 953 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
952 QString file; 954 QString file;
953 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 955 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
954 switch ( tabWidget->currentPageIndex()) { 956 switch ( tabWidget->currentPageIndex()) {
955 case 0: 957 case 0:
956 break; 958 break;
957 case 1: 959 case 1:
958 { 960 {
959 file = audioView->selectedItem()->text(0); 961 file = audioView->currentItem()->text(0);
960// Global::findDocuments(&files, "audio/*"); 962 QListIterator<DocLnk> Pdit( files.children() );
961// AppLnkSet appFiles; 963 for ( ; Pdit.current(); ++Pdit ) {
962 QListIterator<DocLnk> dit( files.children() ); 964 if( Pdit.current()->name() == file) {
963 for ( ; dit.current(); ++dit ) { 965 LnkProperties prop( Pdit.current() );
964 if( dit.current()->name() == file) {
965// qDebug(file);
966 LnkProperties prop( dit.current() );
967// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
968 prop.showMaximized(); 966 prop.showMaximized();
969 prop.exec(); 967 prop.exec();
970 } 968 }
971 } 969 }
972 populateAudioView(); 970 populateAudioView();
973 } 971 }
974 break; 972 break;
975 case 2: 973 case 2:
976 { 974 {
977// file = videoView->selectedItem()->text(0); 975// file = videoView->selectedItem()->text(0);
978// for ( int i = 0; i < noOfFiles; i++ ) { 976// for ( int i = 0; i < noOfFiles; i++ ) {
979// QString entryName; 977// QString entryName;
980// entryName.sprintf( "File%i", i + 1 ); 978// entryName.sprintf( "File%i", i + 1 );
981// QString linkFile = cfg.readEntry( entryName ); 979// QString linkFile = cfg.readEntry( entryName );
982// AppLnk lnk( AppLnk(linkFile)); 980// AppLnk lnk( AppLnk(linkFile));
983// if( lnk.name() == file ) { 981// if( lnk.name() == file ) {
984// LnkProperties prop( &lnk); 982// LnkProperties prop( &lnk);
985// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 983// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
986// prop.showMaximized(); 984// prop.showMaximized();
987// prop.exec(); 985// prop.exec();
988// } 986// }
989// } 987// }
990 } 988 }
991 break; 989 break;
992 }; 990 };
993} 991}
994 992
995void PlayListWidget::scanForAudio() { 993void PlayListWidget::scanForAudio() {
996 qDebug("scan for audio"); 994 qDebug("scan for audio");
997 files.detachChildren(); 995 files.detachChildren();
998 QListIterator<DocLnk> sdit( files.children() ); 996 QListIterator<DocLnk> sdit( files.children() );
999 for ( ; sdit.current(); ++sdit ) { 997 for ( ; sdit.current(); ++sdit ) {
1000 delete sdit.current(); 998 delete sdit.current();
1001 } 999 }
1002 Global::findDocuments(&files, "audio/*"); 1000 Global::findDocuments(&files, "audio/*");
1003 audioScan = TRUE; 1001 audioScan = TRUE;
1004} 1002}
1005void PlayListWidget::scanForVideo() { 1003void PlayListWidget::scanForVideo() {
1006 qDebug("scan for video"); 1004 qDebug("scan for video");
1007 vFiles.detachChildren(); 1005 vFiles.detachChildren();
1008 QListIterator<DocLnk> sdit( vFiles.children() ); 1006 QListIterator<DocLnk> sdit( vFiles.children() );
1009 for ( ; sdit.current(); ++sdit ) { 1007 for ( ; sdit.current(); ++sdit ) {
1010 delete sdit.current(); 1008 delete sdit.current();
1011 } 1009 }
1012 Global::findDocuments(&vFiles, "video/*"); 1010 Global::findDocuments(&vFiles, "video/*");
1013 videoScan = TRUE; 1011 videoScan = TRUE;
1014} 1012}
1015 1013
1016void PlayListWidget::populateAudioView() { 1014void PlayListWidget::populateAudioView() {
1017 1015
1018 audioView->clear(); 1016 audioView->clear();
1019 StorageInfo storageInfo; 1017 StorageInfo storageInfo;
1020 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1018 const QList<FileSystem> &fs = storageInfo.fileSystems();
1021 if(!audioScan) scanForAudio(); 1019 if(!audioScan) scanForAudio();
1022 1020
1023 QListIterator<DocLnk> dit( files.children() ); 1021 QListIterator<DocLnk> dit( files.children() );
1024 QListIterator<FileSystem> it ( fs ); 1022 QListIterator<FileSystem> it ( fs );
1025 1023
1026 QString storage; 1024 QString storage;
1027 for ( ; dit.current(); ++dit ) { 1025 for ( ; dit.current(); ++dit ) {
1028 for( ; it.current(); ++it ){ 1026 for( ; it.current(); ++it ){
1029 const QString name = (*it)->name(); 1027 const QString name = (*it)->name();
1030 const QString path = (*it)->path(); 1028 const QString path = (*it)->path();
1031 if(dit.current()->file().find(path) != -1 ) storage=name; 1029 if(dit.current()->file().find(path) != -1 ) storage=name;
1032 } 1030 }
1033 1031
1034 QListViewItem * newItem; 1032 QListViewItem * newItem;
1035 if ( QFile( dit.current()->file()).exists() ) { 1033 if ( QFile( dit.current()->file()).exists() ) {
1036// qDebug(dit.current()->name()); 1034// qDebug(dit.current()->name());
1037 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1035 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1038 QString::number( QFile( dit.current()->file()).size() ), storage); 1036 QString::number( QFile( dit.current()->file()).size() ), storage);
1039 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1037 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1040 } 1038 }
1041 } 1039 }
1042 1040
1043} 1041}
1044 1042
1045void PlayListWidget::populateVideoView() { 1043void PlayListWidget::populateVideoView() {
1046 videoView->clear(); 1044 videoView->clear();
1047 StorageInfo storageInfo; 1045 StorageInfo storageInfo;
1048 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1046 const QList<FileSystem> &fs = storageInfo.fileSystems();
1049 1047
1050 if(!videoScan ) scanForVideo(); 1048 if(!videoScan ) scanForVideo();
1051 1049
1052 QListIterator<DocLnk> Vdit( vFiles.children() ); 1050 QListIterator<DocLnk> Vdit( vFiles.children() );
1053 QListIterator<FileSystem> it ( fs ); 1051 QListIterator<FileSystem> it ( fs );
1054 videoView->clear(); 1052 videoView->clear();
1055 QString storage; 1053 QString storage;
1056 for ( ; Vdit.current(); ++Vdit ) { 1054 for ( ; Vdit.current(); ++Vdit ) {
1057 for( ; it.current(); ++it ){ 1055 for( ; it.current(); ++it ){
1058 const QString name = (*it)->name(); 1056 const QString name = (*it)->name();
1059 const QString path = (*it)->path(); 1057 const QString path = (*it)->path();
1060 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1058 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1061 } 1059 }
1062 1060
1063 QListViewItem * newItem; 1061 QListViewItem * newItem;
1064 if ( QFile( Vdit.current()->file()).exists() ) { 1062 if ( QFile( Vdit.current()->file()).exists() ) {
1065 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1063 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1066 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1064 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1067 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1065 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1068 } 1066 }
1069 } 1067 }
1070} 1068}
1071 1069
1072void PlayListWidget::openFile() { 1070void PlayListWidget::openFile() {
1073 QString filename, name; 1071 QString filename, name;
1074 InputDialog *fileDlg; 1072 InputDialog *fileDlg;
1075 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1073 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1076 fileDlg->exec(); 1074 fileDlg->exec();
1077 if( fileDlg->result() == 1 ) { 1075 if( fileDlg->result() == 1 ) {
1078 filename = fileDlg->LineEdit1->text(); 1076 filename = fileDlg->LineEdit1->text();
1079// http://205.188.234.129:8030 1077// http://205.188.234.129:8030
1080// http://66.28.68.70:8000 1078// http://66.28.68.70:8000
1081// filename.replace(QRegExp("%20")," "); 1079// filename.replace(QRegExp("%20")," ");
1082 if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) {
1083 QMessageBox::message("Note","Spaces in urls are not allowed.");
1084 return;
1085 } else {
1086 qDebug("Selected filename is "+filename); 1080 qDebug("Selected filename is "+filename);
1087 if(filename.right(3) == "m3u") 1081 if(filename.right(3) == "m3u")
1088 readm3u( filename); 1082 readm3u( filename);
1089 else if(filename.right(3) == "pls") 1083 else if(filename.right(3) == "pls")
1090 readPls( filename); 1084 readPls( filename);
1091 else { 1085 else {
1092 DocLnk lnk; 1086 DocLnk lnk;
1093 1087
1094 lnk.setName(filename); //sets file name 1088 lnk.setName(filename); //sets file name
1095 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1089 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1096 filename += "/"; 1090 filename += "/";
1097 lnk.setFile(filename); //sets File property 1091 lnk.setFile(filename); //sets File property
1098 1092
1099 lnk.setType("audio/x-mpegurl"); 1093 lnk.setType("audio/x-mpegurl");
1100 lnk.setExec("opieplayer"); 1094 lnk.setExec("opieplayer");
1101 lnk.setIcon("opieplayer/MPEGPlayer"); 1095 lnk.setIcon("opieplayer/MPEGPlayer");
1102 1096
1103 if(!lnk.writeLink()) 1097 if(!lnk.writeLink())
1104 qDebug("Writing doclink did not work"); 1098 qDebug("Writing doclink did not work");
1105 d->selectedFiles->addToSelection( lnk); 1099 d->selectedFiles->addToSelection( lnk);
1106// if(fileDlg2) 1100// if(fileDlg2)
1107// delete fileDlg2; 1101// delete fileDlg2;
1108 } 1102 }
1109 }
1110 } 1103 }
1111 if(fileDlg) 1104 if(fileDlg)
1112 delete fileDlg; 1105 delete fileDlg;
1113} 1106}
1114 1107
1115void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1108void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1116{ 1109{
1117 switch ( e->key() ) { 1110 switch ( e->key() ) {
1118////////////////////////////// Zaurus keys 1111////////////////////////////// Zaurus keys
1119 case Key_F9: //activity 1112 case Key_F9: //activity
1120// if(audioUI->isHidden()) 1113// if(audioUI->isHidden())
1121// audioUI->showMaximized(); 1114// audioUI->showMaximized();
1122 break; 1115 break;
1123 case Key_F10: //contacts 1116 case Key_F10: //contacts
1124// if( videoUI->isHidden()) 1117// if( videoUI->isHidden())
1125// videoUI->showMaximized(); 1118// videoUI->showMaximized();
1126 break; 1119 break;
1127 case Key_F11: //menu 1120 case Key_F11: //menu
1128 break; 1121 break;
1129 case Key_F12: //home 1122 case Key_F12: //home
1130// doBlank(); 1123// doBlank();
1131 break; 1124 break;
1132 case Key_F13: //mail 1125 case Key_F13: //mail
1133// doUnblank(); 1126// doUnblank();
1134 break; 1127 break;
1135 case Key_Q: //add to playlist 1128 case Key_Q: //add to playlist
1136 qDebug("Add"); 1129 qDebug("Add");
1137 addSelected(); 1130 addSelected();
1138 break; 1131 break;
1139 case Key_R: //remove from playlist 1132 case Key_R: //remove from playlist
1140 removeSelected(); 1133 removeSelected();
1141 break; 1134 break;
1142// case Key_P: //play 1135// case Key_P: //play
1143// qDebug("Play"); 1136// qDebug("Play");
1144// playSelected(); 1137// playSelected();
1145// break; 1138// break;
1146 case Key_Space: 1139 case Key_Space:
1147 qDebug("Play"); 1140 qDebug("Play");
1148// playSelected(); puh 1141// playSelected(); puh
1149 break; 1142 break;
1150 case Key_1: 1143 case Key_1:
1151 tabWidget->setCurrentPage(0); 1144 tabWidget->setCurrentPage(0);
1152 break; 1145 break;
1153 case Key_2: 1146 case Key_2:
1154 tabWidget->setCurrentPage(1); 1147 tabWidget->setCurrentPage(1);
1155 break; 1148 break;
1156 case Key_3: 1149 case Key_3:
1157 tabWidget->setCurrentPage(2); 1150 tabWidget->setCurrentPage(2);
1158 break; 1151 break;
1159 case Key_4: 1152 case Key_4:
1160 tabWidget->setCurrentPage(3); 1153 tabWidget->setCurrentPage(3);
1161 break; 1154 break;
1162 case Key_Down: 1155 case Key_Down:
1163 if ( !d->selectedFiles->next() ) 1156 if ( !d->selectedFiles->next() )
1164 d->selectedFiles->first(); 1157 d->selectedFiles->first();
1165 1158
1166 break; 1159 break;
1167 case Key_Up: 1160 case Key_Up:
1168 if ( !d->selectedFiles->prev() ) 1161 if ( !d->selectedFiles->prev() )
1169 // d->selectedFiles->last(); 1162 // d->selectedFiles->last();
1170 1163
1171 break; 1164 break;
1172 1165
1173 } 1166 }
1174} 1167}
1175 1168
1176void PlayListWidget::keyPressEvent( QKeyEvent *e) 1169void PlayListWidget::keyPressEvent( QKeyEvent *e)
1177{ 1170{
1178// qDebug("Key press"); 1171// qDebug("Key press");
1179// switch ( e->key() ) { 1172// switch ( e->key() ) {
1180// ////////////////////////////// Zaurus keys 1173// ////////////////////////////// Zaurus keys
1181// case Key_A: //add to playlist 1174// case Key_A: //add to playlist
1182// qDebug("Add"); 1175// qDebug("Add");
1183// addSelected(); 1176// addSelected();
1184// break; 1177// break;
1185// case Key_R: //remove from playlist 1178// case Key_R: //remove from playlist
1186// removeSelected(); 1179// removeSelected();
1187// break; 1180// break;
1188// case Key_P: //play 1181// case Key_P: //play
1189// qDebug("Play"); 1182// qDebug("Play");
1190// playSelected(); 1183// playSelected();
1191// break; 1184// break;
1192// case Key_Space: 1185// case Key_Space:
1193// qDebug("Play"); 1186// qDebug("Play");
1194// playSelected(); 1187// playSelected();
1195// break; 1188// break;
1196// } 1189// }
1197} 1190}
1198 1191
1199void PlayListWidget::doBlank() { 1192void PlayListWidget::doBlank() {
1200 qDebug("do blanking"); 1193 qDebug("do blanking");
1201 fd=open("/dev/fb0",O_RDWR); 1194 fd=open("/dev/fb0",O_RDWR);
1202 if (fd != -1) { 1195 if (fd != -1) {
1203 ioctl(fd,FBIOBLANK,1); 1196 ioctl(fd,FBIOBLANK,1);
1204// close(fd); 1197// close(fd);
1205 } 1198 }
1206} 1199}
1207 1200
1208void PlayListWidget::doUnblank() { 1201void PlayListWidget::doUnblank() {
1209 // this crashes opieplayer with a segfault 1202 // this crashes opieplayer with a segfault
1210// int fd; 1203// int fd;
1211// fd=open("/dev/fb0",O_RDWR); 1204// fd=open("/dev/fb0",O_RDWR);
1212 qDebug("do unblanking"); 1205 qDebug("do unblanking");
1213 if (fd != -1) { 1206 if (fd != -1) {
1214 ioctl(fd,FBIOBLANK,0); 1207 ioctl(fd,FBIOBLANK,0);
1215 close(fd); 1208 close(fd);
1216 } 1209 }
1217 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1210 QCopEnvelope h("QPE/System", "setBacklight(int)");
1218 h <<-3;// v[1]; // -3 Force on 1211 h <<-3;// v[1]; // -3 Force on
1219} 1212}
1220 1213
1221void PlayListWidget::readm3u(const QString &filename) { 1214void PlayListWidget::readm3u(const QString &filename) {
1222 1215
1223 qDebug("m3u filename is "+filename); 1216 qDebug("m3u filename is "+filename);
1224 QFile f(filename); 1217 QFile f(filename);
1225 1218
1226 if(f.open(IO_ReadOnly)) { 1219 if(f.open(IO_ReadOnly)) {
1227 QTextStream t(&f); 1220 QTextStream t(&f);
1228 QString s;//, first, second; 1221 QString s;//, first, second;
1229 int i=0; 1222 int i=0;
1230 while ( !t.atEnd()) { 1223 while ( !t.atEnd()) {
1231// Lview->insertLine(t.readLine(),-1); 1224// Lview->insertLine(t.readLine(),-1);
1232 s=t.readLine(); 1225 s=t.readLine();
1233 if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { 1226
1234 QMessageBox::message("Note","Spaces in urls are not allowed."); 1227 if(s.find("#",0,TRUE) == -1) {
1235 }
1236 else if(s.find("#",0,TRUE) == -1) {
1237 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1228 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1238 if(s.left(2) == "E:" || s.left(2) == "P:") { 1229 if(s.left(2) == "E:" || s.left(2) == "P:") {
1239 s=s.right(s.length()-2); 1230 s=s.right(s.length()-2);
1240 DocLnk lnk( s ); 1231 DocLnk lnk( s );
1241 QFileInfo f(s); 1232 QFileInfo f(s);
1242 QString name = f.baseName(); 1233 QString name = f.baseName();
1243 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1234 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1244 lnk.setName( name); 1235 lnk.setName( name);
1245 s=s.replace( QRegExp("\\"),"/"); 1236 s=s.replace( QRegExp("\\"),"/");
1246 lnk.setFile( s); 1237 lnk.setFile( s);
1247 lnk.writeLink(); 1238 lnk.writeLink();
1248// lnk.setIcon(opieplayer/MPEGPlayer); 1239// lnk.setIcon(opieplayer/MPEGPlayer);
1249 qDebug("add "+name); 1240 qDebug("add "+name);
1250 d->selectedFiles->addToSelection( lnk); 1241 d->selectedFiles->addToSelection( lnk);
1251 } else { // is url 1242 } else { // is url
1252 1243
1253 s.replace(QRegExp("%20")," "); 1244 s.replace(QRegExp("%20")," ");
1254 DocLnk lnk( s); 1245 DocLnk lnk( s);
1255 QString name; 1246 QString name;
1256 if(name.left(4)=="http") 1247 if(name.left(4)=="http")
1257 name = s.right( s.length() - 7); 1248 name = s.right( s.length() - 7);
1258 else 1249 else
1259 name=s; 1250 name=s;
1260// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1251// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1261 lnk.setName(name); 1252 lnk.setName(name);
1262 if(s.at(s.length()-4) == '.') 1253 if(s.at(s.length()-4) == '.')
1263 lnk.setFile( s); 1254 lnk.setFile( s);
1264 else 1255 else
1265 lnk.setFile( s+"/"); 1256 lnk.setFile( s+"/");
1266// lnk.setFile( filename); 1257// lnk.setFile( filename);
1267// lnk.setComment( s+"/"); 1258// lnk.setComment( s+"/");
1268 lnk.setType("audio/x-mpegurl"); 1259 lnk.setType("audio/x-mpegurl");
1269 lnk.writeLink(); 1260 lnk.writeLink();
1270// lnk.setIcon( "opieplayer/MPEGPlayer"); 1261// lnk.setIcon( "opieplayer/MPEGPlayer");
1271// qDebug("add "+s); 1262// qDebug("add "+s);
1272 d->selectedFiles->addToSelection( lnk); 1263 d->selectedFiles->addToSelection( lnk);
1273 } 1264 }
1274 i++; 1265 i++;
1275 } 1266 }
1276 } 1267 }
1277 } 1268 }
1278 } 1269 }
1279 f.close(); 1270 f.close();
1280} 1271}
1281 1272
1282void PlayListWidget::writem3u() { 1273void PlayListWidget::writem3u() {
1283 1274
1284 InputDialog *fileDlg; 1275 InputDialog *fileDlg;
1285 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1276 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1286 fileDlg->exec(); 1277 fileDlg->exec();
1287 QString filename,list; 1278 QString filename,list;
1288 if( fileDlg->result() == 1 ) { 1279 if( fileDlg->result() == 1 ) {
1289 filename = fileDlg->LineEdit1->text(); 1280 filename = fileDlg->LineEdit1->text();
1290 qDebug(filename); 1281 qDebug(filename);
1291 int noOfFiles = 0; 1282 int noOfFiles = 0;
1292 d->selectedFiles->first(); 1283 d->selectedFiles->first();
1293 do { 1284 do {
1294// we dont check for existance because of url's 1285// we dont check for existance because of url's
1295// qDebug(d->selectedFiles->current()->file()); 1286// qDebug(d->selectedFiles->current()->file());
1296 list += d->selectedFiles->current()->file()+"\n"; 1287 list += d->selectedFiles->current()->file()+"\n";
1297 noOfFiles++; 1288 noOfFiles++;
1298 } 1289 }
1299 while ( d->selectedFiles->next() ); 1290 while ( d->selectedFiles->next() );
1300 qDebug(list); 1291 qDebug(list);
1301 if(filename.left(1) != "/") 1292 if(filename.left(1) != "/")
1302 filename=QPEApplication::documentDir()+"/"+filename; 1293 filename=QPEApplication::documentDir()+"/"+filename;
1303 if(filename.right(3) != "m3u") 1294 if(filename.right(3) != "m3u")
1304 filename=filename+".m3u"; 1295 filename=filename+".m3u";
1305 1296
1306 QFile f(filename); 1297 QFile f(filename);
1307 f.open(IO_WriteOnly); 1298 f.open(IO_WriteOnly);
1308 f.writeBlock(list, list.length()); 1299 f.writeBlock(list, list.length());
1309 f.close(); 1300 f.close();
1310 } 1301 }
1311 if(fileDlg) delete fileDlg; 1302 if(fileDlg) delete fileDlg;
1312} 1303}
1313 1304
1314void PlayListWidget::readPls(const QString &filename) { 1305void PlayListWidget::readPls(const QString &filename) {
1315 1306
1316 qDebug("pls filename is "+filename); 1307 qDebug("pls filename is "+filename);
1317 QFile f(filename); 1308 QFile f(filename);
1318 1309
1319 if(f.open(IO_ReadOnly)) { 1310 if(f.open(IO_ReadOnly)) {
1320 QTextStream t(&f); 1311 QTextStream t(&f);
1321 QString s;//, first, second; 1312 QString s;//, first, second;
1322 int i=0; 1313 int i=0;
1323 while ( !t.atEnd()) { 1314 while ( !t.atEnd()) {
1324 s=t.readLine(); 1315 s=t.readLine();
1325 if(s.left(4) == "File") { 1316 if(s.left(4) == "File") {
1326 s=s.right(s.length() - 6); 1317 s=s.right(s.length() - 6);
1327 s.replace(QRegExp("%20")," "); 1318 s.replace(QRegExp("%20")," ");
1328 qDebug("adding "+s+" to playlist"); 1319 qDebug("adding "+s+" to playlist");
1329// numberofentries=2 1320// numberofentries=2
1330// File1=http 1321// File1=http
1331// Title 1322// Title
1332// Length 1323// Length
1333// Version 1324// Version
1334// File2=http 1325// File2=http
1335 1326
1336 s=s.replace( QRegExp("\\"),"/"); 1327 s=s.replace( QRegExp("\\"),"/");
1337 DocLnk lnk( s ); 1328 DocLnk lnk( s );
1338 QFileInfo f(s); 1329 QFileInfo f(s);
1339 QString name = f.baseName(); 1330 QString name = f.baseName();
1340 if(name.left(4)=="http") 1331 if(name.left(4)=="http")
1341 name = s.right( s.length() - 7); 1332 name = s.right( s.length() - 7);
1342 else 1333 else
1343 name=s; 1334 name=s;
1344 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1335 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1345// QFileInfo f(s); 1336// QFileInfo f(s);
1346// QString name = f.baseName(); 1337// QString name = f.baseName();
1347// name = name.left(name.length()-4); 1338// name = name.left(name.length()-4);
1348// name = name.right(name.findRev("/",0,TRUE)); 1339// name = name.right(name.findRev("/",0,TRUE));
1349 lnk.setName( name); 1340 lnk.setName( name);
1350 if(s.at(s.length()-4) == '.') // if this is probably a file 1341 if(s.at(s.length()-4) == '.') // if this is probably a file
1351 lnk.setFile( s); 1342 lnk.setFile( s);
1352 else { //if its a url 1343 else { //if its a url
1353 if( name.right(1).find('/') == -1) 1344 if( name.right(1).find('/') == -1)
1354 s+="/"; 1345 s+="/";
1355 lnk.setFile( s); 1346 lnk.setFile( s);
1356 } 1347 }
1357 lnk.setType("audio/x-mpegurl"); 1348 lnk.setType("audio/x-mpegurl");
1358 1349
1359 qDebug("DocLnk add "+name); 1350 qDebug("DocLnk add "+name);
1360 d->selectedFiles->addToSelection( lnk); 1351 d->selectedFiles->addToSelection( lnk);
1361 } 1352 }
1362 } 1353 }
1363 i++; 1354 i++;
1364 } 1355 }
1365} 1356}
1366 1357