author | sandman <sandman> | 2002-12-11 00:17:09 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-11 00:17:09 (UTC) |
commit | 6c71f5ccd9506234a317d9ff3d119613c457e769 (patch) (unidiff) | |
tree | f78a9d2a0981dbb446096bf072ca5decaa5e1d59 | |
parent | e9d1213578b83f8380c4681186246a2b32ae6375 (diff) | |
download | opie-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"
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 11 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 21 |
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,156 +1,163 @@ | |||
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 | ||
49 | static 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 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 58 | Om3u::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 | ||
58 | Om3u::~Om3u(){} | 65 | Om3u::~Om3u(){} |
59 | 66 | ||
60 | void Om3u::readM3u() { | 67 | void 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 | ||
91 | void Om3u::readPls() { //it's a pls file | 98 | void 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 | ||
127 | void Om3u::write() { //writes list to m3u file | 134 | void 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 | ||
139 | void Om3u::add(const QString &filePath) { //adds to m3u file | 146 | void Om3u::add(const QString &filePath) { //adds to m3u file |
140 | append(filePath); | 147 | append(filePath); |
141 | } | 148 | } |
142 | 149 | ||
143 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 150 | void 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 | ||
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 | |||
@@ -38,96 +38,103 @@ | |||
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 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | ||
87 | { | ||
88 | QString str = fi. fileName ( ); | ||
89 | return str. left ( str. findRev ( '.' )); | ||
90 | } | ||
91 | |||
92 | |||
86 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
87 | // class myFileSelector { | 94 | // class myFileSelector { |
88 | 95 | ||
89 | // }; | 96 | // }; |
90 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
91 | public: | 98 | public: |
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 | ||
101 | class ToolButton : public QToolButton { | 108 | class ToolButton : public QToolButton { |
102 | public: | 109 | public: |
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 | ||
116 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
117 | public: | 124 | public: |
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 | ||
126 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::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; |
@@ -279,97 +286,97 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||
333 | PlayListWidget::~PlayListWidget() { | 340 | PlayListWidget::~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 | ||
343 | void PlayListWidget::initializeStates() { | 350 | void 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 | ||
352 | void PlayListWidget::readConfig( Config& cfg ) { | 359 | void 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 | ||
369 | void PlayListWidget::writeConfig( Config& cfg ) const { | 376 | void 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 { |
@@ -636,132 +643,132 @@ void 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 | ||
648 | void PlayListWidget::setPlaylist( bool shown ) { | 655 | void 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 | ||
655 | void PlayListWidget::setView( char view ) { | 662 | void 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 | ||
662 | void PlayListWidget::addSelected() { | 669 | void 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 | ||
692 | void PlayListWidget::removeSelected() { | 699 | void PlayListWidget::removeSelected() { |
693 | d->selectedFiles->removeSelected( ); | 700 | d->selectedFiles->removeSelected( ); |
694 | } | 701 | } |
695 | 702 | ||
696 | void PlayListWidget::playIt( QListViewItem *) { | 703 | void 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 | ||
705 | void PlayListWidget::addToSelection( QListViewItem *it) { | 712 | void 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 | ||
729 | void PlayListWidget::tabChanged(QWidget *) { | 736 | void 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; |
@@ -993,178 +1000,178 @@ void PlayListWidget::populateVideoView() { | |||
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 | ||
1002 | void PlayListWidget::openFile() { | 1009 | void 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 | /* |
1055 | reads m3u and shows files/urls to playlist widget */ | 1062 | reads m3u and shows files/urls to playlist widget */ |
1056 | void PlayListWidget::readm3u( const QString &filename ) { | 1063 | void 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 | /* |
1108 | reads pls and adds files/urls to playlist */ | 1115 | reads pls and adds files/urls to playlist */ |
1109 | void PlayListWidget::readPls( const QString &filename ) { | 1116 | void 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 */ |
1153 | void PlayListWidget::writeCurrentM3u() { | 1160 | void 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 | ||