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