author | simon <simon> | 2002-12-05 19:05:25 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-05 19:05:25 (UTC) |
commit | 4b77aaa27305f0ec120aa6ec4d860f62b7fa7a3f (patch) (unidiff) | |
tree | e4ecf41fafccccd82534df6a1e46115727a9b49c | |
parent | 05757f4914d19f9c392be1e60e5ec972027886bf (diff) | |
download | opie-4b77aaa27305f0ec120aa6ec4d860f62b7fa7a3f.zip opie-4b77aaa27305f0ec120aa6ec4d860f62b7fa7a3f.tar.gz opie-4b77aaa27305f0ec120aa6ec4d860f62b7fa7a3f.tar.bz2 |
- turned if ( foo ) delete foo; into straight delete foo; as the if is
redundant.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 16 |
2 files changed, 8 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 975dec3..2019b3a 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -1,215 +1,214 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | #include <qpainter.h> | 24 | #include <qpainter.h> |
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qheader.h> | 26 | #include <qheader.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | 30 | ||
31 | #include "playlistselection.h" | 31 | #include "playlistselection.h" |
32 | 32 | ||
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | class PlayListSelectionItem : public QListViewItem { | 35 | class PlayListSelectionItem : public QListViewItem { |
36 | public: | 36 | public: |
37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
38 | setText( 0, f->name() ); | 38 | setText( 0, f->name() ); |
39 | setPixmap( 0, f->pixmap() ); | 39 | setPixmap( 0, f->pixmap() ); |
40 | } | 40 | } |
41 | 41 | ||
42 | ~PlayListSelectionItem() { | 42 | ~PlayListSelectionItem() { |
43 | }; | 43 | }; |
44 | 44 | ||
45 | const DocLnk *file() const { return fl; } | 45 | const DocLnk *file() const { return fl; } |
46 | 46 | ||
47 | private: | 47 | private: |
48 | const DocLnk *fl; | 48 | const DocLnk *fl; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
53 | : QListView( parent, name ) | 53 | : QListView( parent, name ) |
54 | { | 54 | { |
55 | // qDebug("starting playlistselector"); | 55 | // qDebug("starting playlistselector"); |
56 | // #ifdef USE_PLAYLIST_BACKGROUND | 56 | // #ifdef USE_PLAYLIST_BACKGROUND |
57 | // setStaticBackground( TRUE ); | 57 | // setStaticBackground( TRUE ); |
58 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 58 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
59 | 59 | ||
60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
61 | // #endif | 61 | // #endif |
62 | // addColumn("Title",236); | 62 | // addColumn("Title",236); |
63 | // setAllColumnsShowFocus( TRUE ); | 63 | // setAllColumnsShowFocus( TRUE ); |
64 | addColumn( tr( "Playlist Selection" ) ); | 64 | addColumn( tr( "Playlist Selection" ) ); |
65 | header()->hide(); | 65 | header()->hide(); |
66 | setSorting( -1, FALSE ); | 66 | setSorting( -1, FALSE ); |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | PlayListSelection::~PlayListSelection() { | 70 | PlayListSelection::~PlayListSelection() { |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | // #ifdef USE_PLAYLIST_BACKGROUND | 74 | // #ifdef USE_PLAYLIST_BACKGROUND |
75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
76 | // qDebug("drawBackground"); | 76 | // qDebug("drawBackground"); |
77 | p->fillRect( r, QBrush( white ) ); | 77 | p->fillRect( r, QBrush( white ) ); |
78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
79 | // if ( !logo.isNull() ) | 79 | // if ( !logo.isNull() ) |
80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
81 | } | 81 | } |
82 | // #endif | 82 | // #endif |
83 | 83 | ||
84 | 84 | ||
85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
86 | if ( event->state() == QMouseEvent::LeftButton ) { | 86 | if ( event->state() == QMouseEvent::LeftButton ) { |
87 | QListViewItem *currentItem = selectedItem(); | 87 | QListViewItem *currentItem = selectedItem(); |
88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
90 | moveSelectedUp(); | 90 | moveSelectedUp(); |
91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
92 | moveSelectedDown(); | 92 | moveSelectedDown(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | const DocLnk *PlayListSelection::current() { | 97 | const DocLnk *PlayListSelection::current() { |
98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
99 | if ( item ) | 99 | if ( item ) |
100 | return item->file(); | 100 | return item->file(); |
101 | return NULL; | 101 | return NULL; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
107 | QListViewItem *current = selectedItem(); | 107 | QListViewItem *current = selectedItem(); |
108 | if ( current ) | 108 | if ( current ) |
109 | item->moveItem( current ); | 109 | item->moveItem( current ); |
110 | setSelected( item, TRUE ); | 110 | setSelected( item, TRUE ); |
111 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | void PlayListSelection::removeSelected() { | 115 | void PlayListSelection::removeSelected() { |
116 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
117 | if ( item ) | 117 | delete item; |
118 | delete item; | ||
119 | setSelected( currentItem(), TRUE ); | 118 | setSelected( currentItem(), TRUE ); |
120 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
121 | } | 120 | } |
122 | 121 | ||
123 | 122 | ||
124 | void PlayListSelection::moveSelectedUp() { | 123 | void PlayListSelection::moveSelectedUp() { |
125 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
126 | if ( item && item->itemAbove() ) | 125 | if ( item && item->itemAbove() ) |
127 | item->itemAbove()->moveItem( item ); | 126 | item->itemAbove()->moveItem( item ); |
128 | ensureItemVisible( selectedItem() ); | 127 | ensureItemVisible( selectedItem() ); |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | void PlayListSelection::moveSelectedDown() { | 131 | void PlayListSelection::moveSelectedDown() { |
133 | QListViewItem *item = selectedItem(); | 132 | QListViewItem *item = selectedItem(); |
134 | if ( item && item->itemBelow() ) | 133 | if ( item && item->itemBelow() ) |
135 | item->moveItem( item->itemBelow() ); | 134 | item->moveItem( item->itemBelow() ); |
136 | ensureItemVisible( selectedItem() ); | 135 | ensureItemVisible( selectedItem() ); |
137 | } | 136 | } |
138 | 137 | ||
139 | 138 | ||
140 | bool PlayListSelection::prev() { | 139 | bool PlayListSelection::prev() { |
141 | QListViewItem *item = selectedItem(); | 140 | QListViewItem *item = selectedItem(); |
142 | if ( item && item->itemAbove() ) | 141 | if ( item && item->itemAbove() ) |
143 | setSelected( item->itemAbove(), TRUE ); | 142 | setSelected( item->itemAbove(), TRUE ); |
144 | else | 143 | else |
145 | return FALSE; | 144 | return FALSE; |
146 | ensureItemVisible( selectedItem() ); | 145 | ensureItemVisible( selectedItem() ); |
147 | return TRUE; | 146 | return TRUE; |
148 | } | 147 | } |
149 | 148 | ||
150 | bool PlayListSelection::next() { | 149 | bool PlayListSelection::next() { |
151 | QListViewItem *item = selectedItem(); | 150 | QListViewItem *item = selectedItem(); |
152 | if ( item && item->itemBelow() ) | 151 | if ( item && item->itemBelow() ) |
153 | setSelected( item->itemBelow(), TRUE ); | 152 | setSelected( item->itemBelow(), TRUE ); |
154 | else | 153 | else |
155 | return FALSE; | 154 | return FALSE; |
156 | ensureItemVisible( selectedItem() ); | 155 | ensureItemVisible( selectedItem() ); |
157 | return TRUE; | 156 | return TRUE; |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | bool PlayListSelection::first() { | 160 | bool PlayListSelection::first() { |
162 | QListViewItem *item = firstChild(); | 161 | QListViewItem *item = firstChild(); |
163 | if ( item ) | 162 | if ( item ) |
164 | setSelected( item, TRUE ); | 163 | setSelected( item, TRUE ); |
165 | else | 164 | else |
166 | return FALSE; | 165 | return FALSE; |
167 | ensureItemVisible( selectedItem() ); | 166 | ensureItemVisible( selectedItem() ); |
168 | return TRUE; | 167 | return TRUE; |
169 | } | 168 | } |
170 | 169 | ||
171 | 170 | ||
172 | bool PlayListSelection::last() { | 171 | bool PlayListSelection::last() { |
173 | QListViewItem *prevItem = NULL; | 172 | QListViewItem *prevItem = NULL; |
174 | QListViewItem *item = firstChild(); | 173 | QListViewItem *item = firstChild(); |
175 | while ( ( item = item->nextSibling() ) ) | 174 | while ( ( item = item->nextSibling() ) ) |
176 | prevItem = item; | 175 | prevItem = item; |
177 | if ( prevItem ) | 176 | if ( prevItem ) |
178 | setSelected( prevItem, TRUE ); | 177 | setSelected( prevItem, TRUE ); |
179 | else | 178 | else |
180 | return FALSE; | 179 | return FALSE; |
181 | ensureItemVisible( selectedItem() ); | 180 | ensureItemVisible( selectedItem() ); |
182 | return TRUE; | 181 | return TRUE; |
183 | } | 182 | } |
184 | 183 | ||
185 | void PlayListSelection::unSelect() | 184 | void PlayListSelection::unSelect() |
186 | { | 185 | { |
187 | //QListViewItem *item = selectedItem(); | 186 | //QListViewItem *item = selectedItem(); |
188 | setSelected( currentItem(), FALSE); | 187 | setSelected( currentItem(), FALSE); |
189 | } | 188 | } |
190 | 189 | ||
191 | void PlayListSelection::writeCurrent( Config& cfg ) { | 190 | void PlayListSelection::writeCurrent( Config& cfg ) { |
192 | cfg.setGroup("PlayList"); | 191 | cfg.setGroup("PlayList"); |
193 | QListViewItem *item = selectedItem(); | 192 | QListViewItem *item = selectedItem(); |
194 | if ( item ) | 193 | if ( item ) |
195 | cfg.writeEntry("current", item->text(0) ); | 194 | cfg.writeEntry("current", item->text(0) ); |
196 | qDebug(item->text(0)); | 195 | qDebug(item->text(0)); |
197 | 196 | ||
198 | } | 197 | } |
199 | 198 | ||
200 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 199 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
201 | 200 | ||
202 | unSelect(); | 201 | unSelect(); |
203 | QListViewItemIterator it( this ); | 202 | QListViewItemIterator it( this ); |
204 | for ( ; it.current(); ++it ) { | 203 | for ( ; it.current(); ++it ) { |
205 | // qDebug( it.current()->text(0)); | 204 | // qDebug( it.current()->text(0)); |
206 | if( strk == it.current()->text(0)) { | 205 | if( strk == it.current()->text(0)) { |
207 | // qDebug( "We have a match "+strk); | 206 | // qDebug( "We have a match "+strk); |
208 | setSelected( it.current(), TRUE); | 207 | setSelected( it.current(), TRUE); |
209 | ensureItemVisible( it.current() ); | 208 | ensureItemVisible( it.current() ); |
210 | return; | 209 | return; |
211 | } | 210 | } |
212 | } | 211 | } |
213 | // setSelected( item, TRUE ); | 212 | // setSelected( item, TRUE ); |
214 | // ensureItemVisible( selectedItem() ); | 213 | // ensureItemVisible( selectedItem() ); |
215 | } | 214 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 86b3424..ac52b07 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -2,385 +2,385 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | 52 | #include "playlistfileview.h" |
53 | 53 | ||
54 | //only needed for the random play | 54 | //only needed for the random play |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <assert.h> | 56 | #include <assert.h> |
57 | 57 | ||
58 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
59 | #include "videowidget.h" | 59 | #include "videowidget.h" |
60 | 60 | ||
61 | extern MediaPlayerState *mediaPlayerState; | 61 | extern MediaPlayerState *mediaPlayerState; |
62 | // extern AudioWidget *audioUI; | 62 | // extern AudioWidget *audioUI; |
63 | // extern VideoWidget *videoUI; | 63 | // extern VideoWidget *videoUI; |
64 | 64 | ||
65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { | 66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { |
67 | 67 | ||
68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
69 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
70 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
72 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
73 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
75 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
80 | 80 | ||
81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
83 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
85 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
87 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
88 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
90 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
92 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
93 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
95 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
96 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
98 | audioView, SLOT( scanFiles() ) ); | 98 | audioView, SLOT( scanFiles() ) ); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
100 | videoView, SLOT( scanFiles() ) ); | 100 | videoView, SLOT( scanFiles() ) ); |
101 | 101 | ||
102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
104 | 104 | ||
105 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
106 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
107 | mediaPlayerState.setFullscreen( b ); | 107 | mediaPlayerState.setFullscreen( b ); |
108 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
109 | 109 | ||
110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
113 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
116 | // QVBox *stretch2 = new QVBox( vbox1 ); | 116 | // QVBox *stretch2 = new QVBox( vbox1 ); |
117 | 117 | ||
118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
119 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
120 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
121 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
122 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
123 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
135 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
137 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
139 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
141 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
143 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
145 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
147 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 152 | ||
153 | // see which skins are installed | 153 | // see which skins are installed |
154 | populateSkinsMenu(); | 154 | populateSkinsMenu(); |
155 | initializeStates(); | 155 | initializeStates(); |
156 | 156 | ||
157 | cfg.setGroup("PlayList"); | 157 | cfg.setGroup("PlayList"); |
158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 158 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
159 | loadList(DocLnk( currentPlaylist ) ); | 159 | loadList(DocLnk( currentPlaylist ) ); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
164 | delete d; | 164 | delete d; |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void PlayListWidget::initializeStates() { | 168 | void PlayListWidget::initializeStates() { |
169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 169 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 170 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 171 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
172 | d->playListFrame->show(); | 172 | d->playListFrame->show(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void PlayListWidget::writeDefaultPlaylist() { | 175 | void PlayListWidget::writeDefaultPlaylist() { |
176 | 176 | ||
177 | Config config( "OpiePlayer" ); | 177 | Config config( "OpiePlayer" ); |
178 | config.setGroup( "PlayList" ); | 178 | config.setGroup( "PlayList" ); |
179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 179 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 180 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
181 | if( currentString == filename) { | 181 | if( currentString == filename) { |
182 | Om3u *m3uList; | 182 | Om3u *m3uList; |
183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 183 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
184 | if( d->selectedFiles->first() ) { | 184 | if( d->selectedFiles->first() ) { |
185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 185 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
186 | do { | 186 | do { |
187 | // qDebug(d->selectedFiles->current()->file()); | 187 | // qDebug(d->selectedFiles->current()->file()); |
188 | m3uList->add( d->selectedFiles->current()->file() ); | 188 | m3uList->add( d->selectedFiles->current()->file() ); |
189 | } | 189 | } |
190 | while ( d->selectedFiles->next() ); | 190 | while ( d->selectedFiles->next() ); |
191 | 191 | ||
192 | m3uList->write(); | 192 | m3uList->write(); |
193 | m3uList->close(); | 193 | m3uList->close(); |
194 | if(m3uList) delete m3uList; | 194 | delete m3uList; |
195 | 195 | ||
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 200 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
201 | d->setDocumentUsed = FALSE; | 201 | d->setDocumentUsed = FALSE; |
202 | if( QFileInfo( lnk.file() ).exists() || | 202 | if( QFileInfo( lnk.file() ).exists() || |
203 | lnk.file().left(4) == "http" ) { | 203 | lnk.file().left(4) == "http" ) { |
204 | d->selectedFiles->addToSelection( lnk ); | 204 | d->selectedFiles->addToSelection( lnk ); |
205 | } | 205 | } |
206 | // writeCurrentM3u(); | 206 | // writeCurrentM3u(); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void PlayListWidget::clearList() { | 210 | void PlayListWidget::clearList() { |
211 | while ( first() ) { | 211 | while ( first() ) { |
212 | d->selectedFiles->removeSelected(); | 212 | d->selectedFiles->removeSelected(); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case 1: | 218 | case 1: |
219 | break; | 219 | break; |
220 | case 2: | 220 | case 2: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case 1: | 234 | case 1: |
235 | break; | 235 | break; |
236 | case 2: | 236 | case 2: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
292 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
293 | // } | 293 | // } |
294 | // } | 294 | // } |
295 | 295 | ||
296 | // qDebug("elapsed time %d", t.elapsed() ); | 296 | // qDebug("elapsed time %d", t.elapsed() ); |
297 | 297 | ||
298 | tabWidget->setCurrentPage(0); | 298 | tabWidget->setCurrentPage(0); |
299 | 299 | ||
300 | writeCurrentM3u(); | 300 | writeCurrentM3u(); |
301 | d->selectedFiles->first(); | 301 | d->selectedFiles->first(); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void PlayListWidget::addAllMusicToList() { | 305 | void PlayListWidget::addAllMusicToList() { |
306 | 306 | ||
307 | audioView->populateView(); | 307 | audioView->populateView(); |
308 | 308 | ||
309 | QListViewItemIterator audioIt( audioView ); | 309 | QListViewItemIterator audioIt( audioView ); |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | QString filename; | 311 | QString filename; |
312 | // iterate through all items of the listview | 312 | // iterate through all items of the listview |
313 | for ( ; audioIt.current(); ++audioIt ) { | 313 | for ( ; audioIt.current(); ++audioIt ) { |
314 | filename = audioIt.current()->text(3); | 314 | filename = audioIt.current()->text(3); |
315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
316 | lnk.setFile( filename ); //sets file name | 316 | lnk.setFile( filename ); //sets file name |
317 | d->selectedFiles->addToSelection( lnk); | 317 | d->selectedFiles->addToSelection( lnk); |
318 | } | 318 | } |
319 | 319 | ||
320 | /* if(!audioScan) | 320 | /* if(!audioScan) |
321 | scanForAudio(); | 321 | scanForAudio(); |
322 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
323 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
325 | d->selectedFiles->addToSelection( **dit ); | 325 | d->selectedFiles->addToSelection( **dit ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | */ | 328 | */ |
329 | tabWidget->setCurrentPage(0); | 329 | tabWidget->setCurrentPage(0); |
330 | writeCurrentM3u(); | 330 | writeCurrentM3u(); |
331 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void PlayListWidget::addAllVideoToList() { | 335 | void PlayListWidget::addAllVideoToList() { |
336 | 336 | ||
337 | videoView->populateView(); | 337 | videoView->populateView(); |
338 | 338 | ||
339 | QListViewItemIterator videoIt( videoView ); | 339 | QListViewItemIterator videoIt( videoView ); |
340 | DocLnk lnk; | 340 | DocLnk lnk; |
341 | QString filename; | 341 | QString filename; |
342 | for ( ; videoIt.current(); ++videoIt ) { | 342 | for ( ; videoIt.current(); ++videoIt ) { |
343 | filename = videoIt.current()->text(3); | 343 | filename = videoIt.current()->text(3); |
344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
345 | lnk.setFile( filename ); //sets file name | 345 | lnk.setFile( filename ); //sets file name |
346 | d->selectedFiles->addToSelection( lnk); | 346 | d->selectedFiles->addToSelection( lnk); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /* if(!videoScan) | 350 | /* if(!videoScan) |
351 | scanForVideo(); | 351 | scanForVideo(); |
352 | QListIterator<DocLnk> dit( vFiles.children() ); | 352 | QListIterator<DocLnk> dit( vFiles.children() ); |
353 | for ( ; dit.current(); ++dit ) { | 353 | for ( ; dit.current(); ++dit ) { |
354 | if( QFileInfo( dit.current()->file() ).exists() ) { | 354 | if( QFileInfo( dit.current()->file() ).exists() ) { |
355 | d->selectedFiles->addToSelection( **dit ); | 355 | d->selectedFiles->addToSelection( **dit ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | */ | 358 | */ |
359 | tabWidget->setCurrentPage(0); | 359 | tabWidget->setCurrentPage(0); |
360 | writeCurrentM3u(); | 360 | writeCurrentM3u(); |
361 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void PlayListWidget::setDocument( const QString& fileref ) { | 365 | void PlayListWidget::setDocument( const QString& fileref ) { |
366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
367 | fromSetDocument = TRUE; | 367 | fromSetDocument = TRUE; |
368 | if ( fileref.isNull() ) { | 368 | if ( fileref.isNull() ) { |
369 | QMessageBox::warning( this, tr( "Invalid File" ), | 369 | QMessageBox::warning( this, tr( "Invalid File" ), |
370 | tr( "There was a problem in getting the file." ) ); | 370 | tr( "There was a problem in getting the file." ) ); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | clearList(); | 374 | clearList(); |
375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
376 | readm3u( fileref ); | 376 | readm3u( fileref ); |
377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
378 | readm3u( DocLnk( fileref).file() ); | 378 | readm3u( DocLnk( fileref).file() ); |
379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
380 | readPls( fileref ); | 380 | readPls( fileref ); |
381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
382 | readPls( DocLnk( fileref).file() ); | 382 | readPls( DocLnk( fileref).file() ); |
383 | } else { | 383 | } else { |
384 | clearList(); | 384 | clearList(); |
385 | addToSelection( DocLnk( fileref ) ); | 385 | addToSelection( DocLnk( fileref ) ); |
386 | writeCurrentM3u(); | 386 | writeCurrentM3u(); |
@@ -495,514 +495,512 @@ void PlayListWidget::addSelected() { | |||
495 | lnk.setFile( filename ); //sets file name | 495 | lnk.setFile( filename ); //sets file name |
496 | 496 | ||
497 | d->selectedFiles->addToSelection( lnk ); | 497 | d->selectedFiles->addToSelection( lnk ); |
498 | } | 498 | } |
499 | 499 | ||
500 | fileListView->clearSelection(); | 500 | fileListView->clearSelection(); |
501 | 501 | ||
502 | tabWidget->setCurrentPage( 0 ); | 502 | tabWidget->setCurrentPage( 0 ); |
503 | writeCurrentM3u(); | 503 | writeCurrentM3u(); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void PlayListWidget::removeSelected() { | 507 | void PlayListWidget::removeSelected() { |
508 | d->selectedFiles->removeSelected( ); | 508 | d->selectedFiles->removeSelected( ); |
509 | writeCurrentM3u(); | 509 | writeCurrentM3u(); |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | void PlayListWidget::playIt( QListViewItem *it) { | 513 | void PlayListWidget::playIt( QListViewItem *it) { |
514 | if(!it) return; | 514 | if(!it) return; |
515 | mediaPlayerState.setPlaying(FALSE); | 515 | mediaPlayerState.setPlaying(FALSE); |
516 | mediaPlayerState.setPlaying(TRUE); | 516 | mediaPlayerState.setPlaying(TRUE); |
517 | d->selectedFiles->unSelect(); | 517 | d->selectedFiles->unSelect(); |
518 | } | 518 | } |
519 | 519 | ||
520 | 520 | ||
521 | void PlayListWidget::addToSelection( QListViewItem *it) { | 521 | void PlayListWidget::addToSelection( QListViewItem *it) { |
522 | d->setDocumentUsed = FALSE; | 522 | d->setDocumentUsed = FALSE; |
523 | 523 | ||
524 | if(it) { | 524 | if(it) { |
525 | if ( currentTab() == CurrentPlayList ) | 525 | if ( currentTab() == CurrentPlayList ) |
526 | return; | 526 | return; |
527 | // case 1: { | 527 | // case 1: { |
528 | DocLnk lnk; | 528 | DocLnk lnk; |
529 | QString filename; | 529 | QString filename; |
530 | 530 | ||
531 | filename=it->text(3); | 531 | filename=it->text(3); |
532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 532 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
533 | lnk.setFile( filename ); //sets file name | 533 | lnk.setFile( filename ); //sets file name |
534 | d->selectedFiles->addToSelection( lnk); | 534 | d->selectedFiles->addToSelection( lnk); |
535 | 535 | ||
536 | writeCurrentM3u(); | 536 | writeCurrentM3u(); |
537 | tabWidget->setCurrentPage(0); | 537 | tabWidget->setCurrentPage(0); |
538 | 538 | ||
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | void PlayListWidget::tabChanged(QWidget *) { | 543 | void PlayListWidget::tabChanged(QWidget *) { |
544 | 544 | ||
545 | d->tbPlay->setEnabled( true ); | 545 | d->tbPlay->setEnabled( true ); |
546 | 546 | ||
547 | switch ( currentTab() ) { | 547 | switch ( currentTab() ) { |
548 | case CurrentPlayList: | 548 | case CurrentPlayList: |
549 | { | 549 | { |
550 | if( !tbDeletePlaylist->isHidden() ) { | 550 | if( !tbDeletePlaylist->isHidden() ) { |
551 | tbDeletePlaylist->hide(); | 551 | tbDeletePlaylist->hide(); |
552 | } | 552 | } |
553 | d->tbRemoveFromList->setEnabled(TRUE); | 553 | d->tbRemoveFromList->setEnabled(TRUE); |
554 | d->tbAddToList->setEnabled(FALSE); | 554 | d->tbAddToList->setEnabled(FALSE); |
555 | 555 | ||
556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 556 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
557 | } | 557 | } |
558 | break; | 558 | break; |
559 | case AudioFiles: | 559 | case AudioFiles: |
560 | { | 560 | { |
561 | audioView->populateView(); | 561 | audioView->populateView(); |
562 | 562 | ||
563 | if( !tbDeletePlaylist->isHidden() ) { | 563 | if( !tbDeletePlaylist->isHidden() ) { |
564 | tbDeletePlaylist->hide(); | 564 | tbDeletePlaylist->hide(); |
565 | } | 565 | } |
566 | d->tbRemoveFromList->setEnabled(FALSE); | 566 | d->tbRemoveFromList->setEnabled(FALSE); |
567 | d->tbAddToList->setEnabled(TRUE); | 567 | d->tbAddToList->setEnabled(TRUE); |
568 | } | 568 | } |
569 | break; | 569 | break; |
570 | case VideoFiles: | 570 | case VideoFiles: |
571 | { | 571 | { |
572 | videoView->populateView(); | 572 | videoView->populateView(); |
573 | if( !tbDeletePlaylist->isHidden() ) { | 573 | if( !tbDeletePlaylist->isHidden() ) { |
574 | tbDeletePlaylist->hide(); | 574 | tbDeletePlaylist->hide(); |
575 | } | 575 | } |
576 | d->tbRemoveFromList->setEnabled(FALSE); | 576 | d->tbRemoveFromList->setEnabled(FALSE); |
577 | d->tbAddToList->setEnabled(TRUE); | 577 | d->tbAddToList->setEnabled(TRUE); |
578 | } | 578 | } |
579 | break; | 579 | break; |
580 | case PlayLists: | 580 | case PlayLists: |
581 | { | 581 | { |
582 | if( tbDeletePlaylist->isHidden() ) { | 582 | if( tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->show(); | 583 | tbDeletePlaylist->show(); |
584 | } | 584 | } |
585 | playLists->reread(); | 585 | playLists->reread(); |
586 | d->tbAddToList->setEnabled(FALSE); | 586 | d->tbAddToList->setEnabled(FALSE); |
587 | 587 | ||
588 | d->tbPlay->setEnabled( false ); | 588 | d->tbPlay->setEnabled( false ); |
589 | } | 589 | } |
590 | break; | 590 | break; |
591 | }; | 591 | }; |
592 | } | 592 | } |
593 | 593 | ||
594 | 594 | ||
595 | void PlayListWidget::btnPlay(bool b) { | 595 | void PlayListWidget::btnPlay(bool b) { |
596 | // mediaPlayerState->setPlaying(false); | 596 | // mediaPlayerState->setPlaying(false); |
597 | mediaPlayerState.setPlaying(b); | 597 | mediaPlayerState.setPlaying(b); |
598 | insanityBool=FALSE; | 598 | insanityBool=FALSE; |
599 | } | 599 | } |
600 | 600 | ||
601 | void PlayListWidget::deletePlaylist() { | 601 | void PlayListWidget::deletePlaylist() { |
602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 602 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
603 | (tr("You really want to delete\nthis playlist?")), | 603 | (tr("You really want to delete\nthis playlist?")), |
604 | (tr("Yes")), (tr("No")), 0 )){ | 604 | (tr("Yes")), (tr("No")), 0 )){ |
605 | case 0: // Yes clicked, | 605 | case 0: // Yes clicked, |
606 | QFile().remove(playLists->selectedDocument().file()); | 606 | QFile().remove(playLists->selectedDocument().file()); |
607 | QFile().remove(playLists->selectedDocument().linkFile()); | 607 | QFile().remove(playLists->selectedDocument().linkFile()); |
608 | playLists->reread(); | 608 | playLists->reread(); |
609 | break; | 609 | break; |
610 | case 1: // Cancel | 610 | case 1: // Cancel |
611 | break; | 611 | break; |
612 | }; | 612 | }; |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | void PlayListWidget::playSelected() { | 616 | void PlayListWidget::playSelected() { |
617 | btnPlay( TRUE); | 617 | btnPlay( TRUE); |
618 | } | 618 | } |
619 | 619 | ||
620 | QListView *PlayListWidget::currentFileListView() const | 620 | QListView *PlayListWidget::currentFileListView() const |
621 | { | 621 | { |
622 | switch ( currentTab() ) { | 622 | switch ( currentTab() ) { |
623 | case AudioFiles: return audioView; | 623 | case AudioFiles: return audioView; |
624 | case VideoFiles: return videoView; | 624 | case VideoFiles: return videoView; |
625 | default: assert( false ); | 625 | default: assert( false ); |
626 | } | 626 | } |
627 | return 0; | 627 | return 0; |
628 | } | 628 | } |
629 | 629 | ||
630 | bool PlayListWidget::inFileListMode() const | 630 | bool PlayListWidget::inFileListMode() const |
631 | { | 631 | { |
632 | TabType tab = currentTab(); | 632 | TabType tab = currentTab(); |
633 | return tab == AudioFiles || tab == VideoFiles; | 633 | return tab == AudioFiles || tab == VideoFiles; |
634 | } | 634 | } |
635 | 635 | ||
636 | void PlayListWidget::openFile() { | 636 | void PlayListWidget::openFile() { |
637 | // http://66.28.164.33:2080 | 637 | // http://66.28.164.33:2080 |
638 | // http://somafm.com/star0242.m3u | 638 | // http://somafm.com/star0242.m3u |
639 | QString filename, name; | 639 | QString filename, name; |
640 | InputDialog *fileDlg; | 640 | InputDialog *fileDlg; |
641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 641 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
642 | fileDlg->exec(); | 642 | fileDlg->exec(); |
643 | if( fileDlg->result() == 1 ) { | 643 | if( fileDlg->result() == 1 ) { |
644 | filename = fileDlg->text(); | 644 | filename = fileDlg->text(); |
645 | qDebug( "Selected filename is " + filename ); | 645 | qDebug( "Selected filename is " + filename ); |
646 | // Om3u *m3uList; | 646 | // Om3u *m3uList; |
647 | DocLnk lnk; | 647 | DocLnk lnk; |
648 | Config cfg( "OpiePlayer" ); | 648 | Config cfg( "OpiePlayer" ); |
649 | cfg.setGroup("PlayList"); | 649 | cfg.setGroup("PlayList"); |
650 | 650 | ||
651 | if(filename.left(4) == "http") { | 651 | if(filename.left(4) == "http") { |
652 | QString m3uFile, m3uFilePath; | 652 | QString m3uFile, m3uFilePath; |
653 | if(filename.find(":",8,TRUE) != -1) { //found a port | 653 | if(filename.find(":",8,TRUE) != -1) { //found a port |
654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 654 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
655 | m3uFile = m3uFile.right( 7); | 655 | m3uFile = m3uFile.right( 7); |
656 | } else if(filename.left(4) == "http"){ | 656 | } else if(filename.left(4) == "http"){ |
657 | m3uFile=filename; | 657 | m3uFile=filename; |
658 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 658 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
659 | } else{ | 659 | } else{ |
660 | m3uFile=filename; | 660 | m3uFile=filename; |
661 | } | 661 | } |
662 | 662 | ||
663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
664 | lnk.setName( filename ); //sets name | 664 | lnk.setName( filename ); //sets name |
665 | lnk.setFile( filename ); //sets file name | 665 | lnk.setFile( filename ); //sets file name |
666 | 666 | ||
667 | // lnk.setIcon("opieplayer2/musicfile"); | 667 | // lnk.setIcon("opieplayer2/musicfile"); |
668 | 668 | ||
669 | d->selectedFiles->addToSelection( lnk ); | 669 | d->selectedFiles->addToSelection( lnk ); |
670 | writeCurrentM3u(); | 670 | writeCurrentM3u(); |
671 | d->selectedFiles->setSelectedItem( lnk.name()); | 671 | d->selectedFiles->setSelectedItem( lnk.name()); |
672 | } | 672 | } |
673 | else if( filename.right( 3) == "m3u" ) { | 673 | else if( filename.right( 3) == "m3u" ) { |
674 | readm3u( filename ); | 674 | readm3u( filename ); |
675 | 675 | ||
676 | } else if( filename.right(3) == "pls" ) { | 676 | } else if( filename.right(3) == "pls" ) { |
677 | readPls( filename ); | 677 | readPls( filename ); |
678 | } else { | 678 | } else { |
679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 679 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
680 | lnk.setFile( filename ); //sets file name | 680 | lnk.setFile( filename ); //sets file name |
681 | d->selectedFiles->addToSelection( lnk); | 681 | d->selectedFiles->addToSelection( lnk); |
682 | writeCurrentM3u(); | 682 | writeCurrentM3u(); |
683 | d->selectedFiles->setSelectedItem( lnk.name()); | 683 | d->selectedFiles->setSelectedItem( lnk.name()); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | if( fileDlg ) { | 687 | delete fileDlg; |
688 | delete fileDlg; | ||
689 | } | ||
690 | } | 688 | } |
691 | 689 | ||
692 | /* | 690 | /* |
693 | reads m3u and shows files/urls to playlist widget */ | 691 | reads m3u and shows files/urls to playlist widget */ |
694 | void PlayListWidget::readm3u( const QString &filename ) { | 692 | void PlayListWidget::readm3u( const QString &filename ) { |
695 | qDebug( "read m3u filename " + filename ); | 693 | qDebug( "read m3u filename " + filename ); |
696 | 694 | ||
697 | Om3u *m3uList; | 695 | Om3u *m3uList; |
698 | QString s, name; | 696 | QString s, name; |
699 | m3uList = new Om3u( filename, IO_ReadOnly ); | 697 | m3uList = new Om3u( filename, IO_ReadOnly ); |
700 | m3uList->readM3u(); | 698 | m3uList->readM3u(); |
701 | DocLnk lnk; | 699 | DocLnk lnk; |
702 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 700 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
703 | s = *it; | 701 | s = *it; |
704 | // qDebug("reading "+ s); | 702 | // qDebug("reading "+ s); |
705 | if(s.left(4)=="http") { | 703 | if(s.left(4)=="http") { |
706 | lnk.setName( s ); //sets file name | 704 | lnk.setName( s ); //sets file name |
707 | lnk.setIcon("opieplayer2/musicfile"); | 705 | lnk.setIcon("opieplayer2/musicfile"); |
708 | lnk.setFile( s ); //sets file name | 706 | lnk.setFile( s ); //sets file name |
709 | 707 | ||
710 | } else { | 708 | } else { |
711 | // if( QFileInfo( s ).exists() ) { | 709 | // if( QFileInfo( s ).exists() ) { |
712 | lnk.setName( QFileInfo(s).baseName()); | 710 | lnk.setName( QFileInfo(s).baseName()); |
713 | // if(s.right(4) == '.') {//if regular file | 711 | // if(s.right(4) == '.') {//if regular file |
714 | if(s.left(1) != "/") { | 712 | if(s.left(1) != "/") { |
715 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 713 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
716 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 714 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
717 | // lnk.setIcon(MimeType(s).pixmap() ); | 715 | // lnk.setIcon(MimeType(s).pixmap() ); |
718 | // lnk.setIcon("SoundPlayer"); | 716 | // lnk.setIcon("SoundPlayer"); |
719 | } else { | 717 | } else { |
720 | // qDebug("set link2 "+s); | 718 | // qDebug("set link2 "+s); |
721 | lnk.setFile( s); | 719 | lnk.setFile( s); |
722 | // lnk.setIcon(MimeType(s).pixmap() ); | 720 | // lnk.setIcon(MimeType(s).pixmap() ); |
723 | // lnk.setIcon("SoundPlayer"); | 721 | // lnk.setIcon("SoundPlayer"); |
724 | } | 722 | } |
725 | } | 723 | } |
726 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
727 | } | 725 | } |
728 | Config config( "OpiePlayer" ); | 726 | Config config( "OpiePlayer" ); |
729 | config.setGroup( "PlayList" ); | 727 | config.setGroup( "PlayList" ); |
730 | 728 | ||
731 | config.writeEntry("CurrentPlaylist",filename); | 729 | config.writeEntry("CurrentPlaylist",filename); |
732 | config.write(); | 730 | config.write(); |
733 | currentPlayList=filename; | 731 | currentPlayList=filename; |
734 | 732 | ||
735 | // m3uList->write(); | 733 | // m3uList->write(); |
736 | m3uList->close(); | 734 | m3uList->close(); |
737 | if(m3uList) delete m3uList; | 735 | delete m3uList; |
738 | 736 | ||
739 | d->selectedFiles->setSelectedItem( s); | 737 | d->selectedFiles->setSelectedItem( s); |
740 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 738 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | /* | 742 | /* |
745 | reads pls and adds files/urls to playlist */ | 743 | reads pls and adds files/urls to playlist */ |
746 | void PlayListWidget::readPls( const QString &filename ) { | 744 | void PlayListWidget::readPls( const QString &filename ) { |
747 | 745 | ||
748 | qDebug( "pls filename is " + filename ); | 746 | qDebug( "pls filename is " + filename ); |
749 | Om3u *m3uList; | 747 | Om3u *m3uList; |
750 | QString s, name; | 748 | QString s, name; |
751 | m3uList = new Om3u( filename, IO_ReadOnly ); | 749 | m3uList = new Om3u( filename, IO_ReadOnly ); |
752 | m3uList->readPls(); | 750 | m3uList->readPls(); |
753 | 751 | ||
754 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 752 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
755 | s = *it; | 753 | s = *it; |
756 | // s.replace( QRegExp( "%20" )," " ); | 754 | // s.replace( QRegExp( "%20" )," " ); |
757 | DocLnk lnk( s ); | 755 | DocLnk lnk( s ); |
758 | QFileInfo f( s ); | 756 | QFileInfo f( s ); |
759 | QString name = f.baseName(); | 757 | QString name = f.baseName(); |
760 | 758 | ||
761 | if( name.left( 4 ) == "http" ) { | 759 | if( name.left( 4 ) == "http" ) { |
762 | name = s.right( s.length() - 7); | 760 | name = s.right( s.length() - 7); |
763 | } else { | 761 | } else { |
764 | name = s; | 762 | name = s; |
765 | } | 763 | } |
766 | 764 | ||
767 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 765 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
768 | 766 | ||
769 | lnk.setName( name ); | 767 | lnk.setName( name ); |
770 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 768 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
771 | lnk.setFile( s ); | 769 | lnk.setFile( s ); |
772 | } else { //if its a url | 770 | } else { //if its a url |
773 | // if( name.right( 1 ).find( '/' ) == -1) { | 771 | // if( name.right( 1 ).find( '/' ) == -1) { |
774 | // s += "/"; | 772 | // s += "/"; |
775 | // } | 773 | // } |
776 | lnk.setFile( s ); | 774 | lnk.setFile( s ); |
777 | } | 775 | } |
778 | lnk.setType( "audio/x-mpegurl" ); | 776 | lnk.setType( "audio/x-mpegurl" ); |
779 | 777 | ||
780 | lnk.writeLink(); | 778 | lnk.writeLink(); |
781 | d->selectedFiles->addToSelection( lnk ); | 779 | d->selectedFiles->addToSelection( lnk ); |
782 | } | 780 | } |
783 | 781 | ||
784 | m3uList->close(); | 782 | m3uList->close(); |
785 | if(m3uList) delete m3uList; | 783 | delete m3uList; |
786 | } | 784 | } |
787 | 785 | ||
788 | /* | 786 | /* |
789 | writes current playlist to current m3u file */ | 787 | writes current playlist to current m3u file */ |
790 | void PlayListWidget::writeCurrentM3u() { | 788 | void PlayListWidget::writeCurrentM3u() { |
791 | qDebug("writing to current m3u"); | 789 | qDebug("writing to current m3u"); |
792 | Config cfg( "OpiePlayer" ); | 790 | Config cfg( "OpiePlayer" ); |
793 | cfg.setGroup("PlayList"); | 791 | cfg.setGroup("PlayList"); |
794 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 792 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
795 | 793 | ||
796 | Om3u *m3uList; | 794 | Om3u *m3uList; |
797 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 795 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
798 | if( d->selectedFiles->first()) { | 796 | if( d->selectedFiles->first()) { |
799 | 797 | ||
800 | do { | 798 | do { |
801 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 799 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
802 | m3uList->add( d->selectedFiles->current()->file() ); | 800 | m3uList->add( d->selectedFiles->current()->file() ); |
803 | } | 801 | } |
804 | while ( d->selectedFiles->next() ); | 802 | while ( d->selectedFiles->next() ); |
805 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 803 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
806 | m3uList->write(); | 804 | m3uList->write(); |
807 | m3uList->close(); | 805 | m3uList->close(); |
808 | 806 | ||
809 | if(m3uList) delete m3uList; | 807 | delete m3uList; |
810 | } | 808 | } |
811 | 809 | ||
812 | } | 810 | } |
813 | 811 | ||
814 | /* | 812 | /* |
815 | writes current playlist to m3u file */ | 813 | writes current playlist to m3u file */ |
816 | void PlayListWidget::writem3u() { | 814 | void PlayListWidget::writem3u() { |
817 | InputDialog *fileDlg; | 815 | InputDialog *fileDlg; |
818 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 816 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
819 | fileDlg->exec(); | 817 | fileDlg->exec(); |
820 | QString name, filename, list; | 818 | QString name, filename, list; |
821 | Om3u *m3uList; | 819 | Om3u *m3uList; |
822 | 820 | ||
823 | if( fileDlg->result() == 1 ) { | 821 | if( fileDlg->result() == 1 ) { |
824 | name = fileDlg->text(); | 822 | name = fileDlg->text(); |
825 | // qDebug( filename ); | 823 | // qDebug( filename ); |
826 | 824 | ||
827 | if( name.left( 1) != "/" ) { | 825 | if( name.left( 1) != "/" ) { |
828 | filename = QPEApplication::documentDir() + "/" + name; | 826 | filename = QPEApplication::documentDir() + "/" + name; |
829 | } | 827 | } |
830 | 828 | ||
831 | if( name.right( 3 ) != "m3u" ) { | 829 | if( name.right( 3 ) != "m3u" ) { |
832 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 830 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
833 | } | 831 | } |
834 | 832 | ||
835 | if( d->selectedFiles->first()) { | 833 | if( d->selectedFiles->first()) { |
836 | m3uList = new Om3u(filename, IO_ReadWrite); | 834 | m3uList = new Om3u(filename, IO_ReadWrite); |
837 | 835 | ||
838 | do { | 836 | do { |
839 | m3uList->add( d->selectedFiles->current()->file()); | 837 | m3uList->add( d->selectedFiles->current()->file()); |
840 | } | 838 | } |
841 | while ( d->selectedFiles->next() ); | 839 | while ( d->selectedFiles->next() ); |
842 | // qDebug( list ); | 840 | // qDebug( list ); |
843 | m3uList->write(); | 841 | m3uList->write(); |
844 | m3uList->close(); | 842 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 843 | delete m3uList; |
846 | 844 | ||
847 | if(fileDlg) delete fileDlg; | 845 | delete fileDlg; |
848 | 846 | ||
849 | DocLnk lnk; | 847 | DocLnk lnk; |
850 | lnk.setFile( filename); | 848 | lnk.setFile( filename); |
851 | lnk.setIcon("opieplayer2/playlist2"); | 849 | lnk.setIcon("opieplayer2/playlist2"); |
852 | lnk.setName( name); //sets file name | 850 | lnk.setName( name); //sets file name |
853 | 851 | ||
854 | // qDebug(filename); | 852 | // qDebug(filename); |
855 | Config config( "OpiePlayer" ); | 853 | Config config( "OpiePlayer" ); |
856 | config.setGroup( "PlayList" ); | 854 | config.setGroup( "PlayList" ); |
857 | 855 | ||
858 | config.writeEntry("CurrentPlaylist",filename); | 856 | config.writeEntry("CurrentPlaylist",filename); |
859 | currentPlayList=filename; | 857 | currentPlayList=filename; |
860 | 858 | ||
861 | if(!lnk.writeLink()) { | 859 | if(!lnk.writeLink()) { |
862 | qDebug("Writing doclink did not work"); | 860 | qDebug("Writing doclink did not work"); |
863 | } | 861 | } |
864 | 862 | ||
865 | setCaption(tr("OpiePlayer: ") + name); | 863 | setCaption(tr("OpiePlayer: ") + name); |
866 | } | 864 | } |
867 | } | 865 | } |
868 | } | 866 | } |
869 | 867 | ||
870 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
871 | switch ( e->key() ) { | 869 | switch ( e->key() ) { |
872 | ////////////////////////////// Zaurus keys | 870 | ////////////////////////////// Zaurus keys |
873 | case Key_F9: //activity | 871 | case Key_F9: //activity |
874 | // if(audioUI->isHidden()) | 872 | // if(audioUI->isHidden()) |
875 | // audioUI->showMaximized(); | 873 | // audioUI->showMaximized(); |
876 | break; | 874 | break; |
877 | case Key_F10: //contacts | 875 | case Key_F10: //contacts |
878 | // if( videoUI->isHidden()) | 876 | // if( videoUI->isHidden()) |
879 | // videoUI->showMaximized(); | 877 | // videoUI->showMaximized(); |
880 | break; | 878 | break; |
881 | case Key_F11: //menu | 879 | case Key_F11: //menu |
882 | break; | 880 | break; |
883 | case Key_F12: //home | 881 | case Key_F12: //home |
884 | // doBlank(); | 882 | // doBlank(); |
885 | break; | 883 | break; |
886 | case Key_F13: //mail | 884 | case Key_F13: //mail |
887 | // doUnblank(); | 885 | // doUnblank(); |
888 | break; | 886 | break; |
889 | case Key_Q: //add to playlist | 887 | case Key_Q: //add to playlist |
890 | addSelected(); | 888 | addSelected(); |
891 | break; | 889 | break; |
892 | case Key_R: //remove from playlist | 890 | case Key_R: //remove from playlist |
893 | removeSelected(); | 891 | removeSelected(); |
894 | break; | 892 | break; |
895 | // case Key_P: //play | 893 | // case Key_P: //play |
896 | // qDebug("Play"); | 894 | // qDebug("Play"); |
897 | // playSelected(); | 895 | // playSelected(); |
898 | // break; | 896 | // break; |
899 | case Key_Space: | 897 | case Key_Space: |
900 | // playSelected(); puh | 898 | // playSelected(); puh |
901 | break; | 899 | break; |
902 | case Key_1: | 900 | case Key_1: |
903 | tabWidget->setCurrentPage( 0 ); | 901 | tabWidget->setCurrentPage( 0 ); |
904 | break; | 902 | break; |
905 | case Key_2: | 903 | case Key_2: |
906 | tabWidget->setCurrentPage( 1 ); | 904 | tabWidget->setCurrentPage( 1 ); |
907 | break; | 905 | break; |
908 | case Key_3: | 906 | case Key_3: |
909 | tabWidget->setCurrentPage( 2 ); | 907 | tabWidget->setCurrentPage( 2 ); |
910 | break; | 908 | break; |
911 | case Key_4: | 909 | case Key_4: |
912 | tabWidget->setCurrentPage( 3 ); | 910 | tabWidget->setCurrentPage( 3 ); |
913 | break; | 911 | break; |
914 | case Key_Down: | 912 | case Key_Down: |
915 | if ( !d->selectedFiles->next() ) | 913 | if ( !d->selectedFiles->next() ) |
916 | d->selectedFiles->first(); | 914 | d->selectedFiles->first(); |
917 | break; | 915 | break; |
918 | case Key_Up: | 916 | case Key_Up: |
919 | if ( !d->selectedFiles->prev() ) | 917 | if ( !d->selectedFiles->prev() ) |
920 | // d->selectedFiles->last(); | 918 | // d->selectedFiles->last(); |
921 | break; | 919 | break; |
922 | } | 920 | } |
923 | } | 921 | } |
924 | 922 | ||
925 | void PlayListWidget::pmViewActivated(int index) { | 923 | void PlayListWidget::pmViewActivated(int index) { |
926 | // qDebug("%d", index); | 924 | // qDebug("%d", index); |
927 | switch(index) { | 925 | switch(index) { |
928 | case -16: | 926 | case -16: |
929 | { | 927 | { |
930 | mediaPlayerState.toggleFullscreen(); | 928 | mediaPlayerState.toggleFullscreen(); |
931 | bool b=mediaPlayerState.isFullscreen(); | 929 | bool b=mediaPlayerState.isFullscreen(); |
932 | pmView->setItemChecked( index, b); | 930 | pmView->setItemChecked( index, b); |
933 | Config cfg( "OpiePlayer" ); | 931 | Config cfg( "OpiePlayer" ); |
934 | cfg.writeEntry( "FullScreen", b ); | 932 | cfg.writeEntry( "FullScreen", b ); |
935 | } | 933 | } |
936 | break; | 934 | break; |
937 | }; | 935 | }; |
938 | } | 936 | } |
939 | 937 | ||
940 | void PlayListWidget::populateSkinsMenu() { | 938 | void PlayListWidget::populateSkinsMenu() { |
941 | int item = 0; | 939 | int item = 0; |
942 | defaultSkinIndex = 0; | 940 | defaultSkinIndex = 0; |
943 | QString skinName; | 941 | QString skinName; |
944 | Config cfg( "OpiePlayer" ); | 942 | Config cfg( "OpiePlayer" ); |
945 | cfg.setGroup("Options" ); | 943 | cfg.setGroup("Options" ); |
946 | QString skin = cfg.readEntry( "Skin", "default" ); | 944 | QString skin = cfg.readEntry( "Skin", "default" ); |
947 | 945 | ||
948 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 946 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
949 | skinsDir.setFilter( QDir::Dirs ); | 947 | skinsDir.setFilter( QDir::Dirs ); |
950 | skinsDir.setSorting(QDir::Name ); | 948 | skinsDir.setSorting(QDir::Name ); |
951 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 949 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
952 | QFileInfoListIterator it( *skinslist ); | 950 | QFileInfoListIterator it( *skinslist ); |
953 | QFileInfo *fi; | 951 | QFileInfo *fi; |
954 | while ( ( fi = it.current() ) ) { | 952 | while ( ( fi = it.current() ) ) { |
955 | skinName = fi->fileName(); | 953 | skinName = fi->fileName(); |
956 | // qDebug( fi->fileName() ); | 954 | // qDebug( fi->fileName() ); |
957 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 955 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
958 | item = skinsMenu->insertItem( fi->fileName() ) ; | 956 | item = skinsMenu->insertItem( fi->fileName() ) ; |
959 | } | 957 | } |
960 | if( skinName == "default" ) { | 958 | if( skinName == "default" ) { |
961 | defaultSkinIndex = item; | 959 | defaultSkinIndex = item; |
962 | } | 960 | } |
963 | if( skinName == skin ) { | 961 | if( skinName == skin ) { |
964 | skinsMenu->setItemChecked( item, TRUE ); | 962 | skinsMenu->setItemChecked( item, TRUE ); |
965 | } | 963 | } |
966 | ++it; | 964 | ++it; |
967 | } | 965 | } |
968 | } | 966 | } |
969 | 967 | ||
970 | void PlayListWidget::skinsMenuActivated( int item ) { | 968 | void PlayListWidget::skinsMenuActivated( int item ) { |
971 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 969 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
972 | skinsMenu->setItemChecked( i, FALSE ); | 970 | skinsMenu->setItemChecked( i, FALSE ); |
973 | } | 971 | } |
974 | skinsMenu->setItemChecked( item, TRUE ); | 972 | skinsMenu->setItemChecked( item, TRUE ); |
975 | 973 | ||
976 | { | 974 | { |
977 | Config cfg( "OpiePlayer" ); | 975 | Config cfg( "OpiePlayer" ); |
978 | cfg.setGroup("Options"); | 976 | cfg.setGroup("Options"); |
979 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 977 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
980 | } | 978 | } |
981 | 979 | ||
982 | emit skinSelected(); | 980 | emit skinSelected(); |
983 | } | 981 | } |
984 | 982 | ||
985 | PlayListWidget::TabType PlayListWidget::currentTab() const | 983 | PlayListWidget::TabType PlayListWidget::currentTab() const |
986 | { | 984 | { |
987 | static const TabType indexToTabType[ TabTypeCount ] = | 985 | static const TabType indexToTabType[ TabTypeCount ] = |
988 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 986 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
989 | 987 | ||
990 | int index = tabWidget->currentPageIndex(); | 988 | int index = tabWidget->currentPageIndex(); |
991 | assert( index < TabTypeCount && index >= 0 ); | 989 | assert( index < TabTypeCount && index >= 0 ); |
992 | 990 | ||
993 | return indexToTabType[ index ]; | 991 | return indexToTabType[ index ]; |
994 | } | 992 | } |
995 | 993 | ||
996 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 994 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
997 | { | 995 | { |
998 | if ( currentTab() == CurrentPlayList ) { | 996 | if ( currentTab() == CurrentPlayList ) { |
999 | const DocLnk *lnk = current(); | 997 | const DocLnk *lnk = current(); |
1000 | return Entry( lnk->name(), lnk->file() ); | 998 | return Entry( lnk->name(), lnk->file() ); |
1001 | } | 999 | } |
1002 | 1000 | ||
1003 | return Entry( currentFileListPathName() ); | 1001 | return Entry( currentFileListPathName() ); |
1004 | } | 1002 | } |
1005 | 1003 | ||
1006 | QString PlayListWidget::currentFileListPathName() const { | 1004 | QString PlayListWidget::currentFileListPathName() const { |
1007 | return currentFileListView()->currentItem()->text( 3 ); | 1005 | return currentFileListView()->currentItem()->text( 3 ); |
1008 | } | 1006 | } |