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