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