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