Diffstat (limited to 'core/multimedia/opieplayer/playlistselection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index ad831cf..58c3966 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,93 +1,98 @@ | |||
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 | 20 | ||
21 | #include <qheader.h> | ||
22 | |||
23 | #include "playlistselection.h" | 21 | #include "playlistselection.h" |
24 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
25 | |||
26 | /* QT */ | ||
27 | #include <qheader.h> | ||
28 | |||
29 | /* STD */ | ||
25 | #include <stdlib.h> | 30 | #include <stdlib.h> |
26 | 31 | ||
27 | class PlayListSelectionItem : public QListViewItem { | 32 | class PlayListSelectionItem : public QListViewItem { |
28 | public: | 33 | public: |
29 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
30 | setText( 0, f->name() ); | 35 | setText( 0, f->name() ); |
31 | setPixmap( 0, f->pixmap() ); | 36 | setPixmap( 0, f->pixmap() ); |
32 | } | 37 | } |
33 | 38 | ||
34 | ~PlayListSelectionItem() { | 39 | ~PlayListSelectionItem() { |
35 | }; | 40 | }; |
36 | 41 | ||
37 | const DocLnk *file() const { return fl; } | 42 | const DocLnk *file() const { return fl; } |
38 | 43 | ||
39 | private: | 44 | private: |
40 | const DocLnk *fl; | 45 | const DocLnk *fl; |
41 | }; | 46 | }; |
42 | 47 | ||
43 | 48 | ||
44 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
45 | : QListView( parent, name ) | 50 | : QListView( parent, name ) |
46 | { | 51 | { |
47 | // qDebug("starting playlistselector"); | 52 | // odebug << "starting playlistselector" << oendl; |
48 | // #ifdef USE_PLAYLIST_BACKGROUND | 53 | // #ifdef USE_PLAYLIST_BACKGROUND |
49 | // setStaticBackground( TRUE ); | 54 | // setStaticBackground( TRUE ); |
50 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
51 | 56 | ||
52 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
53 | // #endif | 58 | // #endif |
54 | // addColumn("Title",236); | 59 | // addColumn("Title",236); |
55 | // setAllColumnsShowFocus( TRUE ); | 60 | // setAllColumnsShowFocus( TRUE ); |
56 | addColumn( tr( "Playlist Selection" ) ); | 61 | addColumn( tr( "Playlist Selection" ) ); |
57 | header()->hide(); | 62 | header()->hide(); |
58 | // setSorting( -1, FALSE ); | 63 | // setSorting( -1, FALSE ); |
59 | // FIXME | 64 | // FIXME |
60 | } | 65 | } |
61 | 66 | ||
62 | 67 | ||
63 | PlayListSelection::~PlayListSelection() { | 68 | PlayListSelection::~PlayListSelection() { |
64 | } | 69 | } |
65 | 70 | ||
66 | 71 | ||
67 | // #ifdef USE_PLAYLIST_BACKGROUND | 72 | // #ifdef USE_PLAYLIST_BACKGROUND |
68 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
69 | // qDebug("drawBackground"); | 74 | // odebug << "drawBackground" << oendl; |
70 | p->fillRect( r, QBrush( white ) ); | 75 | p->fillRect( r, QBrush( white ) ); |
71 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 76 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
72 | // if ( !logo.isNull() ) | 77 | // if ( !logo.isNull() ) |
73 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 78 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
74 | } | 79 | } |
75 | // #endif | 80 | // #endif |
76 | 81 | ||
77 | 82 | ||
78 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 83 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
79 | if ( event->state() == QMouseEvent::LeftButton ) { | 84 | if ( event->state() == QMouseEvent::LeftButton ) { |
80 | QListViewItem *currentItem = selectedItem(); | 85 | QListViewItem *currentItem = selectedItem(); |
81 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 86 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
82 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 87 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
83 | moveSelectedUp(); | 88 | moveSelectedUp(); |
84 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 89 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
85 | moveSelectedDown(); | 90 | moveSelectedDown(); |
86 | } | 91 | } |
87 | } | 92 | } |
88 | 93 | ||
89 | 94 | ||
90 | const DocLnk *PlayListSelection::current() { | 95 | const DocLnk *PlayListSelection::current() { |
91 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 96 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
92 | if ( item ) | 97 | if ( item ) |
93 | return item->file(); | 98 | return item->file(); |
@@ -165,44 +170,44 @@ bool PlayListSelection::first() { | |||
165 | bool PlayListSelection::last() { | 170 | bool PlayListSelection::last() { |
166 | QListViewItem *prevItem = NULL; | 171 | QListViewItem *prevItem = NULL; |
167 | QListViewItem *item = firstChild(); | 172 | QListViewItem *item = firstChild(); |
168 | while ( ( item = item->nextSibling() ) ) | 173 | while ( ( item = item->nextSibling() ) ) |
169 | prevItem = item; | 174 | prevItem = item; |
170 | if ( prevItem ) | 175 | if ( prevItem ) |
171 | setSelected( prevItem, TRUE ); | 176 | setSelected( prevItem, TRUE ); |
172 | else | 177 | else |
173 | return FALSE; | 178 | return FALSE; |
174 | ensureItemVisible( selectedItem() ); | 179 | ensureItemVisible( selectedItem() ); |
175 | return TRUE; | 180 | return TRUE; |
176 | } | 181 | } |
177 | 182 | ||
178 | void PlayListSelection::unSelect() | 183 | void PlayListSelection::unSelect() |
179 | { | 184 | { |
180 | QListViewItem *item = selectedItem(); | 185 | QListViewItem *item = selectedItem(); |
181 | setSelected( currentItem(), FALSE); | 186 | setSelected( currentItem(), FALSE); |
182 | } | 187 | } |
183 | 188 | ||
184 | void PlayListSelection::writeCurrent( Config& cfg ) { | 189 | void PlayListSelection::writeCurrent( Config& cfg ) { |
185 | cfg.setGroup("PlayList"); | 190 | cfg.setGroup("PlayList"); |
186 | QListViewItem *item = selectedItem(); | 191 | QListViewItem *item = selectedItem(); |
187 | if ( item ) | 192 | if ( item ) |
188 | cfg.writeEntry("current", item->text(0) ); | 193 | cfg.writeEntry("current", item->text(0) ); |
189 | // qDebug(item->text(0)); | 194 | // odebug << item->text(0) << oendl; |
190 | 195 | ||
191 | } | 196 | } |
192 | 197 | ||
193 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 198 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
194 | 199 | ||
195 | unSelect(); | 200 | unSelect(); |
196 | QListViewItemIterator it( this ); | 201 | QListViewItemIterator it( this ); |
197 | for ( ; it.current(); ++it ) { | 202 | for ( ; it.current(); ++it ) { |
198 | // qDebug( it.current()->text(0)); | 203 | // odebug << it.current()->text(0) << oendl; |
199 | if( strk == it.current()->text(0)) { | 204 | if( strk == it.current()->text(0)) { |
200 | // qDebug( "We have a match "+strk); | 205 | // odebug << "We have a match "+strk << oendl; |
201 | setSelected( it.current(), TRUE); | 206 | setSelected( it.current(), TRUE); |
202 | ensureItemVisible( it.current() ); | 207 | ensureItemVisible( it.current() ); |
203 | return; | 208 | return; |
204 | } | 209 | } |
205 | } | 210 | } |
206 | // setSelected( item, TRUE ); | 211 | // setSelected( item, TRUE ); |
207 | // ensureItemVisible( selectedItem() ); | 212 | // ensureItemVisible( selectedItem() ); |
208 | } | 213 | } |