summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp15
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp30
2 files changed, 29 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 62240b2..2c4be1b 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,62 +1,69 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2 2
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4#include <qpe/qpeapplication.h>
5#include <qpe/config.h>
5#include <opie/ofiledialog.h> 6#include <opie/ofiledialog.h>
6 7
8#include <qfileinfo.h>
7#include <qlineedit.h> 9#include <qlineedit.h>
8#include <qlayout.h> 10#include <qlayout.h>
9#include <qvariant.h> 11#include <qvariant.h>
10#include <qpushbutton.h> 12#include <qpushbutton.h>
11#include <qwhatsthis.h> 13#include <qwhatsthis.h>
12 14
13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 15InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl ) { 16 : QDialog( parent, name, modal, fl ) {
15 if ( !name ) { 17 if ( !name ) {
16 setName( "InputDialog" ); 18 setName( "InputDialog" );
17 } 19 }
18 resize( 234, 115); 20 resize( 234, 115);
19 setMaximumSize( QSize( 240, 40)); 21 setMaximumSize( QSize( 240, 40));
20 setCaption( tr( name ) ); 22 setCaption( tr( name ) );
21 23
22 QPushButton *browserButton; 24 QPushButton *browserButton;
23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 25 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
24 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 26 browserButton->setGeometry( QRect( 205, 10, 22, 22));
25 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 27 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
26 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 28 LineEdit1 = new QLineEdit( this, "LineEdit1" );
27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 29 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28 LineEdit1->setFocus(); 30 LineEdit1->setFocus();
29} 31}
30/* 32/*
31 * return the current text(input) 33 * return the current text(input)
32 */ 34 */
33QString InputDialog::text() const { 35QString InputDialog::text() const {
34 return LineEdit1->text(); 36 return LineEdit1->text();
35} 37}
36/* 38/*
37 * Destroys the object and frees any allocated resources 39 * Destroys the object and frees any allocated resources
38 */ 40 */
39InputDialog::~InputDialog() { 41InputDialog::~InputDialog() {
40} 42}
41 43
42void InputDialog::browse() { 44void InputDialog::browse() {
43 45 Config cfg( "OpiePlayer" );
44 MimeTypes types; 46 cfg.setGroup("Dialog");
47 MimeTypes types;
45 QStringList audio, video, all; 48 QStringList audio, video, all;
46 audio << "audio/*"; 49 audio << "audio/*";
47 audio << "playlist/plain"; 50 audio << "playlist/plain";
48 audio << "audio/x-mpegurl"; 51 audio << "audio/x-mpegurl";
49 52
50 video << "video/*"; 53 video << "video/*";
51 video << "playlist/plain"; 54 video << "playlist/plain";
52 55
53 all += audio; 56 all += audio;
54 all += video; 57 all += video;
55 types.insert("All Media Files", all ); 58 types.insert("All Media Files", all );
56 types.insert("Audio", audio ); 59 types.insert("Audio", audio );
57 types.insert("Video", video ); 60 types.insert("Video", video );
58 61
59 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 62 QString str = OFileDialog::getOpenFileName( 1,
63 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
64 types, 0 );
65 if(str.left(2) == "//") str=str.right(str.length()-1);
60 LineEdit1->setText(str); 66 LineEdit1->setText(str);
67 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
61} 68}
62 69
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b15f95e..0825eed 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1066 +1,1072 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50#include "om3u.h" 50#include "om3u.h"
51 51
52//only needed for the random play 52//only needed for the random play
53#include <stdlib.h> 53#include <stdlib.h>
54 54
55#include "audiowidget.h" 55#include "audiowidget.h"
56#include "videowidget.h" 56#include "videowidget.h"
57 57
58extern MediaPlayerState *mediaPlayerState; 58extern MediaPlayerState *mediaPlayerState;
59 59
60QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 60QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
61// no m3u's here please 61// no m3u's here please
62 62
63PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 63PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
64 : PlayListWidgetGui( parent, name, fl ) { 64 : PlayListWidgetGui( parent, name, fl ) {
65 65
66 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 66 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
67 "opieplayer2/add_to_playlist", 67 "opieplayer2/add_to_playlist",
68 this , SLOT(addSelected() ) ); 68 this , SLOT(addSelected() ) );
69 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 69 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
70 "opieplayer2/remove_from_playlist", 70 "opieplayer2/remove_from_playlist",
71 this , SLOT(removeSelected() ) ); 71 this , SLOT(removeSelected() ) );
72 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 72 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
73 this , SLOT( btnPlay( bool) ), TRUE ); 73 this , SLOT( btnPlay( bool) ), TRUE );
74 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 74 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
75 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 75 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
76 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 76 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
77 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 77 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
78 78
79 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 79 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
81 this, SLOT( addAllMusicToList() ) ); 81 this, SLOT( addAllMusicToList() ) );
82 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 82 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
83 this, SLOT( addAllVideoToList() ) ); 83 this, SLOT( addAllVideoToList() ) );
84 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 84 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
85 this, SLOT( addAllToList() ) ); 85 this, SLOT( addAllToList() ) );
86 pmPlayList->insertSeparator(-1); 86 pmPlayList->insertSeparator(-1);
87// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 87// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
88// this, SLOT( saveList() ) ); 88// this, SLOT( saveList() ) );
89 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 89 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
90 this, SLOT(writem3u() ) ); 90 this, SLOT(writem3u() ) );
91 pmPlayList->insertSeparator(-1); 91 pmPlayList->insertSeparator(-1);
92 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 92 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
93 this,SLOT( openFile() ) ); 93 this,SLOT( openFile() ) );
94 pmPlayList->insertSeparator(-1); 94 pmPlayList->insertSeparator(-1);
95 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 95 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
96 this,SLOT( scanForAudio() ) ); 96 this,SLOT( scanForAudio() ) );
97 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 97 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
98 this,SLOT( scanForVideo() ) ); 98 this,SLOT( scanForVideo() ) );
99 99
100 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 100 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
101 mediaPlayerState, SLOT( toggleFullscreen() ) ); 101 mediaPlayerState, SLOT( toggleFullscreen() ) );
102 102
103 Config cfg( "OpiePlayer" ); 103 Config cfg( "OpiePlayer" );
104 bool b= cfg.readBoolEntry("FullScreen", 0); 104 bool b= cfg.readBoolEntry("FullScreen", 0);
105 mediaPlayerState->setFullscreen( b ); 105 mediaPlayerState->setFullscreen( b );
106 pmView->setItemChecked( -16, b ); 106 pmView->setItemChecked( -16, b );
107 107
108 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 108 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
109 d->selectedFiles, SLOT(moveSelectedUp() ) ); 109 d->selectedFiles, SLOT(moveSelectedUp() ) );
110 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 110 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
111 d->selectedFiles, SLOT(removeSelected() ) ); 111 d->selectedFiles, SLOT(removeSelected() ) );
112 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 112 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
113 d->selectedFiles, SLOT(moveSelectedDown() ) ); 113 d->selectedFiles, SLOT(moveSelectedDown() ) );
114 QVBox *stretch2 = new QVBox( vbox1 ); 114 QVBox *stretch2 = new QVBox( vbox1 );
115 115
116 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 116 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
117 SLOT( deletePlaylist() ) ); 117 SLOT( deletePlaylist() ) );
118 connect( pmView, SIGNAL( activated( int ) ), 118 connect( pmView, SIGNAL( activated( int ) ),
119 this, SLOT( pmViewActivated( int ) ) ); 119 this, SLOT( pmViewActivated( int ) ) );
120 connect( skinsMenu, SIGNAL( activated( int ) ) , 120 connect( skinsMenu, SIGNAL( activated( int ) ) ,
121 this, SLOT( skinsMenuActivated( int ) ) ); 121 this, SLOT( skinsMenuActivated( int ) ) );
122 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 122 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
123 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 123 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
124 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 124 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
125 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 125 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
126 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 126 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
127 this,SLOT( playIt( QListViewItem *) ) ); 127 this,SLOT( playIt( QListViewItem *) ) );
128 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 128 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
129 this, SLOT( addToSelection( QListViewItem *) ) ); 129 this, SLOT( addToSelection( QListViewItem *) ) );
130 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 130 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
131 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 131 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
132 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 132 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
133 this,SLOT( playIt( QListViewItem *) ) ); 133 this,SLOT( playIt( QListViewItem *) ) );
134 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 134 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
135 this, SLOT( addToSelection( QListViewItem *) ) ); 135 this, SLOT( addToSelection( QListViewItem *) ) );
136 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 136 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
137 this, SLOT( loadList( const DocLnk & ) ) ); 137 this, SLOT( loadList( const DocLnk & ) ) );
138 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 138 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
139 this, SLOT( tabChanged( QWidget* ) ) ); 139 this, SLOT( tabChanged( QWidget* ) ) );
140 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 140 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
141 d->tbPlay, SLOT( setOn( bool ) ) ); 141 d->tbPlay, SLOT( setOn( bool ) ) );
142 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 142 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
143 d->tbLoop, SLOT( setOn( bool ) ) ); 143 d->tbLoop, SLOT( setOn( bool ) ) );
144 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
145 d->tbShuffle, SLOT( setOn( bool ) ) ); 145 d->tbShuffle, SLOT( setOn( bool ) ) );
146 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 146 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
147 this, SLOT( setPlaylist( bool ) ) ); 147 this, SLOT( setPlaylist( bool ) ) );
148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
149 this, SLOT( playIt( QListViewItem *) ) ); 149 this, SLOT( playIt( QListViewItem *) ) );
150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
151 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 151 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
152 152
153 // see which skins are installed 153 // see which skins are installed
154 videoScan=FALSE; 154 videoScan=FALSE;
155 audioScan=FALSE; 155 audioScan=FALSE;
156 populateSkinsMenu(); 156 populateSkinsMenu();
157 initializeStates(); 157 initializeStates();
158 158
159 cfg.setGroup("PlayList"); 159 cfg.setGroup("PlayList");
160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 160 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
161 loadList(DocLnk( currentPlaylist ) ); 161 loadList(DocLnk( currentPlaylist ) );
162 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 162
163} 163}
164 164
165 165
166PlayListWidget::~PlayListWidget() { 166PlayListWidget::~PlayListWidget() {
167 if ( d->current ) { 167 if ( d->current ) {
168 delete d->current; 168 delete d->current;
169 } 169 }
170 delete d; 170 delete d;
171} 171}
172 172
173 173
174void PlayListWidget::initializeStates() { 174void PlayListWidget::initializeStates() {
175 d->tbPlay->setOn( mediaPlayerState->playing() ); 175 d->tbPlay->setOn( mediaPlayerState->playing() );
176 d->tbLoop->setOn( mediaPlayerState->looping() ); 176 d->tbLoop->setOn( mediaPlayerState->looping() );
177 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 177 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
178 setPlaylist( true ); 178 setPlaylist( true );
179} 179}
180 180
181void PlayListWidget::writeDefaultPlaylist() { 181void PlayListWidget::writeDefaultPlaylist() {
182 182
183 Config config( "OpiePlayer" ); 183 Config config( "OpiePlayer" );
184 config.setGroup( "PlayList" ); 184 config.setGroup( "PlayList" );
185 QString filename=QPEApplication::documentDir() + "/default.m3u"; 185 QString filename=QPEApplication::documentDir() + "/default.m3u";
186 QString currentString = config.readEntry( "CurrentPlaylist", filename); 186 QString currentString = config.readEntry( "CurrentPlaylist", filename);
187 if( currentString == filename) { 187 if( currentString == filename) {
188 Om3u *m3uList; 188 Om3u *m3uList;
189 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 189 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
190 if( d->selectedFiles->first() ) { 190 if( d->selectedFiles->first() ) {
191 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 191 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
192 do { 192 do {
193 // qDebug(d->selectedFiles->current()->file()); 193 // qDebug(d->selectedFiles->current()->file());
194 m3uList->add( d->selectedFiles->current()->file() ); 194 m3uList->add( d->selectedFiles->current()->file() );
195 } 195 }
196 while ( d->selectedFiles->next() ); 196 while ( d->selectedFiles->next() );
197 197
198 m3uList->write(); 198 m3uList->write();
199 m3uList->close(); 199 m3uList->close();
200 if(m3uList) delete m3uList; 200 if(m3uList) delete m3uList;
201 201
202 } 202 }
203 } 203 }
204} 204}
205 205
206void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
207 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
208 if ( mediaPlayerState->playlist() ) { 208 if ( mediaPlayerState->playlist() ) {
209 if( QFileInfo( lnk.file() ).exists() || 209 if( QFileInfo( lnk.file() ).exists() ||
210 lnk.file().left(4) == "http" ) 210 lnk.file().left(4) == "http" )
211 d->selectedFiles->addToSelection( lnk ); 211 d->selectedFiles->addToSelection( lnk );
212// writeCurrentM3u(); 212// writeCurrentM3u();
213 } 213 }
214 else 214 else
215 mediaPlayerState->setPlaying( TRUE ); 215 mediaPlayerState->setPlaying( TRUE );
216} 216}
217 217
218 218
219void PlayListWidget::clearList() { 219void PlayListWidget::clearList() {
220 while ( first() ) { 220 while ( first() ) {
221 d->selectedFiles->removeSelected(); 221 d->selectedFiles->removeSelected();
222 } 222 }
223} 223}
224 224
225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
226 switch (mouse) { 226 switch (mouse) {
227 case 1: 227 case 1:
228 break; 228 break;
229 case 2: 229 case 2:
230 { 230 {
231 QPopupMenu m; 231 QPopupMenu m;
232 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 232 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
234 m.exec( QCursor::pos() ); 234 m.exec( QCursor::pos() );
235 } 235 }
236 break; 236 break;
237 } 237 }
238} 238}
239 239
240 240
241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
242 switch (mouse) { 242 switch (mouse) {
243 case 1: 243 case 1:
244 break; 244 break;
245 case 2: 245 case 2:
246 { 246 {
247 QPopupMenu m; 247 QPopupMenu m;
248 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 248 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
250 m.exec( QCursor::pos() ); 250 m.exec( QCursor::pos() );
251 } 251 }
252 break; 252 break;
253 } 253 }
254} 254}
255 255
256 256
257void PlayListWidget::addAllToList() { 257void PlayListWidget::addAllToList() {
258 DocLnkSet filesAll; 258 DocLnkSet filesAll;
259 Global::findDocuments(&filesAll, "video/*;"+audioMimes); 259 Global::findDocuments(&filesAll, "video/*;"+audioMimes);
260 QListIterator<DocLnk> Adit( filesAll.children() ); 260 QListIterator<DocLnk> Adit( filesAll.children() );
261 for ( ; Adit.current(); ++Adit ) { 261 for ( ; Adit.current(); ++Adit ) {
262 if( QFileInfo( Adit.current()->file() ).exists() ) { 262 if( QFileInfo( Adit.current()->file() ).exists() ) {
263 d->selectedFiles->addToSelection( **Adit ); 263 d->selectedFiles->addToSelection( **Adit );
264 } 264 }
265 } 265 }
266 writeCurrentM3u(); 266 writeCurrentM3u();
267} 267}
268 268
269 269
270void PlayListWidget::addAllMusicToList() { 270void PlayListWidget::addAllMusicToList() {
271 if(!audioScan) 271 if(!audioScan)
272 scanForAudio(); 272 scanForAudio();
273 QListIterator<DocLnk> dit( files.children() ); 273 QListIterator<DocLnk> dit( files.children() );
274 for ( ; dit.current(); ++dit ) { 274 for ( ; dit.current(); ++dit ) {
275 if( QFileInfo(dit.current()->file() ).exists() ) { 275 if( QFileInfo(dit.current()->file() ).exists() ) {
276 d->selectedFiles->addToSelection( **dit ); 276 d->selectedFiles->addToSelection( **dit );
277 } 277 }
278 } 278 }
279 writeCurrentM3u(); 279 writeCurrentM3u();
280} 280}
281 281
282 282
283void PlayListWidget::addAllVideoToList() { 283void PlayListWidget::addAllVideoToList() {
284 if(!videoScan) 284 if(!videoScan)
285 scanForVideo(); 285 scanForVideo();
286 QListIterator<DocLnk> dit( vFiles.children() ); 286 QListIterator<DocLnk> dit( vFiles.children() );
287 for ( ; dit.current(); ++dit ) { 287 for ( ; dit.current(); ++dit ) {
288 if( QFileInfo( dit.current()->file() ).exists() ) { 288 if( QFileInfo( dit.current()->file() ).exists() ) {
289 d->selectedFiles->addToSelection( **dit ); 289 d->selectedFiles->addToSelection( **dit );
290 } 290 }
291 } 291 }
292 writeCurrentM3u(); 292 writeCurrentM3u();
293} 293}
294 294
295 295
296void PlayListWidget::setDocument( const QString& fileref ) { 296void PlayListWidget::setDocument( const QString& fileref ) {
297 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 297 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
298 fromSetDocument = TRUE; 298 fromSetDocument = TRUE;
299 if ( fileref.isNull() ) { 299 if ( fileref.isNull() ) {
300 QMessageBox::critical( 0, tr( "Invalid File" ), 300 QMessageBox::critical( 0, tr( "Invalid File" ),
301 tr( "There was a problem in getting the file." ) ); 301 tr( "There was a problem in getting the file." ) );
302 return; 302 return;
303 } 303 }
304 304
305 clearList(); 305 clearList();
306 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 306 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
307 readm3u( fileref ); 307 readm3u( fileref );
308 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 308 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
309 readm3u( DocLnk( fileref).file() ); 309 readm3u( DocLnk( fileref).file() );
310 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 310 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
311 readPls( fileref ); 311 readPls( fileref );
312 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 312 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
313 readPls( DocLnk( fileref).file() ); 313 readPls( DocLnk( fileref).file() );
314 } else { 314 } else {
315 clearList(); 315 clearList();
316 addToSelection( DocLnk( fileref ) ); 316 addToSelection( DocLnk( fileref ) );
317 writeCurrentM3u(); 317 writeCurrentM3u();
318 318
319 d->setDocumentUsed = TRUE; 319 d->setDocumentUsed = TRUE;
320 mediaPlayerState->setPlaying( FALSE ); 320 mediaPlayerState->setPlaying( FALSE );
321 mediaPlayerState->setPlaying( TRUE ); 321 mediaPlayerState->setPlaying( TRUE );
322 } 322 }
323} 323}
324 324
325 325
326void PlayListWidget::useSelectedDocument() { 326void PlayListWidget::useSelectedDocument() {
327 d->setDocumentUsed = FALSE; 327 d->setDocumentUsed = FALSE;
328} 328}
329 329
330 330
331const DocLnk *PlayListWidget::current() { // this is fugly 331const DocLnk *PlayListWidget::current() { // this is fugly
332 switch ( whichList() ) { 332 switch ( whichList() ) {
333 case 0: //playlist 333 case 0: //playlist
334 { 334 {
335// qDebug("playlist"); 335// qDebug("playlist");
336 if ( mediaPlayerState->playlist() ) { 336 if ( mediaPlayerState->playlist() ) {
337 return d->selectedFiles->current(); 337 return d->selectedFiles->current();
338 } else if ( d->setDocumentUsed && d->current ) { 338 } else if ( d->setDocumentUsed && d->current ) {
339 return d->current; 339 return d->current;
340 } else { 340 } else {
341 return &(d->files->selectedDocument()); 341 return &(d->files->selectedDocument());
342 } 342 }
343 } 343 }
344 break; 344 break;
345 }; 345 };
346 return 0; 346 return 0;
347} 347}
348 348
349 349
350bool PlayListWidget::prev() { 350bool PlayListWidget::prev() {
351 if ( mediaPlayerState->playlist() ) { 351 if ( mediaPlayerState->playlist() ) {
352 if ( mediaPlayerState->shuffled() ) { 352 if ( mediaPlayerState->shuffled() ) {
353 const DocLnk *cur = current(); 353 const DocLnk *cur = current();
354 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 354 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
355 for ( int i = 0; i < j; i++ ) { 355 for ( int i = 0; i < j; i++ ) {
356 if ( !d->selectedFiles->next() ) 356 if ( !d->selectedFiles->next() )
357 d->selectedFiles->first(); 357 d->selectedFiles->first();
358 } 358 }
359 if ( cur == current() ) 359 if ( cur == current() )
360 if ( !d->selectedFiles->next() ) { 360 if ( !d->selectedFiles->next() ) {
361 d->selectedFiles->first(); 361 d->selectedFiles->first();
362 } 362 }
363 return TRUE; 363 return TRUE;
364 } else { 364 } else {
365 if ( !d->selectedFiles->prev() ) { 365 if ( !d->selectedFiles->prev() ) {
366 if ( mediaPlayerState->looping() ) { 366 if ( mediaPlayerState->looping() ) {
367 return d->selectedFiles->last(); 367 return d->selectedFiles->last();
368 } else { 368 } else {
369 return FALSE; 369 return FALSE;
370 } 370 }
371 } 371 }
372 return TRUE; 372 return TRUE;
373 } 373 }
374 } else { 374 } else {
375 return mediaPlayerState->looping(); 375 return mediaPlayerState->looping();
376 } 376 }
377} 377}
378 378
379 379
380bool PlayListWidget::next() { 380bool PlayListWidget::next() {
381//qDebug("<<<<<<<<<<<<next()"); 381//qDebug("<<<<<<<<<<<<next()");
382 if ( mediaPlayerState->playlist() ) { 382 if ( mediaPlayerState->playlist() ) {
383 if ( mediaPlayerState->shuffled() ) { 383 if ( mediaPlayerState->shuffled() ) {
384 return prev(); 384 return prev();
385 } else { 385 } else {
386 if ( !d->selectedFiles->next() ) { 386 if ( !d->selectedFiles->next() ) {
387 if ( mediaPlayerState->looping() ) { 387 if ( mediaPlayerState->looping() ) {
388 return d->selectedFiles->first(); 388 return d->selectedFiles->first();
389 } else { 389 } else {
390 return FALSE; 390 return FALSE;
391 } 391 }
392 } 392 }
393 return TRUE; 393 return TRUE;
394 } 394 }
395 } else { 395 } else {
396 return mediaPlayerState->looping(); 396 return mediaPlayerState->looping();
397 } 397 }
398} 398}
399 399
400 400
401bool PlayListWidget::first() { 401bool PlayListWidget::first() {
402 if ( mediaPlayerState->playlist() ) 402 if ( mediaPlayerState->playlist() )
403 return d->selectedFiles->first(); 403 return d->selectedFiles->first();
404 else 404 else
405 return mediaPlayerState->looping(); 405 return mediaPlayerState->looping();
406} 406}
407 407
408 408
409bool PlayListWidget::last() { 409bool PlayListWidget::last() {
410 if ( mediaPlayerState->playlist() ) 410 if ( mediaPlayerState->playlist() )
411 return d->selectedFiles->last(); 411 return d->selectedFiles->last();
412 else 412 else
413 return mediaPlayerState->looping(); 413 return mediaPlayerState->looping();
414} 414}
415 415
416 416
417 void PlayListWidget::saveList() { 417 void PlayListWidget::saveList() {
418 writem3u(); 418 writem3u();
419 } 419 }
420 420
421 421
422void PlayListWidget::loadList( const DocLnk & lnk) { 422void PlayListWidget::loadList( const DocLnk & lnk) {
423 QString name = lnk.name(); 423 QString name = lnk.name();
424 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 424 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
425 425
426 if( name.length()>0) { 426 if( name.length()>0) {
427 setCaption("OpiePlayer: "+name); 427 setCaption("OpiePlayer: "+name);
428 qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 428 qDebug("<<<<<<<<<<<<load list "+ lnk.file());
429 clearList(); 429 clearList();
430 readm3u(lnk.file()); 430 readm3u(lnk.file());
431 tabWidget->setCurrentPage(0); 431 tabWidget->setCurrentPage(0);
432 } 432 }
433} 433}
434 434
435 435
436void PlayListWidget::setPlaylist( bool shown ) { 436void PlayListWidget::setPlaylist( bool shown ) {
437 if ( shown ) { 437 if ( shown ) {
438 d->playListFrame->show(); 438 d->playListFrame->show();
439 } else { 439 } else {
440 d->playListFrame->hide(); 440 d->playListFrame->hide();
441 } 441 }
442} 442}
443 443
444 444
445void PlayListWidget::addSelected() { 445void PlayListWidget::addSelected() {
446 qDebug("addSelected"); 446 qDebug("addSelected");
447 switch (whichList()) { 447 switch (whichList()) {
448 case 0: //playlist 448 case 0: //playlist
449 break; 449 break;
450 case 1: { //audio 450 case 1: { //audio
451 QListViewItemIterator it( audioView ); 451 QListViewItemIterator it( audioView );
452 // iterate through all items of the listview 452 // iterate through all items of the listview
453 for ( ; it.current(); ++it ) { 453 for ( ; it.current(); ++it ) {
454 if ( it.current()->isSelected() ) { 454 if ( it.current()->isSelected() ) {
455 QListIterator<DocLnk> dit( files.children() ); 455 QListIterator<DocLnk> dit( files.children() );
456 for ( ; dit.current(); ++dit ) { 456 for ( ; dit.current(); ++dit ) {
457 if( dit.current()->name() == it.current()->text(0) ) { 457 if( dit.current()->name() == it.current()->text(0) ) {
458 if( QFileInfo( dit.current()->file()).exists()) { 458 if( QFileInfo( dit.current()->file()).exists()) {
459 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
460 audioView->setSelected( it.current(),FALSE); 460 audioView->setSelected( it.current(),FALSE);
461 } 461 }
462 } 462 }
463 } 463 }
464 } 464 }
465 } 465 }
466// tabWidget->setCurrentPage(0); 466// tabWidget->setCurrentPage(0);
467 writeCurrentM3u(); 467 writeCurrentM3u();
468 d->selectedFiles->next(); 468 d->selectedFiles->next();
469 } 469 }
470 break; 470 break;
471 case 2: { // video 471 case 2: { // video
472 QListViewItemIterator it( videoView ); 472 QListViewItemIterator it( videoView );
473 // iterate through all items of the listview 473 // iterate through all items of the listview
474 for ( ; it.current(); ++it ) { 474 for ( ; it.current(); ++it ) {
475 if ( it.current()->isSelected() ) { 475 if ( it.current()->isSelected() ) {
476 QListIterator<DocLnk> dit( vFiles.children() ); 476 QListIterator<DocLnk> dit( vFiles.children() );
477 for ( ; dit.current(); ++dit ) { 477 for ( ; dit.current(); ++dit ) {
478 if( dit.current()->name() == it.current()->text(0) ) { 478 if( dit.current()->name() == it.current()->text(0) ) {
479 if(QFileInfo( dit.current()->file()).exists()) { 479 if(QFileInfo( dit.current()->file()).exists()) {
480 d->selectedFiles->addToSelection( **dit ); 480 d->selectedFiles->addToSelection( **dit );
481 videoView->setSelected( it.current(),FALSE); 481 videoView->setSelected( it.current(),FALSE);
482 } 482 }
483 } 483 }
484 } 484 }
485 } 485 }
486 } 486 }
487// tabWidget->setCurrentPage(0); 487// tabWidget->setCurrentPage(0);
488 writeCurrentM3u(); 488 writeCurrentM3u();
489 489
490 } 490 }
491 break; 491 break;
492 }; 492 };
493} 493}
494 494
495 495
496void PlayListWidget::removeSelected() { 496void PlayListWidget::removeSelected() {
497 d->selectedFiles->removeSelected( ); 497 d->selectedFiles->removeSelected( );
498 writeCurrentM3u(); 498 writeCurrentM3u();
499} 499}
500 500
501 501
502void PlayListWidget::playIt( QListViewItem *it) { 502void PlayListWidget::playIt( QListViewItem *it) {
503 if(!it) return; 503 if(!it) return;
504 mediaPlayerState->setPlaying(FALSE); 504 mediaPlayerState->setPlaying(FALSE);
505 mediaPlayerState->setPlaying(TRUE); 505 mediaPlayerState->setPlaying(TRUE);
506 d->selectedFiles->unSelect(); 506 d->selectedFiles->unSelect();
507} 507}
508 508
509 509
510void PlayListWidget::addToSelection( QListViewItem *it) { 510void PlayListWidget::addToSelection( QListViewItem *it) {
511 d->setDocumentUsed = FALSE; 511 d->setDocumentUsed = FALSE;
512 512
513 if(it) { 513 if(it) {
514 switch ( whichList()) { 514 switch ( whichList()) {
515 case 1: { 515 case 1: {
516 QListIterator<DocLnk> dit( files.children() ); 516 QListIterator<DocLnk> dit( files.children() );
517 for ( ; dit.current(); ++dit ) { 517 for ( ; dit.current(); ++dit ) {
518 if( dit.current()->name() == it->text(0)) { 518 if( dit.current()->name() == it->text(0)) {
519 if(QFileInfo( dit.current()->file()).exists()) 519 if(QFileInfo( dit.current()->file()).exists())
520 d->selectedFiles->addToSelection( **dit ); 520 d->selectedFiles->addToSelection( **dit );
521 } 521 }
522 } 522 }
523 writeCurrentM3u(); 523 writeCurrentM3u();
524 } 524 }
525 break; 525 break;
526 case 2: { 526 case 2: {
527 QListIterator<DocLnk> dit( vFiles.children() ); 527 QListIterator<DocLnk> dit( vFiles.children() );
528 for ( ; dit.current(); ++dit ) { 528 for ( ; dit.current(); ++dit ) {
529 if( dit.current()->name() == it->text(0)) { 529 if( dit.current()->name() == it->text(0)) {
530 if( QFileInfo( dit.current()->file()).exists() ) 530 if( QFileInfo( dit.current()->file()).exists() )
531 d->selectedFiles->addToSelection( **dit ); 531 d->selectedFiles->addToSelection( **dit );
532 } 532 }
533 } 533 }
534 writeCurrentM3u(); 534 writeCurrentM3u();
535 535
536 } 536 }
537 break; 537 break;
538 case 0: 538 case 0:
539 break; 539 break;
540 }; 540 };
541 tabWidget->setCurrentPage(0); 541 tabWidget->setCurrentPage(0);
542 } 542 }
543} 543}
544 544
545 545
546void PlayListWidget::tabChanged(QWidget *) { 546void PlayListWidget::tabChanged(QWidget *) {
547 547
548 switch ( whichList()) { 548 switch ( whichList()) {
549 case 0: 549 case 0:
550 { 550 {
551 if( !tbDeletePlaylist->isHidden() ) { 551 if( !tbDeletePlaylist->isHidden() ) {
552 tbDeletePlaylist->hide(); 552 tbDeletePlaylist->hide();
553 } 553 }
554 d->tbRemoveFromList->setEnabled(TRUE); 554 d->tbRemoveFromList->setEnabled(TRUE);
555 d->tbAddToList->setEnabled(FALSE); 555 d->tbAddToList->setEnabled(FALSE);
556 } 556 }
557 break; 557 break;
558 case 1: 558 case 1:
559 { 559 {
560 audioView->clear(); 560 audioView->clear();
561 populateAudioView(); 561 populateAudioView();
562 562
563 if( !tbDeletePlaylist->isHidden() ) { 563 if( !tbDeletePlaylist->isHidden() ) {
564 tbDeletePlaylist->hide(); 564 tbDeletePlaylist->hide();
565 } 565 }
566 d->tbRemoveFromList->setEnabled(FALSE); 566 d->tbRemoveFromList->setEnabled(FALSE);
567 d->tbAddToList->setEnabled(TRUE); 567 d->tbAddToList->setEnabled(TRUE);
568 } 568 }
569 break; 569 break;
570 case 2: 570 case 2:
571 { 571 {
572 videoView->clear(); 572 videoView->clear();
573 populateVideoView(); 573 populateVideoView();
574 if( !tbDeletePlaylist->isHidden() ) { 574 if( !tbDeletePlaylist->isHidden() ) {
575 tbDeletePlaylist->hide(); 575 tbDeletePlaylist->hide();
576 } 576 }
577 d->tbRemoveFromList->setEnabled(FALSE); 577 d->tbRemoveFromList->setEnabled(FALSE);
578 d->tbAddToList->setEnabled(TRUE); 578 d->tbAddToList->setEnabled(TRUE);
579 } 579 }
580 break; 580 break;
581 case 3: 581 case 3:
582 { 582 {
583 if( tbDeletePlaylist->isHidden() ) { 583 if( tbDeletePlaylist->isHidden() ) {
584 tbDeletePlaylist->show(); 584 tbDeletePlaylist->show();
585 } 585 }
586 playLists->reread(); 586 playLists->reread();
587 } 587 }
588 break; 588 break;
589 }; 589 };
590} 590}
591 591
592 592
593void PlayListWidget::btnPlay(bool b) { 593void PlayListWidget::btnPlay(bool b) {
594// mediaPlayerState->setPlaying(false); 594// mediaPlayerState->setPlaying(false);
595 mediaPlayerState->setPlaying(b); 595 mediaPlayerState->setPlaying(b);
596 insanityBool=FALSE; 596 insanityBool=FALSE;
597} 597}
598 598
599void PlayListWidget::deletePlaylist() { 599void PlayListWidget::deletePlaylist() {
600 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 600 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
601 (tr("You really want to delete\nthis playlist?")), 601 (tr("You really want to delete\nthis playlist?")),
602 (tr("Yes")), (tr("No")), 0 )){ 602 (tr("Yes")), (tr("No")), 0 )){
603 case 0: // Yes clicked, 603 case 0: // Yes clicked,
604 QFile().remove(playLists->selectedDocument().file()); 604 QFile().remove(playLists->selectedDocument().file());
605 QFile().remove(playLists->selectedDocument().linkFile()); 605 QFile().remove(playLists->selectedDocument().linkFile());
606 playLists->reread(); 606 playLists->reread();
607 break; 607 break;
608 case 1: // Cancel 608 case 1: // Cancel
609 break; 609 break;
610 }; 610 };
611} 611}
612 612
613 613
614void PlayListWidget::playSelected() { 614void PlayListWidget::playSelected() {
615 btnPlay( TRUE); 615 btnPlay( TRUE);
616} 616}
617 617
618 618
619void PlayListWidget::scanForAudio() { 619void PlayListWidget::scanForAudio() {
620// qDebug("scan for audio"); 620// qDebug("scan for audio");
621 files.detachChildren(); 621 files.detachChildren();
622 QListIterator<DocLnk> sdit( files.children() ); 622 QListIterator<DocLnk> sdit( files.children() );
623 for ( ; sdit.current(); ++sdit ) { 623 for ( ; sdit.current(); ++sdit ) {
624 delete sdit.current(); 624 delete sdit.current();
625 } 625 }
626// Global::findDocuments( &files, "audio/*"); 626// Global::findDocuments( &files, "audio/*");
627 Global::findDocuments( &files, audioMimes); 627 Global::findDocuments( &files, audioMimes);
628 audioScan = TRUE; 628 audioScan = TRUE;
629} 629}
630 630
631void PlayListWidget::scanForVideo() { 631void PlayListWidget::scanForVideo() {
632// qDebug("scan for video"); 632// qDebug("scan for video");
633 vFiles.detachChildren(); 633 vFiles.detachChildren();
634 QListIterator<DocLnk> sdit( vFiles.children() ); 634 QListIterator<DocLnk> sdit( vFiles.children() );
635 for ( ; sdit.current(); ++sdit ) { 635 for ( ; sdit.current(); ++sdit ) {
636 delete sdit.current(); 636 delete sdit.current();
637 } 637 }
638 Global::findDocuments(&vFiles, "video/*"); 638 Global::findDocuments(&vFiles, "video/*");
639 videoScan = TRUE; 639 videoScan = TRUE;
640} 640}
641 641
642void PlayListWidget::populateAudioView() { 642void PlayListWidget::populateAudioView() {
643 audioView->clear(); 643 audioView->clear();
644 StorageInfo storageInfo; 644 StorageInfo storageInfo;
645 const QList<FileSystem> &fs = storageInfo.fileSystems(); 645 const QList<FileSystem> &fs = storageInfo.fileSystems();
646 if(!audioScan) { 646 if(!audioScan) {
647 scanForAudio(); 647 scanForAudio();
648 } 648 }
649 649
650 QListIterator<DocLnk> dit( files.children() ); 650 QListIterator<DocLnk> dit( files.children() );
651 QListIterator<FileSystem> it ( fs ); 651 QListIterator<FileSystem> it ( fs );
652 652
653 QString storage; 653 QString storage;
654 for ( ; dit.current(); ++dit ) { 654 for ( ; dit.current(); ++dit ) {
655 for( ; it.current(); ++it ){ 655 for( ; it.current(); ++it ){
656 const QString name = (*it)->name(); 656 const QString name = (*it)->name();
657 const QString path = (*it)->path(); 657 const QString path = (*it)->path();
658 if(dit.current()->file().find(path) != -1 ) { 658 if(dit.current()->file().find(path) != -1 ) {
659 storage = name; 659 storage = name;
660 } 660 }
661 } 661 }
662 662
663 QListViewItem * newItem; 663 QListViewItem * newItem;
664 if ( QFile( dit.current()->file()).exists() || 664 if ( QFile( dit.current()->file()).exists() ||
665 dit.current()->file().left(4) == "http" ) { 665 dit.current()->file().left(4) == "http" ) {
666 long size; 666 long size;
667 if( dit.current()->file().left(4) == "http" ) 667 if( dit.current()->file().left(4) == "http" )
668 size=0; 668 size=0;
669 else 669 else
670 size = QFile( dit.current()->file() ).size(); 670 size = QFile( dit.current()->file() ).size();
671 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 671 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
672 QString::number(size ), storage, dit.current()->file()); 672 QString::number(size ), storage, dit.current()->file());
673 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 673 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
674 } 674 }
675 } 675 }
676} 676}
677 677
678 678
679void PlayListWidget::populateVideoView() { 679void PlayListWidget::populateVideoView() {
680 videoView->clear(); 680 videoView->clear();
681 StorageInfo storageInfo; 681 StorageInfo storageInfo;
682 const QList<FileSystem> &fs = storageInfo.fileSystems(); 682 const QList<FileSystem> &fs = storageInfo.fileSystems();
683 683
684 if(!videoScan ) { 684 if(!videoScan ) {
685 scanForVideo(); 685 scanForVideo();
686 } 686 }
687 687
688 QListIterator<DocLnk> Vdit( vFiles.children() ); 688 QListIterator<DocLnk> Vdit( vFiles.children() );
689 QListIterator<FileSystem> it ( fs ); 689 QListIterator<FileSystem> it ( fs );
690 videoView->clear(); 690 videoView->clear();
691 QString storage, pathName; 691 QString storage, pathName;
692 for ( ; Vdit.current(); ++Vdit ) { 692 for ( ; Vdit.current(); ++Vdit ) {
693 for( ; it.current(); ++it ) { 693 for( ; it.current(); ++it ) {
694 const QString name = (*it)->name(); 694 const QString name = (*it)->name();
695 const QString path = (*it)->path(); 695 const QString path = (*it)->path();
696 if( Vdit.current()->file().find(path) != -1 ) { 696 if( Vdit.current()->file().find(path) != -1 ) {
697 storage=name; 697 storage=name;
698 pathName=path; 698 pathName=path;
699 } 699 }
700 } 700 }
701 701
702 QListViewItem * newItem; 702 QListViewItem * newItem;
703 if ( QFile( Vdit.current()->file() ).exists() ) { 703 if ( QFile( Vdit.current()->file() ).exists() ) {
704 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 704 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
705 QString::number( QFile( Vdit.current()->file() ).size() ), 705 QString::number( QFile( Vdit.current()->file() ).size() ),
706 storage, Vdit.current()->file()); 706 storage, Vdit.current()->file());
707 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 707 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
708 } 708 }
709 } 709 }
710} 710}
711 711
712 712
713void PlayListWidget::openFile() { 713void PlayListWidget::openFile() {
714 // http://66.28.164.33:2080 714 // http://66.28.164.33:2080
715 // http://somafm.com/star0242.m3u 715 // http://somafm.com/star0242.m3u
716 QString filename, name; 716 QString filename, name;
717 InputDialog *fileDlg; 717 InputDialog *fileDlg;
718 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 718 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
719 fileDlg->exec(); 719 fileDlg->exec();
720 if( fileDlg->result() == 1 ) { 720 if( fileDlg->result() == 1 ) {
721 filename = fileDlg->text(); 721 filename = fileDlg->text();
722 qDebug( "Selected filename is " + filename ); 722 qDebug( "Selected filename is " + filename );
723 Om3u *m3uList; 723 Om3u *m3uList;
724 DocLnk lnk; 724 DocLnk lnk;
725 Config cfg( "OpiePlayer" ); 725 Config cfg( "OpiePlayer" );
726 cfg.setGroup("PlayList"); 726 cfg.setGroup("PlayList");
727 727
728 if(filename.left(4) == "http") { 728 if(filename.left(4) == "http") {
729 QString m3uFile, m3uFilePath; 729 QString m3uFile, m3uFilePath;
730 if(filename.find(":",8,TRUE) != -1) { //found a port 730 if(filename.find(":",8,TRUE) != -1) { //found a port
731 m3uFile = filename.left( filename.find( ":",8,TRUE)); 731 m3uFile = filename.left( filename.find( ":",8,TRUE));
732 m3uFile = m3uFile.right( 7); 732 m3uFile = m3uFile.right( 7);
733 } else if(filename.left(4) == "http"){ 733 } else if(filename.left(4) == "http"){
734 m3uFile=filename; 734 m3uFile=filename;
735 m3uFile = m3uFile.right( m3uFile.length() - 7); 735 m3uFile = m3uFile.right( m3uFile.length() - 7);
736 } else{ 736 } else{
737 m3uFile=filename; 737 m3uFile=filename;
738 } 738 }
739 739
740// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 740// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
741 lnk.setName( filename ); //sets name 741 lnk.setName( filename ); //sets name
742 lnk.setFile( filename ); //sets file name 742 lnk.setFile( filename ); //sets file name
743 lnk.setIcon("opieplayer2/musicfile"); 743
744// lnk.setIcon("opieplayer2/musicfile");
745
744 d->selectedFiles->addToSelection( lnk ); 746 d->selectedFiles->addToSelection( lnk );
745 writeCurrentM3u(); 747 writeCurrentM3u();
746 } 748 }
747 else if( filename.right( 3) == "m3u" ) { 749 else if( filename.right( 3) == "m3u" ) {
748 readm3u( filename ); 750 readm3u( filename );
749 751
750 } else if( filename.right(3) == "pls" ) { 752 } else if( filename.right(3) == "pls" ) {
751 readPls( filename ); 753 readPls( filename );
752 } else { 754 } else {
753 d->selectedFiles->addToSelection( DocLnk(filename) ); 755 lnk.setName( QFileInfo(filename).baseName() ); //sets name
756 lnk.setFile( filename ); //sets file name
757 d->selectedFiles->addToSelection( lnk);
754 writeCurrentM3u(); 758 writeCurrentM3u();
755 } 759 }
756 } 760 }
757 761
758 if( fileDlg ) { 762 if( fileDlg ) {
759 delete fileDlg; 763 delete fileDlg;
760 } 764 }
761} 765}
762 766
763/* 767/*
764reads m3u and shows files/urls to playlist widget */ 768reads m3u and shows files/urls to playlist widget */
765void PlayListWidget::readm3u( const QString &filename ) { 769void PlayListWidget::readm3u( const QString &filename ) {
766 qDebug( "read m3u filename " + filename ); 770 qDebug( "read m3u filename " + filename );
767 771
768 Om3u *m3uList; 772 Om3u *m3uList;
769 QString s, name; 773 QString s, name;
770 m3uList = new Om3u( filename, IO_ReadOnly ); 774 m3uList = new Om3u( filename, IO_ReadOnly );
771 m3uList->readM3u(); 775 m3uList->readM3u();
772 DocLnk lnk; 776 DocLnk lnk;
773 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 777 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
774 s = *it; 778 s = *it;
775// qDebug("reading "+ s); 779// qDebug("reading "+ s);
776 if(s.left(4)=="http") { 780 if(s.left(4)=="http") {
777 lnk.setName( s ); //sets file name 781 lnk.setName( s ); //sets file name
778 lnk.setIcon("opieplayer2/musicfile"); 782 lnk.setIcon("opieplayer2/musicfile");
779// if(s.right(4) != '.' || s.right(5) != '.') 783// if(s.right(4) != '.' || s.right(5) != '.')
780// lnk.setFile( s+"/"); //if url with no extension 784// lnk.setFile( s+"/"); //if url with no extension
781// else 785// else
782 lnk.setFile( s ); //sets file name 786 lnk.setFile( s ); //sets file name
783 787
784 } else { 788 } else {
785 // if( QFileInfo( s ).exists() ) { 789 // if( QFileInfo( s ).exists() ) {
786 lnk.setName( QFileInfo(s).baseName()); 790 lnk.setName( QFileInfo(s).baseName());
787 // if(s.right(4) == '.') {//if regular file 791 // if(s.right(4) == '.') {//if regular file
788 if(s.left(1) != "/") { 792 if(s.left(1) != "/") {
789 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 793 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
790 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 794 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
791 lnk.setIcon("SoundPlayer"); 795// lnk.setIcon(MimeType(s).pixmap() );
796// lnk.setIcon("SoundPlayer");
792 } else { 797 } else {
793 // qDebug("set link2 "+s); 798 // qDebug("set link2 "+s);
794 lnk.setFile( s); 799 lnk.setFile( s);
795 lnk.setIcon("SoundPlayer"); 800// lnk.setIcon(MimeType(s).pixmap() );
801// lnk.setIcon("SoundPlayer");
796 } 802 }
797 } 803 }
798 d->selectedFiles->addToSelection( lnk ); 804 d->selectedFiles->addToSelection( lnk );
799 } 805 }
800 Config config( "OpiePlayer" ); 806 Config config( "OpiePlayer" );
801 config.setGroup( "PlayList" ); 807 config.setGroup( "PlayList" );
802 808
803 config.writeEntry("CurrentPlaylist",filename); 809 config.writeEntry("CurrentPlaylist",filename);
804 config.write(); 810 config.write();
805 currentPlayList=filename; 811 currentPlayList=filename;
806 812
807// m3uList->write(); 813// m3uList->write();
808 m3uList->close(); 814 m3uList->close();
809 if(m3uList) delete m3uList; 815 if(m3uList) delete m3uList;
810 816
811 d->selectedFiles->setSelectedItem( s); 817 d->selectedFiles->setSelectedItem( s);
812 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 818 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
813 819
814} 820}
815 821
816/* 822/*
817reads pls and adds files/urls to playlist */ 823reads pls and adds files/urls to playlist */
818void PlayListWidget::readPls( const QString &filename ) { 824void PlayListWidget::readPls( const QString &filename ) {
819 825
820 qDebug( "pls filename is " + filename ); 826 qDebug( "pls filename is " + filename );
821 Om3u *m3uList; 827 Om3u *m3uList;
822 QString s, name; 828 QString s, name;
823 m3uList = new Om3u( filename, IO_ReadOnly ); 829 m3uList = new Om3u( filename, IO_ReadOnly );
824 m3uList->readPls(); 830 m3uList->readPls();
825 831
826 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 832 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
827 s = *it; 833 s = *it;
828 // s.replace( QRegExp( "%20" )," " ); 834 // s.replace( QRegExp( "%20" )," " );
829 DocLnk lnk( s ); 835 DocLnk lnk( s );
830 QFileInfo f( s ); 836 QFileInfo f( s );
831 QString name = f.baseName(); 837 QString name = f.baseName();
832 838
833 if( name.left( 4 ) == "http" ) { 839 if( name.left( 4 ) == "http" ) {
834 name = s.right( s.length() - 7); 840 name = s.right( s.length() - 7);
835 } else { 841 } else {
836 name = s; 842 name = s;
837 } 843 }
838 844
839 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 845 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
840 846
841 lnk.setName( name ); 847 lnk.setName( name );
842 if( s.at( s.length() - 4) == '.') {// if this is probably a file 848 if( s.at( s.length() - 4) == '.') {// if this is probably a file
843 lnk.setFile( s ); 849 lnk.setFile( s );
844 } else { //if its a url 850 } else { //if its a url
845 if( name.right( 1 ).find( '/' ) == -1) { 851// if( name.right( 1 ).find( '/' ) == -1) {
846 s += "/"; 852// s += "/";
847 } 853// }
848 lnk.setFile( s ); 854 lnk.setFile( s );
849 } 855 }
850 lnk.setType( "audio/x-mpegurl" ); 856 lnk.setType( "audio/x-mpegurl" );
851 857
852 lnk.writeLink(); 858 lnk.writeLink();
853 d->selectedFiles->addToSelection( lnk ); 859 d->selectedFiles->addToSelection( lnk );
854 } 860 }
855 861
856 m3uList->close(); 862 m3uList->close();
857 if(m3uList) delete m3uList; 863 if(m3uList) delete m3uList;
858} 864}
859 865
860/* 866/*
861 writes current playlist to current m3u file */ 867 writes current playlist to current m3u file */
862void PlayListWidget::writeCurrentM3u() { 868void PlayListWidget::writeCurrentM3u() {
863 qDebug("writing to current m3u"); 869 qDebug("writing to current m3u");
864 Config cfg( "OpiePlayer" ); 870 Config cfg( "OpiePlayer" );
865 cfg.setGroup("PlayList"); 871 cfg.setGroup("PlayList");
866 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 872 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
867 873
868 if( d->selectedFiles->first()) {
869 Om3u *m3uList; 874 Om3u *m3uList;
870 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 875 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
876 if( d->selectedFiles->first()) {
871 877
872 do { 878 do {
873 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 879 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
874 m3uList->add( d->selectedFiles->current()->file() ); 880 m3uList->add( d->selectedFiles->current()->file() );
875 } 881 }
876 while ( d->selectedFiles->next() ); 882 while ( d->selectedFiles->next() );
877 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 883 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
878 m3uList->write(); 884 m3uList->write();
879 m3uList->close(); 885 m3uList->close();
880 886
881 if(m3uList) delete m3uList; 887 if(m3uList) delete m3uList;
882 } 888 }
883} 889}
884 890
885 /* 891 /*
886 writes current playlist to m3u file */ 892 writes current playlist to m3u file */
887void PlayListWidget::writem3u() { 893void PlayListWidget::writem3u() {
888 InputDialog *fileDlg; 894 InputDialog *fileDlg;
889 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 895 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
890 fileDlg->exec(); 896 fileDlg->exec();
891 QString name, filename, list; 897 QString name, filename, list;
892 Om3u *m3uList; 898 Om3u *m3uList;
893 899
894 if( fileDlg->result() == 1 ) { 900 if( fileDlg->result() == 1 ) {
895 name = fileDlg->text(); 901 name = fileDlg->text();
896// qDebug( filename ); 902// qDebug( filename );
897 903
898 if( name.left( 1) != "/" ) { 904 if( name.left( 1) != "/" ) {
899 filename = QPEApplication::documentDir() + "/" + name; 905 filename = QPEApplication::documentDir() + "/" + name;
900 } 906 }
901 907
902 if( name.right( 3 ) != "m3u" ) { 908 if( name.right( 3 ) != "m3u" ) {
903 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 909 filename = QPEApplication::documentDir() + "/" +name+".m3u";
904 } 910 }
905 911
906 if( d->selectedFiles->first()) { 912 if( d->selectedFiles->first()) {
907 m3uList = new Om3u(filename, IO_ReadWrite); 913 m3uList = new Om3u(filename, IO_ReadWrite);
908 914
909 do { 915 do {
910 m3uList->add( d->selectedFiles->current()->file()); 916 m3uList->add( d->selectedFiles->current()->file());
911 } 917 }
912 while ( d->selectedFiles->next() ); 918 while ( d->selectedFiles->next() );
913 // qDebug( list ); 919 // qDebug( list );
914 m3uList->write(); 920 m3uList->write();
915 m3uList->close(); 921 m3uList->close();
916 if(m3uList) delete m3uList; 922 if(m3uList) delete m3uList;
917 923
918 if(fileDlg) delete fileDlg; 924 if(fileDlg) delete fileDlg;
919 925
920 DocLnk lnk; 926 DocLnk lnk;
921 lnk.setFile( filename); 927 lnk.setFile( filename);
922 lnk.setIcon("opieplayer2/playlist2"); 928// lnk.setIcon("opieplayer2/playlist2");
923 lnk.setName( name); //sets file name 929 lnk.setName( name); //sets file name
924 930
925 // qDebug(filename); 931 // qDebug(filename);
926 Config config( "OpiePlayer" ); 932 Config config( "OpiePlayer" );
927 config.setGroup( "PlayList" ); 933 config.setGroup( "PlayList" );
928 934
929 config.writeEntry("CurrentPlaylist",filename); 935 config.writeEntry("CurrentPlaylist",filename);
930 currentPlayList=filename; 936 currentPlayList=filename;
931 937
932 if(!lnk.writeLink()) { 938 if(!lnk.writeLink()) {
933 qDebug("Writing doclink did not work"); 939 qDebug("Writing doclink did not work");
934 } 940 }
935 941
936 setCaption(tr("OpiePlayer: ") + name); 942 setCaption(tr("OpiePlayer: ") + name);
937 } 943 }
938 } 944 }
939} 945}
940 946
941void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 947void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
942 switch ( e->key() ) { 948 switch ( e->key() ) {
943 ////////////////////////////// Zaurus keys 949 ////////////////////////////// Zaurus keys
944 case Key_F9: //activity 950 case Key_F9: //activity
945 // if(audioUI->isHidden()) 951 // if(audioUI->isHidden())
946 // audioUI->showMaximized(); 952 // audioUI->showMaximized();
947 break; 953 break;
948 case Key_F10: //contacts 954 case Key_F10: //contacts
949 // if( videoUI->isHidden()) 955 // if( videoUI->isHidden())
950 // videoUI->showMaximized(); 956 // videoUI->showMaximized();
951 break; 957 break;
952 case Key_F11: //menu 958 case Key_F11: //menu
953 break; 959 break;
954 case Key_F12: //home 960 case Key_F12: //home
955 // doBlank(); 961 // doBlank();
956 break; 962 break;
957 case Key_F13: //mail 963 case Key_F13: //mail
958 // doUnblank(); 964 // doUnblank();
959 break; 965 break;
960 case Key_Q: //add to playlist 966 case Key_Q: //add to playlist
961 addSelected(); 967 addSelected();
962 break; 968 break;
963 case Key_R: //remove from playlist 969 case Key_R: //remove from playlist
964 removeSelected(); 970 removeSelected();
965 break; 971 break;
966 // case Key_P: //play 972 // case Key_P: //play
967 // qDebug("Play"); 973 // qDebug("Play");
968 // playSelected(); 974 // playSelected();
969 // break; 975 // break;
970 case Key_Space: 976 case Key_Space:
971 // playSelected(); puh 977 // playSelected(); puh
972 break; 978 break;
973 case Key_1: 979 case Key_1:
974 tabWidget->setCurrentPage( 0 ); 980 tabWidget->setCurrentPage( 0 );
975 break; 981 break;
976 case Key_2: 982 case Key_2:
977 tabWidget->setCurrentPage( 1 ); 983 tabWidget->setCurrentPage( 1 );
978 break; 984 break;
979 case Key_3: 985 case Key_3:
980 tabWidget->setCurrentPage( 2 ); 986 tabWidget->setCurrentPage( 2 );
981 break; 987 break;
982 case Key_4: 988 case Key_4:
983 tabWidget->setCurrentPage( 3 ); 989 tabWidget->setCurrentPage( 3 );
984 break; 990 break;
985 case Key_Down: 991 case Key_Down:
986 if ( !d->selectedFiles->next() ) 992 if ( !d->selectedFiles->next() )
987 d->selectedFiles->first(); 993 d->selectedFiles->first();
988 break; 994 break;
989 case Key_Up: 995 case Key_Up:
990 if ( !d->selectedFiles->prev() ) 996 if ( !d->selectedFiles->prev() )
991 // d->selectedFiles->last(); 997 // d->selectedFiles->last();
992 break; 998 break;
993 } 999 }
994} 1000}
995 1001
996void PlayListWidget::pmViewActivated(int index) { 1002void PlayListWidget::pmViewActivated(int index) {
997// qDebug("%d", index); 1003// qDebug("%d", index);
998 switch(index) { 1004 switch(index) {
999 case -16: 1005 case -16:
1000 { 1006 {
1001 mediaPlayerState->toggleFullscreen(); 1007 mediaPlayerState->toggleFullscreen();
1002 bool b=mediaPlayerState->fullscreen(); 1008 bool b=mediaPlayerState->fullscreen();
1003 pmView->setItemChecked( index, b); 1009 pmView->setItemChecked( index, b);
1004 Config cfg( "OpiePlayer" ); 1010 Config cfg( "OpiePlayer" );
1005 cfg.writeEntry( "FullScreen", b ); 1011 cfg.writeEntry( "FullScreen", b );
1006 } 1012 }
1007 break; 1013 break;
1008 }; 1014 };
1009} 1015}
1010 1016
1011void PlayListWidget::populateSkinsMenu() { 1017void PlayListWidget::populateSkinsMenu() {
1012 int item = 0; 1018 int item = 0;
1013 defaultSkinIndex = 0; 1019 defaultSkinIndex = 0;
1014 QString skinName; 1020 QString skinName;
1015 Config cfg( "OpiePlayer" ); 1021 Config cfg( "OpiePlayer" );
1016 cfg.setGroup("Options" ); 1022 cfg.setGroup("Options" );
1017 QString skin = cfg.readEntry( "Skin", "default" ); 1023 QString skin = cfg.readEntry( "Skin", "default" );
1018 1024
1019 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1025 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1020 skinsDir.setFilter( QDir::Dirs ); 1026 skinsDir.setFilter( QDir::Dirs );
1021 skinsDir.setSorting(QDir::Name ); 1027 skinsDir.setSorting(QDir::Name );
1022 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1028 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1023 QFileInfoListIterator it( *skinslist ); 1029 QFileInfoListIterator it( *skinslist );
1024 QFileInfo *fi; 1030 QFileInfo *fi;
1025 while ( ( fi = it.current() ) ) { 1031 while ( ( fi = it.current() ) ) {
1026 skinName = fi->fileName(); 1032 skinName = fi->fileName();
1027// qDebug( fi->fileName() ); 1033// qDebug( fi->fileName() );
1028 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1034 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1029 item = skinsMenu->insertItem( fi->fileName() ) ; 1035 item = skinsMenu->insertItem( fi->fileName() ) ;
1030 } 1036 }
1031 if( skinName == "default" ) { 1037 if( skinName == "default" ) {
1032 defaultSkinIndex = item; 1038 defaultSkinIndex = item;
1033 } 1039 }
1034 if( skinName == skin ) { 1040 if( skinName == skin ) {
1035 skinsMenu->setItemChecked( item, TRUE ); 1041 skinsMenu->setItemChecked( item, TRUE );
1036 } 1042 }
1037 ++it; 1043 ++it;
1038 } 1044 }
1039} 1045}
1040 1046
1041void PlayListWidget::skinsMenuActivated( int item ) { 1047void PlayListWidget::skinsMenuActivated( int item ) {
1042 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1048 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1043 skinsMenu->setItemChecked( i, FALSE ); 1049 skinsMenu->setItemChecked( i, FALSE );
1044 } 1050 }
1045 skinsMenu->setItemChecked( item, TRUE ); 1051 skinsMenu->setItemChecked( item, TRUE );
1046 1052
1047 Config cfg( "OpiePlayer" ); 1053 Config cfg( "OpiePlayer" );
1048 cfg.setGroup("Options"); 1054 cfg.setGroup("Options");
1049 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1055 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1050} 1056}
1051 1057
1052int PlayListWidget::whichList() { 1058int PlayListWidget::whichList() {
1053 return tabWidget->currentPageIndex(); 1059 return tabWidget->currentPageIndex();
1054} 1060}
1055 1061
1056QString PlayListWidget::currentFileListPathName() { 1062QString PlayListWidget::currentFileListPathName() {
1057 switch (whichList()) { 1063 switch (whichList()) {
1058 case 1: 1064 case 1:
1059 return audioView->currentItem()->text(3); 1065 return audioView->currentItem()->text(3);
1060 break; 1066 break;
1061 case 2: 1067 case 2:
1062 return videoView->currentItem()->text(3); 1068 return videoView->currentItem()->text(3);
1063 break; 1069 break;
1064 }; 1070 };
1065 return ""; 1071 return "";
1066} 1072}