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