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