summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index b0d4958..41fcb30 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -37,769 +37,769 @@
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 if(QFileInfo(lnk.file()).exists()) 421 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
422 d->selectedFiles->addToSelection( lnk ); 422 d->selectedFiles->addToSelection( lnk );
423 } 423 }
424 else 424 else
425 mediaPlayerState->setPlaying( TRUE ); 425 mediaPlayerState->setPlaying( TRUE );
426} 426}
427 427
428 428
429void PlayListWidget::clearList() { 429void PlayListWidget::clearList() {
430 while ( first() ) 430 while ( first() )
431 d->selectedFiles->removeSelected(); 431 d->selectedFiles->removeSelected();
432} 432}
433 433
434 434
435void PlayListWidget::addAllToList() { 435void PlayListWidget::addAllToList() {
436 DocLnkSet filesAll; 436 DocLnkSet filesAll;
437 Global::findDocuments(&filesAll, "video/*;audio/*"); 437 Global::findDocuments(&filesAll, "video/*;audio/*");
438 QListIterator<DocLnk> Adit( filesAll.children() ); 438 QListIterator<DocLnk> Adit( filesAll.children() );
439 for ( ; Adit.current(); ++Adit ) 439 for ( ; Adit.current(); ++Adit )
440 if(QFileInfo(Adit.current()->file()).exists()) 440 if(QFileInfo(Adit.current()->file()).exists())
441 d->selectedFiles->addToSelection( **Adit ); 441 d->selectedFiles->addToSelection( **Adit );
442} 442}
443 443
444 444
445void PlayListWidget::addAllMusicToList() { 445void PlayListWidget::addAllMusicToList() {
446 QListIterator<DocLnk> dit( files.children() ); 446 QListIterator<DocLnk> dit( files.children() );
447 for ( ; dit.current(); ++dit ) 447 for ( ; dit.current(); ++dit )
448 if(QFileInfo(dit.current()->file()).exists()) 448 if(QFileInfo(dit.current()->file()).exists())
449 d->selectedFiles->addToSelection( **dit ); 449 d->selectedFiles->addToSelection( **dit );
450} 450}
451 451
452 452
453void PlayListWidget::addAllVideoToList() { 453void PlayListWidget::addAllVideoToList() {
454 QListIterator<DocLnk> dit( vFiles.children() ); 454 QListIterator<DocLnk> dit( vFiles.children() );
455 for ( ; dit.current(); ++dit ) 455 for ( ; dit.current(); ++dit )
456 if(QFileInfo( dit.current()->file()).exists()) 456 if(QFileInfo( dit.current()->file()).exists())
457 d->selectedFiles->addToSelection( **dit ); 457 d->selectedFiles->addToSelection( **dit );
458} 458}
459 459
460 460
461void PlayListWidget::setDocument(const QString& fileref) { 461void PlayListWidget::setDocument(const QString& fileref) {
462 qDebug(fileref); 462 qDebug(fileref);
463 fromSetDocument = TRUE; 463 fromSetDocument = TRUE;
464 if ( fileref.isNull() ) { 464 if ( fileref.isNull() ) {
465 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." ) );
466 return; 466 return;
467 } 467 }
468// qDebug("setDocument "+fileref); 468// qDebug("setDocument "+fileref);
469 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 469 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
470 readm3u( fileref); 470 readm3u( fileref);
471 } 471 }
472 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 472 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
473 readPls( fileref); 473 readPls( fileref);
474 } 474 }
475 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 475 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
476 clearList(); 476 clearList();
477 loadList(DocLnk(fileref)); 477 loadList(DocLnk(fileref));
478 d->selectedFiles->first(); 478 d->selectedFiles->first();
479 } else { 479 } else {
480 clearList(); 480 clearList();
481 addToSelection( DocLnk( fileref ) ); 481 addToSelection( DocLnk( fileref ) );
482 d->setDocumentUsed = TRUE; 482 d->setDocumentUsed = TRUE;
483 mediaPlayerState->setPlaying( FALSE ); 483 mediaPlayerState->setPlaying( FALSE );
484 qApp->processEvents(); 484 qApp->processEvents();
485 mediaPlayerState->setPlaying( TRUE ); 485 mediaPlayerState->setPlaying( TRUE );
486 qApp->processEvents(); 486 qApp->processEvents();
487 setCaption(tr("OpiePlayer")); 487 setCaption(tr("OpiePlayer"));
488 } 488 }
489} 489}
490 490
491 491
492void PlayListWidget::setActiveWindow() { 492void PlayListWidget::setActiveWindow() {
493 // 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
494 char origView = mediaPlayerState->view(); 494 char origView = mediaPlayerState->view();
495 mediaPlayerState->setView( 'l' ); // invalidate 495 mediaPlayerState->setView( 'l' ); // invalidate
496 mediaPlayerState->setView( origView ); // now switch back 496 mediaPlayerState->setView( origView ); // now switch back
497} 497}
498 498
499 499
500void PlayListWidget::useSelectedDocument() { 500void PlayListWidget::useSelectedDocument() {
501 d->setDocumentUsed = FALSE; 501 d->setDocumentUsed = FALSE;
502} 502}
503 503
504 504
505const DocLnk *PlayListWidget::current() { // this is fugly 505const DocLnk *PlayListWidget::current() { // this is fugly
506 506
507// if( fromSetDocument) { 507// if( fromSetDocument) {
508// qDebug("from setDoc"); 508// qDebug("from setDoc");
509// DocLnkSet files; 509// DocLnkSet files;
510// Global::findDocuments(&files, "video/*;audio/*"); 510// Global::findDocuments(&files, "video/*;audio/*");
511// QListIterator<DocLnk> dit( files.children() ); 511// QListIterator<DocLnk> dit( files.children() );
512// for ( ; dit.current(); ++dit ) { 512// for ( ; dit.current(); ++dit ) {
513// if(dit.current()->linkFile() == setDocFileRef) { 513// if(dit.current()->linkFile() == setDocFileRef) {
514// qDebug(setDocFileRef); 514// qDebug(setDocFileRef);
515// return dit; 515// return dit;
516// } 516// }
517// } 517// }
518// } else 518// } else
519 519
520 520
521 switch (tabWidget->currentPageIndex()) { 521 switch (tabWidget->currentPageIndex()) {
522 case 0: //playlist 522 case 0: //playlist
523 { 523 {
524 qDebug("playlist"); 524 qDebug("playlist");
525 if ( mediaPlayerState->playlist() ) { 525 if ( mediaPlayerState->playlist() ) {
526 return d->selectedFiles->current(); 526 return d->selectedFiles->current();
527 } 527 }
528 else if ( d->setDocumentUsed && d->current ) { 528 else if ( d->setDocumentUsed && d->current ) {
529 return d->current; 529 return d->current;
530 } else { 530 } else {
531 return d->files->selected(); 531 return d->files->selected();
532 } 532 }
533 } 533 }
534 break; 534 break;
535 case 1://audio 535 case 1://audio
536 { 536 {
537 qDebug("audioView"); 537 qDebug("audioView");
538 QListIterator<DocLnk> dit( files.children() ); 538 QListIterator<DocLnk> dit( files.children() );
539 for ( ; dit.current(); ++dit ) { 539 for ( ; dit.current(); ++dit ) {
540 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 540 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
541 qDebug("here"); 541 qDebug("here");
542 insanityBool=TRUE; 542 insanityBool=TRUE;
543 return dit; 543 return dit;
544 } 544 }
545 } 545 }
546 } 546 }
547 break; 547 break;
548 case 2: // video 548 case 2: // video
549 { 549 {
550 qDebug("videoView"); 550 qDebug("videoView");
551 QListIterator<DocLnk> Vdit( vFiles.children() ); 551 QListIterator<DocLnk> Vdit( vFiles.children() );
552 for ( ; Vdit.current(); ++Vdit ) { 552 for ( ; Vdit.current(); ++Vdit ) {
553 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 553 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
554 insanityBool=TRUE; 554 insanityBool=TRUE;
555 return Vdit; 555 return Vdit;
556 } 556 }
557 } 557 }
558 } 558 }
559 break; 559 break;
560 }; 560 };
561 return 0; 561 return 0;
562} 562}
563 563
564bool PlayListWidget::prev() { 564bool PlayListWidget::prev() {
565 if ( mediaPlayerState->playlist() ) { 565 if ( mediaPlayerState->playlist() ) {
566 if ( mediaPlayerState->shuffled() ) { 566 if ( mediaPlayerState->shuffled() ) {
567 const DocLnk *cur = current(); 567 const DocLnk *cur = current();
568 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 568 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
569 for ( int i = 0; i < j; i++ ) { 569 for ( int i = 0; i < j; i++ ) {
570 if ( !d->selectedFiles->next() ) 570 if ( !d->selectedFiles->next() )
571 d->selectedFiles->first(); 571 d->selectedFiles->first();
572 } 572 }
573 if ( cur == current() ) 573 if ( cur == current() )
574 if ( !d->selectedFiles->next() ) 574 if ( !d->selectedFiles->next() )
575 d->selectedFiles->first(); 575 d->selectedFiles->first();
576 return TRUE; 576 return TRUE;
577 } else { 577 } else {
578 if ( !d->selectedFiles->prev() ) { 578 if ( !d->selectedFiles->prev() ) {
579 if ( mediaPlayerState->looping() ) { 579 if ( mediaPlayerState->looping() ) {
580 return d->selectedFiles->last(); 580 return d->selectedFiles->last();
581 } else { 581 } else {
582 return FALSE; 582 return FALSE;
583 } 583 }
584 } 584 }
585 return TRUE; 585 return TRUE;
586 } 586 }
587 } else { 587 } else {
588 return mediaPlayerState->looping(); 588 return mediaPlayerState->looping();
589 } 589 }
590} 590}
591 591
592 592
593bool PlayListWidget::next() { 593bool PlayListWidget::next() {
594 if ( mediaPlayerState->playlist() ) { 594 if ( mediaPlayerState->playlist() ) {
595 if ( mediaPlayerState->shuffled() ) { 595 if ( mediaPlayerState->shuffled() ) {
596 return prev(); 596 return prev();
597 } else { 597 } else {
598 if ( !d->selectedFiles->next() ) { 598 if ( !d->selectedFiles->next() ) {
599 if ( mediaPlayerState->looping() ) { 599 if ( mediaPlayerState->looping() ) {
600 return d->selectedFiles->first(); 600 return d->selectedFiles->first();
601 } else { 601 } else {
602 return FALSE; 602 return FALSE;
603 } 603 }
604 } 604 }
605 return TRUE; 605 return TRUE;
606 } 606 }
607 } else { 607 } else {
608 return mediaPlayerState->looping(); 608 return mediaPlayerState->looping();
609 } 609 }
610} 610}
611 611
612 612
613bool PlayListWidget::first() { 613bool PlayListWidget::first() {
614 if ( mediaPlayerState->playlist() ) 614 if ( mediaPlayerState->playlist() )
615 return d->selectedFiles->first(); 615 return d->selectedFiles->first();
616 else 616 else
617 return mediaPlayerState->looping(); 617 return mediaPlayerState->looping();
618} 618}
619 619
620 620
621bool PlayListWidget::last() { 621bool PlayListWidget::last() {
622 if ( mediaPlayerState->playlist() ) 622 if ( mediaPlayerState->playlist() )
623 return d->selectedFiles->last(); 623 return d->selectedFiles->last();
624 else 624 else
625 return mediaPlayerState->looping(); 625 return mediaPlayerState->looping();
626} 626}
627 627
628 628
629void PlayListWidget::saveList() { 629void PlayListWidget::saveList() {
630 630
631 QString filename; 631 QString filename;
632 InputDialog *fileDlg; 632 InputDialog *fileDlg;
633 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 633 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
634 fileDlg->exec(); 634 fileDlg->exec();
635 if( fileDlg->result() == 1 ) { 635 if( fileDlg->result() == 1 ) {
636 if ( d->current ) 636 if ( d->current )
637 delete d->current; 637 delete d->current;
638 filename = fileDlg->LineEdit1->text();//+".playlist"; 638 filename = fileDlg->LineEdit1->text();//+".playlist";
639// qDebug("saving playlist "+filename+".playlist"); 639// qDebug("saving playlist "+filename+".playlist");
640 Config cfg( filename +".playlist"); 640 Config cfg( filename +".playlist");
641 writeConfig( cfg ); 641 writeConfig( cfg );
642 642
643 DocLnk lnk; 643 DocLnk lnk;
644// lnk.setComment( ""); 644// lnk.setComment( "");
645 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 645 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
646 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
647 lnk.setIcon("opieplayer/playlist2"); 647 lnk.setIcon("opieplayer/playlist2");
648 lnk.setName( filename); //sets file name 648 lnk.setName( filename); //sets file name
649// qDebug(filename); 649// qDebug(filename);
650 if(!lnk.writeLink()) 650 if(!lnk.writeLink())
651 qDebug("Writing doclink did not work"); 651 qDebug("Writing doclink did not work");
652 } 652 }
653 Config config( "OpiePlayer" ); 653 Config config( "OpiePlayer" );
654 config.writeEntry("CurrentPlaylist",filename); 654 config.writeEntry("CurrentPlaylist",filename);
655 setCaption(tr("OpiePlayer: ")+filename); 655 setCaption(tr("OpiePlayer: ")+filename);
656 d->selectedFiles->first(); 656 d->selectedFiles->first();
657 if(fileDlg) 657 if(fileDlg)
658 delete fileDlg; 658 delete fileDlg;
659} 659}
660 660
661void PlayListWidget::loadList( const DocLnk & lnk) { 661void PlayListWidget::loadList( const DocLnk & lnk) {
662 QString name= lnk.name(); 662 QString name= lnk.name();
663// qDebug("currentList is "+name); 663// qDebug("currentList is "+name);
664 if( name.length()>1) { 664 if( name.length()>1) {
665 setCaption("OpiePlayer: "+name); 665 setCaption("OpiePlayer: "+name);
666// qDebug("load list "+ name+".playlist"); 666// qDebug("load list "+ name+".playlist");
667 clearList(); 667 clearList();
668 Config cfg( name+".playlist"); 668 Config cfg( name+".playlist");
669 readConfig(cfg); 669 readConfig(cfg);
670 670
671 tabWidget->setCurrentPage(0); 671 tabWidget->setCurrentPage(0);
672 672
673 Config config( "OpiePlayer" ); 673 Config config( "OpiePlayer" );
674 config.writeEntry("CurrentPlaylist", name); 674 config.writeEntry("CurrentPlaylist", name);
675// d->selectedFiles->first(); 675// d->selectedFiles->first();
676 } 676 }
677 677
678} 678}
679 679
680void PlayListWidget::setPlaylist( bool shown ) { 680void PlayListWidget::setPlaylist( bool shown ) {
681 if ( shown ) 681 if ( shown )
682 d->playListFrame->show(); 682 d->playListFrame->show();
683 else 683 else
684 d->playListFrame->hide(); 684 d->playListFrame->hide();
685} 685}
686 686
687void PlayListWidget::setView( char view ) { 687void PlayListWidget::setView( char view ) {
688 if ( view == 'l' ) 688 if ( view == 'l' )
689 showMaximized(); 689 showMaximized();
690 else 690 else
691 hide(); 691 hide();
692} 692}
693 693
694void PlayListWidget::addSelected() { 694void PlayListWidget::addSelected() {
695 695
696 Config cfg( "OpiePlayer" ); 696 Config cfg( "OpiePlayer" );
697 cfg.setGroup("PlayList"); 697 cfg.setGroup("PlayList");
698 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 698 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
699 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 699 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
700 700
701 switch (tabWidget->currentPageIndex()) { 701 switch (tabWidget->currentPageIndex()) {
702 case 0: //playlist 702 case 0: //playlist
703 break; 703 break;
704 case 1: { //audio 704 case 1: { //audio
705// QString entryName; 705// QString entryName;
706// entryName.sprintf( "File%i", i + 1 ); 706// entryName.sprintf( "File%i", i + 1 );
707// QString linkFile = cfg.readEntry( entryName ); 707// QString linkFile = cfg.readEntry( entryName );
708 QListViewItemIterator it( audioView ); 708 QListViewItemIterator it( audioView );
709 // iterate through all items of the listview 709 // iterate through all items of the listview
710 for ( ; it.current(); ++it ) { 710 for ( ; it.current(); ++it ) {
711 if ( it.current()->isSelected() ) { 711 if ( it.current()->isSelected() ) {
712 QListIterator<DocLnk> dit( files.children() ); 712 QListIterator<DocLnk> dit( files.children() );
713 for ( ; dit.current(); ++dit ) { 713 for ( ; dit.current(); ++dit ) {
714 if( dit.current()->name() == it.current()->text(0) ) { 714 if( dit.current()->name() == it.current()->text(0) ) {
715 d->selectedFiles->addToSelection( **dit ); 715 d->selectedFiles->addToSelection( **dit );
716 } 716 }
717 } 717 }
718 audioView->setSelected( it.current(),FALSE); 718 audioView->setSelected( it.current(),FALSE);
719 } 719 }
720 } 720 }
721 tabWidget->setCurrentPage(0); 721 tabWidget->setCurrentPage(0);
722 } 722 }
723 break; 723 break;
724 case 2: { // video 724 case 2: { // video
725 QListViewItemIterator it( videoView ); 725 QListViewItemIterator it( videoView );
726 // iterate through all items of the listview 726 // iterate through all items of the listview
727 for ( ; it.current(); ++it ) { 727 for ( ; it.current(); ++it ) {
728 if ( it.current()->isSelected() ) { 728 if ( it.current()->isSelected() ) {
729 QListIterator<DocLnk> dit( vFiles.children() ); 729 QListIterator<DocLnk> dit( vFiles.children() );
730 for ( ; dit.current(); ++dit ) { 730 for ( ; dit.current(); ++dit ) {
731 if( dit.current()->name() == it.current()->text(0) ) { 731 if( dit.current()->name() == it.current()->text(0) ) {
732 d->selectedFiles->addToSelection( **dit ); 732 d->selectedFiles->addToSelection( **dit );
733 } 733 }
734 } 734 }
735 735
736 videoView->setSelected( it.current(),FALSE); 736 videoView->setSelected( it.current(),FALSE);
737 } 737 }
738 } 738 }
739// for ( int i = 0; i < noOfFiles; i++ ) { 739// for ( int i = 0; i < noOfFiles; i++ ) {
740// QString entryName; 740// QString entryName;
741// entryName.sprintf( "File%i", i + 1 ); 741// entryName.sprintf( "File%i", i + 1 );
742// QString linkFile = cfg.readEntry( entryName ); 742// QString linkFile = cfg.readEntry( entryName );
743// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 743// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
744// int result= QMessageBox::warning(this,tr("OpiePlayer"), 744// int result= QMessageBox::warning(this,tr("OpiePlayer"),
745// tr("This is all ready in your playlist.\nContinue?"), 745// tr("This is all ready in your playlist.\nContinue?"),
746// tr("Yes"),tr("No"),0,0,1); 746// tr("Yes"),tr("No"),0,0,1);
747// if (result !=0) 747// if (result !=0)
748// return; 748// return;
749// } 749// }
750// } 750// }
751// addToSelection( videoView->selectedItem() ); 751// addToSelection( videoView->selectedItem() );
752 tabWidget->setCurrentPage(0); 752 tabWidget->setCurrentPage(0);
753 } 753 }
754 break; 754 break;
755 }; 755 };
756} 756}
757 757
758void PlayListWidget::removeSelected() { 758void PlayListWidget::removeSelected() {
759 d->selectedFiles->removeSelected( ); 759 d->selectedFiles->removeSelected( );
760} 760}
761 761
762void PlayListWidget::playIt( QListViewItem *it) { 762void PlayListWidget::playIt( QListViewItem *it) {
763// d->setDocumentUsed = FALSE; 763// d->setDocumentUsed = FALSE;
764// mediaPlayerState->curPosition =0; 764// mediaPlayerState->curPosition =0;
765 qDebug("playIt"); 765 qDebug("playIt");
766 mediaPlayerState->setPlaying(FALSE); 766 mediaPlayerState->setPlaying(FALSE);
767 mediaPlayerState->setPlaying(TRUE); 767 mediaPlayerState->setPlaying(TRUE);
768 d->selectedFiles->unSelect(); 768 d->selectedFiles->unSelect();
769} 769}
770 770
771void PlayListWidget::addToSelection( QListViewItem *it) { 771void PlayListWidget::addToSelection( QListViewItem *it) {
772 d->setDocumentUsed = FALSE; 772 d->setDocumentUsed = FALSE;
773 773
774 if(it) { 774 if(it) {
775 switch (tabWidget->currentPageIndex()) { 775 switch (tabWidget->currentPageIndex()) {
776 case 1: { 776 case 1: {
777 QListIterator<DocLnk> dit( files.children() ); 777 QListIterator<DocLnk> dit( files.children() );
778 for ( ; dit.current(); ++dit ) { 778 for ( ; dit.current(); ++dit ) {
779 if( dit.current()->name() == it->text(0)) { 779 if( dit.current()->name() == it->text(0)) {
780 d->selectedFiles->addToSelection( **dit ); 780 d->selectedFiles->addToSelection( **dit );
781 } 781 }
782 } 782 }
783 } 783 }
784 break; 784 break;
785 case 2: { 785 case 2: {
786 QListIterator<DocLnk> dit( vFiles.children() ); 786 QListIterator<DocLnk> dit( vFiles.children() );
787 for ( ; dit.current(); ++dit ) { 787 for ( ; dit.current(); ++dit ) {
788 if( dit.current()->name() == it->text(0)) { 788 if( dit.current()->name() == it->text(0)) {
789 d->selectedFiles->addToSelection( **dit ); 789 d->selectedFiles->addToSelection( **dit );
790 } 790 }
791 } 791 }
792 } 792 }
793 break; 793 break;
794 case 0: 794 case 0:
795 break; 795 break;
796 }; 796 };
797 tabWidget->setCurrentPage(0); 797 tabWidget->setCurrentPage(0);
798 } 798 }
799} 799}
800 800
801void PlayListWidget::tabChanged(QWidget *widg) { 801void PlayListWidget::tabChanged(QWidget *widg) {
802 802
803 switch ( tabWidget->currentPageIndex()) { 803 switch ( tabWidget->currentPageIndex()) {
804 case 0: 804 case 0:
805 { 805 {