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