summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp11
3 files changed, 15 insertions, 8 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 0ced256..c54a00f 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,633 +1,633 @@
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 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/categories.h> 27#include <qpe/categories.h>
28#include <qpe/categoryselect.h> 28#include <qpe/categoryselect.h>
29#include <qpe/menubutton.h> 29#include <qpe/menubutton.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32 32
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qdict.h> 34#include <qdict.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qfileinfo.h> 36#include <qfileinfo.h>
37#include <qhbox.h> 37#include <qhbox.h>
38#include <qiconview.h> 38#include <qiconview.h>
39#include <qpainter.h> 39#include <qpainter.h>
40#include <qregexp.h> 40#include <qregexp.h>
41#include <qtoolbutton.h> 41#include <qtoolbutton.h>
42 42
43class LauncherIconView : public QIconView { 43class LauncherIconView : public QIconView {
44public: 44public:
45 QColor iconText; 45 QColor iconText;
46 QColor background; 46 QColor background;
47 47
48 LauncherIconView( QWidget* parent, const char* name=0 ) : 48 LauncherIconView( QWidget* parent, const char* name=0 ) :
49 QIconView(parent,name), 49 QIconView(parent,name),
50 tf(""), 50 tf(""),
51 cf(0), 51 cf(0),
52 bsy(0) 52 bsy(0)
53 { 53 {
54 sortmeth = Name; 54 sortmeth = Name;
55 hidden.setAutoDelete(TRUE); 55 hidden.setAutoDelete(TRUE);
56 ike = FALSE; 56 ike = FALSE;
57 57
58 Config config( "qpe" ); 58 Config config( "qpe" );
59 config.setGroup( "Appearance" ); 59 config.setGroup( "Appearance" );
60 iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) ); 60 iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) );
61 background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) ); 61 background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) );
62 } 62 }
63 63
64 ~LauncherIconView() 64 ~LauncherIconView()
65 { 65 {
66#if 0 // debuggery 66#if 0 // debuggery
67 QListIterator<AppLnk> it(hidden); 67 QListIterator<AppLnk> it(hidden);
68 AppLnk* l; 68 AppLnk* l;
69 while ((l=it.current())) { 69 while ((l=it.current())) {
70 ++it; 70 ++it;
71 //qDebug("%p: hidden (should remove)",l); 71 //qDebug("%p: hidden (should remove)",l);
72 } 72 }
73#endif 73#endif
74 } 74 }
75 75
76 QIconViewItem* busyItem() const { return bsy; } 76 QIconViewItem* busyItem() const { return bsy; }
77 77
78 void updateCategoriesAndMimeTypes(); 78 void updateCategoriesAndMimeTypes();
79 79
80 void doAutoScroll() 80 void doAutoScroll()
81 { 81 {
82 // We don't want rubberbanding (yet) 82 // We don't want rubberbanding (yet)
83 } 83 }
84 84
85 void setBusy(bool on) 85 void setBusy(bool on)
86 { 86 {
87 QIconViewItem *c = on ? currentItem() : 0; 87 QIconViewItem *c = on ? currentItem() : 0;
88 if ( bsy != c ) { 88 if ( bsy != c ) {
89 QIconViewItem* o = bsy; 89 QIconViewItem* o = bsy;
90 bsy = c; 90 bsy = c;
91 if ( o ) o->repaint(); 91 if ( o ) o->repaint();
92 if ( c ) c->repaint(); 92 if ( c ) c->repaint();
93 } 93 }
94 } 94 }
95 95
96 bool inKeyEvent() const { return ike; } 96 bool inKeyEvent() const { return ike; }
97 void keyPressEvent(QKeyEvent* e) 97 void keyPressEvent(QKeyEvent* e)
98 { 98 {
99 ike = TRUE; 99 ike = TRUE;
100 if ( e->key() == Key_F33 ) { 100 if ( e->key() == Key_F33 ) {
101 // "OK" button 101 // "OK" button
102 returnPressed(currentItem()); 102 returnPressed(currentItem());
103 } 103 }
104 QIconView::keyPressEvent(e); 104 QIconView::keyPressEvent(e);
105 ike = FALSE; 105 ike = FALSE;
106 } 106 }
107 107
108 void addItem(AppLnk* app, bool resort=TRUE); 108 void addItem(AppLnk* app, bool resort=TRUE);
109 bool removeLink(const QString& linkfile); 109 bool removeLink(const QString& linkfile);
110 110
111 QStringList mimeTypes() const; 111 QStringList mimeTypes() const;
112 QStringList categories() const; 112 QStringList categories() const;
113 113
114 void clear() 114 void clear()
115 { 115 {
116 mimes.clear(); 116 mimes.clear();
117 cats.clear(); 117 cats.clear();
118 QIconView::clear(); 118 QIconView::clear();
119 hidden.clear(); 119 hidden.clear();
120 } 120 }
121 121
122 void addCatsAndMimes(AppLnk* app) 122 void addCatsAndMimes(AppLnk* app)
123 { 123 {
124 // QStringList c = app->categories(); 124 // QStringList c = app->categories();
125 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 125 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
126 // cats.replace(*cit,(void*)1); 126 // cats.replace(*cit,(void*)1);
127 // } 127 // }
128 QString maj=app->type(); 128 QString maj=app->type();
129 int sl=maj.find('/'); 129 int sl=maj.find('/');
130 if (sl>=0) { 130 if (sl>=0) {
131 QString k = maj.left(sl); 131 QString k = maj.left(sl);
132 mimes.replace(k,(void*)1); 132 mimes.replace(k,(void*)1);
133 } 133 }
134 } 134 }
135 135
136 void drawBackground( QPainter *p, const QRect &r ) 136 void drawBackground( QPainter *p, const QRect &r )
137 { 137 {
138 Config config("qpe"); 138 Config config("qpe");
139 config.setGroup("Appearance"); 139 config.setGroup("Appearance");
140 QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background"); 140 QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background");
141 // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background"; 141 // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background";
142 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; 142 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0;
143 //int backgroundMode = 2; 143 //int backgroundMode = 2;
144 144
145 if ( backgroundMode == 1 ) { 145 if ( backgroundMode == 1 ) {
146 146
147 // Double buffer the background 147 // Double buffer the background
148 static QPixmap *bg = NULL; 148 static QPixmap *bg = NULL;
149 static QColor bgColor; 149 static QColor bgColor;
150 150
151 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { 151 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) {
152 // Create a new background double buffer 152 // Create a new background double buffer
153 if (bg == NULL) 153 if (bg == NULL)
154 bg = new QPixmap( width(), height() ); 154 bg = new QPixmap( width(), height() );
155 bgColor = colorGroup().button(); 155 bgColor = colorGroup().button();
156 QPainter painter( bg ); 156 QPainter painter( bg );
157 157
158// painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); 158// painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110));
159 painter.fillRect( QRect( 0, 0, width(), height() ), background); 159 painter.fillRect( QRect( 0, 0, width(), height() ), background);
160 // Overlay the Qtopia logo in the center 160 // Overlay the Qtopia logo in the center
161 QImage logo; 161 QImage logo;
162 if (QFile::exists(backgroundImage)) { 162 if (QFile::exists(backgroundImage)) {
163 logo = QImage(backgroundImage); 163 logo = QImage(backgroundImage);
164 } else { 164 } else {
165 logo = Resource::loadImage(backgroundImage ); 165 logo = Resource::loadImage(backgroundImage );
166 } 166 }
167 if ( !logo.isNull() && config.readBoolEntry( "UseBackgroundImage", TRUE ) ) 167 if ( !logo.isNull() && config.readBoolEntry( "UseBackgroundImage", TRUE ) )
168 painter.drawImage( (width() - logo.width()) / 2, 168 painter.drawImage( (width() - logo.width()) / 2,
169 (height() - logo.height()) / 2, logo ); 169 (height() - logo.height()) / 2, logo );
170 } 170 }
171 171
172 // Draw the double buffer to the widget (it is tiled for when the icon view is large) 172 // Draw the double buffer to the widget (it is tiled for when the icon view is large)
173 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 173 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
174 (r.y() + contentsY()) % bg->height() ) ); 174 (r.y() + contentsY()) % bg->height() ) );
175 } else if ( backgroundMode == 2 ) { 175 } else if ( backgroundMode == 2 ) {
176 static QPixmap *bg = 0; 176 static QPixmap *bg = 0;
177 static QColor bgColor; 177 static QColor bgColor;
178 if ( !bg || (bgColor != colorGroup().background()) ) { 178 if ( !bg || (bgColor != colorGroup().background()) ) {
179 bgColor = colorGroup().background(); 179 bgColor = colorGroup().background();
180 bg = new QPixmap( width(), 9 ); 180 bg = new QPixmap( width(), 9 );
181 QPainter painter( bg ); 181 QPainter painter( bg );
182 for ( int i = 0; i < 3; i++ ) { 182 for ( int i = 0; i < 3; i++ ) {
183 painter.setPen( colorGroup().background().light(130) ); 183 painter.setPen( colorGroup().background().light(130) );
184 painter.drawLine( 0, i*3, width()-1, i*3 ); 184 painter.drawLine( 0, i*3, width()-1, i*3 );
185 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 185 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
186 painter.setPen( colorGroup().background().light(105) ); 186 painter.setPen( colorGroup().background().light(105) );
187 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 187 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
188 } 188 }
189 } 189 }
190 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 190 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
191 (r.y() + contentsY()) % bg->height() ) ); 191 (r.y() + contentsY()) % bg->height() ) );
192 } else { 192 } else {
193 p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); 193 p->fillRect( r, QBrush( colorGroup().background().light(110) ) );
194 } 194 }
195 } 195 }
196 196
197 void hideOrShowItems(bool resort); 197 void hideOrShowItems(bool resort);
198 198
199 void setTypeFilter(const QString& typefilter, bool resort) 199 void setTypeFilter(const QString& typefilter, bool resort)
200 { 200 {
201 tf = QRegExp(typefilter,FALSE,TRUE); 201 tf = QRegExp(typefilter,FALSE,TRUE);
202 hideOrShowItems(resort); 202 hideOrShowItems(resort);
203 } 203 }
204 204
205 void setCategoryFilter( int catfilter, bool resort ) 205 void setCategoryFilter( int catfilter, bool resort )
206 { 206 {
207 Categories cat; 207 Categories cat;
208 cat.load( categoryFileName() ); 208 cat.load( categoryFileName() );
209 QString str; 209 QString str;
210 if ( catfilter == -2 ) 210 if ( catfilter == -2 )
211 cf = 0; 211 cf = 0;
212 else 212 else
213 cf = catfilter; 213 cf = catfilter;
214 hideOrShowItems(resort); 214 hideOrShowItems(resort);
215 } 215 }
216 216
217 enum SortMethod { Name, Date, Type }; 217 enum SortMethod { Name, Date, Type };
218 218
219 void setSortMethod( SortMethod m ) 219 void setSortMethod( SortMethod m )
220 { 220 {
221 if ( sortmeth != m ) { 221 if ( sortmeth != m ) {
222 sortmeth = m; 222 sortmeth = m;
223 sort(); 223 sort();
224 } 224 }
225 } 225 }
226 226
227 int compare(const AppLnk* a, const AppLnk* b) 227 int compare(const AppLnk* a, const AppLnk* b)
228 { 228 {
229 switch (sortmeth) { 229 switch (sortmeth) {
230 case Name: 230 case Name:
231 return a->name().compare(b->name()); 231 return a->name().compare(b->name());
232 case Date: { 232 case Date: {
233 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 233 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
234 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 234 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
235 return fa.lastModified().secsTo(fb.lastModified()); 235 return fa.lastModified().secsTo(fb.lastModified());
236 } 236 }
237 case Type: 237 case Type:
238 return a->type().compare(b->type()); 238 return a->type().compare(b->type());
239 } 239 }
240 return 0; 240 return 0;
241 } 241 }
242 242
243protected: 243protected:
244 244
245 void styleChange( QStyle &old ) 245 void styleChange( QStyle &old )
246 { 246 {
247 QIconView::styleChange( old ); 247 QIconView::styleChange( old );
248 //### duplicated code from LauncherView constructor 248 //### duplicated code from LauncherView constructor
249 int dw = QApplication::desktop()->width(); 249 int dw = QApplication::desktop()->width();
250 setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 250 setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240
251 } 251 }
252 252
253private: 253private:
254 QList<AppLnk> hidden; 254 QList<AppLnk> hidden;
255 QDict<void> mimes; 255 QDict<void> mimes;
256 QDict<void> cats; 256 QDict<void> cats;
257 SortMethod sortmeth; 257 SortMethod sortmeth;
258 QRegExp tf; 258 QRegExp tf;
259 int cf; 259 int cf;
260 QIconViewItem* bsy; 260 QIconViewItem* bsy;
261 bool ike; 261 bool ike;
262 262
263}; 263};
264 264
265 265
266bool LauncherView::bsy=FALSE; 266bool LauncherView::bsy=FALSE;
267 267
268void LauncherView::setBusy(bool on) 268void LauncherView::setBusy(bool on)
269{ 269{
270 icons->setBusy(on); 270 icons->setBusy(on);
271} 271}
272 272
273class LauncherItem : public QIconViewItem 273class LauncherItem : public QIconViewItem
274{ 274{
275public: 275public:
276 LauncherItem( QIconView *parent, AppLnk* applnk ); 276 LauncherItem( QIconView *parent, AppLnk* applnk );
277 ~LauncherItem() 277 ~LauncherItem()
278 { 278 {
279 LauncherIconView* liv = (LauncherIconView*)iconView(); 279 LauncherIconView* liv = (LauncherIconView*)iconView();
280 if ( liv->busyItem() == this ) 280 if ( liv->busyItem() == this )
281 liv->setBusy(FALSE); 281 liv->setBusy(FALSE);
282 delete app; 282 delete app;
283 } 283 }
284 284
285 AppLnk* appLnk() const { return app; } 285 AppLnk* appLnk() const { return app; }
286 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 286 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
287 287
288 virtual int compare ( QIconViewItem * i ) const; 288 virtual int compare ( QIconViewItem * i ) const;
289 289
290 void paintItem( QPainter *p, const QColorGroup &cg ) 290 void paintItem( QPainter *p, const QColorGroup &cg )
291 { 291 {
292 LauncherIconView* liv = (LauncherIconView*)iconView(); 292 LauncherIconView* liv = (LauncherIconView*)iconView();
293 QBrush oldBrush( liv->itemTextBackground() ); 293 QBrush oldBrush( liv->itemTextBackground() );
294 QColorGroup mycg( cg ); 294 QColorGroup mycg( cg );
295 if ( liv->currentItem() == this ) { 295 if ( liv->currentItem() == this ) {
296 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 296 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
297 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 297 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
298 } 298 }
299 else { 299 else {
300 mycg.setColor( QColorGroup::Text, liv->iconText ); 300 mycg.setColor( QColorGroup::Text, liv->iconText );
301 } 301 }
302 302
303 QIconViewItem::paintItem(p,mycg); 303 QIconViewItem::paintItem(p,mycg);
304 if ( liv->currentItem() == this ) 304 if ( liv->currentItem() == this )
305 liv->setItemTextBackground( oldBrush ); 305 liv->setItemTextBackground( oldBrush );
306 if ( liv->busyItem() == this ) { 306 if ( liv->busyItem() == this ) {
307 static QPixmap* busypm=0; 307 static QPixmap* busypm=0;
308 if ( !busypm ) 308 if ( !busypm )
309 busypm = new QPixmap(Resource::loadPixmap("launching")); 309 busypm = new QPixmap(Resource::loadPixmap("launching"));
310 p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); 310 p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm);
311 } 311 }
312 } 312 }
313 313
314protected: 314protected:
315 AppLnk* app; 315 AppLnk* app;
316}; 316};
317 317
318 318
319LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) 319LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk )
320 : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), 320 : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ),
321 app(applnk) // Takes ownership 321 app(applnk) // Takes ownership
322{ 322{
323} 323}
324 324
325int LauncherItem::compare ( QIconViewItem * i ) const 325int LauncherItem::compare ( QIconViewItem * i ) const
326{ 326{
327 LauncherIconView* view = (LauncherIconView*)iconView(); 327 LauncherIconView* view = (LauncherIconView*)iconView();
328 return view->compare(app,((LauncherItem *)i)->appLnk()); 328 return view->compare(app,((LauncherItem *)i)->appLnk());
329} 329}
330 330
331QStringList LauncherIconView::mimeTypes() const 331QStringList LauncherIconView::mimeTypes() const
332{ 332{
333 QStringList r; 333 QStringList r;
334 QDictIterator<void> it(mimes); 334 QDictIterator<void> it(mimes);
335 while (it.current()) { 335 while (it.current()) {
336 r.append(it.currentKey()); 336 r.append(it.currentKey());
337 ++it; 337 ++it;
338 } 338 }
339 r.sort(); 339 r.sort();
340 return r; 340 return r;
341} 341}
342 342
343void LauncherIconView::addItem(AppLnk* app, bool resort) 343void LauncherIconView::addItem(AppLnk* app, bool resort)
344{ 344{
345 addCatsAndMimes(app); 345 addCatsAndMimes(app);
346 346
347 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 347 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
348 && (cf == 0 || app->categories().contains(cf) 348 && (cf == 0 || app->categories().contains(cf)
349 || cf == -1 && app->categories().count() == 0 ) ) 349 || cf == -1 && app->categories().count() == 0 ) )
350 (void) new LauncherItem( this, app ); 350 (void) new LauncherItem( this, app );
351 else 351 else
352 hidden.append(app); 352 hidden.append(app);
353 if ( resort ) 353 if ( resort )
354 sort(); 354 sort();
355} 355}
356 356
357void LauncherIconView::updateCategoriesAndMimeTypes() 357void LauncherIconView::updateCategoriesAndMimeTypes()
358{ 358{
359 mimes.clear(); 359 mimes.clear();
360 cats.clear(); 360 cats.clear();
361 LauncherItem* item = (LauncherItem*)firstItem(); 361 LauncherItem* item = (LauncherItem*)firstItem();
362 while (item) { 362 while (item) {
363 addCatsAndMimes(item->appLnk()); 363 addCatsAndMimes(item->appLnk());
364 item = (LauncherItem*)item->nextItem(); 364 item = (LauncherItem*)item->nextItem();
365 } 365 }
366 QListIterator<AppLnk> it(hidden); 366 QListIterator<AppLnk> it(hidden);
367 AppLnk* l; 367 AppLnk* l;
368 while ((l=it.current())) { 368 while ((l=it.current())) {
369 addCatsAndMimes(l); 369 addCatsAndMimes(l);
370 ++it; 370 ++it;
371 } 371 }
372} 372}
373 373
374void LauncherIconView::hideOrShowItems(bool resort) 374void LauncherIconView::hideOrShowItems(bool resort)
375{ 375{
376 hidden.setAutoDelete(FALSE); 376 hidden.setAutoDelete(FALSE);
377 QList<AppLnk> links=hidden; 377 QList<AppLnk> links=hidden;
378 hidden.clear(); 378 hidden.clear();
379 hidden.setAutoDelete(TRUE); 379 hidden.setAutoDelete(TRUE);
380 LauncherItem* item = (LauncherItem*)firstItem(); 380 LauncherItem* item = (LauncherItem*)firstItem();
381 while (item) { 381 while (item) {
382 links.append(item->takeAppLnk()); 382 links.append(item->takeAppLnk());
383 item = (LauncherItem*)item->nextItem(); 383 item = (LauncherItem*)item->nextItem();
384 } 384 }
385 bool oldAutoArrange = autoArrange(); 385 bool oldAutoArrange = autoArrange();
386 setAutoArrange( FALSE ); 386 setAutoArrange( FALSE );
387 clear(); 387 clear();
388 QListIterator<AppLnk> it(links); 388 QListIterator<AppLnk> it(links);
389 AppLnk* l; 389 AppLnk* l;
390 while ((l=it.current())) { 390 while ((l=it.current())) {
391 addItem(l,FALSE); 391 addItem(l,FALSE);
392 ++it; 392 ++it;
393 } 393 }
394 if ( resort ) 394 if ( resort )
395 sort(); 395 sort();
396 setAutoArrange( oldAutoArrange ); 396 setAutoArrange( oldAutoArrange );
397} 397}
398 398
399bool LauncherIconView::removeLink(const QString& linkfile) 399bool LauncherIconView::removeLink(const QString& linkfile)
400{ 400{
401 LauncherItem* item = (LauncherItem*)firstItem(); 401 LauncherItem* item = (LauncherItem*)firstItem();
402 AppLnk* l; 402 AppLnk* l;
403 bool did = FALSE; 403 bool did = FALSE;
404 DocLnk dl(linkfile); 404 DocLnk dl(linkfile);
405 while (item) { 405 while (item) {
406 l = item->appLnk(); 406 l = item->appLnk();
407 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { 407 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) {
408 delete item; 408 delete item;
409 did = TRUE; 409 did = TRUE;
410 } 410 }
411 item = (LauncherItem*)item->nextItem(); 411 item = (LauncherItem*)item->nextItem();
412 } 412 }
413 QListIterator<AppLnk> it(hidden); 413 QListIterator<AppLnk> it(hidden);
414 while ((l=it.current())) { 414 while ((l=it.current())) {
415 ++it; 415 ++it;
416 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { 416 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) {
417 hidden.removeRef(l); 417 hidden.removeRef(l);
418 did = TRUE; 418 did = TRUE;
419 } 419 }
420 } 420 }
421 return did; 421 return did;
422} 422}
423 423
424LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 424LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
425 : QVBox( parent, name, fl ) 425 : QVBox( parent, name, fl )
426{ 426{
427 icons = new LauncherIconView( this ); 427 icons = new LauncherIconView( this );
428 setFocusProxy(icons); 428 setFocusProxy(icons);
429 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 429 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
430 430
431 int dw = QApplication::desktop()->width(); 431 int dw = QApplication::desktop()->width();
432 icons->setItemsMovable( FALSE ); 432 icons->setItemsMovable( FALSE );
433 icons->setAutoArrange( TRUE ); 433 icons->setAutoArrange( TRUE );
434 icons->setSorting( TRUE ); 434 icons->setSorting( TRUE );
435 icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 435 icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240
436 icons->setGridY( fontMetrics().height()*2+24 ); 436 icons->setGridY( fontMetrics().height()*2+24 );
437 icons->setFrameStyle( QFrame::NoFrame ); 437 icons->setFrameStyle( QFrame::NoFrame );
438 icons->setSpacing( 4 ); 438 icons->setSpacing( 4 );
439 icons->setMargin( 0 ); 439 icons->setMargin( 0 );
440 icons->setSelectionMode( QIconView::Multi ); 440 icons->setSelectionMode( QIconView::Multi );
441 icons->setBackgroundMode( PaletteBase ); 441 icons->setBackgroundMode( PaletteBase );
442 442
443 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 443 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
444 SLOT(itemClicked(int, QIconViewItem *)) ); 444 SLOT(itemClicked(int, QIconViewItem *)) );
445 connect( icons, SIGNAL(selectionChanged()), 445 connect( icons, SIGNAL(selectionChanged()),
446 SLOT(selectionChanged()) ); 446 SLOT(selectionChanged()) );
447 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 447 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
448 SLOT(returnPressed(QIconViewItem *)) ); 448 SLOT(returnPressed(QIconViewItem *)) );
449 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 449 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
450 SLOT(itemPressed(int, QIconViewItem *)) ); 450 SLOT(itemPressed(int, QIconViewItem *)) );
451 451
452 tools = 0; 452 tools = 0;
453} 453}
454 454
455LauncherView::~LauncherView() 455LauncherView::~LauncherView()
456{ 456{
457} 457}
458 458
459void LauncherView::setToolsEnabled(bool y) 459void LauncherView::setToolsEnabled(bool y)
460{ 460{
461 if ( !y != !tools ) { 461 if ( !y != !tools ) {
462 if ( y ) { 462 if ( y ) {
463 tools = new QHBox(this); 463 tools = new QHBox(this);
464 464
465 // Type filter 465 // Type filter
466 typemb = new MenuButton(tools); 466 typemb = new MenuButton(tools);
467 typemb->setLabel(tr("Type: %1")); 467 typemb->setLabel(tr("Type: %1"));
468 typemb->setFixedHeight ( 20 ); 468 typemb->setFixedHeight ( 20 );
469 469
470 // Category filter 470 // Category filter
471 catmb = new CategorySelect(tools); 471 catmb = new CategorySelect(tools);
472 catmb->setFixedHeight ( 20 ); 472 catmb->setFixedHeight ( 20 );
473 473
474 updateTools(); 474 updateTools();
475 tools->show(); 475 tools->show();
476 } else { 476 } else {
477 delete tools; 477 delete tools;
478 tools = 0; 478 tools = 0;
479 } 479 }
480 } 480 }
481} 481}
482 482
483void LauncherView::updateTools() 483void LauncherView::updateTools()
484{ 484{
485 disconnect( typemb, SIGNAL(selected(const QString&)), 485 disconnect( typemb, SIGNAL(selected(const QString&)),
486 this, SLOT(showType(const QString&)) ); 486 this, SLOT(showType(const QString&)) );
487 disconnect( catmb, SIGNAL(signalSelected(int)), 487 disconnect( catmb, SIGNAL(signalSelected(int)),
488 this, SLOT(showCategory(int)) ); 488 this, SLOT(showCategory(int)) );
489 489
490 icons->updateCategoriesAndMimeTypes(); 490 icons->updateCategoriesAndMimeTypes();
491 491
492 QString prev; 492 QString prev;
493 493
494 // Type filter 494 // Type filter
495 QStringList types; 495 QStringList types;
496 types << tr("All"); 496 types << tr("All");
497 types << "--"; 497 types << "--";
498 types += icons->mimeTypes(); 498 types += icons->mimeTypes();
499 prev = typemb->currentText(); 499 prev = typemb->currentText();
500 typemb->clear(); 500 typemb->clear();
501 typemb->insertItems(types); 501 typemb->insertItems(types);
502 typemb->select(prev); 502 typemb->select(prev);
503 503
504 Categories cats( 0 ); 504 Categories cats( 0 );
505 cats.load( categoryFileName() ); 505 cats.load( categoryFileName() );
506 QArray<int> vl( 0 ); 506 QArray<int> vl( 0 );
507 catmb->setCategories( vl, "Document View", tr("Document View") ); 507 catmb->setCategories( vl, "Document View", tr("Document View") );
508 catmb->setRemoveCategoryEdit( TRUE ); 508 catmb->setRemoveCategoryEdit( TRUE );
509 catmb->setAllCategories( TRUE ); 509 catmb->setAllCategories( TRUE );
510 510
511 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 511 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
512 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 512 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
513} 513}
514 514
515void LauncherView::sortBy(int s) 515void LauncherView::sortBy(int s)
516{ 516{
517 icons->setSortMethod((LauncherIconView::SortMethod)s); 517 icons->setSortMethod((LauncherIconView::SortMethod)s);
518} 518}
519 519
520void LauncherView::showType(const QString& t) 520void LauncherView::showType(const QString& t)
521{ 521{
522 if ( t == tr("All") ) { 522 if ( t == tr("All") ) {
523 icons->setTypeFilter("",TRUE); 523 icons->setTypeFilter("",TRUE);
524 } else { 524 } else {
525 icons->setTypeFilter(t+"/*",TRUE); 525 icons->setTypeFilter(t+"/*",TRUE);
526 } 526 }
527} 527}
528 528
529void LauncherView::showCategory( int c ) 529void LauncherView::showCategory( int c )
530{ 530{
531 icons->setCategoryFilter( c, TRUE ); 531 icons->setCategoryFilter( c, TRUE );
532} 532}
533 533
534void LauncherView::resizeEvent(QResizeEvent *e) 534void LauncherView::resizeEvent(QResizeEvent *e)
535{ 535{
536 QVBox::resizeEvent( e ); 536 QVBox::resizeEvent( e );
537 if ( e->size().width() != e->oldSize().width() ) 537 if ( e->size().width() != e->oldSize().width() )
538 sort(); 538 sort();
539} 539}
540 540
541void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 541void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
542{ 542{
543 icons->clear(); 543 icons->clear();
544 internalPopulate( folder, typefilter ); 544 internalPopulate( folder, typefilter );
545} 545}
546 546
547void LauncherView::selectionChanged() 547void LauncherView::selectionChanged()
548{ 548{
549 QIconViewItem* item = icons->currentItem(); 549 QIconViewItem* item = icons->currentItem();
550 if ( item && item->isSelected() ) { 550 if ( item && item->isSelected() ) {
551 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 551 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
552 if ( icons->inKeyEvent() ) // not for mouse press 552 if ( icons->inKeyEvent() ) // not for mouse press
553 emit clicked( appLnk ); 553 emit clicked( appLnk );
554 item->setSelected(FALSE); 554 item->setSelected(FALSE);
555 } 555 }
556} 556}
557 557
558void LauncherView::returnPressed( QIconViewItem *item ) 558void LauncherView::returnPressed( QIconViewItem *item )
559{ 559{
560 if ( item ) { 560 if ( item ) {
561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
562 emit clicked( appLnk ); 562 emit clicked( appLnk );
563 } 563 }
564} 564}
565 565
566void LauncherView::itemClicked( int btn, QIconViewItem *item ) 566void LauncherView::itemClicked( int btn, QIconViewItem *item )
567{ 567{
568 if ( item ) { 568 if ( item ) {
569 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 569 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
570 if ( btn == LeftButton ) { 570 if ( btn == LeftButton ) {
571 // Make sure it's the item we execute that gets highlighted 571 // Make sure it's the item we execute that gets highlighted
572 icons->setCurrentItem( item ); 572 icons->setCurrentItem( item );
573 emit clicked( appLnk ); 573 emit clicked( appLnk );
574 } 574 }
575 item->setSelected(FALSE); 575 item->setSelected(FALSE);
576 } 576 }
577} 577}
578 578
579void LauncherView::itemPressed( int btn, QIconViewItem *item ) 579void LauncherView::itemPressed( int btn, QIconViewItem *item )
580{ 580{
581 if ( item ) { 581 if ( item ) {
582 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 582 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
583 if ( btn == RightButton ) 583 if ( btn == RightButton )
584 emit rightPressed( appLnk ); 584 emit rightPressed( appLnk );
585/* 585/*
586 else if ( btn == LeftButton ) 586 else if ( btn == LeftButton )
587 emit clicked( appLnk ); 587 emit clicked( appLnk );
588*/ 588*/
589 item->setSelected(FALSE); 589 item->setSelected(FALSE);
590 } 590 }
591} 591}
592 592
593void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 593void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
594{ 594{
595 QListIterator<AppLnk> it( folder->children() ); 595 QListIterator<AppLnk> it( folder->children() );
596 icons->setTypeFilter(typefilter,FALSE); 596 icons->setTypeFilter(typefilter,FALSE);
597 597
598 while ( it.current() ) { 598 while ( it.current() ) {
599 // show only the icons for existing files 599 // show only the icons for existing files
600 if (!QFile(it.current()->file()).exists() ) 600 if (!QFile(it.current()->file()).exists() & it.current()->file().left(4) != "http")
601 { 601 {
602 //maybe insert some .desktop file deletion code later 602 //maybe insert some .desktop file deletion code later
603 //maybe dir specific 603 //maybe dir specific
604 } 604 }
605 else 605 else
606 { 606 {
607 icons->addItem(*it,FALSE); 607 icons->addItem(*it,FALSE);
608 } 608 }
609 ++it; 609 ++it;
610 } 610 }
611 611
612 icons->sort(); 612 icons->sort();
613} 613}
614 614
615bool LauncherView::removeLink(const QString& linkfile) 615bool LauncherView::removeLink(const QString& linkfile)
616{ 616{
617 return icons->removeLink(linkfile); 617 return icons->removeLink(linkfile);
618} 618}
619 619
620void LauncherView::sort() 620void LauncherView::sort()
621{ 621{
622 icons->sort(); 622 icons->sort();
623} 623}
624 624
625void LauncherView::addItem(AppLnk* app, bool resort) 625void LauncherView::addItem(AppLnk* app, bool resort)
626{ 626{
627 icons->addItem(app,resort); 627 icons->addItem(app,resort);
628} 628}
629 629
630void LauncherView::setFileSystems(const QList<FileSystem> &) 630void LauncherView::setFileSystems(const QList<FileSystem> &)
631{ 631{
632 // ### does nothing now... 632 // ### does nothing now...
633} 633}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 65dc5fb..8d66407 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1357 +1,1361 @@
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#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54 54
55//#include <qtimer.h> 55//#include <qtimer.h>
56 56
57#include "playlistselection.h" 57#include "playlistselection.h"
58#include "playlistwidget.h" 58#include "playlistwidget.h"
59#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
60 60
61#include "inputDialog.h" 61#include "inputDialog.h"
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
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
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86// class myFileSelector { 86// class myFileSelector {
87 87
88// }; 88// };
89class PlayListWidgetPrivate { 89class PlayListWidgetPrivate {
90public: 90public:
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
100class ToolButton : public QToolButton { 100class ToolButton : public QToolButton {
101public: 101public:
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
115class MenuItem : public QAction { 115class MenuItem : public QAction {
116public: 116public:
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
125PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 125PlayListWidget::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 160
161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 161 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
162 this , SLOT(addSelected()) ); 162 this , SLOT(addSelected()) );
163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 163 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
164 this , SLOT(removeSelected()) ); 164 this , SLOT(removeSelected()) );
165// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 165// 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", 166 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
167 this , SLOT( btnPlay(bool) ), TRUE ); 167 this , SLOT( btnPlay(bool) ), TRUE );
168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 168 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 169 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 170 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
171 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 171 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
172 tbDeletePlaylist->hide(); 172 tbDeletePlaylist->hide();
173 173
174 QPopupMenu *pmPlayList = new QPopupMenu( this ); 174 QPopupMenu *pmPlayList = new QPopupMenu( this );
175 menu->insertItem( tr( "File" ), pmPlayList ); 175 menu->insertItem( tr( "File" ), pmPlayList );
176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 176 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 177 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180 pmPlayList->insertSeparator(-1); 180 pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
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 fullScreenButton->addTo(pmView); 193 fullScreenButton->addTo(pmView);
194 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 194 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
195 scaleButton->addTo(pmView); 195 scaleButton->addTo(pmView);
196 196
197 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 197 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
198 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 198 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
199 199
200 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 200 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
201 201
202 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 202 tabWidget = new QTabWidget( hbox6, "tabWidget" );
203 tabWidget->setTabShape(QTabWidget::Triangular); 203 tabWidget->setTabShape(QTabWidget::Triangular);
204 204
205 QWidget *pTab; 205 QWidget *pTab;
206 pTab = new QWidget( tabWidget, "pTab" ); 206 pTab = new QWidget( tabWidget, "pTab" );
207// playlistView = new QListView( pTab, "playlistview" ); 207// playlistView = new QListView( pTab, "playlistview" );
208// playlistView->setMinimumSize(236,260); 208// playlistView->setMinimumSize(236,260);
209 tabWidget->insertTab( pTab,"Playlist"); 209 tabWidget->insertTab( pTab,"Playlist");
210 210
211 211
212 // Add the playlist area 212 // Add the playlist area
213 213
214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 214 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
215 d->playListFrame = vbox3; 215 d->playListFrame = vbox3;
216 d->playListFrame ->setMinimumSize(235,260); 216 d->playListFrame ->setMinimumSize(235,260);
217 217
218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 218 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
219 219
220 d->selectedFiles = new PlayListSelection( hbox2); 220 d->selectedFiles = new PlayListSelection( hbox2);
221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 221 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
222 222
223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 223 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
224 224
225 225
226 226
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 232
233 QWidget *aTab; 233 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 234 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 235 audioView = new QListView( aTab, "Audioview" );
236 audioView->setMinimumSize(233,260); 236 audioView->setMinimumSize(233,260);
237 audioView->addColumn( tr("Title"),140); 237 audioView->addColumn( tr("Title"),140);
238 audioView->addColumn(tr("Size"), -1); 238 audioView->addColumn(tr("Size"), -1);
239 audioView->addColumn(tr("Media"),-1); 239 audioView->addColumn(tr("Media"),-1);
240 audioView->setColumnAlignment(1, Qt::AlignRight); 240 audioView->setColumnAlignment(1, Qt::AlignRight);
241 audioView->setColumnAlignment(2, Qt::AlignRight); 241 audioView->setColumnAlignment(2, Qt::AlignRight);
242 audioView->setAllColumnsShowFocus(TRUE); 242 audioView->setAllColumnsShowFocus(TRUE);
243 243
244 audioView->setMultiSelection( TRUE ); 244 audioView->setMultiSelection( TRUE );
245 audioView->setSelectionMode( QListView::Extended); 245 audioView->setSelectionMode( QListView::Extended);
246 246
247 tabWidget->insertTab(aTab,tr("Audio")); 247 tabWidget->insertTab(aTab,tr("Audio"));
248 248
249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
250 250
251// audioView 251// audioView
252// populateAudioView(); 252// populateAudioView();
253// videowidget 253// videowidget
254 254
255 QWidget *vTab; 255 QWidget *vTab;
256 vTab = new QWidget( tabWidget, "vTab" ); 256 vTab = new QWidget( tabWidget, "vTab" );
257 videoView = new QListView( vTab, "Videoview" ); 257 videoView = new QListView( vTab, "Videoview" );
258 videoView->setMinimumSize(233,260); 258 videoView->setMinimumSize(233,260);
259 259
260 videoView->addColumn(tr("Title"),140); 260 videoView->addColumn(tr("Title"),140);
261 videoView->addColumn(tr("Size"),-1); 261 videoView->addColumn(tr("Size"),-1);
262 videoView->addColumn(tr("Media"),-1); 262 videoView->addColumn(tr("Media"),-1);
263 videoView->setColumnAlignment(1, Qt::AlignRight); 263 videoView->setColumnAlignment(1, Qt::AlignRight);
264 videoView->setColumnAlignment(2, Qt::AlignRight); 264 videoView->setColumnAlignment(2, Qt::AlignRight);
265 videoView->setAllColumnsShowFocus(TRUE); 265 videoView->setAllColumnsShowFocus(TRUE);
266 videoView->setMultiSelection( TRUE ); 266 videoView->setMultiSelection( TRUE );
267 videoView->setSelectionMode( QListView::Extended); 267 videoView->setSelectionMode( QListView::Extended);
268 268
269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
270 270
271 tabWidget->insertTab( vTab,tr("Video")); 271 tabWidget->insertTab( vTab,tr("Video"));
272// populateVideoView(); 272// populateVideoView();
273 273
274//playlists list 274//playlists list
275 QWidget *LTab; 275 QWidget *LTab;
276 LTab = new QWidget( tabWidget, "LTab" ); 276 LTab = new QWidget( tabWidget, "LTab" );
277 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 277 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
278 playLists->setMinimumSize(233,260); 278 playLists->setMinimumSize(233,260);
279 tabWidget->insertTab(LTab,tr("Lists")); 279 tabWidget->insertTab(LTab,tr("Lists"));
280 280
281// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 281// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
282 282
283// add the library area 283// add the library area
284 284
285// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 285// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
286// this, SLOT( fauxPlay( QListViewItem *) ) ); 286// this, SLOT( fauxPlay( QListViewItem *) ) );
287// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 287// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
288// this, SLOT( fauxPlay( QListViewItem *)) ); 288// this, SLOT( fauxPlay( QListViewItem *)) );
289 289
290// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 290// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
291// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 291// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
292 292
293 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 293 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
298 298
299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
301 301
302 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 302 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
303 this,SLOT( playIt( QListViewItem *)) ); 303 this,SLOT( playIt( QListViewItem *)) );
304 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 304 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
305 305
306 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 306 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
309 this,SLOT( playIt( QListViewItem *)) ); 309 this,SLOT( playIt( QListViewItem *)) );
310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
311 311
312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
313 313
314 314
315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
316 316
317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
321 321
322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
324 324
325 setCentralWidget( vbox5 ); 325 setCentralWidget( vbox5 );
326 326
327 Config cfg( "OpiePlayer" ); 327 Config cfg( "OpiePlayer" );
328 readConfig( cfg ); 328 readConfig( cfg );
329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
330// qDebug("currentList is "+currentPlaylist); 330// qDebug("currentList is "+currentPlaylist);
331 loadList(DocLnk( currentPlaylist)); 331 loadList(DocLnk( currentPlaylist));
332 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 332 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
333 333
334 initializeStates(); 334 initializeStates();
335} 335}
336 336
337 337
338PlayListWidget::~PlayListWidget() { 338PlayListWidget::~PlayListWidget() {
339 Config cfg( "OpiePlayer" ); 339 Config cfg( "OpiePlayer" );
340 writeConfig( cfg ); 340 writeConfig( cfg );
341 341
342 342
343 if ( d->current ) 343 if ( d->current )
344 delete d->current; 344 delete d->current;
345 delete d; 345 delete d;
346} 346}
347 347
348 348
349void PlayListWidget::initializeStates() { 349void PlayListWidget::initializeStates() {
350 350
351 d->tbPlay->setOn( mediaPlayerState->playing() ); 351 d->tbPlay->setOn( mediaPlayerState->playing() );
352 d->tbLoop->setOn( mediaPlayerState->looping() ); 352 d->tbLoop->setOn( mediaPlayerState->looping() );
353 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 353 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
354// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 354// d->tbFull->setOn( mediaPlayerState->fullscreen() );
355// d->tbScale->setOn( mediaPlayerState->scaled() ); 355// d->tbScale->setOn( mediaPlayerState->scaled() );
356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
357// setPlaylist( mediaPlayerState->playlist() ); 357// setPlaylist( mediaPlayerState->playlist() );
358 setPlaylist( true); 358 setPlaylist( true);
359// d->selectedFiles->first(); 359// d->selectedFiles->first();
360 360
361} 361}
362 362
363 363
364void PlayListWidget::readConfig( Config& cfg ) { 364void PlayListWidget::readConfig( Config& cfg ) {
365 cfg.setGroup("PlayList"); 365 cfg.setGroup("PlayList");
366 QString currentString = cfg.readEntry("current", "" ); 366 QString currentString = cfg.readEntry("current", "" );
367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
368 for ( int i = 0; i < noOfFiles; i++ ) { 368 for ( int i = 0; i < noOfFiles; i++ ) {
369 QString entryName; 369 QString entryName;
370 entryName.sprintf( "File%i", i + 1 ); 370 entryName.sprintf( "File%i", i + 1 );
371 QString linkFile = cfg.readEntry( entryName ); 371 QString linkFile = cfg.readEntry( entryName );
372 DocLnk lnk( linkFile ); 372 DocLnk lnk( linkFile );
373 if ( lnk.isValid() ) { 373 if ( lnk.isValid() ) {
374 d->selectedFiles->addToSelection( lnk ); 374 d->selectedFiles->addToSelection( lnk );
375 } 375 }
376 } 376 }
377 d->selectedFiles->setSelectedItem( currentString); 377 d->selectedFiles->setSelectedItem( currentString);
378// d->selectedFiles->setSelectedItem( (const QString &)currentString); 378// d->selectedFiles->setSelectedItem( (const QString &)currentString);
379} 379}
380 380
381 381
382void PlayListWidget::writeConfig( Config& cfg ) const { 382void PlayListWidget::writeConfig( Config& cfg ) const {
383 383
384 d->selectedFiles->writeCurrent( cfg); 384 d->selectedFiles->writeCurrent( cfg);
385 cfg.setGroup("PlayList"); 385 cfg.setGroup("PlayList");
386 int noOfFiles = 0; 386 int noOfFiles = 0;
387 d->selectedFiles->first(); 387 d->selectedFiles->first();
388 do { 388 do {
389 const DocLnk *lnk = d->selectedFiles->current(); 389 const DocLnk *lnk = d->selectedFiles->current();
390 if ( lnk ) { 390 if ( lnk ) {
391 QString entryName; 391 QString entryName;
392 entryName.sprintf( "File%i", noOfFiles + 1 ); 392 entryName.sprintf( "File%i", noOfFiles + 1 );
393// qDebug(entryName); 393// qDebug(entryName);
394 cfg.writeEntry( entryName, lnk->linkFile() ); 394 cfg.writeEntry( entryName, lnk->linkFile() );
395 // if this link does exist, add it so we have the file 395 // if this link does exist, add it so we have the file
396 // next time... 396 // next time...
397 if ( !QFile::exists( lnk->linkFile() ) ) { 397 if ( !QFile::exists( lnk->linkFile() ) ) {
398 // the way writing lnks doesn't really check for out 398 // the way writing lnks doesn't really check for out
399 // of disk space, but check it anyway. 399 // of disk space, but check it anyway.
400 if ( !lnk->writeLink() ) { 400 if ( !lnk->writeLink() ) {
401 QMessageBox::critical( 0, tr("Out of space"), 401 QMessageBox::critical( 0, tr("Out of space"),
402 tr( "There was a problem saving " 402 tr( "There was a problem saving "
403 "the playlist.\n" 403 "the playlist.\n"
404 "Your playlist " 404 "Your playlist "
405 "may be missing some entries\n" 405 "may be missing some entries\n"
406 "the next time you start it." ) 406 "the next time you start it." )
407 ); 407 );
408 } 408 }
409 } 409 }
410 noOfFiles++; 410 noOfFiles++;
411 } 411 }
412 } 412 }
413 while ( d->selectedFiles->next() ); 413 while ( d->selectedFiles->next() );
414 cfg.writeEntry("NumberOfFiles", noOfFiles ); 414 cfg.writeEntry("NumberOfFiles", noOfFiles );
415} 415}
416 416
417 417
418void PlayListWidget::addToSelection( const DocLnk& lnk ) { 418void PlayListWidget::addToSelection( const DocLnk& lnk ) {
419// qDebug("add"); 419// qDebug("add");
420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { 420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
421// QMessageBox::message("Note","You are trying to play\na malformed url."); 421// QMessageBox::message("Note","You are trying to play\na malformed url.");
422 422
423// } else { 423// } else {
424 424
425 d->setDocumentUsed = FALSE; 425 d->setDocumentUsed = FALSE;
426 if ( mediaPlayerState->playlist() ) { 426 if ( mediaPlayerState->playlist() ) {
427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
428 d->selectedFiles->addToSelection( lnk ); 428 d->selectedFiles->addToSelection( lnk );
429 } 429 }
430 else 430 else
431 mediaPlayerState->setPlaying( TRUE ); 431 mediaPlayerState->setPlaying( TRUE );
432// } 432// }
433} 433}
434 434
435 435
436void PlayListWidget::clearList() { 436void PlayListWidget::clearList() {
437 while ( first() ) 437 while ( first() )
438 d->selectedFiles->removeSelected(); 438 d->selectedFiles->removeSelected();
439} 439}
440 440
441 441
442void PlayListWidget::addAllToList() { 442void PlayListWidget::addAllToList() {
443 DocLnkSet filesAll; 443 DocLnkSet filesAll;
444 Global::findDocuments(&filesAll, "video/*;audio/*"); 444 Global::findDocuments(&filesAll, "video/*;audio/*");
445 QListIterator<DocLnk> Adit( filesAll.children() ); 445 QListIterator<DocLnk> Adit( filesAll.children() );
446 for ( ; Adit.current(); ++Adit ) 446 for ( ; Adit.current(); ++Adit )
447 if(QFileInfo(Adit.current()->file()).exists()) 447 if(QFileInfo(Adit.current()->file()).exists())
448 d->selectedFiles->addToSelection( **Adit ); 448 d->selectedFiles->addToSelection( **Adit );
449} 449}
450 450
451 451
452void PlayListWidget::addAllMusicToList() { 452void PlayListWidget::addAllMusicToList() {
453 QListIterator<DocLnk> dit( files.children() ); 453 QListIterator<DocLnk> dit( files.children() );
454 for ( ; dit.current(); ++dit ) 454 for ( ; dit.current(); ++dit )
455 if(QFileInfo(dit.current()->file()).exists()) 455 if(QFileInfo(dit.current()->file()).exists())
456 d->selectedFiles->addToSelection( **dit ); 456 d->selectedFiles->addToSelection( **dit );
457} 457}
458 458
459 459
460void PlayListWidget::addAllVideoToList() { 460void PlayListWidget::addAllVideoToList() {
461 QListIterator<DocLnk> dit( vFiles.children() ); 461 QListIterator<DocLnk> dit( vFiles.children() );
462 for ( ; dit.current(); ++dit ) 462 for ( ; dit.current(); ++dit )
463 if(QFileInfo( dit.current()->file()).exists()) 463 if(QFileInfo( dit.current()->file()).exists())
464 d->selectedFiles->addToSelection( **dit ); 464 d->selectedFiles->addToSelection( **dit );
465} 465}
466 466
467 467
468void PlayListWidget::setDocument(const QString& fileref) { 468void PlayListWidget::setDocument(const QString& fileref) {
469 qDebug(fileref); 469 qDebug(fileref);
470 fromSetDocument = TRUE; 470 fromSetDocument = TRUE;
471 if ( fileref.isNull() ) { 471 if ( fileref.isNull() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
473 return; 473 return;
474 } 474 }
475// qDebug("setDocument "+fileref); 475// qDebug("setDocument "+fileref);
476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
477 readm3u( fileref); 477 readm3u( fileref);
478 } 478 }
479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
480 readPls( fileref); 480 readPls( fileref);
481 } 481 }
482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 482 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
483 clearList(); 483 clearList();
484 loadList(DocLnk(fileref)); 484 loadList(DocLnk(fileref));
485 d->selectedFiles->first(); 485 d->selectedFiles->first();
486 } else { 486 } else {
487 clearList(); 487 clearList();
488 addToSelection( DocLnk( fileref ) ); 488 addToSelection( DocLnk( fileref ) );
489 d->setDocumentUsed = TRUE; 489 d->setDocumentUsed = TRUE;
490 mediaPlayerState->setPlaying( FALSE ); 490 mediaPlayerState->setPlaying( FALSE );
491 qApp->processEvents(); 491 qApp->processEvents();
492 mediaPlayerState->setPlaying( TRUE ); 492 mediaPlayerState->setPlaying( TRUE );
493 qApp->processEvents(); 493 qApp->processEvents();
494 setCaption(tr("OpiePlayer")); 494 setCaption(tr("OpiePlayer"));
495 } 495 }
496} 496}
497 497
498 498
499void PlayListWidget::setActiveWindow() { 499void PlayListWidget::setActiveWindow() {
500 qDebug("SETTING active window"); 500 qDebug("SETTING active window");
501 501
502 // When we get raised we need to ensure that it switches views 502 // When we get raised we need to ensure that it switches views
503 char origView = mediaPlayerState->view(); 503 char origView = mediaPlayerState->view();
504 mediaPlayerState->setView( 'l' ); // invalidate 504 mediaPlayerState->setView( 'l' ); // invalidate
505 mediaPlayerState->setView( origView ); // now switch back 505 mediaPlayerState->setView( origView ); // now switch back
506} 506}
507 507
508 508
509void PlayListWidget::useSelectedDocument() { 509void PlayListWidget::useSelectedDocument() {
510 d->setDocumentUsed = FALSE; 510 d->setDocumentUsed = FALSE;
511} 511}
512 512
513 513
514const DocLnk *PlayListWidget::current() { // this is fugly 514const DocLnk *PlayListWidget::current() { // this is fugly
515 515
516// if( fromSetDocument) { 516// if( fromSetDocument) {
517// qDebug("from setDoc"); 517// qDebug("from setDoc");
518// DocLnkSet files; 518// DocLnkSet files;
519// Global::findDocuments(&files, "video/*;audio/*"); 519// Global::findDocuments(&files, "video/*;audio/*");
520// QListIterator<DocLnk> dit( files.children() ); 520// QListIterator<DocLnk> dit( files.children() );
521// for ( ; dit.current(); ++dit ) { 521// for ( ; dit.current(); ++dit ) {
522// if(dit.current()->linkFile() == setDocFileRef) { 522// if(dit.current()->linkFile() == setDocFileRef) {
523// qDebug(setDocFileRef); 523// qDebug(setDocFileRef);
524// return dit; 524// return dit;
525// } 525// }
526// } 526// }
527// } else 527// } else
528 528
529 529
530 switch (tabWidget->currentPageIndex()) { 530 switch (tabWidget->currentPageIndex()) {
531 case 0: //playlist 531 case 0: //playlist
532 { 532 {
533 qDebug("playlist"); 533 qDebug("playlist");
534 if ( mediaPlayerState->playlist() ) { 534 if ( mediaPlayerState->playlist() ) {
535 return d->selectedFiles->current(); 535 return d->selectedFiles->current();
536 } 536 }
537 else if ( d->setDocumentUsed && d->current ) { 537 else if ( d->setDocumentUsed && d->current ) {
538 return d->current; 538 return d->current;
539 } else { 539 } else {
540 return d->files->selected(); 540 return d->files->selected();
541 } 541 }
542 } 542 }
543 break; 543 break;
544 case 1://audio 544 case 1://audio
545 { 545 {
546 qDebug("audioView"); 546 qDebug("audioView");
547 QListIterator<DocLnk> dit( files.children() ); 547 QListIterator<DocLnk> dit( files.children() );
548 for ( ; dit.current(); ++dit ) { 548 for ( ; dit.current(); ++dit ) {
549 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 549 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
550 qDebug("here"); 550 qDebug("here");
551 insanityBool=TRUE; 551 insanityBool=TRUE;
552 return dit; 552 return dit;
553 } 553 }
554 } 554 }
555 } 555 }
556 break; 556 break;
557 case 2: // video 557 case 2: // video
558 { 558 {
559 qDebug("videoView"); 559 qDebug("videoView");
560 QListIterator<DocLnk> Vdit( vFiles.children() ); 560 QListIterator<DocLnk> Vdit( vFiles.children() );
561 for ( ; Vdit.current(); ++Vdit ) { 561 for ( ; Vdit.current(); ++Vdit ) {
562 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 562 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
563 insanityBool=TRUE; 563 insanityBool=TRUE;
564 return Vdit; 564 return Vdit;
565 } 565 }
566 } 566 }
567 } 567 }
568 break; 568 break;
569 }; 569 };
570 return 0; 570 return 0;
571} 571}
572 572
573bool PlayListWidget::prev() { 573bool PlayListWidget::prev() {
574 if ( mediaPlayerState->playlist() ) { 574 if ( mediaPlayerState->playlist() ) {
575 if ( mediaPlayerState->shuffled() ) { 575 if ( mediaPlayerState->shuffled() ) {
576 const DocLnk *cur = current(); 576 const DocLnk *cur = current();
577 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 577 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
578 for ( int i = 0; i < j; i++ ) { 578 for ( int i = 0; i < j; i++ ) {
579 if ( !d->selectedFiles->next() ) 579 if ( !d->selectedFiles->next() )
580 d->selectedFiles->first(); 580 d->selectedFiles->first();
581 } 581 }
582 if ( cur == current() ) 582 if ( cur == current() )
583 if ( !d->selectedFiles->next() ) 583 if ( !d->selectedFiles->next() )
584 d->selectedFiles->first(); 584 d->selectedFiles->first();
585 return TRUE; 585 return TRUE;
586 } else { 586 } else {
587 if ( !d->selectedFiles->prev() ) { 587 if ( !d->selectedFiles->prev() ) {
588 if ( mediaPlayerState->looping() ) { 588 if ( mediaPlayerState->looping() ) {
589 return d->selectedFiles->last(); 589 return d->selectedFiles->last();
590 } else { 590 } else {
591 return FALSE; 591 return FALSE;
592 } 592 }
593 } 593 }
594 return TRUE; 594 return TRUE;
595 } 595 }
596 } else { 596 } else {
597 return mediaPlayerState->looping(); 597 return mediaPlayerState->looping();
598 } 598 }
599} 599}
600 600
601 601
602bool PlayListWidget::next() { 602bool PlayListWidget::next() {
603 if ( mediaPlayerState->playlist() ) { 603 if ( mediaPlayerState->playlist() ) {
604 if ( mediaPlayerState->shuffled() ) { 604 if ( mediaPlayerState->shuffled() ) {
605 return prev(); 605 return prev();
606 } else { 606 } else {
607 if ( !d->selectedFiles->next() ) { 607 if ( !d->selectedFiles->next() ) {
608 if ( mediaPlayerState->looping() ) { 608 if ( mediaPlayerState->looping() ) {
609 return d->selectedFiles->first(); 609 return d->selectedFiles->first();
610 } else { 610 } else {
611 return FALSE; 611 return FALSE;
612 } 612 }
613 } 613 }
614 return TRUE; 614 return TRUE;
615 } 615 }
616 } else { 616 } else {
617 return mediaPlayerState->looping(); 617 return mediaPlayerState->looping();
618 } 618 }
619} 619}
620 620
621 621
622bool PlayListWidget::first() { 622bool PlayListWidget::first() {
623 if ( mediaPlayerState->playlist() ) 623 if ( mediaPlayerState->playlist() )
624 return d->selectedFiles->first(); 624 return d->selectedFiles->first();
625 else 625 else
626 return mediaPlayerState->looping(); 626 return mediaPlayerState->looping();
627} 627}
628 628
629 629
630bool PlayListWidget::last() { 630bool PlayListWidget::last() {
631 if ( mediaPlayerState->playlist() ) 631 if ( mediaPlayerState->playlist() )
632 return d->selectedFiles->last(); 632 return d->selectedFiles->last();
633 else 633 else
634 return mediaPlayerState->looping(); 634 return mediaPlayerState->looping();
635} 635}
636 636
637 637
638void PlayListWidget::saveList() { 638void PlayListWidget::saveList() {
639 639
640 QString filename; 640 QString filename;
641 InputDialog *fileDlg; 641 InputDialog *fileDlg;
642 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 642 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
643 fileDlg->exec(); 643 fileDlg->exec();
644 if( fileDlg->result() == 1 ) { 644 if( fileDlg->result() == 1 ) {
645 if ( d->current ) 645 if ( d->current )
646 delete d->current; 646 delete d->current;
647 filename = fileDlg->LineEdit1->text();//+".playlist"; 647 filename = fileDlg->LineEdit1->text();//+".playlist";
648// qDebug("saving playlist "+filename+".playlist"); 648// qDebug("saving playlist "+filename+".playlist");
649 Config cfg( filename +".playlist"); 649 Config cfg( filename +".playlist");
650 writeConfig( cfg ); 650 writeConfig( cfg );
651 651
652 DocLnk lnk; 652 DocLnk lnk;
653// lnk.setComment( ""); 653// lnk.setComment( "");
654 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 654 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
655 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 655 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
656 lnk.setIcon("opieplayer/playlist2"); 656 lnk.setIcon("opieplayer/playlist2");
657 lnk.setName( filename); //sets file name 657 lnk.setName( filename); //sets file name
658// qDebug(filename); 658// qDebug(filename);
659 if(!lnk.writeLink()) 659 if(!lnk.writeLink())
660 qDebug("Writing doclink did not work"); 660 qDebug("Writing doclink did not work");
661 } 661 }
662 Config config( "OpiePlayer" ); 662 Config config( "OpiePlayer" );
663 config.writeEntry("CurrentPlaylist",filename); 663 config.writeEntry("CurrentPlaylist",filename);
664 setCaption(tr("OpiePlayer: ")+filename); 664 setCaption(tr("OpiePlayer: ")+filename);
665 d->selectedFiles->first(); 665 d->selectedFiles->first();
666 if(fileDlg) 666 if(fileDlg)
667 delete fileDlg; 667 delete fileDlg;
668} 668}
669 669
670void PlayListWidget::loadList( const DocLnk & lnk) { 670void PlayListWidget::loadList( const DocLnk & lnk) {
671 QString name= lnk.name(); 671 QString name= lnk.name();
672// qDebug("currentList is "+name); 672// qDebug("currentList is "+name);
673 if( name.length()>1) { 673 if( name.length()>1) {
674 setCaption("OpiePlayer: "+name); 674 setCaption("OpiePlayer: "+name);
675// qDebug("load list "+ name+".playlist"); 675// qDebug("load list "+ name+".playlist");
676 clearList(); 676 clearList();
677 Config cfg( name+".playlist"); 677 Config cfg( name+".playlist");
678 readConfig(cfg); 678 readConfig(cfg);
679 679
680 tabWidget->setCurrentPage(0); 680 tabWidget->setCurrentPage(0);
681 681
682 Config config( "OpiePlayer" ); 682 Config config( "OpiePlayer" );
683 config.writeEntry("CurrentPlaylist", name); 683 config.writeEntry("CurrentPlaylist", name);
684// d->selectedFiles->first(); 684// d->selectedFiles->first();
685 } 685 }
686 686
687} 687}
688 688
689void PlayListWidget::setPlaylist( bool shown ) { 689void PlayListWidget::setPlaylist( bool shown ) {
690 if ( shown ) 690 if ( shown )
691 d->playListFrame->show(); 691 d->playListFrame->show();
692 else 692 else
693 d->playListFrame->hide(); 693 d->playListFrame->hide();
694} 694}
695 695
696void PlayListWidget::setView( char view ) { 696void PlayListWidget::setView( char view ) {
697 if ( view == 'l' ) 697 if ( view == 'l' )
698 showMaximized(); 698 showMaximized();
699 else 699 else
700 hide(); 700 hide();
701} 701}
702 702
703void PlayListWidget::addSelected() { 703void PlayListWidget::addSelected() {
704 704
705 Config cfg( "OpiePlayer" ); 705 Config cfg( "OpiePlayer" );
706 cfg.setGroup("PlayList"); 706 cfg.setGroup("PlayList");
707 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 707 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
708 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 708 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
709 709
710 switch (tabWidget->currentPageIndex()) { 710 switch (tabWidget->currentPageIndex()) {
711 case 0: //playlist 711 case 0: //playlist
712 break; 712 break;
713 case 1: { //audio 713 case 1: { //audio
714// QString entryName; 714// QString entryName;
715// entryName.sprintf( "File%i", i + 1 ); 715// entryName.sprintf( "File%i", i + 1 );
716// QString linkFile = cfg.readEntry( entryName ); 716// QString linkFile = cfg.readEntry( entryName );
717 QListViewItemIterator it( audioView ); 717 QListViewItemIterator it( audioView );
718 // iterate through all items of the listview 718 // iterate through all items of the listview
719 for ( ; it.current(); ++it ) { 719 for ( ; it.current(); ++it ) {
720 if ( it.current()->isSelected() ) { 720 if ( it.current()->isSelected() ) {
721 QListIterator<DocLnk> dit( files.children() ); 721 QListIterator<DocLnk> dit( files.children() );
722 for ( ; dit.current(); ++dit ) { 722 for ( ; dit.current(); ++dit ) {
723 if( dit.current()->name() == it.current()->text(0) ) { 723 if( dit.current()->name() == it.current()->text(0) ) {
724 d->selectedFiles->addToSelection( **dit ); 724 d->selectedFiles->addToSelection( **dit );
725 } 725 }
726 } 726 }
727 audioView->setSelected( it.current(),FALSE); 727 audioView->setSelected( it.current(),FALSE);
728 } 728 }
729 } 729 }
730 tabWidget->setCurrentPage(0); 730 tabWidget->setCurrentPage(0);
731 } 731 }
732 break; 732 break;
733 case 2: { // video 733 case 2: { // video
734 QListViewItemIterator it( videoView ); 734 QListViewItemIterator it( videoView );
735 // iterate through all items of the listview 735 // iterate through all items of the listview
736 for ( ; it.current(); ++it ) { 736 for ( ; it.current(); ++it ) {
737 if ( it.current()->isSelected() ) { 737 if ( it.current()->isSelected() ) {
738 QListIterator<DocLnk> dit( vFiles.children() ); 738 QListIterator<DocLnk> dit( vFiles.children() );
739 for ( ; dit.current(); ++dit ) { 739 for ( ; dit.current(); ++dit ) {
740 if( dit.current()->name() == it.current()->text(0) ) { 740 if( dit.current()->name() == it.current()->text(0) ) {
741 d->selectedFiles->addToSelection( **dit ); 741 d->selectedFiles->addToSelection( **dit );
742 } 742 }
743 } 743 }
744 744
745 videoView->setSelected( it.current(),FALSE); 745 videoView->setSelected( it.current(),FALSE);
746 } 746 }
747 } 747 }
748// for ( int i = 0; i < noOfFiles; i++ ) { 748// for ( int i = 0; i < noOfFiles; i++ ) {
749// QString entryName; 749// QString entryName;
750// entryName.sprintf( "File%i", i + 1 ); 750// entryName.sprintf( "File%i", i + 1 );
751// QString linkFile = cfg.readEntry( entryName ); 751// QString linkFile = cfg.readEntry( entryName );
752// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 752// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
753// int result= QMessageBox::warning(this,tr("OpiePlayer"), 753// int result= QMessageBox::warning(this,tr("OpiePlayer"),
754// tr("This is all ready in your playlist.\nContinue?"), 754// tr("This is all ready in your playlist.\nContinue?"),
755// tr("Yes"),tr("No"),0,0,1); 755// tr("Yes"),tr("No"),0,0,1);
756// if (result !=0) 756// if (result !=0)
757// return; 757// return;
758// } 758// }
759// } 759// }
760// addToSelection( videoView->selectedItem() ); 760// addToSelection( videoView->selectedItem() );
761 tabWidget->setCurrentPage(0); 761 tabWidget->setCurrentPage(0);
762 } 762 }
763 break; 763 break;
764 }; 764 };
765} 765}
766 766
767void PlayListWidget::removeSelected() { 767void PlayListWidget::removeSelected() {
768 d->selectedFiles->removeSelected( ); 768 d->selectedFiles->removeSelected( );
769} 769}
770 770
771void PlayListWidget::playIt( QListViewItem *it) { 771void PlayListWidget::playIt( QListViewItem *it) {
772// d->setDocumentUsed = FALSE; 772// d->setDocumentUsed = FALSE;
773// mediaPlayerState->curPosition =0; 773// mediaPlayerState->curPosition =0;
774 qDebug("playIt"); 774 qDebug("playIt");
775 mediaPlayerState->setPlaying(FALSE); 775 mediaPlayerState->setPlaying(FALSE);
776 mediaPlayerState->setPlaying(TRUE); 776 mediaPlayerState->setPlaying(TRUE);
777 d->selectedFiles->unSelect(); 777 d->selectedFiles->unSelect();
778} 778}
779 779
780void PlayListWidget::addToSelection( QListViewItem *it) { 780void PlayListWidget::addToSelection( QListViewItem *it) {
781 d->setDocumentUsed = FALSE; 781 d->setDocumentUsed = FALSE;
782 782
783 if(it) { 783 if(it) {
784 switch (tabWidget->currentPageIndex()) { 784 switch (tabWidget->currentPageIndex()) {
785 case 1: { 785 case 1: {
786 QListIterator<DocLnk> dit( files.children() ); 786 QListIterator<DocLnk> dit( files.children() );
787 for ( ; dit.current(); ++dit ) { 787 for ( ; dit.current(); ++dit ) {
788 if( dit.current()->name() == it->text(0)) { 788 if( dit.current()->name() == it->text(0)) {
789 d->selectedFiles->addToSelection( **dit ); 789 d->selectedFiles->addToSelection( **dit );
790 } 790 }
791 } 791 }
792 } 792 }
793 break; 793 break;
794 case 2: { 794 case 2: {
795 QListIterator<DocLnk> dit( vFiles.children() ); 795 QListIterator<DocLnk> dit( vFiles.children() );
796 for ( ; dit.current(); ++dit ) { 796 for ( ; dit.current(); ++dit ) {
797 if( dit.current()->name() == it->text(0)) { 797 if( dit.current()->name() == it->text(0)) {
798 d->selectedFiles->addToSelection( **dit ); 798 d->selectedFiles->addToSelection( **dit );
799 } 799 }
800 } 800 }
801 } 801 }
802 break; 802 break;
803 case 0: 803 case 0:
804 break; 804 break;
805 }; 805 };
806 tabWidget->setCurrentPage(0); 806 tabWidget->setCurrentPage(0);
807 } 807 }
808} 808}
809 809
810void PlayListWidget::tabChanged(QWidget *widg) { 810void PlayListWidget::tabChanged(QWidget *widg) {
811 811
812 switch ( tabWidget->currentPageIndex()) { 812 switch ( tabWidget->currentPageIndex()) {
813 case 0: 813 case 0:
814 { 814 {
815 if( !tbDeletePlaylist->isHidden()) 815 if( !tbDeletePlaylist->isHidden())
816 tbDeletePlaylist->hide(); 816 tbDeletePlaylist->hide();
817 d->tbRemoveFromList->setEnabled(TRUE); 817 d->tbRemoveFromList->setEnabled(TRUE);
818 d->tbAddToList->setEnabled(FALSE); 818 d->tbAddToList->setEnabled(FALSE);
819 } 819 }
820 break; 820 break;
821 case 1: 821 case 1:
822 { 822 {
823 audioView->clear(); 823 audioView->clear();
824 populateAudioView(); 824 populateAudioView();
825 825
826 if( !tbDeletePlaylist->isHidden()) 826 if( !tbDeletePlaylist->isHidden())
827 tbDeletePlaylist->hide(); 827 tbDeletePlaylist->hide();
828 d->tbRemoveFromList->setEnabled(FALSE); 828 d->tbRemoveFromList->setEnabled(FALSE);
829 d->tbAddToList->setEnabled(TRUE); 829 d->tbAddToList->setEnabled(TRUE);
830 } 830 }
831 break; 831 break;
832 case 2: 832 case 2:
833 { 833 {
834 videoView->clear(); 834 videoView->clear();
835 populateVideoView(); 835 populateVideoView();
836 if( !tbDeletePlaylist->isHidden()) 836 if( !tbDeletePlaylist->isHidden())
837 tbDeletePlaylist->hide(); 837 tbDeletePlaylist->hide();
838 d->tbRemoveFromList->setEnabled(FALSE); 838 d->tbRemoveFromList->setEnabled(FALSE);
839 d->tbAddToList->setEnabled(TRUE); 839 d->tbAddToList->setEnabled(TRUE);
840 } 840 }
841 break; 841 break;
842 case 3: 842 case 3:
843 { 843 {
844 if( tbDeletePlaylist->isHidden()) 844 if( tbDeletePlaylist->isHidden())
845 tbDeletePlaylist->show(); 845 tbDeletePlaylist->show();
846 playLists->reread(); 846 playLists->reread();
847 } 847 }
848 break; 848 break;
849 }; 849 };
850} 850}
851 851
852void PlayListWidget::btnPlay(bool b) { 852void PlayListWidget::btnPlay(bool b) {
853 853
854// mediaPlayerState->setPlaying(b); 854// mediaPlayerState->setPlaying(b);
855 switch ( tabWidget->currentPageIndex()) { 855 switch ( tabWidget->currentPageIndex()) {
856 case 0: 856 case 0:
857 { 857 {
858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
860// QMessageBox::message("Note","You are trying to play\na malformed url."); 860// QMessageBox::message("Note","You are trying to play\na malformed url.");
861// } else { 861// } else {
862 mediaPlayerState->setPlaying(b); 862 mediaPlayerState->setPlaying(b);
863// } 863// }
864 } 864 }
865 break; 865 break;
866 case 1: 866 case 1:
867 { 867 {
868 addToSelection( audioView->currentItem() ); 868 addToSelection( audioView->currentItem() );
869 mediaPlayerState->setPlaying(b); 869 mediaPlayerState->setPlaying(b);
870 d->selectedFiles->removeSelected( ); 870 d->selectedFiles->removeSelected( );
871 tabWidget->setCurrentPage(1); 871 tabWidget->setCurrentPage(1);
872 d->selectedFiles->unSelect(); 872 d->selectedFiles->unSelect();
873 insanityBool=FALSE; 873 insanityBool=FALSE;
874 }// audioView->clearSelection(); 874 }// audioView->clearSelection();
875 break; 875 break;
876 case 2: 876 case 2:
877 { 877 {
878 addToSelection( videoView->currentItem() ); 878 addToSelection( videoView->currentItem() );
879 mediaPlayerState->setPlaying(b); 879 mediaPlayerState->setPlaying(b);
880 qApp->processEvents(); 880 qApp->processEvents();
881 d->selectedFiles->removeSelected( ); 881 d->selectedFiles->removeSelected( );
882 tabWidget->setCurrentPage(2); 882 tabWidget->setCurrentPage(2);
883 d->selectedFiles->unSelect(); 883 d->selectedFiles->unSelect();
884 insanityBool=FALSE; 884 insanityBool=FALSE;
885 }// videoView->clearSelection(); 885 }// videoView->clearSelection();
886 break; 886 break;
887 }; 887 };
888 888
889} 889}
890 890
891void PlayListWidget::deletePlaylist() { 891void PlayListWidget::deletePlaylist() {
892 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 892 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
893 (tr("You really want to delete\nthis playlist?")), 893 (tr("You really want to delete\nthis playlist?")),
894 (tr("Yes")), (tr("No")), 0 )){ 894 (tr("Yes")), (tr("No")), 0 )){
895 case 0: // Yes clicked, 895 case 0: // Yes clicked,
896 QFile().remove(playLists->selected()->file()); 896 QFile().remove(playLists->selected()->file());
897 QFile().remove(playLists->selected()->linkFile()); 897 QFile().remove(playLists->selected()->linkFile());
898 playLists->reread(); 898 playLists->reread();
899 break; 899 break;
900 case 1: // Cancel 900 case 1: // Cancel
901 break; 901 break;
902 }; 902 };
903} 903}
904 904
905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
906{ 906{
907 switch (mouse) { 907 switch (mouse) {
908 case 1: 908 case 1:
909 break; 909 break;
910 case 2:{ 910 case 2:{
911 911
912 QPopupMenu m; 912 QPopupMenu m;
913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
915 m.insertSeparator(); 915 m.insertSeparator();
916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
918 918
919 m.exec( QCursor::pos() ); 919 m.exec( QCursor::pos() );
920 } 920 }
921 break; 921 break;
922 }; 922 };
923} 923}
924 924
925void PlayListWidget::playSelected() 925void PlayListWidget::playSelected()
926{ 926{
927 btnPlay( TRUE); 927 btnPlay( TRUE);
928// d->selectedFiles->unSelect(); 928// d->selectedFiles->unSelect();
929} 929}
930 930
931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
932{ 932{
933 switch (mouse) { 933 switch (mouse) {
934 case 1: 934 case 1:
935 935
936 break; 936 break;
937 case 2:{ 937 case 2:{
938 QPopupMenu m; 938 QPopupMenu m;
939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
941// m.insertSeparator(); 941// m.insertSeparator();
942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
943 m.exec( QCursor::pos() ); 943 m.exec( QCursor::pos() );
944 } 944 }
945 break; 945 break;
946 }; 946 };
947 947
948} 948}
949 949
950void PlayListWidget::listDelete() { 950void PlayListWidget::listDelete() {
951 Config cfg( "OpiePlayer" ); 951 Config cfg( "OpiePlayer" );
952 cfg.setGroup("PlayList"); 952 cfg.setGroup("PlayList");
953 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 953 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
954 QString file; 954 QString file;
955 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 955 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
956 switch ( tabWidget->currentPageIndex()) { 956 switch ( tabWidget->currentPageIndex()) {
957 case 0: 957 case 0:
958 break; 958 break;
959 case 1: 959 case 1:
960 { 960 {
961 file = audioView->currentItem()->text(0); 961 file = audioView->currentItem()->text(0);
962 QListIterator<DocLnk> Pdit( files.children() ); 962 QListIterator<DocLnk> Pdit( files.children() );
963 for ( ; Pdit.current(); ++Pdit ) { 963 for ( ; Pdit.current(); ++Pdit ) {
964 if( Pdit.current()->name() == file) { 964 if( Pdit.current()->name() == file) {
965 LnkProperties prop( Pdit.current() ); 965 LnkProperties prop( Pdit.current() );
966 prop.showMaximized(); 966 prop.showMaximized();
967 prop.exec(); 967 prop.exec();
968 } 968 }
969 } 969 }
970 populateAudioView(); 970 populateAudioView();
971 } 971 }
972 break; 972 break;
973 case 2: 973 case 2:
974 { 974 {
975// file = videoView->selectedItem()->text(0); 975// file = videoView->selectedItem()->text(0);
976// for ( int i = 0; i < noOfFiles; i++ ) { 976// for ( int i = 0; i < noOfFiles; i++ ) {
977// QString entryName; 977// QString entryName;
978// entryName.sprintf( "File%i", i + 1 ); 978// entryName.sprintf( "File%i", i + 1 );
979// QString linkFile = cfg.readEntry( entryName ); 979// QString linkFile = cfg.readEntry( entryName );
980// AppLnk lnk( AppLnk(linkFile)); 980// AppLnk lnk( AppLnk(linkFile));
981// if( lnk.name() == file ) { 981// if( lnk.name() == file ) {
982// LnkProperties prop( &lnk); 982// LnkProperties prop( &lnk);
983// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 983// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
984// prop.showMaximized(); 984// prop.showMaximized();
985// prop.exec(); 985// prop.exec();
986// } 986// }
987// } 987// }
988 } 988 }
989 break; 989 break;
990 }; 990 };
991} 991}
992 992
993void PlayListWidget::scanForAudio() { 993void PlayListWidget::scanForAudio() {
994 qDebug("scan for audio"); 994 qDebug("scan for audio");
995 files.detachChildren(); 995 files.detachChildren();
996 QListIterator<DocLnk> sdit( files.children() ); 996 QListIterator<DocLnk> sdit( files.children() );
997 for ( ; sdit.current(); ++sdit ) { 997 for ( ; sdit.current(); ++sdit ) {
998 delete sdit.current(); 998 delete sdit.current();
999 } 999 }
1000 Global::findDocuments(&files, "audio/*"); 1000 Global::findDocuments(&files, "audio/*");
1001 audioScan = TRUE; 1001 audioScan = TRUE;
1002} 1002}
1003void PlayListWidget::scanForVideo() { 1003void PlayListWidget::scanForVideo() {
1004 qDebug("scan for video"); 1004 qDebug("scan for video");
1005 vFiles.detachChildren(); 1005 vFiles.detachChildren();
1006 QListIterator<DocLnk> sdit( vFiles.children() ); 1006 QListIterator<DocLnk> sdit( vFiles.children() );
1007 for ( ; sdit.current(); ++sdit ) { 1007 for ( ; sdit.current(); ++sdit ) {
1008 delete sdit.current(); 1008 delete sdit.current();
1009 } 1009 }
1010 Global::findDocuments(&vFiles, "video/*"); 1010 Global::findDocuments(&vFiles, "video/*");
1011 videoScan = TRUE; 1011 videoScan = TRUE;
1012} 1012}
1013 1013
1014void PlayListWidget::populateAudioView() { 1014void PlayListWidget::populateAudioView() {
1015 1015
1016 audioView->clear(); 1016 audioView->clear();
1017 StorageInfo storageInfo; 1017 StorageInfo storageInfo;
1018 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1018 const QList<FileSystem> &fs = storageInfo.fileSystems();
1019 if(!audioScan) scanForAudio(); 1019 if(!audioScan) scanForAudio();
1020 1020
1021 QListIterator<DocLnk> dit( files.children() ); 1021 QListIterator<DocLnk> dit( files.children() );
1022 QListIterator<FileSystem> it ( fs ); 1022 QListIterator<FileSystem> it ( fs );
1023 1023
1024 QString storage; 1024 QString storage;
1025 for ( ; dit.current(); ++dit ) { 1025 for ( ; dit.current(); ++dit ) {
1026 for( ; it.current(); ++it ){ 1026 for( ; it.current(); ++it ){
1027 const QString name = (*it)->name(); 1027 const QString name = (*it)->name();
1028 const QString path = (*it)->path(); 1028 const QString path = (*it)->path();
1029 if(dit.current()->file().find(path) != -1 ) storage=name; 1029 if(dit.current()->file().find(path) != -1 ) storage=name;
1030 } 1030 }
1031 1031
1032 QListViewItem * newItem; 1032 QListViewItem * newItem;
1033 if ( QFile( dit.current()->file()).exists() ) { 1033 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1034// qDebug(dit.current()->name()); 1034 long size;
1035 if( dit.current()->file().left(4) == "http" )
1036 size=0;
1037 else
1038 size = QFile( dit.current()->file() ).size();
1035 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1039 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1036 QString::number( QFile( dit.current()->file()).size() ), storage); 1040 QString::number(size ), storage);
1037 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1041 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1038 } 1042 }
1039 } 1043 }
1040 1044
1041} 1045}
1042 1046
1043void PlayListWidget::populateVideoView() { 1047void PlayListWidget::populateVideoView() {
1044 videoView->clear(); 1048 videoView->clear();
1045 StorageInfo storageInfo; 1049 StorageInfo storageInfo;
1046 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1050 const QList<FileSystem> &fs = storageInfo.fileSystems();
1047 1051
1048 if(!videoScan ) scanForVideo(); 1052 if(!videoScan ) scanForVideo();
1049 1053
1050 QListIterator<DocLnk> Vdit( vFiles.children() ); 1054 QListIterator<DocLnk> Vdit( vFiles.children() );
1051 QListIterator<FileSystem> it ( fs ); 1055 QListIterator<FileSystem> it ( fs );
1052 videoView->clear(); 1056 videoView->clear();
1053 QString storage; 1057 QString storage;
1054 for ( ; Vdit.current(); ++Vdit ) { 1058 for ( ; Vdit.current(); ++Vdit ) {
1055 for( ; it.current(); ++it ){ 1059 for( ; it.current(); ++it ){
1056 const QString name = (*it)->name(); 1060 const QString name = (*it)->name();
1057 const QString path = (*it)->path(); 1061 const QString path = (*it)->path();
1058 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1062 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1059 } 1063 }
1060 1064
1061 QListViewItem * newItem; 1065 QListViewItem * newItem;
1062 if ( QFile( Vdit.current()->file()).exists() ) { 1066 if ( QFile( Vdit.current()->file()).exists() ) {
1063 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1067 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1064 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1068 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1065 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1069 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1066 } 1070 }
1067 } 1071 }
1068} 1072}
1069 1073
1070void PlayListWidget::openFile() { 1074void PlayListWidget::openFile() {
1071 QString filename, name; 1075 QString filename, name;
1072 InputDialog *fileDlg; 1076 InputDialog *fileDlg;
1073 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1077 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1074 fileDlg->exec(); 1078 fileDlg->exec();
1075 if( fileDlg->result() == 1 ) { 1079 if( fileDlg->result() == 1 ) {
1076 filename = fileDlg->LineEdit1->text(); 1080 filename = fileDlg->LineEdit1->text();
1077// http://205.188.234.129:8030 1081// http://205.188.234.129:8030
1078// http://66.28.68.70:8000 1082// http://66.28.68.70:8000
1079// filename.replace(QRegExp("%20")," "); 1083// filename.replace(QRegExp("%20")," ");
1080 qDebug("Selected filename is "+filename); 1084 qDebug("Selected filename is "+filename);
1081 if(filename.right(3) == "m3u") 1085 if(filename.right(3) == "m3u")
1082 readm3u( filename); 1086 readm3u( filename);
1083 else if(filename.right(3) == "pls") 1087 else if(filename.right(3) == "pls")
1084 readPls( filename); 1088 readPls( filename);
1085 else { 1089 else {
1086 DocLnk lnk; 1090 DocLnk lnk;
1087 1091
1088 lnk.setName(filename); //sets file name 1092 lnk.setName(filename); //sets file name
1089 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1093 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1090 filename += "/"; 1094 filename += "/";
1091 lnk.setFile(filename); //sets File property 1095 lnk.setFile(filename); //sets File property
1092 1096
1093 lnk.setType("audio/x-mpegurl"); 1097 lnk.setType("audio/x-mpegurl");
1094 lnk.setExec("opieplayer"); 1098 lnk.setExec("opieplayer");
1095 lnk.setIcon("opieplayer/MPEGPlayer"); 1099 lnk.setIcon("opieplayer/MPEGPlayer");
1096 1100
1097 if(!lnk.writeLink()) 1101 if(!lnk.writeLink())
1098 qDebug("Writing doclink did not work"); 1102 qDebug("Writing doclink did not work");
1099 d->selectedFiles->addToSelection( lnk); 1103 d->selectedFiles->addToSelection( lnk);
1100// if(fileDlg2) 1104// if(fileDlg2)
1101// delete fileDlg2; 1105// delete fileDlg2;
1102 } 1106 }
1103 } 1107 }
1104 if(fileDlg) 1108 if(fileDlg)
1105 delete fileDlg; 1109 delete fileDlg;
1106} 1110}
1107 1111
1108void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1112void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1109{ 1113{
1110 switch ( e->key() ) { 1114 switch ( e->key() ) {
1111////////////////////////////// Zaurus keys 1115////////////////////////////// Zaurus keys
1112 case Key_F9: //activity 1116 case Key_F9: //activity
1113// if(audioUI->isHidden()) 1117// if(audioUI->isHidden())
1114// audioUI->showMaximized(); 1118// audioUI->showMaximized();
1115 break; 1119 break;
1116 case Key_F10: //contacts 1120 case Key_F10: //contacts
1117// if( videoUI->isHidden()) 1121// if( videoUI->isHidden())
1118// videoUI->showMaximized(); 1122// videoUI->showMaximized();
1119 break; 1123 break;
1120 case Key_F11: //menu 1124 case Key_F11: //menu
1121 break; 1125 break;
1122 case Key_F12: //home 1126 case Key_F12: //home
1123// doBlank(); 1127// doBlank();
1124 break; 1128 break;
1125 case Key_F13: //mail 1129 case Key_F13: //mail
1126// doUnblank(); 1130// doUnblank();
1127 break; 1131 break;
1128 case Key_Q: //add to playlist 1132 case Key_Q: //add to playlist
1129 qDebug("Add"); 1133 qDebug("Add");
1130 addSelected(); 1134 addSelected();
1131 break; 1135 break;
1132 case Key_R: //remove from playlist 1136 case Key_R: //remove from playlist
1133 removeSelected(); 1137 removeSelected();
1134 break; 1138 break;
1135// case Key_P: //play 1139// case Key_P: //play
1136// qDebug("Play"); 1140// qDebug("Play");
1137// playSelected(); 1141// playSelected();
1138// break; 1142// break;
1139 case Key_Space: 1143 case Key_Space:
1140 qDebug("Play"); 1144 qDebug("Play");
1141// playSelected(); puh 1145// playSelected(); puh
1142 break; 1146 break;
1143 case Key_1: 1147 case Key_1:
1144 tabWidget->setCurrentPage(0); 1148 tabWidget->setCurrentPage(0);
1145 break; 1149 break;
1146 case Key_2: 1150 case Key_2:
1147 tabWidget->setCurrentPage(1); 1151 tabWidget->setCurrentPage(1);
1148 break; 1152 break;
1149 case Key_3: 1153 case Key_3:
1150 tabWidget->setCurrentPage(2); 1154 tabWidget->setCurrentPage(2);
1151 break; 1155 break;
1152 case Key_4: 1156 case Key_4:
1153 tabWidget->setCurrentPage(3); 1157 tabWidget->setCurrentPage(3);
1154 break; 1158 break;
1155 case Key_Down: 1159 case Key_Down:
1156 if ( !d->selectedFiles->next() ) 1160 if ( !d->selectedFiles->next() )
1157 d->selectedFiles->first(); 1161 d->selectedFiles->first();
1158 1162
1159 break; 1163 break;
1160 case Key_Up: 1164 case Key_Up:
1161 if ( !d->selectedFiles->prev() ) 1165 if ( !d->selectedFiles->prev() )
1162 // d->selectedFiles->last(); 1166 // d->selectedFiles->last();
1163 1167
1164 break; 1168 break;
1165 1169
1166 } 1170 }
1167} 1171}
1168 1172
1169void PlayListWidget::keyPressEvent( QKeyEvent *e) 1173void PlayListWidget::keyPressEvent( QKeyEvent *e)
1170{ 1174{
1171// qDebug("Key press"); 1175// qDebug("Key press");
1172// switch ( e->key() ) { 1176// switch ( e->key() ) {
1173// ////////////////////////////// Zaurus keys 1177// ////////////////////////////// Zaurus keys
1174// case Key_A: //add to playlist 1178// case Key_A: //add to playlist
1175// qDebug("Add"); 1179// qDebug("Add");
1176// addSelected(); 1180// addSelected();
1177// break; 1181// break;
1178// case Key_R: //remove from playlist 1182// case Key_R: //remove from playlist
1179// removeSelected(); 1183// removeSelected();
1180// break; 1184// break;
1181// case Key_P: //play 1185// case Key_P: //play
1182// qDebug("Play"); 1186// qDebug("Play");
1183// playSelected(); 1187// playSelected();
1184// break; 1188// break;
1185// case Key_Space: 1189// case Key_Space:
1186// qDebug("Play"); 1190// qDebug("Play");
1187// playSelected(); 1191// playSelected();
1188// break; 1192// break;
1189// } 1193// }
1190} 1194}
1191 1195
1192void PlayListWidget::doBlank() { 1196void PlayListWidget::doBlank() {
1193 qDebug("do blanking"); 1197 qDebug("do blanking");
1194 fd=open("/dev/fb0",O_RDWR); 1198 fd=open("/dev/fb0",O_RDWR);
1195 if (fd != -1) { 1199 if (fd != -1) {
1196 ioctl(fd,FBIOBLANK,1); 1200 ioctl(fd,FBIOBLANK,1);
1197// close(fd); 1201// close(fd);
1198 } 1202 }
1199} 1203}
1200 1204
1201void PlayListWidget::doUnblank() { 1205void PlayListWidget::doUnblank() {
1202 // this crashes opieplayer with a segfault 1206 // this crashes opieplayer with a segfault
1203// int fd; 1207// int fd;
1204// fd=open("/dev/fb0",O_RDWR); 1208// fd=open("/dev/fb0",O_RDWR);
1205 qDebug("do unblanking"); 1209 qDebug("do unblanking");
1206 if (fd != -1) { 1210 if (fd != -1) {
1207 ioctl(fd,FBIOBLANK,0); 1211 ioctl(fd,FBIOBLANK,0);
1208 close(fd); 1212 close(fd);
1209 } 1213 }
1210 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1214 QCopEnvelope h("QPE/System", "setBacklight(int)");
1211 h <<-3;// v[1]; // -3 Force on 1215 h <<-3;// v[1]; // -3 Force on
1212} 1216}
1213 1217
1214void PlayListWidget::readm3u(const QString &filename) { 1218void PlayListWidget::readm3u(const QString &filename) {
1215 1219
1216 qDebug("m3u filename is "+filename); 1220 qDebug("m3u filename is "+filename);
1217 QFile f(filename); 1221 QFile f(filename);
1218 1222
1219 if(f.open(IO_ReadOnly)) { 1223 if(f.open(IO_ReadOnly)) {
1220 QTextStream t(&f); 1224 QTextStream t(&f);
1221 QString s;//, first, second; 1225 QString s;//, first, second;
1222 int i=0; 1226 int i=0;
1223 while ( !t.atEnd()) { 1227 while ( !t.atEnd()) {
1224// Lview->insertLine(t.readLine(),-1); 1228// Lview->insertLine(t.readLine(),-1);
1225 s=t.readLine(); 1229 s=t.readLine();
1226 1230
1227 if(s.find("#",0,TRUE) == -1) { 1231 if(s.find("#",0,TRUE) == -1) {
1228 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1232 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1229 if(s.left(2) == "E:" || s.left(2) == "P:") { 1233 if(s.left(2) == "E:" || s.left(2) == "P:") {
1230 s=s.right(s.length()-2); 1234 s=s.right(s.length()-2);
1231 DocLnk lnk( s ); 1235 DocLnk lnk( s );
1232 QFileInfo f(s); 1236 QFileInfo f(s);
1233 QString name = f.baseName(); 1237 QString name = f.baseName();
1234 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1238 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1235 lnk.setName( name); 1239 lnk.setName( name);
1236 s=s.replace( QRegExp("\\"),"/"); 1240 s=s.replace( QRegExp("\\"),"/");
1237 lnk.setFile( s); 1241 lnk.setFile( s);
1238 lnk.writeLink(); 1242 lnk.writeLink();
1239// lnk.setIcon(opieplayer/MPEGPlayer); 1243// lnk.setIcon(opieplayer/MPEGPlayer);
1240 qDebug("add "+name); 1244 qDebug("add "+name);
1241 d->selectedFiles->addToSelection( lnk); 1245 d->selectedFiles->addToSelection( lnk);
1242 } else { // is url 1246 } else { // is url
1243 1247
1244 s.replace(QRegExp("%20")," "); 1248 s.replace(QRegExp("%20")," ");
1245 DocLnk lnk( s); 1249 DocLnk lnk( s);
1246 QString name; 1250 QString name;
1247 if(name.left(4)=="http") 1251 if(name.left(4)=="http")
1248 name = s.right( s.length() - 7); 1252 name = s.right( s.length() - 7);
1249 else 1253 else
1250 name=s; 1254 name=s;
1251// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1255// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1252 lnk.setName(name); 1256 lnk.setName(name);
1253 if(s.at(s.length()-4) == '.') 1257 if(s.at(s.length()-4) == '.')
1254 lnk.setFile( s); 1258 lnk.setFile( s);
1255 else 1259 else
1256 lnk.setFile( s+"/"); 1260 lnk.setFile( s+"/");
1257// lnk.setFile( filename); 1261// lnk.setFile( filename);
1258// lnk.setComment( s+"/"); 1262// lnk.setComment( s+"/");
1259 lnk.setType("audio/x-mpegurl"); 1263 lnk.setType("audio/x-mpegurl");
1260 lnk.writeLink(); 1264 lnk.writeLink();
1261// lnk.setIcon( "opieplayer/MPEGPlayer"); 1265// lnk.setIcon( "opieplayer/MPEGPlayer");
1262// qDebug("add "+s); 1266// qDebug("add "+s);
1263 d->selectedFiles->addToSelection( lnk); 1267 d->selectedFiles->addToSelection( lnk);
1264 } 1268 }
1265 i++; 1269 i++;
1266 } 1270 }
1267 } 1271 }
1268 } 1272 }
1269 } 1273 }
1270 f.close(); 1274 f.close();
1271} 1275}
1272 1276
1273void PlayListWidget::writem3u() { 1277void PlayListWidget::writem3u() {
1274 1278
1275 InputDialog *fileDlg; 1279 InputDialog *fileDlg;
1276 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1280 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1277 fileDlg->exec(); 1281 fileDlg->exec();
1278 QString filename,list; 1282 QString filename,list;
1279 if( fileDlg->result() == 1 ) { 1283 if( fileDlg->result() == 1 ) {
1280 filename = fileDlg->LineEdit1->text(); 1284 filename = fileDlg->LineEdit1->text();
1281 qDebug(filename); 1285 qDebug(filename);
1282 int noOfFiles = 0; 1286 int noOfFiles = 0;
1283 d->selectedFiles->first(); 1287 d->selectedFiles->first();
1284 do { 1288 do {
1285// we dont check for existance because of url's 1289// we dont check for existance because of url's
1286// qDebug(d->selectedFiles->current()->file()); 1290// qDebug(d->selectedFiles->current()->file());
1287 list += d->selectedFiles->current()->file()+"\n"; 1291 list += d->selectedFiles->current()->file()+"\n";
1288 noOfFiles++; 1292 noOfFiles++;
1289 } 1293 }
1290 while ( d->selectedFiles->next() ); 1294 while ( d->selectedFiles->next() );
1291 qDebug(list); 1295 qDebug(list);
1292 if(filename.left(1) != "/") 1296 if(filename.left(1) != "/")
1293 filename=QPEApplication::documentDir()+"/"+filename; 1297 filename=QPEApplication::documentDir()+"/"+filename;
1294 if(filename.right(3) != "m3u") 1298 if(filename.right(3) != "m3u")
1295 filename=filename+".m3u"; 1299 filename=filename+".m3u";
1296 1300
1297 QFile f(filename); 1301 QFile f(filename);
1298 f.open(IO_WriteOnly); 1302 f.open(IO_WriteOnly);
1299 f.writeBlock(list, list.length()); 1303 f.writeBlock(list, list.length());
1300 f.close(); 1304 f.close();
1301 } 1305 }
1302 if(fileDlg) delete fileDlg; 1306 if(fileDlg) delete fileDlg;
1303} 1307}
1304 1308
1305void PlayListWidget::readPls(const QString &filename) { 1309void PlayListWidget::readPls(const QString &filename) {
1306 1310
1307 qDebug("pls filename is "+filename); 1311 qDebug("pls filename is "+filename);
1308 QFile f(filename); 1312 QFile f(filename);
1309 1313
1310 if(f.open(IO_ReadOnly)) { 1314 if(f.open(IO_ReadOnly)) {
1311 QTextStream t(&f); 1315 QTextStream t(&f);
1312 QString s;//, first, second; 1316 QString s;//, first, second;
1313 int i=0; 1317 int i=0;
1314 while ( !t.atEnd()) { 1318 while ( !t.atEnd()) {
1315 s=t.readLine(); 1319 s=t.readLine();
1316 if(s.left(4) == "File") { 1320 if(s.left(4) == "File") {
1317 s=s.right(s.length() - 6); 1321 s=s.right(s.length() - 6);
1318 s.replace(QRegExp("%20")," "); 1322 s.replace(QRegExp("%20")," ");
1319 qDebug("adding "+s+" to playlist"); 1323 qDebug("adding "+s+" to playlist");
1320// numberofentries=2 1324// numberofentries=2
1321// File1=http 1325// File1=http
1322// Title 1326// Title
1323// Length 1327// Length
1324// Version 1328// Version
1325// File2=http 1329// File2=http
1326 1330
1327 s=s.replace( QRegExp("\\"),"/"); 1331 s=s.replace( QRegExp("\\"),"/");
1328 DocLnk lnk( s ); 1332 DocLnk lnk( s );
1329 QFileInfo f(s); 1333 QFileInfo f(s);
1330 QString name = f.baseName(); 1334 QString name = f.baseName();
1331 if(name.left(4)=="http") 1335 if(name.left(4)=="http")
1332 name = s.right( s.length() - 7); 1336 name = s.right( s.length() - 7);
1333 else 1337 else
1334 name=s; 1338 name=s;
1335 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1339 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1336// QFileInfo f(s); 1340// QFileInfo f(s);
1337// QString name = f.baseName(); 1341// QString name = f.baseName();
1338// name = name.left(name.length()-4); 1342// name = name.left(name.length()-4);
1339// name = name.right(name.findRev("/",0,TRUE)); 1343// name = name.right(name.findRev("/",0,TRUE));
1340 lnk.setName( name); 1344 lnk.setName( name);
1341 if(s.at(s.length()-4) == '.') // if this is probably a file 1345 if(s.at(s.length()-4) == '.') // if this is probably a file
1342 lnk.setFile( s); 1346 lnk.setFile( s);
1343 else { //if its a url 1347 else { //if its a url
1344 if( name.right(1).find('/') == -1) 1348 if( name.right(1).find('/') == -1)
1345 s+="/"; 1349 s+="/";
1346 lnk.setFile( s); 1350 lnk.setFile( s);
1347 } 1351 }
1348 lnk.setType("audio/x-mpegurl"); 1352 lnk.setType("audio/x-mpegurl");
1349 1353
1350 qDebug("DocLnk add "+name); 1354 qDebug("DocLnk add "+name);
1351 d->selectedFiles->addToSelection( lnk); 1355 d->selectedFiles->addToSelection( lnk);
1352 } 1356 }
1353 } 1357 }
1354 i++; 1358 i++;
1355 } 1359 }
1356} 1360}
1357 1361
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 603a7a3..6c4d07f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1060 +1,1063 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50 50
51//only needed for the random play 51//only needed for the random play
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include "audiowidget.h" 54#include "audiowidget.h"
55#include "videowidget.h" 55#include "videowidget.h"
56 56
57extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
58 58
59 59
60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
61 : PlayListWidgetGui( parent, name, fl ) { 61 : PlayListWidgetGui( parent, name, fl ) {
62 62
63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
64 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
66 this , SLOT(removeSelected() ) ); 66 this , SLOT(removeSelected() ) );
67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
68 this , SLOT( btnPlay( bool) ), TRUE ); 68 this , SLOT( btnPlay( bool) ), TRUE );
69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
70 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 70 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
72 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 72 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
73 73
74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
78 pmPlayList->insertSeparator(-1); 78 pmPlayList->insertSeparator(-1);
79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
81 pmPlayList->insertSeparator(-1); 81 pmPlayList->insertSeparator(-1);
82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
83 pmPlayList->insertSeparator(-1); 83 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
86 86
87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
88 88
89 Config cfg( "OpiePlayer" ); 89 Config cfg( "OpiePlayer" );
90 bool b= cfg.readBoolEntry("FullScreen", 0); 90 bool b= cfg.readBoolEntry("FullScreen", 0);
91 mediaPlayerState->setFullscreen( b ); 91 mediaPlayerState->setFullscreen( b );
92 pmView->setItemChecked( -16, b ); 92 pmView->setItemChecked( -16, b );
93 93
94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); 94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) );
95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); 95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) );
96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); 96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) );
97 QVBox *stretch2 = new QVBox( vbox1 ); 97 QVBox *stretch2 = new QVBox( vbox1 );
98 98
99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); 99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) );
100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); 100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) );
101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); 101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) );
102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
107 this,SLOT( playIt( QListViewItem *) ) ); 107 this,SLOT( playIt( QListViewItem *) ) );
108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
112 this,SLOT( playIt( QListViewItem *) ) ); 112 this,SLOT( playIt( QListViewItem *) ) );
113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); 115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) );
116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
121 121
122 readConfig( cfg ); 122 readConfig( cfg );
123 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 123 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
124 loadList(DocLnk( currentPlaylist ) ); 124 loadList(DocLnk( currentPlaylist ) );
125 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 125 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
126 126
127 // see which skins are installed 127 // see which skins are installed
128 videoScan=FALSE; 128 videoScan=FALSE;
129 audioScan=FALSE; 129 audioScan=FALSE;
130 populateSkinsMenu(); 130 populateSkinsMenu();
131 initializeStates(); 131 initializeStates();
132} 132}
133 133
134 134
135PlayListWidget::~PlayListWidget() { 135PlayListWidget::~PlayListWidget() {
136 // WTF?!@?! 136 // WTF?!@?!
137 137
138 if ( d->current ) { 138 if ( d->current ) {
139 delete d->current; 139 delete d->current;
140 } 140 }
141 delete d; 141 delete d;
142} 142}
143 143
144 144
145void PlayListWidget::initializeStates() { 145void PlayListWidget::initializeStates() {
146 d->tbPlay->setOn( mediaPlayerState->playing() ); 146 d->tbPlay->setOn( mediaPlayerState->playing() );
147 d->tbLoop->setOn( mediaPlayerState->looping() ); 147 d->tbLoop->setOn( mediaPlayerState->looping() );
148 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 148 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
149 setPlaylist( true ); 149 setPlaylist( true );
150} 150}
151 151
152 152
153void PlayListWidget::readConfig( Config& cfg ) { 153void PlayListWidget::readConfig( Config& cfg ) {
154 cfg.setGroup( "PlayList" ); 154 cfg.setGroup( "PlayList" );
155 QString currentString = cfg.readEntry( "current", "" ); 155 QString currentString = cfg.readEntry( "current", "" );
156 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 156 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
157 for ( int i = 0; i < noOfFiles; i++ ) { 157 for ( int i = 0; i < noOfFiles; i++ ) {
158 QString entryName; 158 QString entryName;
159 entryName.sprintf( "File%i", i + 1 ); 159 entryName.sprintf( "File%i", i + 1 );
160 QString linkFile = cfg.readEntry( entryName ); 160 QString linkFile = cfg.readEntry( entryName );
161 if( QFileInfo( linkFile ).exists() ) { 161 if( QFileInfo( linkFile ).exists() ) {
162 DocLnk lnk( linkFile ); 162 DocLnk lnk( linkFile );
163 if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { 163 if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) {
164 d->selectedFiles->addToSelection( lnk ); 164 d->selectedFiles->addToSelection( lnk );
165 } 165 }
166 } 166 }
167 } 167 }
168 d->selectedFiles->setSelectedItem( currentString ); 168 d->selectedFiles->setSelectedItem( currentString );
169} 169}
170 170
171 171
172void PlayListWidget::writeConfig( Config& cfg ) const { 172void PlayListWidget::writeConfig( Config& cfg ) const {
173 d->selectedFiles->writeCurrent( cfg ); 173 d->selectedFiles->writeCurrent( cfg );
174 cfg.setGroup( "PlayList" ); 174 cfg.setGroup( "PlayList" );
175 int noOfFiles = 0; 175 int noOfFiles = 0;
176 d->selectedFiles->first(); 176 d->selectedFiles->first();
177 do { 177 do {
178 const DocLnk *lnk = d->selectedFiles->current(); 178 const DocLnk *lnk = d->selectedFiles->current();
179 if ( lnk ) { 179 if ( lnk ) {
180 QString entryName; 180 QString entryName;
181 entryName.sprintf( "File%i", noOfFiles + 1 ); 181 entryName.sprintf( "File%i", noOfFiles + 1 );
182 cfg.writeEntry( entryName, lnk->linkFile() ); 182 cfg.writeEntry( entryName, lnk->linkFile() );
183 // if this link does exist, add it so we have the file 183 // if this link does exist, add it so we have the file
184 // next time... 184 // next time...
185 if ( !QFile::exists( lnk->linkFile() ) ) { 185 if ( !QFile::exists( lnk->linkFile() ) ) {
186 // the way writing lnks doesn't really check for out 186 // the way writing lnks doesn't really check for out
187 // of disk space, but check it anyway. 187 // of disk space, but check it anyway.
188 if ( !lnk->writeLink() ) { 188 if ( !lnk->writeLink() ) {
189 QMessageBox::critical( 0, tr("Out of space"), 189 QMessageBox::critical( 0, tr("Out of space"),
190 tr( "There was a problem saving " 190 tr( "There was a problem saving "
191 "the playlist.\n" 191 "the playlist.\n"
192 "Your playlist " 192 "Your playlist "
193 "may be missing some entries\n" 193 "may be missing some entries\n"
194 "the next time you start it." ) 194 "the next time you start it." )
195 ); 195 );
196 } 196 }
197 } 197 }
198 noOfFiles++; 198 noOfFiles++;
199 } 199 }
200 } 200 }
201 while ( d->selectedFiles->next() ); 201 while ( d->selectedFiles->next() );
202 cfg.writeEntry("NumberOfFiles", noOfFiles ); 202 cfg.writeEntry("NumberOfFiles", noOfFiles );
203} 203}
204 204
205 205
206void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
207 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
208 if ( mediaPlayerState->playlist() ) { 208 if ( mediaPlayerState->playlist() ) {
209 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) 209 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" )
210 d->selectedFiles->addToSelection( lnk ); 210 d->selectedFiles->addToSelection( lnk );
211 } 211 }
212 else 212 else
213 mediaPlayerState->setPlaying( TRUE ); 213 mediaPlayerState->setPlaying( TRUE );
214} 214}
215 215
216 216
217void PlayListWidget::clearList() { 217void PlayListWidget::clearList() {
218 while ( first() ) { 218 while ( first() ) {
219 d->selectedFiles->removeSelected(); 219 d->selectedFiles->removeSelected();
220 } 220 }
221} 221}
222 222
223 223
224void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 224void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
225 switch (mouse) { 225 switch (mouse) {
226 case 1: 226 case 1:
227 break; 227 break;
228 case 2: 228 case 2:
229 { 229 {
230 QPopupMenu m; 230 QPopupMenu m;
231 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 231 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
232 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 232 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
233 m.exec( QCursor::pos() ); 233 m.exec( QCursor::pos() );
234 } 234 }
235 break; 235 break;
236 } 236 }
237} 237}
238 238
239 239
240void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 240void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
241 switch (mouse) { 241 switch (mouse) {
242 case 1: 242 case 1:
243 break; 243 break;
244 case 2: 244 case 2:
245 { 245 {
246 QPopupMenu m; 246 QPopupMenu m;
247 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 247 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
248 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 248 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
249 m.exec( QCursor::pos() ); 249 m.exec( QCursor::pos() );
250 } 250 }
251 break; 251 break;
252 } 252 }
253} 253}
254 254
255 255
256void PlayListWidget::addAllToList() { 256void PlayListWidget::addAllToList() {
257 DocLnkSet filesAll; 257 DocLnkSet filesAll;
258 Global::findDocuments(&filesAll, "video/*;audio/*"); 258 Global::findDocuments(&filesAll, "video/*;audio/*");
259 QListIterator<DocLnk> Adit( filesAll.children() ); 259 QListIterator<DocLnk> Adit( filesAll.children() );
260 for ( ; Adit.current(); ++Adit ) { 260 for ( ; Adit.current(); ++Adit ) {
261 if( QFileInfo( Adit.current()->file() ).exists() ) { 261 if( QFileInfo( Adit.current()->file() ).exists() ) {
262 d->selectedFiles->addToSelection( **Adit ); 262 d->selectedFiles->addToSelection( **Adit );
263 } 263 }
264 } 264 }
265} 265}
266 266
267 267
268void PlayListWidget::addAllMusicToList() { 268void PlayListWidget::addAllMusicToList() {
269 QListIterator<DocLnk> dit( files.children() ); 269 QListIterator<DocLnk> dit( files.children() );
270 for ( ; dit.current(); ++dit ) { 270 for ( ; dit.current(); ++dit ) {
271 if( QFileInfo(dit.current()->file() ).exists() ) { 271 if( QFileInfo(dit.current()->file() ).exists() ) {
272 d->selectedFiles->addToSelection( **dit ); 272 d->selectedFiles->addToSelection( **dit );
273 } 273 }
274 } 274 }
275} 275}
276 276
277 277
278void PlayListWidget::addAllVideoToList() { 278void PlayListWidget::addAllVideoToList() {
279 QListIterator<DocLnk> dit( vFiles.children() ); 279 QListIterator<DocLnk> dit( vFiles.children() );
280 for ( ; dit.current(); ++dit ) { 280 for ( ; dit.current(); ++dit ) {
281 if( QFileInfo( dit.current()->file() ).exists() ) { 281 if( QFileInfo( dit.current()->file() ).exists() ) {
282 d->selectedFiles->addToSelection( **dit ); 282 d->selectedFiles->addToSelection( **dit );
283 } 283 }
284 } 284 }
285} 285}
286 286
287 287
288void PlayListWidget::setDocument( const QString& fileref ) { 288void PlayListWidget::setDocument( const QString& fileref ) {
289 //qDebug( fileref ); 289 //qDebug( fileref );
290 fromSetDocument = TRUE; 290 fromSetDocument = TRUE;
291 if ( fileref.isNull() ) { 291 if ( fileref.isNull() ) {
292 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 292 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
293 return; 293 return;
294 } 294 }
295 295
296 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 296 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
297 readm3u( fileref ); 297 readm3u( fileref );
298 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 298 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
299 readPls( fileref ); 299 readPls( fileref );
300 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 300 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
301 clearList(); 301 clearList();
302 loadList( DocLnk( fileref ) ); 302 loadList( DocLnk( fileref ) );
303 d->selectedFiles->first(); 303 d->selectedFiles->first();
304 } else { 304 } else {
305 clearList(); 305 clearList();
306 addToSelection( DocLnk( fileref ) ); 306 addToSelection( DocLnk( fileref ) );
307 d->setDocumentUsed = TRUE; 307 d->setDocumentUsed = TRUE;
308 mediaPlayerState->setPlaying( FALSE ); 308 mediaPlayerState->setPlaying( FALSE );
309 qApp->processEvents(); 309 qApp->processEvents();
310 mediaPlayerState->setPlaying( TRUE ); 310 mediaPlayerState->setPlaying( TRUE );
311 qApp->processEvents(); 311 qApp->processEvents();
312 setCaption( tr("OpiePlayer") ); 312 setCaption( tr("OpiePlayer") );
313 } 313 }
314} 314}
315 315
316 316
317void PlayListWidget::useSelectedDocument() { 317void PlayListWidget::useSelectedDocument() {
318 d->setDocumentUsed = FALSE; 318 d->setDocumentUsed = FALSE;
319} 319}
320 320
321 321
322const DocLnk *PlayListWidget::current() { // this is fugly 322const DocLnk *PlayListWidget::current() { // this is fugly
323 switch ( tabWidget->currentPageIndex() ) { 323 switch ( tabWidget->currentPageIndex() ) {
324 case 0: //playlist 324 case 0: //playlist
325 { 325 {
326// qDebug("playlist"); 326// qDebug("playlist");
327 if ( mediaPlayerState->playlist() ) { 327 if ( mediaPlayerState->playlist() ) {
328 return d->selectedFiles->current(); 328 return d->selectedFiles->current();
329 } else if ( d->setDocumentUsed && d->current ) { 329 } else if ( d->setDocumentUsed && d->current ) {
330 return d->current; 330 return d->current;
331 } else { 331 } else {
332 return d->files->selected(); 332 return d->files->selected();
333 } 333 }
334 } 334 }
335 break; 335 break;
336 case 1://audio 336 case 1://audio
337 { 337 {
338// qDebug("audioView"); 338// qDebug("audioView");
339 QListIterator<DocLnk> dit( files.children() ); 339 QListIterator<DocLnk> dit( files.children() );
340 for ( ; dit.current(); ++dit ) { 340 for ( ; dit.current(); ++dit ) {
341 if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { 341 if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) {
342 insanityBool = TRUE; 342 insanityBool = TRUE;
343 return dit; 343 return dit;
344 } 344 }
345 } 345 }
346 } 346 }
347 break; 347 break;
348 case 2: // video 348 case 2: // video
349 { 349 {
350// qDebug("videoView"); 350// qDebug("videoView");
351 QListIterator<DocLnk> Vdit( vFiles.children() ); 351 QListIterator<DocLnk> Vdit( vFiles.children() );
352 for ( ; Vdit.current(); ++Vdit ) { 352 for ( ; Vdit.current(); ++Vdit ) {
353 if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { 353 if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) {
354 insanityBool = TRUE; 354 insanityBool = TRUE;
355 return Vdit; 355 return Vdit;
356 } 356 }
357 } 357 }
358 } 358 }
359 break; 359 break;
360 }; 360 };
361 return 0; 361 return 0;
362} 362}
363 363
364 364
365bool PlayListWidget::prev() { 365bool PlayListWidget::prev() {
366 if ( mediaPlayerState->playlist() ) { 366 if ( mediaPlayerState->playlist() ) {
367 if ( mediaPlayerState->shuffled() ) { 367 if ( mediaPlayerState->shuffled() ) {
368 const DocLnk *cur = current(); 368 const DocLnk *cur = current();
369 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 369 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
370 for ( int i = 0; i < j; i++ ) { 370 for ( int i = 0; i < j; i++ ) {
371 if ( !d->selectedFiles->next() ) 371 if ( !d->selectedFiles->next() )
372 d->selectedFiles->first(); 372 d->selectedFiles->first();
373 } 373 }
374 if ( cur == current() ) 374 if ( cur == current() )
375 if ( !d->selectedFiles->next() ) { 375 if ( !d->selectedFiles->next() ) {
376 d->selectedFiles->first(); 376 d->selectedFiles->first();
377 } 377 }
378 return TRUE; 378 return TRUE;
379 } else { 379 } else {
380 if ( !d->selectedFiles->prev() ) { 380 if ( !d->selectedFiles->prev() ) {
381 if ( mediaPlayerState->looping() ) { 381 if ( mediaPlayerState->looping() ) {
382 return d->selectedFiles->last(); 382 return d->selectedFiles->last();
383 } else { 383 } else {
384 return FALSE; 384 return FALSE;
385 } 385 }
386 } 386 }
387 return TRUE; 387 return TRUE;
388 } 388 }
389 } else { 389 } else {
390 return mediaPlayerState->looping(); 390 return mediaPlayerState->looping();
391 } 391 }
392} 392}
393 393
394 394
395bool PlayListWidget::next() { 395bool PlayListWidget::next() {
396 if ( mediaPlayerState->playlist() ) { 396 if ( mediaPlayerState->playlist() ) {
397 if ( mediaPlayerState->shuffled() ) { 397 if ( mediaPlayerState->shuffled() ) {
398 return prev(); 398 return prev();
399 } else { 399 } else {
400 if ( !d->selectedFiles->next() ) { 400 if ( !d->selectedFiles->next() ) {
401 if ( mediaPlayerState->looping() ) { 401 if ( mediaPlayerState->looping() ) {
402 return d->selectedFiles->first(); 402 return d->selectedFiles->first();
403 } else { 403 } else {
404 return FALSE; 404 return FALSE;
405 } 405 }
406 } 406 }
407 return TRUE; 407 return TRUE;
408 } 408 }
409 } else { 409 } else {
410 return mediaPlayerState->looping(); 410 return mediaPlayerState->looping();
411 } 411 }
412} 412}
413 413
414 414
415bool PlayListWidget::first() { 415bool PlayListWidget::first() {
416 if ( mediaPlayerState->playlist() ) 416 if ( mediaPlayerState->playlist() )
417 return d->selectedFiles->first(); 417 return d->selectedFiles->first();
418 else 418 else
419 return mediaPlayerState->looping(); 419 return mediaPlayerState->looping();
420} 420}
421 421
422 422
423bool PlayListWidget::last() { 423bool PlayListWidget::last() {
424 if ( mediaPlayerState->playlist() ) 424 if ( mediaPlayerState->playlist() )
425 return d->selectedFiles->last(); 425 return d->selectedFiles->last();
426 else 426 else
427 return mediaPlayerState->looping(); 427 return mediaPlayerState->looping();
428} 428}
429 429
430 430
431void PlayListWidget::saveList() { 431void PlayListWidget::saveList() {
432 432
433 QString filename; 433 QString filename;
434 InputDialog *fileDlg = 0l; 434 InputDialog *fileDlg = 0l;
435 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 435 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
436 fileDlg->exec(); 436 fileDlg->exec();
437 if( fileDlg->result() == 1 ) { 437 if( fileDlg->result() == 1 ) {
438 if ( d->current ) 438 if ( d->current )
439 delete d->current; 439 delete d->current;
440 filename = fileDlg->text();//+".playlist"; 440 filename = fileDlg->text();//+".playlist";
441 // qDebug("saving playlist "+filename+".playlist"); 441 // qDebug("saving playlist "+filename+".playlist");
442 Config cfg( filename +".playlist"); 442 Config cfg( filename +".playlist");
443 writeConfig( cfg ); 443 writeConfig( cfg );
444 444
445 DocLnk lnk; 445 DocLnk lnk;
446 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 446 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
447 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 447 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
448 lnk.setIcon("opieplayer2/playlist2"); 448 lnk.setIcon("opieplayer2/playlist2");
449 lnk.setName( filename); //sets file name 449 lnk.setName( filename); //sets file name
450 // qDebug(filename); 450 // qDebug(filename);
451 if(!lnk.writeLink()) { 451 if(!lnk.writeLink()) {
452 qDebug("Writing doclink did not work"); 452 qDebug("Writing doclink did not work");
453 } 453 }
454 } 454 }
455 Config config( "OpiePlayer" ); 455 Config config( "OpiePlayer" );
456 config.writeEntry("CurrentPlaylist",filename); 456 config.writeEntry("CurrentPlaylist",filename);
457 setCaption(tr("OpiePlayer: ")+filename); 457 setCaption(tr("OpiePlayer: ")+filename);
458 d->selectedFiles->first(); 458 d->selectedFiles->first();
459 if(fileDlg) { 459 if(fileDlg) {
460 delete fileDlg; 460 delete fileDlg;
461 } 461 }
462} 462}
463 463
464void PlayListWidget::loadList( const DocLnk & lnk) { 464void PlayListWidget::loadList( const DocLnk & lnk) {
465 QString name= lnk.name(); 465 QString name= lnk.name();
466 // qDebug("currentList is "+name); 466 // qDebug("currentList is "+name);
467 if( name.length()>1) { 467 if( name.length()>1) {
468 setCaption("OpiePlayer: "+name); 468 setCaption("OpiePlayer: "+name);
469 // qDebug("load list "+ name+".playlist"); 469 // qDebug("load list "+ name+".playlist");
470 clearList(); 470 clearList();
471 Config cfg( name+".playlist"); 471 Config cfg( name+".playlist");
472 readConfig(cfg); 472 readConfig(cfg);
473 473
474 tabWidget->setCurrentPage(0); 474 tabWidget->setCurrentPage(0);
475 475
476 Config config( "OpiePlayer" ); 476 Config config( "OpiePlayer" );
477 config.writeEntry("CurrentPlaylist", name); 477 config.writeEntry("CurrentPlaylist", name);
478 // d->selectedFiles->first(); 478 // d->selectedFiles->first();
479 } 479 }
480} 480}
481 481
482 482
483void PlayListWidget::setPlaylist( bool shown ) { 483void PlayListWidget::setPlaylist( bool shown ) {
484 if ( shown ) { 484 if ( shown ) {
485 d->playListFrame->show(); 485 d->playListFrame->show();
486 } else { 486 } else {
487 d->playListFrame->hide(); 487 d->playListFrame->hide();
488 } 488 }
489} 489}
490 490
491 491
492void PlayListWidget::addSelected() { 492void PlayListWidget::addSelected() {
493 493
494 Config cfg( "OpiePlayer" ); 494 Config cfg( "OpiePlayer" );
495 cfg.setGroup("PlayList"); 495 cfg.setGroup("PlayList");
496 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 496 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
497 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 497 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
498 498
499 switch (tabWidget->currentPageIndex()) { 499 switch (tabWidget->currentPageIndex()) {
500 case 0: //playlist 500 case 0: //playlist
501 break; 501 break;
502 case 1: { //audio 502 case 1: { //audio
503 QListViewItemIterator it( audioView ); 503 QListViewItemIterator it( audioView );
504 // iterate through all items of the listview 504 // iterate through all items of the listview
505 for ( ; it.current(); ++it ) { 505 for ( ; it.current(); ++it ) {
506 if ( it.current()->isSelected() ) { 506 if ( it.current()->isSelected() ) {
507 QListIterator<DocLnk> dit( files.children() ); 507 QListIterator<DocLnk> dit( files.children() );
508 for ( ; dit.current(); ++dit ) { 508 for ( ; dit.current(); ++dit ) {
509 if( dit.current()->name() == it.current()->text(0) ) { 509 if( dit.current()->name() == it.current()->text(0) ) {
510 if(QFileInfo( dit.current()->file()).exists()) 510 if(QFileInfo( dit.current()->file()).exists())
511 d->selectedFiles->addToSelection( **dit ); 511 d->selectedFiles->addToSelection( **dit );
512 } 512 }
513 } 513 }
514 audioView->setSelected( it.current(),FALSE); 514 audioView->setSelected( it.current(),FALSE);
515 } 515 }
516 } 516 }
517 tabWidget->setCurrentPage(0); 517 tabWidget->setCurrentPage(0);
518 } 518 }
519 break; 519 break;
520 case 2: { // video 520 case 2: { // video
521 QListViewItemIterator it( videoView ); 521 QListViewItemIterator it( videoView );
522 // iterate through all items of the listview 522 // iterate through all items of the listview
523 for ( ; it.current(); ++it ) { 523 for ( ; it.current(); ++it ) {
524 if ( it.current()->isSelected() ) { 524 if ( it.current()->isSelected() ) {
525 QListIterator<DocLnk> dit( vFiles.children() ); 525 QListIterator<DocLnk> dit( vFiles.children() );
526 for ( ; dit.current(); ++dit ) { 526 for ( ; dit.current(); ++dit ) {
527 if( dit.current()->name() == it.current()->text(0) ) { 527 if( dit.current()->name() == it.current()->text(0) ) {
528 if(QFileInfo( dit.current()->file()).exists()) 528 if(QFileInfo( dit.current()->file()).exists())
529 d->selectedFiles->addToSelection( **dit ); 529 d->selectedFiles->addToSelection( **dit );
530 } 530 }
531 } 531 }
532 videoView->setSelected( it.current(),FALSE); 532 videoView->setSelected( it.current(),FALSE);
533 } 533 }
534 } 534 }
535 tabWidget->setCurrentPage(0); 535 tabWidget->setCurrentPage(0);
536 } 536 }
537 break; 537 break;
538 }; 538 };
539} 539}
540 540
541 541
542void PlayListWidget::removeSelected() { 542void PlayListWidget::removeSelected() {
543 d->selectedFiles->removeSelected( ); 543 d->selectedFiles->removeSelected( );
544} 544}
545 545
546 546
547void PlayListWidget::playIt( QListViewItem *it) { 547void PlayListWidget::playIt( QListViewItem *it) {
548 if(!it) return; 548 if(!it) return;
549 mediaPlayerState->setPlaying(FALSE); 549 mediaPlayerState->setPlaying(FALSE);
550 mediaPlayerState->setPlaying(TRUE); 550 mediaPlayerState->setPlaying(TRUE);
551 d->selectedFiles->unSelect(); 551 d->selectedFiles->unSelect();
552} 552}
553 553
554 554
555void PlayListWidget::addToSelection( QListViewItem *it) { 555void PlayListWidget::addToSelection( QListViewItem *it) {
556 d->setDocumentUsed = FALSE; 556 d->setDocumentUsed = FALSE;
557 557
558 if(it) { 558 if(it) {
559 switch (tabWidget->currentPageIndex()) { 559 switch (tabWidget->currentPageIndex()) {
560 case 1: { 560 case 1: {
561 QListIterator<DocLnk> dit( files.children() ); 561 QListIterator<DocLnk> dit( files.children() );
562 for ( ; dit.current(); ++dit ) { 562 for ( ; dit.current(); ++dit ) {
563 if( dit.current()->name() == it->text(0)) { 563 if( dit.current()->name() == it->text(0)) {
564 if(QFileInfo( dit.current()->file()).exists()) 564 if(QFileInfo( dit.current()->file()).exists())
565 d->selectedFiles->addToSelection( **dit ); 565 d->selectedFiles->addToSelection( **dit );
566 } 566 }
567 } 567 }
568 } 568 }
569 break; 569 break;
570 case 2: { 570 case 2: {
571 QListIterator<DocLnk> dit( vFiles.children() ); 571 QListIterator<DocLnk> dit( vFiles.children() );
572 for ( ; dit.current(); ++dit ) { 572 for ( ; dit.current(); ++dit ) {
573 if( dit.current()->name() == it->text(0)) { 573 if( dit.current()->name() == it->text(0)) {
574 if(QFileInfo( dit.current()->file()).exists()) 574 if(QFileInfo( dit.current()->file()).exists())
575 d->selectedFiles->addToSelection( **dit ); 575 d->selectedFiles->addToSelection( **dit );
576 } 576 }
577 } 577 }
578 } 578 }
579 break; 579 break;
580 case 0: 580 case 0:
581 break; 581 break;
582 }; 582 };
583 tabWidget->setCurrentPage(0); 583 tabWidget->setCurrentPage(0);
584 } 584 }
585} 585}
586 586
587 587
588void PlayListWidget::tabChanged(QWidget *) { 588void PlayListWidget::tabChanged(QWidget *) {
589 589
590 switch ( tabWidget->currentPageIndex()) { 590 switch ( tabWidget->currentPageIndex()) {
591 case 0: 591 case 0:
592 { 592 {
593 if( !tbDeletePlaylist->isHidden() ) { 593 if( !tbDeletePlaylist->isHidden() ) {
594 tbDeletePlaylist->hide(); 594 tbDeletePlaylist->hide();
595 } 595 }
596 d->tbRemoveFromList->setEnabled(TRUE); 596 d->tbRemoveFromList->setEnabled(TRUE);
597 d->tbAddToList->setEnabled(FALSE); 597 d->tbAddToList->setEnabled(FALSE);
598 } 598 }
599 break; 599 break;
600 case 1: 600 case 1:
601 { 601 {
602 audioView->clear(); 602 audioView->clear();
603 populateAudioView(); 603 populateAudioView();
604 604
605 if( !tbDeletePlaylist->isHidden() ) { 605 if( !tbDeletePlaylist->isHidden() ) {
606 tbDeletePlaylist->hide(); 606 tbDeletePlaylist->hide();
607 } 607 }
608 d->tbRemoveFromList->setEnabled(FALSE); 608 d->tbRemoveFromList->setEnabled(FALSE);
609 d->tbAddToList->setEnabled(TRUE); 609 d->tbAddToList->setEnabled(TRUE);
610 } 610 }
611 break; 611 break;
612 case 2: 612 case 2:
613 { 613 {
614 videoView->clear(); 614 videoView->clear();
615 populateVideoView(); 615 populateVideoView();
616 if( !tbDeletePlaylist->isHidden() ) { 616 if( !tbDeletePlaylist->isHidden() ) {
617 tbDeletePlaylist->hide(); 617 tbDeletePlaylist->hide();
618 } 618 }
619 d->tbRemoveFromList->setEnabled(FALSE); 619 d->tbRemoveFromList->setEnabled(FALSE);
620 d->tbAddToList->setEnabled(TRUE); 620 d->tbAddToList->setEnabled(TRUE);
621 } 621 }
622 break; 622 break;
623 case 3: 623 case 3:
624 { 624 {
625 if( tbDeletePlaylist->isHidden() ) { 625 if( tbDeletePlaylist->isHidden() ) {
626 tbDeletePlaylist->show(); 626 tbDeletePlaylist->show();
627 } 627 }
628 playLists->reread(); 628 playLists->reread();
629 } 629 }
630 break; 630 break;
631 }; 631 };
632} 632}
633 633
634 634
635void PlayListWidget::btnPlay(bool b) { 635void PlayListWidget::btnPlay(bool b) {
636 // mediaPlayerState->setPlaying(b); 636 // mediaPlayerState->setPlaying(b);
637 switch ( tabWidget->currentPageIndex()) { 637 switch ( tabWidget->currentPageIndex()) {
638 case 0: 638 case 0:
639 { 639 {
640 mediaPlayerState->setPlaying(b); 640 mediaPlayerState->setPlaying(b);
641 } 641 }
642 break; 642 break;
643 case 1: 643 case 1:
644 { 644 {
645 addToSelection( audioView->currentItem() ); 645 addToSelection( audioView->currentItem() );
646 mediaPlayerState->setPlaying(b); 646 mediaPlayerState->setPlaying(b);
647 d->selectedFiles->removeSelected( ); 647 d->selectedFiles->removeSelected( );
648 tabWidget->setCurrentPage(1); 648 tabWidget->setCurrentPage(1);
649 d->selectedFiles->unSelect(); 649 d->selectedFiles->unSelect();
650 insanityBool=FALSE; 650 insanityBool=FALSE;
651 }// audioView->clearSelection(); 651 }// audioView->clearSelection();
652 break; 652 break;
653 case 2: 653 case 2:
654 { 654 {
655 addToSelection( videoView->currentItem() ); 655 addToSelection( videoView->currentItem() );
656 mediaPlayerState->setPlaying(b); 656 mediaPlayerState->setPlaying(b);
657 qApp->processEvents(); 657 qApp->processEvents();
658 d->selectedFiles->removeSelected( ); 658 d->selectedFiles->removeSelected( );
659 tabWidget->setCurrentPage(2); 659 tabWidget->setCurrentPage(2);
660 d->selectedFiles->unSelect(); 660 d->selectedFiles->unSelect();
661 insanityBool=FALSE; 661 insanityBool=FALSE;
662 }// videoView->clearSelection(); 662 }// videoView->clearSelection();
663 break; 663 break;
664 }; 664 };
665 665
666} 666}
667 667
668void PlayListWidget::deletePlaylist() { 668void PlayListWidget::deletePlaylist() {
669 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 669 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
670 (tr("You really want to delete\nthis playlist?")), 670 (tr("You really want to delete\nthis playlist?")),
671 (tr("Yes")), (tr("No")), 0 )){ 671 (tr("Yes")), (tr("No")), 0 )){
672 case 0: // Yes clicked, 672 case 0: // Yes clicked,
673 QFile().remove(playLists->selected()->file()); 673 QFile().remove(playLists->selected()->file());
674 QFile().remove(playLists->selected()->linkFile()); 674 QFile().remove(playLists->selected()->linkFile());
675 playLists->reread(); 675 playLists->reread();
676 break; 676 break;
677 case 1: // Cancel 677 case 1: // Cancel
678 break; 678 break;
679 }; 679 };
680} 680}
681 681
682 682
683void PlayListWidget::playSelected() { 683void PlayListWidget::playSelected() {
684 btnPlay( TRUE); 684 btnPlay( TRUE);
685} 685}
686 686
687 687
688void PlayListWidget::scanForAudio() { 688void PlayListWidget::scanForAudio() {
689// qDebug("scan for audio"); 689// qDebug("scan for audio");
690 files.detachChildren(); 690 files.detachChildren();
691 QListIterator<DocLnk> sdit( files.children() ); 691 QListIterator<DocLnk> sdit( files.children() );
692 for ( ; sdit.current(); ++sdit ) { 692 for ( ; sdit.current(); ++sdit ) {
693 delete sdit.current(); 693 delete sdit.current();
694 } 694 }
695 Global::findDocuments(&files, "audio/*"); 695 Global::findDocuments(&files, "audio/*");
696 audioScan = TRUE; 696 audioScan = TRUE;
697} 697}
698 698
699void PlayListWidget::scanForVideo() { 699void PlayListWidget::scanForVideo() {
700// qDebug("scan for video"); 700// qDebug("scan for video");
701 vFiles.detachChildren(); 701 vFiles.detachChildren();
702 QListIterator<DocLnk> sdit( vFiles.children() ); 702 QListIterator<DocLnk> sdit( vFiles.children() );
703 for ( ; sdit.current(); ++sdit ) { 703 for ( ; sdit.current(); ++sdit ) {
704 delete sdit.current(); 704 delete sdit.current();
705 } 705 }
706 Global::findDocuments(&vFiles, "video/*"); 706 Global::findDocuments(&vFiles, "video/*");
707 videoScan = TRUE; 707 videoScan = TRUE;
708} 708}
709 709
710void PlayListWidget::populateAudioView() { 710void PlayListWidget::populateAudioView() {
711 audioView->clear(); 711 audioView->clear();
712 StorageInfo storageInfo; 712 StorageInfo storageInfo;
713 const QList<FileSystem> &fs = storageInfo.fileSystems(); 713 const QList<FileSystem> &fs = storageInfo.fileSystems();
714 if(!audioScan) { 714 if(!audioScan) {
715 scanForAudio(); 715 scanForAudio();
716 } 716 }
717 717
718 QListIterator<DocLnk> dit( files.children() ); 718 QListIterator<DocLnk> dit( files.children() );
719 QListIterator<FileSystem> it ( fs ); 719 QListIterator<FileSystem> it ( fs );
720 720
721 QString storage; 721 QString storage;
722 for ( ; dit.current(); ++dit ) { 722 for ( ; dit.current(); ++dit ) {
723 for( ; it.current(); ++it ){ 723 for( ; it.current(); ++it ){
724 const QString name = (*it)->name(); 724 const QString name = (*it)->name();
725 const QString path = (*it)->path(); 725 const QString path = (*it)->path();
726 if(dit.current()->file().find(path) != -1 ) { 726 if(dit.current()->file().find(path) != -1 ) {
727 storage = name; 727 storage = name;
728 } 728 }
729 } 729 }
730 730
731 QListViewItem * newItem; 731 QListViewItem * newItem;
732 if ( QFile( dit.current()->file()).exists() ) { 732 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
733 // qDebug(dit.current()->name()); 733 long size;
734 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 734 if( dit.current()->file().left(4) == "http" )
735 QString::number( QFile( dit.current()->file()).size() ), storage); 735 size=0;
736 else
737 size = QFile( dit.current()->file() ).size();
738 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage);
736 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 739 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
737 } 740 }
738 } 741 }
739} 742}
740 743
741 744
742void PlayListWidget::populateVideoView() { 745void PlayListWidget::populateVideoView() {
743 videoView->clear(); 746 videoView->clear();
744 StorageInfo storageInfo; 747 StorageInfo storageInfo;
745 const QList<FileSystem> &fs = storageInfo.fileSystems(); 748 const QList<FileSystem> &fs = storageInfo.fileSystems();
746 749
747 if(!videoScan ) { 750 if(!videoScan ) {
748 scanForVideo(); 751 scanForVideo();
749 } 752 }
750 753
751 QListIterator<DocLnk> Vdit( vFiles.children() ); 754 QListIterator<DocLnk> Vdit( vFiles.children() );
752 QListIterator<FileSystem> it ( fs ); 755 QListIterator<FileSystem> it ( fs );
753 videoView->clear(); 756 videoView->clear();
754 QString storage; 757 QString storage;
755 for ( ; Vdit.current(); ++Vdit ) { 758 for ( ; Vdit.current(); ++Vdit ) {
756 for( ; it.current(); ++it ) { 759 for( ; it.current(); ++it ) {
757 const QString name = (*it)->name(); 760 const QString name = (*it)->name();
758 const QString path = (*it)->path(); 761 const QString path = (*it)->path();
759 if( Vdit.current()->file().find(path) != -1 ) { 762 if( Vdit.current()->file().find(path) != -1 ) {
760 storage=name; 763 storage=name;
761 } 764 }
762 } 765 }
763 766
764 QListViewItem * newItem; 767 QListViewItem * newItem;
765 if ( QFile( Vdit.current()->file() ).exists() ) { 768 if ( QFile( Vdit.current()->file() ).exists() ) {
766 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 769 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
767 QString::number( QFile( Vdit.current()->file() ).size() ), storage ); 770 QString::number( QFile( Vdit.current()->file() ).size() ), storage );
768 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 771 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
769 } 772 }
770 } 773 }
771} 774}
772 775
773 776
774void PlayListWidget::openFile() { 777void PlayListWidget::openFile() {
775 QString filename, name; 778 QString filename, name;
776 InputDialog *fileDlg; 779 InputDialog *fileDlg;
777 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 780 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
778 fileDlg->exec(); 781 fileDlg->exec();
779 if( fileDlg->result() == 1 ) { 782 if( fileDlg->result() == 1 ) {
780 filename = fileDlg->text(); 783 filename = fileDlg->text();
781 784
782 qDebug( "Selected filename is " + filename ); 785 qDebug( "Selected filename is " + filename );
783 if( filename.right( 3 ) == "m3u" ) { 786 if( filename.right( 3 ) == "m3u" ) {
784 readm3u( filename ); 787 readm3u( filename );
785 } else if( filename.right(3) == "pls" ) { 788 } else if( filename.right(3) == "pls" ) {
786 readPls( filename ); 789 readPls( filename );
787 } else { 790 } else {
788 // this doesnt need fixing 791 // this doesnt need fixing
789 DocLnk lnk; 792 DocLnk lnk;
790 lnk.setName( filename ); //sets file name 793 lnk.setName( filename ); //sets file name
791 lnk.setFile( filename ); //sets File property 794 lnk.setFile( filename ); //sets File property
792 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 795 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
793 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 796 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
794 lnk.setExec( "opieplayer" ); 797 lnk.setExec( "opieplayer" );
795 lnk.setIcon( "opieplayer2/MPEGPlayer" ); 798 lnk.setIcon( "opieplayer2/MPEGPlayer" );
796 799
797 if( !lnk.writeLink() ) { 800 if( !lnk.writeLink() ) {
798 qDebug( "Writing doclink did not work" ); 801 qDebug( "Writing doclink did not work" );
799 } 802 }
800 d->selectedFiles->addToSelection( lnk ); 803 d->selectedFiles->addToSelection( lnk );
801 } 804 }
802 } 805 }
803 if( fileDlg ) { 806 if( fileDlg ) {
804 delete fileDlg; 807 delete fileDlg;
805 } 808 }
806} 809}
807 810
808void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 811void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
809 switch ( e->key() ) { 812 switch ( e->key() ) {
810 ////////////////////////////// Zaurus keys 813 ////////////////////////////// Zaurus keys
811 case Key_F9: //activity 814 case Key_F9: //activity
812 // if(audioUI->isHidden()) 815 // if(audioUI->isHidden())
813 // audioUI->showMaximized(); 816 // audioUI->showMaximized();
814 break; 817 break;
815 case Key_F10: //contacts 818 case Key_F10: //contacts
816 // if( videoUI->isHidden()) 819 // if( videoUI->isHidden())
817 // videoUI->showMaximized(); 820 // videoUI->showMaximized();
818 break; 821 break;
819 case Key_F11: //menu 822 case Key_F11: //menu
820 break; 823 break;
821 case Key_F12: //home 824 case Key_F12: //home
822 // doBlank(); 825 // doBlank();
823 break; 826 break;
824 case Key_F13: //mail 827 case Key_F13: //mail
825 // doUnblank(); 828 // doUnblank();
826 break; 829 break;
827 case Key_Q: //add to playlist 830 case Key_Q: //add to playlist
828 addSelected(); 831 addSelected();
829 break; 832 break;
830 case Key_R: //remove from playlist 833 case Key_R: //remove from playlist
831 removeSelected(); 834 removeSelected();
832 break; 835 break;
833 // case Key_P: //play 836 // case Key_P: //play
834 // qDebug("Play"); 837 // qDebug("Play");
835 // playSelected(); 838 // playSelected();
836 // break; 839 // break;
837 case Key_Space: 840 case Key_Space:
838 // playSelected(); puh 841 // playSelected(); puh
839 break; 842 break;
840 case Key_1: 843 case Key_1:
841 tabWidget->setCurrentPage( 0 ); 844 tabWidget->setCurrentPage( 0 );
842 break; 845 break;
843 case Key_2: 846 case Key_2:
844 tabWidget->setCurrentPage( 1 ); 847 tabWidget->setCurrentPage( 1 );
845 break; 848 break;
846 case Key_3: 849 case Key_3:
847 tabWidget->setCurrentPage( 2 ); 850 tabWidget->setCurrentPage( 2 );
848 break; 851 break;
849 case Key_4: 852 case Key_4:
850 tabWidget->setCurrentPage( 3 ); 853 tabWidget->setCurrentPage( 3 );
851 break; 854 break;
852 case Key_Down: 855 case Key_Down:
853 if ( !d->selectedFiles->next() ) 856 if ( !d->selectedFiles->next() )
854 d->selectedFiles->first(); 857 d->selectedFiles->first();
855 858
856 break; 859 break;
857 case Key_Up: 860 case Key_Up:
858 if ( !d->selectedFiles->prev() ) 861 if ( !d->selectedFiles->prev() )
859 // d->selectedFiles->last(); 862 // d->selectedFiles->last();
860 863
861 break; 864 break;
862 865
863 } 866 }
864} 867}
865 868
866void PlayListWidget::readm3u( const QString &filename ) { 869void PlayListWidget::readm3u( const QString &filename ) {
867 qDebug( "m3u filename is " + filename ); 870 qDebug( "m3u filename is " + filename );
868 QFile f( filename ); 871 QFile f( filename );
869 872
870 if( f.open( IO_ReadOnly ) ) { 873 if( f.open( IO_ReadOnly ) ) {
871 QTextStream t(&f); 874 QTextStream t(&f);
872 QString s;//, first, second; 875 QString s;//, first, second;
873 int i=0; 876 int i=0;
874 while ( !t.atEnd() ) { 877 while ( !t.atEnd() ) {
875 s=t.readLine(); 878 s=t.readLine();
876 879
877 if( s.find( "#", 0, TRUE) == -1 ) { 880 if( s.find( "#", 0, TRUE) == -1 ) {
878 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat 881 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat
879 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 882 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
880 s = s.right( s.length() -2 ); 883 s = s.right( s.length() -2 );
881 DocLnk lnk( s ); 884 DocLnk lnk( s );
882 QFileInfo f( s ); 885 QFileInfo f( s );
883 QString name = f.baseName(); 886 QString name = f.baseName();
884 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 887 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
885 lnk.setName( name ); 888 lnk.setName( name );
886 s=s.replace( QRegExp( "\\" ), "/" ); 889 s=s.replace( QRegExp( "\\" ), "/" );
887 lnk.setFile( s ); 890 lnk.setFile( s );
888 lnk.writeLink(); 891 lnk.writeLink();
889 qDebug( "add " + name); 892 qDebug( "add " + name);
890 d->selectedFiles->addToSelection( lnk ); 893 d->selectedFiles->addToSelection( lnk );
891 } else { // is url 894 } else { // is url
892 s.replace( QRegExp( "%20" )," " ); 895 s.replace( QRegExp( "%20" )," " );
893 DocLnk lnk( s ); 896 DocLnk lnk( s );
894 QString name; 897 QString name;
895 if( name.left( 4 ) == "http" ) { 898 if( name.left( 4 ) == "http" ) {
896 name = s.right( s.length() - 7 ); 899 name = s.right( s.length() - 7 );
897 } else { 900 } else {
898 name = s; 901 name = s;
899 } 902 }
900 lnk.setName( name ); 903 lnk.setName( name );
901 if( s.at( s.length() - 4) == '.' ) { 904 if( s.at( s.length() - 4) == '.' ) {
902 lnk.setFile( s ); 905 lnk.setFile( s );
903 } else { 906 } else {
904 lnk.setFile( s + "/" ); 907 lnk.setFile( s + "/" );
905 } 908 }
906 lnk.setType( "audio/x-mpegurl" ); 909 lnk.setType( "audio/x-mpegurl" );
907 lnk.writeLink(); 910 lnk.writeLink();
908 d->selectedFiles->addToSelection( lnk ); 911 d->selectedFiles->addToSelection( lnk );
909 } 912 }
910 i++; 913 i++;
911 } 914 }
912 } 915 }
913 } 916 }
914 } 917 }
915 f.close(); 918 f.close();
916} 919}
917 920
918void PlayListWidget::writem3u() { 921void PlayListWidget::writem3u() {
919 InputDialog *fileDlg; 922 InputDialog *fileDlg;
920 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 923 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
921 fileDlg->exec(); 924 fileDlg->exec();
922 QString filename, list; 925 QString filename, list;
923 if( fileDlg->result() == 1 ) { 926 if( fileDlg->result() == 1 ) {
924 filename = fileDlg->text(); 927 filename = fileDlg->text();
925 qDebug( filename ); 928 qDebug( filename );
926 int noOfFiles = 0; 929 int noOfFiles = 0;
927 d->selectedFiles->first(); 930 d->selectedFiles->first();
928 do { 931 do {
929 // we dont check for existance because of url's 932 // we dont check for existance because of url's
930 // qDebug(d->selectedFiles->current()->file()); 933 // qDebug(d->selectedFiles->current()->file());
931 934
932 // so maybe we should do some net checking to ,-) 935 // so maybe we should do some net checking to ,-)
933 // no, cause it takes to long... 936 // no, cause it takes to long...
934 937
935 list += d->selectedFiles->current()->file() + "\n"; 938 list += d->selectedFiles->current()->file() + "\n";
936 noOfFiles++; 939 noOfFiles++;
937 } 940 }
938 while ( d->selectedFiles->next() ); 941 while ( d->selectedFiles->next() );
939 qDebug( list ); 942 qDebug( list );
940 if( filename.left( 1) != "/" ) { 943 if( filename.left( 1) != "/" ) {
941 filename=QPEApplication::documentDir() + "/" + filename; 944 filename=QPEApplication::documentDir() + "/" + filename;
942 } 945 }
943 if( filename.right( 3 ) != "m3u" ) { 946 if( filename.right( 3 ) != "m3u" ) {
944 filename=filename+".m3u"; 947 filename=filename+".m3u";
945 } 948 }
946 QFile f( filename ); 949 QFile f( filename );
947 f.open( IO_WriteOnly ); 950 f.open( IO_WriteOnly );
948 f.writeBlock( list, list.length() ); 951 f.writeBlock( list, list.length() );
949 f.close(); 952 f.close();
950 } 953 }
951 if( fileDlg ) { 954 if( fileDlg ) {
952 delete fileDlg; 955 delete fileDlg;
953 } 956 }
954} 957}
955 958
956void PlayListWidget::readPls( const QString &filename ) { 959void PlayListWidget::readPls( const QString &filename ) {
957 960
958 qDebug( "pls filename is " + filename ); 961 qDebug( "pls filename is " + filename );
959 QFile f( filename ); 962 QFile f( filename );
960 963
961 if( f.open( IO_ReadOnly ) ) { 964 if( f.open( IO_ReadOnly ) ) {
962 QTextStream t( &f ); 965 QTextStream t( &f );
963 QString s;//, first, second; 966 QString s;//, first, second;
964 int i = 0; 967 int i = 0;
965 while ( !t.atEnd() ) { 968 while ( !t.atEnd() ) {
966 s = t.readLine(); 969 s = t.readLine();
967 if( s.left(4) == "File" ) { 970 if( s.left(4) == "File" ) {
968 s = s.right( s.length() - 6 ); 971 s = s.right( s.length() - 6 );
969 s.replace( QRegExp( "%20" )," "); 972 s.replace( QRegExp( "%20" )," ");
970 qDebug( "adding " + s + " to playlist" ); 973 qDebug( "adding " + s + " to playlist" );
971 // numberofentries=2 974 // numberofentries=2
972 // File1=http 975 // File1=http
973 // Title 976 // Title
974 // Length 977 // Length
975 // Version 978 // Version
976 // File2=http 979 // File2=http
977 s = s.replace( QRegExp( "\\" ), "/" ); 980 s = s.replace( QRegExp( "\\" ), "/" );
978 DocLnk lnk( s ); 981 DocLnk lnk( s );
979 QFileInfo f( s ); 982 QFileInfo f( s );
980 QString name = f.baseName(); 983 QString name = f.baseName();
981 if( name.left( 4 ) == "http" ) { 984 if( name.left( 4 ) == "http" ) {
982 name = s.right( s.length() - 7); 985 name = s.right( s.length() - 7);
983 } else { 986 } else {
984 name = s; 987 name = s;
985 } 988 }
986 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 989 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
987 lnk.setName( name ); 990 lnk.setName( name );
988 if( s.at( s.length() - 4) == '.') // if this is probably a file 991 if( s.at( s.length() - 4) == '.') // if this is probably a file
989 lnk.setFile( s ); 992 lnk.setFile( s );
990 else { //if its a url 993 else { //if its a url
991 if( name.right( 1 ).find( '/' ) == -1) { 994 if( name.right( 1 ).find( '/' ) == -1) {
992 s += "/"; 995 s += "/";
993 } 996 }
994 lnk.setFile( s ); 997 lnk.setFile( s );
995 } 998 }
996 lnk.setType( "audio/x-mpegurl" ); 999 lnk.setType( "audio/x-mpegurl" );
997 1000
998 //qDebug("DocLnk add "+name); 1001 //qDebug("DocLnk add "+name);
999 d->selectedFiles->addToSelection( lnk ); 1002 d->selectedFiles->addToSelection( lnk );
1000 } 1003 }
1001 } 1004 }
1002 i++; 1005 i++;
1003 } 1006 }
1004} 1007}
1005 1008
1006void PlayListWidget::pmViewActivated(int index) { 1009void PlayListWidget::pmViewActivated(int index) {
1007// qDebug("%d", index); 1010// qDebug("%d", index);
1008 switch(index) { 1011 switch(index) {
1009 case -16: 1012 case -16:
1010 { 1013 {
1011 mediaPlayerState->toggleFullscreen(); 1014 mediaPlayerState->toggleFullscreen();
1012 bool b=mediaPlayerState->fullscreen(); 1015 bool b=mediaPlayerState->fullscreen();
1013 pmView->setItemChecked( index, b); 1016 pmView->setItemChecked( index, b);
1014 Config cfg( "OpiePlayer" ); 1017 Config cfg( "OpiePlayer" );
1015 cfg.writeEntry( "FullScreen", b ); 1018 cfg.writeEntry( "FullScreen", b );
1016 } 1019 }
1017 break; 1020 break;
1018 }; 1021 };
1019} 1022}
1020 1023
1021void PlayListWidget::populateSkinsMenu() { 1024void PlayListWidget::populateSkinsMenu() {
1022 int item = 0; 1025 int item = 0;
1023 defaultSkinIndex = 0; 1026 defaultSkinIndex = 0;
1024 QString skinName; 1027 QString skinName;
1025 Config cfg( "OpiePlayer" ); 1028 Config cfg( "OpiePlayer" );
1026 cfg.setGroup("Options" ); 1029 cfg.setGroup("Options" );
1027 QString skin = cfg.readEntry( "Skin", "default" ); 1030 QString skin = cfg.readEntry( "Skin", "default" );
1028 1031
1029 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1032 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1030 skinsDir.setFilter( QDir::Dirs ); 1033 skinsDir.setFilter( QDir::Dirs );
1031 skinsDir.setSorting(QDir::Name ); 1034 skinsDir.setSorting(QDir::Name );
1032 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1035 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1033 QFileInfoListIterator it( *skinslist ); 1036 QFileInfoListIterator it( *skinslist );
1034 QFileInfo *fi; 1037 QFileInfo *fi;
1035 while ( ( fi = it.current() ) ) { 1038 while ( ( fi = it.current() ) ) {
1036 skinName = fi->fileName(); 1039 skinName = fi->fileName();
1037 qDebug( fi->fileName() ); 1040 qDebug( fi->fileName() );
1038 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1041 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1039 item = skinsMenu->insertItem( fi->fileName() ) ; 1042 item = skinsMenu->insertItem( fi->fileName() ) ;
1040 } 1043 }
1041 if( skinName == "default" ) { 1044 if( skinName == "default" ) {
1042 defaultSkinIndex = item; 1045 defaultSkinIndex = item;
1043 } 1046 }
1044 if( skinName == skin ) { 1047 if( skinName == skin ) {
1045 skinsMenu->setItemChecked( item, TRUE ); 1048 skinsMenu->setItemChecked( item, TRUE );
1046 } 1049 }
1047 ++it; 1050 ++it;
1048 } 1051 }
1049} 1052}
1050 1053
1051void PlayListWidget::skinsMenuActivated( int item ) { 1054void PlayListWidget::skinsMenuActivated( int item ) {
1052 for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1055 for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1053 skinsMenu->setItemChecked( i, FALSE ); 1056 skinsMenu->setItemChecked( i, FALSE );
1054 } 1057 }
1055 skinsMenu->setItemChecked( item, TRUE ); 1058 skinsMenu->setItemChecked( item, TRUE );
1056 1059
1057 Config cfg( "OpiePlayer" ); 1060 Config cfg( "OpiePlayer" );
1058 cfg.setGroup("Options"); 1061 cfg.setGroup("Options");
1059 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1062 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1060} 1063}