summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/playlistwidget.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp553
1 files changed, 399 insertions, 154 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 969fc4b..4e1543e 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -22,2 +22,4 @@
22#include <qpe/fileselector.h> 22#include <qpe/fileselector.h>
23#include <qpe/qpeapplication.h>
24
23#include <qpe/applnk.h> 25#include <qpe/applnk.h>
@@ -36,2 +38,6 @@
36#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h>
40#include <qlistview.h>
41#include <qpoint.h>
42#include <qtimer.h>
37 43
@@ -43,2 +49,5 @@
43 49
50#define BUTTONS_ON_TOOLBAR
51#define SIDE_BUTTONS
52#define CAN_SAVE_LOAD_PLAYLISTS
44 53
@@ -46,11 +55,8 @@ extern MediaPlayerState *mediaPlayerState;
46 55
56// class myFileSelector {
47 57
58// };
48class PlayListWidgetPrivate { 59class PlayListWidgetPrivate {
49public: 60public:
50 QToolButton *tbPlay; 61 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
51 QToolButton *tbFull;
52 QToolButton *tbLoop;
53 QToolButton *tbScale;
54 QToolButton *tbShuffle;
55
56 QFrame *playListFrame; 62 QFrame *playListFrame;
@@ -66,10 +72,10 @@ public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 73 : QToolButton( parent, name ) {
68 setTextLabel( name ); 74 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 75 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 76 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 77 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 78 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 80 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 81 }
@@ -81,5 +87,5 @@ public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 87 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 88 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 89 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 90 addTo( parent );
85 } 91 }
@@ -94,2 +100,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
94 d->current = NULL; 100 d->current = NULL;
101 menuTimer = new QTimer( this ,"menu timer"),
102 connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
95 103
@@ -97,3 +105,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
97 105
98 setCaption( tr("MediaPlayer") ); 106 setCaption( tr("OpiePlayer") );
99 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 107 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
@@ -112,67 +120,149 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
112 bar->setLabel( tr( "Play Operations" ) ); 120 bar->setLabel( tr( "Play Operations" ) );
113#ifdef BUTTONS_ON_TOOLBAR 121 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
114 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 122 this , SLOT(addSelected()) );
115 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
116#endif 124 this , SLOT(removeSelected()) );
117 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 125 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
118 d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); 126 mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
119 d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); 127
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132
133// d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
134// d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
120 135
121 QPopupMenu *pmPlayList = new QPopupMenu( this ); 136 QPopupMenu *pmPlayList = new QPopupMenu( this );
122 menu->insertItem( tr( "PlayList" ), pmPlayList ); 137 menu->insertItem( tr( "File" ), pmPlayList );
123 new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) );
124 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 138 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
125 new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
126 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 140 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
127 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 141 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
128#ifdef CAN_SAVE_LOAD_PLAYLISTS
129 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 142 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
130 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 143 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
131#endif 144
145 QPopupMenu *pmView = new QPopupMenu( this );
146 menu->insertItem( tr( "View" ), pmView );
147
148 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
149 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
150 fullScreenButton->addTo(pmView);
151 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
152 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
153 scaleButton->addTo(pmView);
132 154
133 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 155 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
156 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
157// vbox4->setMargin(4);
158// libString = new QLabel( tr(" Media Library"), vbox4 );
159// libString->setBackgroundMode( QButton::PaletteButton );
160// libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
161
162 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
163
164 tabWidget = new QTabWidget( hbox6, "tabWidget" );
165 tabWidget->setTabShape(QTabWidget::Triangular);
166
167
168 QWidget *pTab;
169 pTab = new QWidget( tabWidget, "pTab" );
170 playlistView = new QListView( pTab, "Videoview" );
171 playlistView->setMinimumSize(236,260);
172 tabWidget->insertTab( pTab,"Playlist");
134 173
135 // Add the playlist area 174 // Add the playlist area
136 QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton );
137 d->playListFrame = vbox3;
138 175
139 QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); 176 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
140 plString->setBackgroundMode( QButton::PaletteButton ); 177 d->playListFrame = vbox3;
141 plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); 178 d->playListFrame ->setMinimumSize(235,260);
142 179
143 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 180 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
144 d->selectedFiles = new PlayListSelection( hbox2 ); 181 d->selectedFiles = new PlayListSelection( hbox2);
145 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 182 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
146 183
147#ifndef BUTTONS_ON_TOOLBAR 184 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
148 d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 185 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
149 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 186 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
150#endif 187 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
151 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 188 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
152 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 189
153 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 190 QWidget *aTab;
154 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 191 aTab = new QWidget( tabWidget, "aTab" );
155#ifndef BUTTONS_ON_TOOLBAR 192 audioView = new QListView( aTab, "Audioview" );
156 d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 193 audioView->setMinimumSize(233,260);
157#endif 194 audioView->addColumn( "Title",150);
195 audioView->addColumn("Size", 45);
196 audioView->addColumn("Media",35);
197 audioView->setColumnAlignment(1, Qt::AlignRight);
198 audioView->setColumnAlignment(2, Qt::AlignRight);
199 tabWidget->insertTab(aTab,"Audio");
200// audioView
201 Global::findDocuments(&files, "audio/*");
202 QListIterator<DocLnk> dit( files.children() );
203 QString storage;
204 for ( ; dit.current(); ++dit ) {
205 QListViewItem * newItem;
206 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
207 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
208 else storage="RAM";
209
210 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
211 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
212 }
213// videowidget
214
215 QWidget *vTab;
216 vTab = new QWidget( tabWidget, "vTab" );
217 videoView = new QListView( vTab, "Videoview" );
218 videoView->setMinimumSize(233,260);
219
220 videoView->addColumn("Title",150);
221 videoView->addColumn("Size",45);
222 videoView->addColumn("Media",35);
223 videoView->setColumnAlignment(1, Qt::AlignRight);
224 videoView->setColumnAlignment(2, Qt::AlignRight);
225
226 tabWidget->insertTab( vTab,"Video");
227
228 Global::findDocuments(&vFiles, "video/*");
229 QListIterator<DocLnk> Vdit( vFiles.children() );
230 for ( ; Vdit.current(); ++Vdit ) {
231 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
232 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
233 else storage="RAM";
234 QListViewItem * newItem;
235 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
236 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
237 }
238
239
240// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
241// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
158 242
159 // add the library area 243 // add the library area
160 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
161 244
162 QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); 245// d->files->setBackgroundMode( PaletteButton );
163 libString->setBackgroundMode( QButton::PaletteButton ); 246// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
164 libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
165 247
166 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 248// #ifdef SIDE_BUTTONS
167 d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); 249// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
168 d->files->setBackgroundMode( PaletteButton ); 250// #endif
169 QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); 251 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
252
253// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
254// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
170 255
171#ifdef SIDE_BUTTONS 256 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
172 new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); 257 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
173 new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) );
174 QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
175#endif
176 258
177 connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 259 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
260 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
261 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
262 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
263
264 connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
265 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
266 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
267 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
178 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 268 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
@@ -180,5 +270,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
180 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 270 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
181 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); 271
182 connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); 272// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) );
183 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); 273// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) );
274// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
275
184 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 276 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
@@ -199,3 +291,3 @@ PlayListWidget::~PlayListWidget() {
199 if ( d->current ) 291 if ( d->current )
200 delete d->current; 292 delete d->current;
201 delete d; 293 delete d;
@@ -205,2 +297,3 @@ PlayListWidget::~PlayListWidget() {
205void PlayListWidget::initializeStates() { 297void PlayListWidget::initializeStates() {
298
206 d->tbPlay->setOn( mediaPlayerState->playing() ); 299 d->tbPlay->setOn( mediaPlayerState->playing() );
@@ -208,6 +301,6 @@ void PlayListWidget::initializeStates() {
208 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 301 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
209 d->tbFull->setOn( mediaPlayerState->fullscreen() ); 302// d->tbFull->setOn( mediaPlayerState->fullscreen() );
210 d->tbScale->setOn( mediaPlayerState->scaled() ); 303// d->tbScale->setOn( mediaPlayerState->scaled() );
211 d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 304// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
212 setPlaylist( mediaPlayerState->playlist() ); 305// setPlaylist( mediaPlayerState->playlist() );
213} 306}
@@ -221,7 +314,7 @@ void PlayListWidget::readConfig( Config& cfg ) {
221 for ( int i = 0; i < noOfFiles; i++ ) { 314 for ( int i = 0; i < noOfFiles; i++ ) {
222 QString entryName; 315 QString entryName;
223 entryName.sprintf( "File%i", i + 1 ); 316 entryName.sprintf( "File%i", i + 1 );
224 QString linkFile = cfg.readEntry( entryName ); 317 QString linkFile = cfg.readEntry( entryName );
225 DocLnk lnk( linkFile ); 318 DocLnk lnk( linkFile );
226 if ( lnk.isValid() ) 319 if ( lnk.isValid() )
227 d->selectedFiles->addToSelection( lnk ); 320 d->selectedFiles->addToSelection( lnk );
@@ -239,24 +332,24 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
239 do { 332 do {
240 const DocLnk *lnk = d->selectedFiles->current(); 333 const DocLnk *lnk = d->selectedFiles->current();
241 if ( lnk ) { 334 if ( lnk ) {
242 QString entryName; 335 QString entryName;
243 entryName.sprintf( "File%i", noOfFiles + 1 ); 336 entryName.sprintf( "File%i", noOfFiles + 1 );
244 cfg.writeEntry( entryName, lnk->linkFile() ); 337 cfg.writeEntry( entryName, lnk->linkFile() );
245 // if this link does exist, add it so we have the file 338 // if this link does exist, add it so we have the file
246 // next time... 339 // next time...
247 if ( !QFile::exists( lnk->linkFile() ) ) { 340 if ( !QFile::exists( lnk->linkFile() ) ) {
248 // the way writing lnks doesn't really check for out 341 // the way writing lnks doesn't really check for out
249 // of disk space, but check it anyway. 342 // of disk space, but check it anyway.
250 if ( !lnk->writeLink() ) { 343 if ( !lnk->writeLink() ) {
251 QMessageBox::critical( 0, tr("Out of space"), 344 QMessageBox::critical( 0, tr("Out of space"),
252 tr( "There was a problem saving " 345 tr( "There was a problem saving "
253 "the playlist.\n" 346 "the playlist.\n"
254 "Your playlist " 347 "Your playlist "
255 "may be missing some entries\n" 348 "may be missing some entries\n"
256 "the next time you start it." ) 349 "the next time you start it." )
257 ); 350 );
258 } 351 }
259 } 352 }
260 noOfFiles++; 353 noOfFiles++;
261 } 354 }
262 } while ( d->selectedFiles->next() ); 355 } while ( d->selectedFiles->next() );
@@ -268,3 +361,3 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
268void PlayListWidget::addToSelection( const DocLnk& lnk ) { 361void PlayListWidget::addToSelection( const DocLnk& lnk ) {
269 d->setDocumentUsed = FALSE; 362 d->setDocumentUsed = FALSE;
270 if ( mediaPlayerState->playlist() ) 363 if ( mediaPlayerState->playlist() )
@@ -272,3 +365,13 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
272 else 365 else
273 mediaPlayerState->setPlaying( TRUE ); 366 mediaPlayerState->setPlaying( TRUE );
367}
368
369
370void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
371 qDebug("add");
372// d->selectedFiles->addToSelection( lnk );
373 // }
374// else
375// mediaPlayerState->setPlaying( TRUE );
376//
274} 377}
@@ -278,3 +381,3 @@ void PlayListWidget::clearList() {
278 while ( first() ) 381 while ( first() )
279 d->selectedFiles->removeSelected(); 382 d->selectedFiles->removeSelected();
280} 383}
@@ -311,12 +414,12 @@ void PlayListWidget::setDocument(const QString& fileref) {
311 if ( fileref.isNull() ) { 414 if ( fileref.isNull() ) {
312 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 415 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
313 return; 416 return;
314 } 417 }
315 if ( mediaPlayerState->playlist() ) 418 if ( mediaPlayerState->playlist() )
316 addToSelection( DocLnk( fileref ) ); 419 addToSelection( DocLnk( fileref ) );
317 else { 420 else {
318 d->setDocumentUsed = TRUE; 421 d->setDocumentUsed = TRUE;
319 if ( d->current ) 422 if ( d->current )
320 delete d->current; 423 delete d->current;
321 d->current = new DocLnk( fileref ); 424 d->current = new DocLnk( fileref );
322 } 425 }
@@ -342,7 +445,7 @@ const DocLnk *PlayListWidget::current() {
342 if ( mediaPlayerState->playlist() ) 445 if ( mediaPlayerState->playlist() )
343 return d->selectedFiles->current(); 446 return d->selectedFiles->current();
344 else if ( d->setDocumentUsed && d->current ) { 447 else if ( d->setDocumentUsed && d->current ) {
345 return d->current; 448 return d->current;
346 } else 449 } else
347 return d->files->selected(); 450 return d->files->selected();
348} 451}
@@ -352,25 +455,25 @@ bool PlayListWidget::prev() {
352 if ( mediaPlayerState->playlist() ) { 455 if ( mediaPlayerState->playlist() ) {
353 if ( mediaPlayerState->shuffled() ) { 456 if ( mediaPlayerState->shuffled() ) {
354 const DocLnk *cur = current(); 457 const DocLnk *cur = current();
355 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 458 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
356 for ( int i = 0; i < j; i++ ) { 459 for ( int i = 0; i < j; i++ ) {
357 if ( !d->selectedFiles->next() ) 460 if ( !d->selectedFiles->next() )
358 d->selectedFiles->first(); 461 d->selectedFiles->first();
359 } 462 }
360 if ( cur == current() ) 463 if ( cur == current() )
361 if ( !d->selectedFiles->next() ) 464 if ( !d->selectedFiles->next() )
362 d->selectedFiles->first(); 465 d->selectedFiles->first();
363 return TRUE; 466 return TRUE;
364 } else { 467 } else {
365 if ( !d->selectedFiles->prev() ) { 468 if ( !d->selectedFiles->prev() ) {
366 if ( mediaPlayerState->looping() ) { 469 if ( mediaPlayerState->looping() ) {
367 return d->selectedFiles->last(); 470 return d->selectedFiles->last();
368 } else { 471 } else {
369 return FALSE; 472 return FALSE;
370 } 473 }
371 } 474 }
372 return TRUE; 475 return TRUE;
373 } 476 }
374 } else { 477 } else {
375 return mediaPlayerState->looping(); 478 return mediaPlayerState->looping();
376 } 479 }
@@ -381,16 +484,16 @@ bool PlayListWidget::next() {
381 if ( mediaPlayerState->playlist() ) { 484 if ( mediaPlayerState->playlist() ) {
382 if ( mediaPlayerState->shuffled() ) { 485 if ( mediaPlayerState->shuffled() ) {
383 return prev(); 486 return prev();
384 } else { 487 } else {
385 if ( !d->selectedFiles->next() ) { 488 if ( !d->selectedFiles->next() ) {
386 if ( mediaPlayerState->looping() ) { 489 if ( mediaPlayerState->looping() ) {
387 return d->selectedFiles->first(); 490 return d->selectedFiles->first();
388 } else {
389 return FALSE;
390 }
391 }
392 return TRUE;
393 }
394 } else { 491 } else {
395 return mediaPlayerState->looping(); 492 return FALSE;
493 }
494 }
495 return TRUE;
496 }
497 } else {
498 return mediaPlayerState->looping();
396 } 499 }
@@ -401,5 +504,5 @@ bool PlayListWidget::first() {
401 if ( mediaPlayerState->playlist() ) 504 if ( mediaPlayerState->playlist() )
402 return d->selectedFiles->first(); 505 return d->selectedFiles->first();
403 else 506 else
404 return mediaPlayerState->looping(); 507 return mediaPlayerState->looping();
405} 508}
@@ -409,5 +512,5 @@ bool PlayListWidget::last() {
409 if ( mediaPlayerState->playlist() ) 512 if ( mediaPlayerState->playlist() )
410 return d->selectedFiles->last(); 513 return d->selectedFiles->last();
411 else 514 else
412 return mediaPlayerState->looping(); 515 return mediaPlayerState->looping();
413} 516}
@@ -435,5 +538,5 @@ void PlayListWidget::setPlaylist( bool shown ) {
435 if ( shown ) 538 if ( shown )
436 d->playListFrame->show(); 539 d->playListFrame->show();
437 else 540 else
438 d->playListFrame->hide(); 541 d->playListFrame->hide();
439} 542}
@@ -443,6 +546,148 @@ void PlayListWidget::setView( char view ) {
443 if ( view == 'l' ) 546 if ( view == 'l' )
444 showMaximized(); 547 showMaximized();
445 else 548 else
446 hide(); 549 hide();
550}
551
552void PlayListWidget::addSelected() {
553// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here");
554 int tabPage=tabWidget->currentPageIndex();
555 switch (tabPage) {
556 case 0: //playlist
557 break;
558 case 1: { //audio
559 addToSelection( audioView->selectedItem() );
560 }
561 break;
562 case 2: { // video
563 addToSelection( videoView->selectedItem() );
564 }
565 break;
566 };
567}
568
569void PlayListWidget::removeSelected() {
570 d->selectedFiles->removeSelected( );
571}
572
573
574void PlayListWidget::playIt( QListViewItem *it) {
575 d->setDocumentUsed = FALSE;
576
577 if(it) {
578 qDebug("playit");
579 int tabPage=tabWidget->currentPageIndex();
580 switch (tabPage) {
581 case 1: {
582 DocLnkSet files;
583 QListIterator<DocLnk> dit( files.children() );
584 for ( ; dit.current(); ++dit ) {
585 if( dit.current()->name() == it->text(0)) {
586 setDocument( dit.current()->name());
587 }
588 }
589 }
590 break;
591 case 2: {
592 DocLnkSet vFiles;
593 QListIterator<DocLnk> dit( vFiles.children() );
594 for ( ; dit.current(); ++dit ) {
595 qDebug(dit.current()->name());
596 if( dit.current()->name() == it->text(0)) {
597 qDebug(it->text(0));
598 setDocument( dit.current()->name());
599 }
600 }
601 }
602 break;
603 };
604 }
605}
606
607void PlayListWidget::addToSelection( QListViewItem *it) {
608 d->setDocumentUsed = FALSE;
609
610 if(it) {
611 qDebug("add to selection");
612 int tabPage=tabWidget->currentPageIndex();
613 switch (tabPage) {
614 case 1: {
615 QListIterator<DocLnk> dit( files.children() );
616 for ( ; dit.current(); ++dit ) {
617 if( dit.current()->name() == it->text(0)) {
618 d->selectedFiles->addToSelection( **dit );
619 }
620 }
621 }
622 break;
623 case 2: {
624 QListIterator<DocLnk> dit( vFiles.children() );
625 for ( ; dit.current(); ++dit ) {
626 qDebug(dit.current()->name());
627 if( dit.current()->name() == it->text(0)) {
628 d->selectedFiles->addToSelection( **dit );
629 }
630 }
631 }
632 break;
633 case 0:
634 break;
635 };
636 tabWidget->setCurrentPage(0);
637// mediaPlayerState->setPlaying( TRUE );
638 }
639}
640
641void PlayListWidget::tabChanged(QWidget *widg) {
642
643 int tabPage=tabWidget->currentPageIndex();
644 switch (tabPage) {
645 case 0:
646 {
647 d->tbRemoveFromList->setEnabled(TRUE);
648 d->tbAddToList->setEnabled(FALSE);
649 }
650 break;
651 case 1:
652 {
653 d->tbRemoveFromList->setEnabled(FALSE);
654 d->tbAddToList->setEnabled(TRUE);
655 }
656 break;
657 case 2:
658 {
659 d->tbRemoveFromList->setEnabled(FALSE);
660 d->tbAddToList->setEnabled(TRUE);
661 }
662 break;
663 };
664}
665
666void PlayListWidget::cancelMenuTimer() {
667 if( menuTimer->isActive() )
668 menuTimer->stop();
669}
670
671void PlayListWidget::showFileMenu() {
672
673}
674
675void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
676{
677// QListView::contentsMousePressEvent( e );
678 menuTimer->start( 750, TRUE );
679}
680
681
682void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e )
683{
684// QListView::contentsMouseReleaseEvent( e );
685 menuTimer->stop();
447} 686}
687// void PlayListWidget::setFullScreen() {
688// mediaPlayerState->toggleFullscreen( );
689// }
448 690
691// void PlayListWidget::setScaled() {
692// mediaPlayerState->toggleScaled();
693// }