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