summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 23:28:58 (UTC)
committer llornkcor <llornkcor>2002-04-20 23:28:58 (UTC)
commit7ae1d2a136454122b28c50df2f7807a4780d507c (patch) (unidiff)
treefbc1cf37200a05d004c0a3595bd6391ed6e5f001
parente657b8203c7b649fd3df96afbe7f8b1d24b5b8ed (diff)
downloadopie-7ae1d2a136454122b28c50df2f7807a4780d507c.zip
opie-7ae1d2a136454122b28c50df2f7807a4780d507c.tar.gz
opie-7ae1d2a136454122b28c50df2f7807a4780d507c.tar.bz2
url stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp98
1 files changed, 58 insertions, 40 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 218fd49..250645c 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,305 +1,307 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22 22
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/fileselector.h> 25#include <qpe/fileselector.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/lnkproperties.h> 27#include <qpe/lnkproperties.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29 29
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/global.h> 32#include <qpe/global.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34
34#include <qaction.h> 35#include <qaction.h>
35#include <qimage.h> 36#include <qimage.h>
36#include <qfile.h> 37#include <qfile.h>
37#include <qdir.h> 38#include <qdir.h>
38#include <qlayout.h> 39#include <qlayout.h>
39#include <qlabel.h> 40#include <qlabel.h>
40#include <qlist.h> 41#include <qlist.h>
41#include <qlistbox.h> 42#include <qlistbox.h>
42#include <qmainwindow.h> 43#include <qmainwindow.h>
43#include <qmessagebox.h> 44#include <qmessagebox.h>
44#include <qtoolbutton.h> 45#include <qtoolbutton.h>
45#include <qtabwidget.h> 46#include <qtabwidget.h>
46#include <qlistview.h> 47#include <qlistview.h>
47#include <qpoint.h> 48#include <qpoint.h>
48#include <qlineedit.h> 49#include <qlineedit.h>
49#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qregexp.h>
50 52
51//#include <qtimer.h> 53//#include <qtimer.h>
52 54
53#include "playlistselection.h" 55#include "playlistselection.h"
54#include "playlistwidget.h" 56#include "playlistwidget.h"
55#include "mediaplayerstate.h" 57#include "mediaplayerstate.h"
56 58
57#include "inputDialog.h" 59#include "inputDialog.h"
58 60
59#include <stdlib.h> 61#include <stdlib.h>
60 62
61#define BUTTONS_ON_TOOLBAR 63#define BUTTONS_ON_TOOLBAR
62#define SIDE_BUTTONS 64#define SIDE_BUTTONS
63#define CAN_SAVE_LOAD_PLAYLISTS 65#define CAN_SAVE_LOAD_PLAYLISTS
64 66
65extern MediaPlayerState *mediaPlayerState; 67extern MediaPlayerState *mediaPlayerState;
66 68
67// class myFileSelector { 69// class myFileSelector {
68 70
69// }; 71// };
70class PlayListWidgetPrivate { 72class PlayListWidgetPrivate {
71public: 73public:
72 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 74 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
73 QFrame *playListFrame; 75 QFrame *playListFrame;
74 FileSelector *files; 76 FileSelector *files;
75 PlayListSelection *selectedFiles; 77 PlayListSelection *selectedFiles;
76 bool setDocumentUsed; 78 bool setDocumentUsed;
77 DocLnk *current; 79 DocLnk *current;
78}; 80};
79 81
80 82
81class ToolButton : public QToolButton { 83class ToolButton : public QToolButton {
82public: 84public:
83 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 85 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
84 : QToolButton( parent, name ) { 86 : QToolButton( parent, name ) {
85 setTextLabel( name ); 87 setTextLabel( name );
86 setPixmap( Resource::loadPixmap( icon ) ); 88 setPixmap( Resource::loadPixmap( icon ) );
87 setAutoRaise( TRUE ); 89 setAutoRaise( TRUE );
88 setFocusPolicy( QWidget::NoFocus ); 90 setFocusPolicy( QWidget::NoFocus );
89 setToggleButton( t ); 91 setToggleButton( t );
90 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 92 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
91 QPEMenuToolFocusManager::manager()->addWidget( this ); 93 QPEMenuToolFocusManager::manager()->addWidget( this );
92 } 94 }
93}; 95};
94 96
95 97
96class MenuItem : public QAction { 98class MenuItem : public QAction {
97public: 99public:
98 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 100 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
99 : QAction( text, QString::null, 0, 0 ) { 101 : QAction( text, QString::null, 0, 0 ) {
100 connect( this, SIGNAL( activated() ), handler, slot ); 102 connect( this, SIGNAL( activated() ), handler, slot );
101 addTo( parent ); 103 addTo( parent );
102 } 104 }
103}; 105};
104 106
105 107
106PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 108PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
107 : QMainWindow( parent, name, fl ) { 109 : QMainWindow( parent, name, fl ) {
108 110
109 d = new PlayListWidgetPrivate; 111 d = new PlayListWidgetPrivate;
110 d->setDocumentUsed = FALSE; 112 d->setDocumentUsed = FALSE;
111 d->current = NULL; 113 d->current = NULL;
112 fromSetDocument = FALSE; 114 fromSetDocument = FALSE;
113 insanityBool=FALSE; 115 insanityBool=FALSE;
114// menuTimer = new QTimer( this ,"menu timer"), 116// menuTimer = new QTimer( this ,"menu timer"),
115// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 117// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
116 118
117 setBackgroundMode( PaletteButton ); 119 setBackgroundMode( PaletteButton );
118 120
119 setCaption( tr("OpiePlayer") ); 121 setCaption( tr("OpiePlayer") );
120 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 122 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
121 123
122 setToolBarsMovable( FALSE ); 124 setToolBarsMovable( FALSE );
123 125
124 // Create Toolbar 126 // Create Toolbar
125 QPEToolBar *toolbar = new QPEToolBar( this ); 127 QPEToolBar *toolbar = new QPEToolBar( this );
126 toolbar->setHorizontalStretchable( TRUE ); 128 toolbar->setHorizontalStretchable( TRUE );
127 129
128 // Create Menubar 130 // Create Menubar
129 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 131 QPEMenuBar *menu = new QPEMenuBar( toolbar );
130 menu->setMargin( 0 ); 132 menu->setMargin( 0 );
131 133
132 QPEToolBar *bar = new QPEToolBar( this ); 134 QPEToolBar *bar = new QPEToolBar( this );
133 bar->setLabel( tr( "Play Operations" ) ); 135 bar->setLabel( tr( "Play Operations" ) );
134// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", 136// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
135// this , SLOT( addSelected()) ); 137// this , SLOT( addSelected()) );
136 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 138 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
137 tbDeletePlaylist->setFlat(TRUE); 139 tbDeletePlaylist->setFlat(TRUE);
138 tbDeletePlaylist->setFixedSize(20,20); 140 tbDeletePlaylist->setFixedSize(20,20);
139 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 141 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
140 142
141 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", 143 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
142 this , SLOT(addSelected()) ); 144 this , SLOT(addSelected()) );
143 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", 145 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
144 this , SLOT(removeSelected()) ); 146 this , SLOT(removeSelected()) );
145// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 147// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
146 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", 148 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
147 this , SLOT( btnPlay(bool) ), TRUE ); 149 this , SLOT( btnPlay(bool) ), TRUE );
148 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", 150 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
149 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 151 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
150 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", 152 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
151 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 153 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
152 tbDeletePlaylist->hide(); 154 tbDeletePlaylist->hide();
153 155
154 QPopupMenu *pmPlayList = new QPopupMenu( this ); 156 QPopupMenu *pmPlayList = new QPopupMenu( this );
155 menu->insertItem( tr( "File" ), pmPlayList ); 157 menu->insertItem( tr( "File" ), pmPlayList );
156 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 158 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
157 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 159 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
158 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 160 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
159 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 161 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
160// pmPlayList->insertSeparator(-1); 162// pmPlayList->insertSeparator(-1);
161 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 163 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
162 pmPlayList->insertSeparator(-1); 164 pmPlayList->insertSeparator(-1);
163 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 165 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
164 166
165 QPopupMenu *pmView = new QPopupMenu( this ); 167 QPopupMenu *pmView = new QPopupMenu( this );
166 menu->insertItem( tr( "View" ), pmView ); 168 menu->insertItem( tr( "View" ), pmView );
167 169
168 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 170 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
169 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 171 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
170 fullScreenButton->addTo(pmView); 172 fullScreenButton->addTo(pmView);
171 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); 173 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
172 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 174 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
173 scaleButton->addTo(pmView); 175 scaleButton->addTo(pmView);
174 176
175 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 177 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
176 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 178 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
177 179
178 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 180 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
179 181
180 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 182 tabWidget = new QTabWidget( hbox6, "tabWidget" );
181 tabWidget->setTabShape(QTabWidget::Triangular); 183 tabWidget->setTabShape(QTabWidget::Triangular);
182 184
183 QWidget *pTab; 185 QWidget *pTab;
184 pTab = new QWidget( tabWidget, "pTab" ); 186 pTab = new QWidget( tabWidget, "pTab" );
185// playlistView = new QListView( pTab, "playlistview" ); 187// playlistView = new QListView( pTab, "playlistview" );
186// playlistView->setMinimumSize(236,260); 188// playlistView->setMinimumSize(236,260);
187 tabWidget->insertTab( pTab,"Playlist"); 189 tabWidget->insertTab( pTab,"Playlist");
188 190
189 191
190 // Add the playlist area 192 // Add the playlist area
191 193
192 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 194 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
193 d->playListFrame = vbox3; 195 d->playListFrame = vbox3;
194 d->playListFrame ->setMinimumSize(235,260); 196 d->playListFrame ->setMinimumSize(235,260);
195 197
196 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 198 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
197 199
198 d->selectedFiles = new PlayListSelection( hbox2); 200 d->selectedFiles = new PlayListSelection( hbox2);
199 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 201 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
200 202
201 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 203 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
202 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 204 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
203 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 205 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
204 206
205 207
206 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 208 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
207 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 209 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
208 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 210 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
209 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 211 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
210 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 212 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
211 213
212 QWidget *aTab; 214 QWidget *aTab;
213 aTab = new QWidget( tabWidget, "aTab" ); 215 aTab = new QWidget( tabWidget, "aTab" );
214 audioView = new QListView( aTab, "Audioview" ); 216 audioView = new QListView( aTab, "Audioview" );
215 audioView->setMinimumSize(233,260); 217 audioView->setMinimumSize(233,260);
216 audioView->addColumn( tr("Title"),140); 218 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1); 219 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1); 220 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight); 221 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight); 222 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE); 223 audioView->setAllColumnsShowFocus(TRUE);
222// audioView->setMultiSelection( TRUE ); 224// audioView->setMultiSelection( TRUE );
223// audioView->setSelectionMode( QListView::Extended); 225// audioView->setSelectionMode( QListView::Extended);
224 226
225 tabWidget->insertTab(aTab,tr("Audio")); 227 tabWidget->insertTab(aTab,tr("Audio"));
226 228
227 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 229 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
228 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 230 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
229 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 231 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
230 232
231 233
232// audioView 234// audioView
233 populateAudioView(); 235 populateAudioView();
234// videowidget 236// videowidget
235 237
236 QWidget *vTab; 238 QWidget *vTab;
237 vTab = new QWidget( tabWidget, "vTab" ); 239 vTab = new QWidget( tabWidget, "vTab" );
238 videoView = new QListView( vTab, "Videoview" ); 240 videoView = new QListView( vTab, "Videoview" );
239 videoView->setMinimumSize(233,260); 241 videoView->setMinimumSize(233,260);
240 242
241 videoView->addColumn(tr("Title"),140); 243 videoView->addColumn(tr("Title"),140);
242 videoView->addColumn(tr("Size"),-1); 244 videoView->addColumn(tr("Size"),-1);
243 videoView->addColumn(tr("Media"),-1); 245 videoView->addColumn(tr("Media"),-1);
244 videoView->setColumnAlignment(1, Qt::AlignRight); 246 videoView->setColumnAlignment(1, Qt::AlignRight);
245 videoView->setColumnAlignment(2, Qt::AlignRight); 247 videoView->setColumnAlignment(2, Qt::AlignRight);
246 videoView->setAllColumnsShowFocus(TRUE); 248 videoView->setAllColumnsShowFocus(TRUE);
247// videoView->setMultiSelection( TRUE ); 249// videoView->setMultiSelection( TRUE );
248// videoView->setSelectionMode( QListView::Extended); 250// videoView->setSelectionMode( QListView::Extended);
249 251
250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 252 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 253 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 254 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
253 255
254 tabWidget->insertTab( vTab,tr("Video")); 256 tabWidget->insertTab( vTab,tr("Video"));
255populateVideoView(); 257populateVideoView();
256 258
257//playlists list 259//playlists list
258 QWidget *LTab; 260 QWidget *LTab;
259 LTab = new QWidget( tabWidget, "LTab" ); 261 LTab = new QWidget( tabWidget, "LTab" );
260 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 262 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
261 playLists->setMinimumSize(233,260);; 263 playLists->setMinimumSize(233,260);;
262 tabWidget->insertTab(LTab,tr("Lists")); 264 tabWidget->insertTab(LTab,tr("Lists"));
263 265
264 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 266 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
265// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 267// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
266 268
267 269
268// add the library area 270// add the library area
269 271
270// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 272// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
271// this, SLOT( fauxPlay( QListViewItem *) ) ); 273// this, SLOT( fauxPlay( QListViewItem *) ) );
272// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 274// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
273// this, SLOT( fauxPlay( QListViewItem *)) ); 275// this, SLOT( fauxPlay( QListViewItem *)) );
274 276
275// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 277// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
276// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 278// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
277 279
278 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 280 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
279 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 281 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
280 282
281 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 283 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
282 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 284 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
283 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 285 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
284 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 286 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
285 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 287 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
286 288
287 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 289 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
288// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 290// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
289 291
290 setCentralWidget( vbox5 ); 292 setCentralWidget( vbox5 );
291 293
292 Config cfg( "OpiePlayer" ); 294 Config cfg( "OpiePlayer" );
293 readConfig( cfg ); 295 readConfig( cfg );
294 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 296 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
295// qDebug("currentList is "+currentPlaylist); 297// qDebug("currentList is "+currentPlaylist);
296 loadList(DocLnk( currentPlaylist)); 298 loadList(DocLnk( currentPlaylist));
297 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 299 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
298 300
299 initializeStates(); 301 initializeStates();
300} 302}
301 303
302 304
303PlayListWidget::~PlayListWidget() { 305PlayListWidget::~PlayListWidget() {
304 Config cfg( "OpiePlayer" ); 306 Config cfg( "OpiePlayer" );
305 writeConfig( cfg ); 307 writeConfig( cfg );
@@ -336,383 +338,384 @@ void PlayListWidget::readConfig( Config& cfg ) {
336 QString linkFile = cfg.readEntry( entryName ); 338 QString linkFile = cfg.readEntry( entryName );
337 DocLnk lnk( linkFile ); 339 DocLnk lnk( linkFile );
338 if ( lnk.isValid() ) { 340 if ( lnk.isValid() ) {
339 d->selectedFiles->addToSelection( lnk ); 341 d->selectedFiles->addToSelection( lnk );
340 } 342 }
341 } 343 }
342 d->selectedFiles->setSelectedItem( currentString); 344 d->selectedFiles->setSelectedItem( currentString);
343// d->selectedFiles->setSelectedItem( (const QString &)currentString); 345// d->selectedFiles->setSelectedItem( (const QString &)currentString);
344} 346}
345 347
346 348
347void PlayListWidget::writeConfig( Config& cfg ) const { 349void PlayListWidget::writeConfig( Config& cfg ) const {
348 350
349 d->selectedFiles->writeCurrent( cfg); 351 d->selectedFiles->writeCurrent( cfg);
350 cfg.setGroup("PlayList"); 352 cfg.setGroup("PlayList");
351 int noOfFiles = 0; 353 int noOfFiles = 0;
352 d->selectedFiles->first(); 354 d->selectedFiles->first();
353 do { 355 do {
354 const DocLnk *lnk = d->selectedFiles->current(); 356 const DocLnk *lnk = d->selectedFiles->current();
355 if ( lnk ) { 357 if ( lnk ) {
356 QString entryName; 358 QString entryName;
357 entryName.sprintf( "File%i", noOfFiles + 1 ); 359 entryName.sprintf( "File%i", noOfFiles + 1 );
358// qDebug(entryName); 360// qDebug(entryName);
359 cfg.writeEntry( entryName, lnk->linkFile() ); 361 cfg.writeEntry( entryName, lnk->linkFile() );
360 // if this link does exist, add it so we have the file 362 // if this link does exist, add it so we have the file
361 // next time... 363 // next time...
362 if ( !QFile::exists( lnk->linkFile() ) ) { 364 if ( !QFile::exists( lnk->linkFile() ) ) {
363 // the way writing lnks doesn't really check for out 365 // the way writing lnks doesn't really check for out
364 // of disk space, but check it anyway. 366 // of disk space, but check it anyway.
365 if ( !lnk->writeLink() ) { 367 if ( !lnk->writeLink() ) {
366 QMessageBox::critical( 0, tr("Out of space"), 368 QMessageBox::critical( 0, tr("Out of space"),
367 tr( "There was a problem saving " 369 tr( "There was a problem saving "
368 "the playlist.\n" 370 "the playlist.\n"
369 "Your playlist " 371 "Your playlist "
370 "may be missing some entries\n" 372 "may be missing some entries\n"
371 "the next time you start it." ) 373 "the next time you start it." )
372 ); 374 );
373 } 375 }
374 } 376 }
375 noOfFiles++; 377 noOfFiles++;
376 } 378 }
377 } 379 }
378 while ( d->selectedFiles->next() ); 380 while ( d->selectedFiles->next() );
379 cfg.writeEntry("NumberOfFiles", noOfFiles ); 381 cfg.writeEntry("NumberOfFiles", noOfFiles );
380} 382}
381 383
382 384
383void PlayListWidget::addToSelection( const DocLnk& lnk ) { 385void PlayListWidget::addToSelection( const DocLnk& lnk ) {
384// qDebug("add"); 386// qDebug("add");
385 d->setDocumentUsed = FALSE; 387 d->setDocumentUsed = FALSE;
386 if ( mediaPlayerState->playlist() ) 388 if ( mediaPlayerState->playlist() )
387 d->selectedFiles->addToSelection( lnk ); 389 d->selectedFiles->addToSelection( lnk );
388 else 390 else
389 mediaPlayerState->setPlaying( TRUE ); 391 mediaPlayerState->setPlaying( TRUE );
390} 392}
391 393
392 394
393void PlayListWidget::clearList() { 395void PlayListWidget::clearList() {
394 while ( first() ) 396 while ( first() )
395 d->selectedFiles->removeSelected(); 397 d->selectedFiles->removeSelected();
396} 398}
397 399
398 400
399void PlayListWidget::addAllToList() { 401void PlayListWidget::addAllToList() {
400 DocLnkSet filesAll; 402 DocLnkSet filesAll;
401 Global::findDocuments(&filesAll, "video/*;audio/*"); 403 Global::findDocuments(&filesAll, "video/*;audio/*");
402 QListIterator<DocLnk> Adit( filesAll.children() ); 404 QListIterator<DocLnk> Adit( filesAll.children() );
403 for ( ; Adit.current(); ++Adit ) 405 for ( ; Adit.current(); ++Adit )
404 d->selectedFiles->addToSelection( **Adit ); 406 d->selectedFiles->addToSelection( **Adit );
405} 407}
406 408
407 409
408void PlayListWidget::addAllMusicToList() { 410void PlayListWidget::addAllMusicToList() {
409// DocLnkSet files; 411// DocLnkSet files;
410// Global::findDocuments(&files, "audio/*"); 412// Global::findDocuments(&files, "audio/*");
411 QListIterator<DocLnk> dit( files.children() ); 413 QListIterator<DocLnk> dit( files.children() );
412 for ( ; dit.current(); ++dit ) 414 for ( ; dit.current(); ++dit )
413 d->selectedFiles->addToSelection( **dit ); 415 d->selectedFiles->addToSelection( **dit );
414} 416}
415 417
416 418
417void PlayListWidget::addAllVideoToList() { 419void PlayListWidget::addAllVideoToList() {
418 QListIterator<DocLnk> dit( vFiles.children() ); 420 QListIterator<DocLnk> dit( vFiles.children() );
419 for ( ; dit.current(); ++dit ) 421 for ( ; dit.current(); ++dit )
420 d->selectedFiles->addToSelection( **dit ); 422 d->selectedFiles->addToSelection( **dit );
421} 423}
422 424
423 425
424void PlayListWidget::setDocument(const QString& fileref) { 426void PlayListWidget::setDocument(const QString& fileref) {
425 qDebug(fileref); 427 qDebug(fileref);
426 fromSetDocument = TRUE; 428 fromSetDocument = TRUE;
427 if ( fileref.isNull() ) { 429 if ( fileref.isNull() ) {
428 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 430 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
429 return; 431 return;
430 } 432 }
431// qDebug("setDocument "+fileref); 433// qDebug("setDocument "+fileref);
432 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 434// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
433 clearList(); 435// clearList();
434 addToSelection( DocLnk( fileref ) ); 436// addToSelection( DocLnk( fileref ) );
435 d->setDocumentUsed = TRUE; 437// d->setDocumentUsed = TRUE;
436 d->selectedFiles->first(); 438// d->selectedFiles->first();
437 qApp->processEvents(); 439// qApp->processEvents();
438 } 440// }
439 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 441// else
442 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
440 clearList(); 443 clearList();
441 loadList(DocLnk(fileref)); 444 loadList(DocLnk(fileref));
442 d->selectedFiles->first(); 445 d->selectedFiles->first();
443 } else { 446 } else {
444 clearList(); 447 clearList();
445 addToSelection( DocLnk( fileref ) ); 448 addToSelection( DocLnk( fileref ) );
446 d->setDocumentUsed = TRUE; 449 d->setDocumentUsed = TRUE;
447 mediaPlayerState->setPlaying( FALSE ); 450 mediaPlayerState->setPlaying( FALSE );
448 qApp->processEvents(); 451 qApp->processEvents();
449 mediaPlayerState->setPlaying( TRUE ); 452 mediaPlayerState->setPlaying( TRUE );
450 qApp->processEvents(); 453 qApp->processEvents();
451 setCaption(tr("OpiePlayer")); 454 setCaption(tr("OpiePlayer"));
452 } 455 }
453} 456}
454 457
455 458
456void PlayListWidget::setActiveWindow() { 459void PlayListWidget::setActiveWindow() {
457 // When we get raised we need to ensure that it switches views 460 // When we get raised we need to ensure that it switches views
458 char origView = mediaPlayerState->view(); 461 char origView = mediaPlayerState->view();
459 mediaPlayerState->setView( 'l' ); // invalidate 462 mediaPlayerState->setView( 'l' ); // invalidate
460 mediaPlayerState->setView( origView ); // now switch back 463 mediaPlayerState->setView( origView ); // now switch back
461} 464}
462 465
463 466
464void PlayListWidget::useSelectedDocument() { 467void PlayListWidget::useSelectedDocument() {
465 d->setDocumentUsed = FALSE; 468 d->setDocumentUsed = FALSE;
466} 469}
467 470
468 471
469const DocLnk *PlayListWidget::current() { // this is fugly 472const DocLnk *PlayListWidget::current() { // this is fugly
470 473
471// if( fromSetDocument) { 474// if( fromSetDocument) {
472// qDebug("from setDoc"); 475// qDebug("from setDoc");
473// DocLnkSet files; 476// DocLnkSet files;
474// Global::findDocuments(&files, "video/*;audio/*"); 477// Global::findDocuments(&files, "video/*;audio/*");
475// QListIterator<DocLnk> dit( files.children() ); 478// QListIterator<DocLnk> dit( files.children() );
476// for ( ; dit.current(); ++dit ) { 479// for ( ; dit.current(); ++dit ) {
477// if(dit.current()->linkFile() == setDocFileRef) { 480// if(dit.current()->linkFile() == setDocFileRef) {
478// qDebug(setDocFileRef); 481// qDebug(setDocFileRef);
479// return dit; 482// return dit;
480// } 483// }
481// } 484// }
482// } else 485// } else
483 486
484 487
485 switch (tabWidget->currentPageIndex()) { 488 switch (tabWidget->currentPageIndex()) {
486 case 0: //playlist 489 case 0: //playlist
487 { 490 {
488 qDebug("playlist"); 491 qDebug("playlist");
489 if ( mediaPlayerState->playlist() ) { 492 if ( mediaPlayerState->playlist() ) {
490 return d->selectedFiles->current(); 493 return d->selectedFiles->current();
491 } 494 }
492 else if ( d->setDocumentUsed && d->current ) { 495 else if ( d->setDocumentUsed && d->current ) {
493 return d->current; 496 return d->current;
494 } else { 497 } else {
495 return d->files->selected(); 498 return d->files->selected();
496 } 499 }
497 } 500 }
498 break; 501 break;
499 case 1://audio 502 case 1://audio
500 { 503 {
501 qDebug("audioView"); 504 qDebug("audioView");
502// Global::findDocuments(&files, "audio/*"); 505// Global::findDocuments(&files, "audio/*");
503 QListIterator<DocLnk> dit( files.children() ); 506 QListIterator<DocLnk> dit( files.children() );
504 for ( ; dit.current(); ++dit ) { 507 for ( ; dit.current(); ++dit ) {
505 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 508 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
506 qDebug("here"); 509 qDebug("here");
507 insanityBool=TRUE; 510 insanityBool=TRUE;
508 return dit; 511 return dit;
509 } 512 }
510 } 513 }
511 } 514 }
512 break; 515 break;
513 case 2: // video 516 case 2: // video
514 { 517 {
515 qDebug("videoView"); 518 qDebug("videoView");
516// Global::findDocuments(&vFiles, "video/*"); 519// Global::findDocuments(&vFiles, "video/*");
517 QListIterator<DocLnk> Vdit( vFiles.children() ); 520 QListIterator<DocLnk> Vdit( vFiles.children() );
518 for ( ; Vdit.current(); ++Vdit ) { 521 for ( ; Vdit.current(); ++Vdit ) {
519 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 522 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
520 insanityBool=TRUE; 523 insanityBool=TRUE;
521 return Vdit; 524 return Vdit;
522 } 525 }
523 } 526 }
524 } 527 }
525 break; 528 break;
526 }; 529 };
527 return 0; 530 return 0;
528} 531}
529 532
530bool PlayListWidget::prev() { 533bool PlayListWidget::prev() {
531 if ( mediaPlayerState->playlist() ) { 534 if ( mediaPlayerState->playlist() ) {
532 if ( mediaPlayerState->shuffled() ) { 535 if ( mediaPlayerState->shuffled() ) {
533 const DocLnk *cur = current(); 536 const DocLnk *cur = current();
534 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 537 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
535 for ( int i = 0; i < j; i++ ) { 538 for ( int i = 0; i < j; i++ ) {
536 if ( !d->selectedFiles->next() ) 539 if ( !d->selectedFiles->next() )
537 d->selectedFiles->first(); 540 d->selectedFiles->first();
538 } 541 }
539 if ( cur == current() ) 542 if ( cur == current() )
540 if ( !d->selectedFiles->next() ) 543 if ( !d->selectedFiles->next() )
541 d->selectedFiles->first(); 544 d->selectedFiles->first();
542 return TRUE; 545 return TRUE;
543 } else { 546 } else {
544 if ( !d->selectedFiles->prev() ) { 547 if ( !d->selectedFiles->prev() ) {
545 if ( mediaPlayerState->looping() ) { 548 if ( mediaPlayerState->looping() ) {
546 return d->selectedFiles->last(); 549 return d->selectedFiles->last();
547 } else { 550 } else {
548 return FALSE; 551 return FALSE;
549 } 552 }
550 } 553 }
551 return TRUE; 554 return TRUE;
552 } 555 }
553 } else { 556 } else {
554 return mediaPlayerState->looping(); 557 return mediaPlayerState->looping();
555 } 558 }
556} 559}
557 560
558 561
559bool PlayListWidget::next() { 562bool PlayListWidget::next() {
560 if ( mediaPlayerState->playlist() ) { 563 if ( mediaPlayerState->playlist() ) {
561 if ( mediaPlayerState->shuffled() ) { 564 if ( mediaPlayerState->shuffled() ) {
562 return prev(); 565 return prev();
563 } else { 566 } else {
564 if ( !d->selectedFiles->next() ) { 567 if ( !d->selectedFiles->next() ) {
565 if ( mediaPlayerState->looping() ) { 568 if ( mediaPlayerState->looping() ) {
566 return d->selectedFiles->first(); 569 return d->selectedFiles->first();
567 } else { 570 } else {
568 return FALSE; 571 return FALSE;
569 } 572 }
570 } 573 }
571 return TRUE; 574 return TRUE;
572 } 575 }
573 } else { 576 } else {
574 return mediaPlayerState->looping(); 577 return mediaPlayerState->looping();
575 } 578 }
576} 579}
577 580
578 581
579bool PlayListWidget::first() { 582bool PlayListWidget::first() {
580 if ( mediaPlayerState->playlist() ) 583 if ( mediaPlayerState->playlist() )
581 return d->selectedFiles->first(); 584 return d->selectedFiles->first();
582 else 585 else
583 return mediaPlayerState->looping(); 586 return mediaPlayerState->looping();
584} 587}
585 588
586 589
587bool PlayListWidget::last() { 590bool PlayListWidget::last() {
588 if ( mediaPlayerState->playlist() ) 591 if ( mediaPlayerState->playlist() )
589 return d->selectedFiles->last(); 592 return d->selectedFiles->last();
590 else 593 else
591 return mediaPlayerState->looping(); 594 return mediaPlayerState->looping();
592} 595}
593 596
594 597
595void PlayListWidget::saveList() { 598void PlayListWidget::saveList() {
596 599
597 QString filename; 600 QString filename;
598 InputDialog *fileDlg; 601 InputDialog *fileDlg;
599 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 602 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
600 fileDlg->exec(); 603 fileDlg->exec();
601 if( fileDlg->result() == 1 ) { 604 if( fileDlg->result() == 1 ) {
602 if ( d->current ) 605 if ( d->current )
603 delete d->current; 606 delete d->current;
604 filename = fileDlg->LineEdit1->text();//+".playlist"; 607 filename = fileDlg->LineEdit1->text();//+".playlist";
605// qDebug("saving playlist "+filename+".playlist"); 608// qDebug("saving playlist "+filename+".playlist");
606 Config cfg( filename +".playlist"); 609 Config cfg( filename +".playlist");
607 writeConfig( cfg ); 610 writeConfig( cfg );
608 611
609// qDebug("same name so delete lnk??"); 612// qDebug("same name so delete lnk??");
610// if( playLists->selected()->name() == filename) { 613// if( playLists->selected()->name() == filename) {
611 614
612// qDebug("same name so delete lnk"); 615// qDebug("same name so delete lnk");
613// QFile().remove(playLists->selected()->file()); 616// QFile().remove(playLists->selected()->file());
614// QFile().remove(playLists->selected()->linkFile()); 617// QFile().remove(playLists->selected()->linkFile());
615// playLists->reread(); 618// playLists->reread();
616// } 619// }
617// qDebug("new doclnk"); 620// qDebug("new doclnk");
618 DocLnk lnk; 621 DocLnk lnk;
619// lnk.setComment( ""); 622// lnk.setComment( "");
620 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 623 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
621 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 624 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
622 lnk.setIcon("mpegplayer/playlist2"); 625 lnk.setIcon("opieplayer/playlist2");
623 lnk.setName( filename); //sets file name 626 lnk.setName( filename); //sets file name
624// qDebug(filename); 627// qDebug(filename);
625 if(!lnk.writeLink()) 628 if(!lnk.writeLink())
626 qDebug("Writing doclink did not work"); 629 qDebug("Writing doclink did not work");
627 } 630 }
628 Config config( "OpiePlayer" ); 631 Config config( "OpiePlayer" );
629 config.writeEntry("CurrentPlaylist",filename); 632 config.writeEntry("CurrentPlaylist",filename);
630 setCaption(tr("OpiePlayer: ")+filename); 633 setCaption(tr("OpiePlayer: ")+filename);
631 d->selectedFiles->first(); 634 d->selectedFiles->first();
632 if(fileDlg) 635 if(fileDlg)
633 delete fileDlg; 636 delete fileDlg;
634} 637}
635 638
636void PlayListWidget::loadList( const DocLnk & lnk) { 639void PlayListWidget::loadList( const DocLnk & lnk) {
637 QString name= lnk.name(); 640 QString name= lnk.name();
638// qDebug("currentList is "+name); 641// qDebug("currentList is "+name);
639 if( name.length()>1) { 642 if( name.length()>1) {
640 setCaption("OpiePlayer: "+name); 643 setCaption("OpiePlayer: "+name);
641// qDebug("load list "+ name+".playlist"); 644// qDebug("load list "+ name+".playlist");
642 clearList(); 645 clearList();
643 Config cfg( name+".playlist"); 646 Config cfg( name+".playlist");
644 readConfig(cfg); 647 readConfig(cfg);
645 648
646 tabWidget->setCurrentPage(0); 649 tabWidget->setCurrentPage(0);
647 650
648 Config config( "OpiePlayer" ); 651 Config config( "OpiePlayer" );
649 config.writeEntry("CurrentPlaylist", name); 652 config.writeEntry("CurrentPlaylist", name);
650// d->selectedFiles->first(); 653// d->selectedFiles->first();
651 } 654 }
652 655
653} 656}
654 657
655void PlayListWidget::setPlaylist( bool shown ) { 658void PlayListWidget::setPlaylist( bool shown ) {
656 if ( shown ) 659 if ( shown )
657 d->playListFrame->show(); 660 d->playListFrame->show();
658 else 661 else
659 d->playListFrame->hide(); 662 d->playListFrame->hide();
660} 663}
661 664
662void PlayListWidget::setView( char view ) { 665void PlayListWidget::setView( char view ) {
663 if ( view == 'l' ) 666 if ( view == 'l' )
664 showMaximized(); 667 showMaximized();
665 else 668 else
666 hide(); 669 hide();
667} 670}
668 671
669void PlayListWidget::addSelected() { 672void PlayListWidget::addSelected() {
670 673
671 Config cfg( "OpiePlayer" ); 674 Config cfg( "OpiePlayer" );
672 cfg.setGroup("PlayList"); 675 cfg.setGroup("PlayList");
673 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 676 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
674 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 677 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
675 678
676 switch (tabWidget->currentPageIndex()) { 679 switch (tabWidget->currentPageIndex()) {
677 case 0: //playlist 680 case 0: //playlist
678 break; 681 break;
679 case 1: { //audio 682 case 1: { //audio
680 for ( int i = 0; i < noOfFiles; i++ ) { 683 for ( int i = 0; i < noOfFiles; i++ ) {
681 QString entryName; 684 QString entryName;
682 entryName.sprintf( "File%i", i + 1 ); 685 entryName.sprintf( "File%i", i + 1 );
683 QString linkFile = cfg.readEntry( entryName ); 686 QString linkFile = cfg.readEntry( entryName );
684 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { 687 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) {
685 int result= QMessageBox::warning(this,tr("OpiePlayer"), 688 int result= QMessageBox::warning(this,tr("OpiePlayer"),
686 tr("This is all ready in your playlist.\nContinue?"), 689 tr("This is all ready in your playlist.\nContinue?"),
687 tr("Yes"),tr("No"),0,0,1); 690 tr("Yes"),tr("No"),0,0,1);
688 if (result !=0) 691 if (result !=0)
689 return; 692 return;
690 } 693 }
691 } 694 }
692 addToSelection( audioView->selectedItem() ); 695 addToSelection( audioView->selectedItem() );
693 tabWidget->setCurrentPage(1); 696 tabWidget->setCurrentPage(1);
694 } 697 }
695 break; 698 break;
696 case 2: { // video 699 case 2: { // video
697 for ( int i = 0; i < noOfFiles; i++ ) { 700 for ( int i = 0; i < noOfFiles; i++ ) {
698 QString entryName; 701 QString entryName;
699 entryName.sprintf( "File%i", i + 1 ); 702 entryName.sprintf( "File%i", i + 1 );
700 QString linkFile = cfg.readEntry( entryName ); 703 QString linkFile = cfg.readEntry( entryName );
701 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 704 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
702 int result= QMessageBox::warning(this,tr("OpiePlayer"), 705 int result= QMessageBox::warning(this,tr("OpiePlayer"),
703 tr("This is all ready in your playlist.\nContinue?"), 706 tr("This is all ready in your playlist.\nContinue?"),
704 tr("Yes"),tr("No"),0,0,1); 707 tr("Yes"),tr("No"),0,0,1);
705 if (result !=0) 708 if (result !=0)
706 return; 709 return;
707 } 710 }
708 } 711 }
709 addToSelection( videoView->selectedItem() ); 712 addToSelection( videoView->selectedItem() );
710 tabWidget->setCurrentPage(2); 713 tabWidget->setCurrentPage(2);
711 } 714 }
712 break; 715 break;
713 }; 716 };
714} 717}
715 718
716void PlayListWidget::removeSelected() { 719void PlayListWidget::removeSelected() {
717 d->selectedFiles->removeSelected( ); 720 d->selectedFiles->removeSelected( );
718} 721}
@@ -853,151 +856,166 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
853 m.exec( QCursor::pos() ); 856 m.exec( QCursor::pos() );
854 } 857 }
855 break; 858 break;
856 }; 859 };
857} 860}
858 861
859void PlayListWidget::playSelected() 862void PlayListWidget::playSelected()
860{ 863{
861 btnPlay( TRUE); 864 btnPlay( TRUE);
862} 865}
863 866
864void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 867void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
865{ 868{
866 switch (mouse) { 869 switch (mouse) {
867 case 1: 870 case 1:
868 break; 871 break;
869 case 2:{ 872 case 2:{
870 QPopupMenu m; 873 QPopupMenu m;
871 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 874 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
872 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 875 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
873// m.insertSeparator(); 876// m.insertSeparator();
874 m.exec( QCursor::pos() ); 877 m.exec( QCursor::pos() );
875 } 878 }
876 break; 879 break;
877 }; 880 };
878 881
879} 882}
880 883
881void PlayListWidget::listDelete() { 884void PlayListWidget::listDelete() {
882 Config cfg( "OpiePlayer" ); 885 Config cfg( "OpiePlayer" );
883 cfg.setGroup("PlayList"); 886 cfg.setGroup("PlayList");
884 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 887 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
885 QString file; 888 QString file;
886 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 889 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
887 switch ( tabWidget->currentPageIndex()) { 890 switch ( tabWidget->currentPageIndex()) {
888 case 0: 891 case 0:
889 break; 892 break;
890 case 1: 893 case 1:
891 { 894 {
892 file = audioView->selectedItem()->text(0); 895 file = audioView->selectedItem()->text(0);
893// Global::findDocuments(&files, "audio/*"); 896// Global::findDocuments(&files, "audio/*");
894// AppLnkSet appFiles; 897// AppLnkSet appFiles;
895 QListIterator<DocLnk> dit( files.children() ); 898 QListIterator<DocLnk> dit( files.children() );
896 for ( ; dit.current(); ++dit ) { 899 for ( ; dit.current(); ++dit ) {
897 if( dit.current()->name() == file) { 900 if( dit.current()->name() == file) {
898// qDebug(file); 901// qDebug(file);
899 LnkProperties prop( dit.current() ); 902 LnkProperties prop( dit.current() );
900// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 903// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
901 prop.showMaximized(); 904 prop.showMaximized();
902 prop.exec(); 905 prop.exec();
903 } 906 }
904 } 907 }
905 populateAudioView(); 908 populateAudioView();
906 } 909 }
907 break; 910 break;
908 case 2: 911 case 2:
909 { 912 {
910// file = videoView->selectedItem()->text(0); 913// file = videoView->selectedItem()->text(0);
911// for ( int i = 0; i < noOfFiles; i++ ) { 914// for ( int i = 0; i < noOfFiles; i++ ) {
912// QString entryName; 915// QString entryName;
913// entryName.sprintf( "File%i", i + 1 ); 916// entryName.sprintf( "File%i", i + 1 );
914// QString linkFile = cfg.readEntry( entryName ); 917// QString linkFile = cfg.readEntry( entryName );
915// AppLnk lnk( AppLnk(linkFile)); 918// AppLnk lnk( AppLnk(linkFile));
916// if( lnk.name() == file ) { 919// if( lnk.name() == file ) {
917// LnkProperties prop( &lnk); 920// LnkProperties prop( &lnk);
918// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 921// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
919// prop.showMaximized(); 922// prop.showMaximized();
920// prop.exec(); 923// prop.exec();
921// } 924// }
922// } 925// }
923 } 926 }
924 break; 927 break;
925 }; 928 };
926} 929}
927 930
928void PlayListWidget::populateAudioView() { 931void PlayListWidget::populateAudioView() {
929// if(files) 932// if(files)
930// files.~DocLnkSet(); 933// files.~DocLnkSet();
931 StorageInfo storageInfo; 934 StorageInfo storageInfo;
932 const QList<FileSystem> &fs = storageInfo.fileSystems(); 935 const QList<FileSystem> &fs = storageInfo.fileSystems();
933 936
934 Global::findDocuments(&files, "audio/*"); 937 Global::findDocuments(&files, "audio/*");
935 QListIterator<DocLnk> dit( files.children() ); 938 QListIterator<DocLnk> dit( files.children() );
936 QListIterator<FileSystem> it ( fs ); 939 QListIterator<FileSystem> it ( fs );
937 audioView->clear(); 940 audioView->clear();
938 QString storage; 941 QString storage;
939 for ( ; dit.current(); ++dit ) { 942 for ( ; dit.current(); ++dit ) {
940 for( ; it.current(); ++it ){ 943 for( ; it.current(); ++it ){
941 const QString name = (*it)->name(); 944 const QString name = (*it)->name();
942 const QString path = (*it)->path(); 945 const QString path = (*it)->path();
943 if(dit.current()->file().find(path) != -1 ) storage=name; 946 if(dit.current()->file().find(path) != -1 ) storage=name;
944 } 947 }
945 948
946 QListViewItem * newItem; 949 QListViewItem * newItem;
947 if ( QFile( dit.current()->file()).exists() ) { 950 if ( QFile( dit.current()->file()).exists() ) {
948 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 951 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
949 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); 952 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
950 } 953 }
951 } 954 }
952} 955}
953 956
954void PlayListWidget::populateVideoView() { 957void PlayListWidget::populateVideoView() {
955 StorageInfo storageInfo; 958 StorageInfo storageInfo;
956 const QList<FileSystem> &fs = storageInfo.fileSystems(); 959 const QList<FileSystem> &fs = storageInfo.fileSystems();
957 960
958 Global::findDocuments(&vFiles, "video/*"); 961 Global::findDocuments(&vFiles, "video/*");
959 QListIterator<DocLnk> Vdit( vFiles.children() ); 962 QListIterator<DocLnk> Vdit( vFiles.children() );
960 QListIterator<FileSystem> it ( fs ); 963 QListIterator<FileSystem> it ( fs );
961 videoView->clear(); 964 videoView->clear();
962 QString storage; 965 QString storage;
963 for ( ; Vdit.current(); ++Vdit ) { 966 for ( ; Vdit.current(); ++Vdit ) {
964 for( ; it.current(); ++it ){ 967 for( ; it.current(); ++it ){
965 const QString name = (*it)->name(); 968 const QString name = (*it)->name();
966 const QString path = (*it)->path(); 969 const QString path = (*it)->path();
967 if( Vdit.current()->file().find(path) != -1 ) storage=name; 970 if( Vdit.current()->file().find(path) != -1 ) storage=name;
968 } 971 }
969 972
970 QListViewItem * newItem; 973 QListViewItem * newItem;
971 if ( QFile( Vdit.current()->file()).exists() ) { 974 if ( QFile( Vdit.current()->file()).exists() ) {
972 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 975 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
973 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 976 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
974 } 977 }
975 } 978 }
976} 979}
977 980
978void PlayListWidget::openFile() { 981void PlayListWidget::openFile() {
979 QString filename; 982 QString filename, name;
980 InputDialog *fileDlg; 983 InputDialog *fileDlg;
981 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 984 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
982 fileDlg->exec(); 985 fileDlg->exec();
983 if( fileDlg->result() == 1 ) { 986 if( fileDlg->result() == 1 ) {
984 filename = fileDlg->LineEdit1->text(); 987 filename = fileDlg->LineEdit1->text();
988
989// InputDialog *fileDlg2;
990// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0);
991// fileDlg2->exec();
992// if( fileDlg2->result() == 1 ) {
993// name = fileDlg2->LineEdit1->text();
994// }
995//http://205.188.234.129:8030
996 qDebug(filename);
997 DocLnk lnk;
998// if(filename.left(7) == "http://")
999// name= filename.right(filename.length()-filename.find("http://")-7);
1000// else name = filename;
1001// qDebug("name is "+name);
1002// lnk.setComment(filename);
1003 lnk.setName(filename); //sets file name
1004 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1005 filename += "/";
1006 lnk.setFile(filename); //sets File property
1007
1008 lnk.setType("audio/x-mpegurl");
1009 lnk.setExec("opieplayer");
1010 lnk.setIcon("opieplayer/MPEGPlayer");
1011
1012 if(!lnk.writeLink())
1013 qDebug("Writing doclink did not work");
1014 d->selectedFiles->addToSelection( lnk);
1015// if(fileDlg2)
1016// delete fileDlg2;
985 } 1017 }
986 qDebug(filename); 1018
987 DocLnk lnk;
988 QString name = filename.right(filename.length()-filename.find("http://")-7);
989 qDebug(name);
990 lnk.setName( name); //sets file name
991// lnk.setComment();
992 lnk.setFile(filename); //sets File property
993// problem is, the launcher sees this as a broken link and does not display it :(
994 lnk.setType("audio/x-mpegurl");
995 lnk.setExec("opieplayer");
996 lnk.setIcon("opieplayer/MPEGPlayer");
997
998 if(!lnk.writeLink())
999 qDebug("Writing doclink did not work");
1000 d->selectedFiles->addToSelection( lnk);
1001 if(fileDlg) 1019 if(fileDlg)
1002 delete fileDlg; 1020 delete fileDlg;
1003} 1021}