author | harlekin <harlekin> | 2002-04-20 23:33:47 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-20 23:33:47 (UTC) |
commit | d616ece749006d720305632700228a41bcdd5c53 (patch) (unidiff) | |
tree | 8bcac6765bb070a672564116fcec62d92b9a626f | |
parent | 7ae1d2a136454122b28c50df2f7807a4780d507c (diff) | |
download | opie-d616ece749006d720305632700228a41bcdd5c53.zip opie-d616ece749006d720305632700228a41bcdd5c53.tar.gz opie-d616ece749006d720305632700228a41bcdd5c53.tar.bz2 |
update
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 3c47256..85228a9 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,215 +1,215 @@ | |||
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( "mpegplayer/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 | if ( item ) |
118 | delete item; | 118 | delete item; |
119 | setSelected( currentItem(), TRUE ); | 119 | setSelected( currentItem(), TRUE ); |
120 | ensureItemVisible( selectedItem() ); | 120 | ensureItemVisible( selectedItem() ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | void PlayListSelection::moveSelectedUp() { | 124 | void PlayListSelection::moveSelectedUp() { |
125 | QListViewItem *item = selectedItem(); | 125 | QListViewItem *item = selectedItem(); |
126 | if ( item && item->itemAbove() ) | 126 | if ( item && item->itemAbove() ) |
127 | item->itemAbove()->moveItem( item ); | 127 | item->itemAbove()->moveItem( item ); |
128 | ensureItemVisible( selectedItem() ); | 128 | ensureItemVisible( selectedItem() ); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void PlayListSelection::moveSelectedDown() { | 132 | void PlayListSelection::moveSelectedDown() { |
133 | QListViewItem *item = selectedItem(); | 133 | QListViewItem *item = selectedItem(); |
134 | if ( item && item->itemBelow() ) | 134 | if ( item && item->itemBelow() ) |
135 | item->moveItem( item->itemBelow() ); | 135 | item->moveItem( item->itemBelow() ); |
136 | ensureItemVisible( selectedItem() ); | 136 | ensureItemVisible( selectedItem() ); |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | bool PlayListSelection::prev() { | 140 | bool PlayListSelection::prev() { |
141 | QListViewItem *item = selectedItem(); | 141 | QListViewItem *item = selectedItem(); |
142 | if ( item && item->itemAbove() ) | 142 | if ( item && item->itemAbove() ) |
143 | setSelected( item->itemAbove(), TRUE ); | 143 | setSelected( item->itemAbove(), TRUE ); |
144 | else | 144 | else |
145 | return FALSE; | 145 | return FALSE; |
146 | ensureItemVisible( selectedItem() ); | 146 | ensureItemVisible( selectedItem() ); |
147 | return TRUE; | 147 | return TRUE; |
148 | } | 148 | } |
149 | 149 | ||
150 | bool PlayListSelection::next() { | 150 | bool PlayListSelection::next() { |
151 | QListViewItem *item = selectedItem(); | 151 | QListViewItem *item = selectedItem(); |
152 | if ( item && item->itemBelow() ) | 152 | if ( item && item->itemBelow() ) |
153 | setSelected( item->itemBelow(), TRUE ); | 153 | setSelected( item->itemBelow(), TRUE ); |
154 | else | 154 | else |
155 | return FALSE; | 155 | return FALSE; |
156 | ensureItemVisible( selectedItem() ); | 156 | ensureItemVisible( selectedItem() ); |
157 | return TRUE; | 157 | return TRUE; |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | bool PlayListSelection::first() { | 161 | bool PlayListSelection::first() { |
162 | QListViewItem *item = firstChild(); | 162 | QListViewItem *item = firstChild(); |
163 | if ( item ) | 163 | if ( item ) |
164 | setSelected( item, TRUE ); | 164 | setSelected( item, TRUE ); |
165 | else | 165 | else |
166 | return FALSE; | 166 | return FALSE; |
167 | ensureItemVisible( selectedItem() ); | 167 | ensureItemVisible( selectedItem() ); |
168 | return TRUE; | 168 | return TRUE; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | bool PlayListSelection::last() { | 172 | bool PlayListSelection::last() { |
173 | QListViewItem *prevItem = NULL; | 173 | QListViewItem *prevItem = NULL; |
174 | QListViewItem *item = firstChild(); | 174 | QListViewItem *item = firstChild(); |
175 | while ( ( item = item->nextSibling() ) ) | 175 | while ( ( item = item->nextSibling() ) ) |
176 | prevItem = item; | 176 | prevItem = item; |
177 | if ( prevItem ) | 177 | if ( prevItem ) |
178 | setSelected( prevItem, TRUE ); | 178 | setSelected( prevItem, TRUE ); |
179 | else | 179 | else |
180 | return FALSE; | 180 | return FALSE; |
181 | ensureItemVisible( selectedItem() ); | 181 | ensureItemVisible( selectedItem() ); |
182 | return TRUE; | 182 | return TRUE; |
183 | } | 183 | } |
184 | 184 | ||
185 | void PlayListSelection::unSelect() | 185 | void PlayListSelection::unSelect() |
186 | { | 186 | { |
187 | QListViewItem *item = selectedItem(); | 187 | QListViewItem *item = selectedItem(); |
188 | setSelected( currentItem(), FALSE); | 188 | setSelected( currentItem(), FALSE); |
189 | } | 189 | } |
190 | 190 | ||
191 | void PlayListSelection::writeCurrent( Config& cfg ) { | 191 | void PlayListSelection::writeCurrent( Config& cfg ) { |
192 | cfg.setGroup("PlayList"); | 192 | cfg.setGroup("PlayList"); |
193 | QListViewItem *item = selectedItem(); | 193 | QListViewItem *item = selectedItem(); |
194 | if ( item ) | 194 | if ( item ) |
195 | cfg.writeEntry("current", item->text(0) ); | 195 | cfg.writeEntry("current", item->text(0) ); |
196 | qDebug(item->text(0)); | 196 | qDebug(item->text(0)); |
197 | 197 | ||
198 | } | 198 | } |
199 | 199 | ||
200 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 200 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
201 | 201 | ||
202 | unSelect(); | 202 | unSelect(); |
203 | QListViewItemIterator it( this ); | 203 | QListViewItemIterator it( this ); |
204 | for ( ; it.current(); ++it ) { | 204 | for ( ; it.current(); ++it ) { |
205 | // qDebug( it.current()->text(0)); | 205 | // qDebug( it.current()->text(0)); |
206 | if( strk == it.current()->text(0)) { | 206 | if( strk == it.current()->text(0)) { |
207 | // qDebug( "We have a match "+strk); | 207 | // qDebug( "We have a match "+strk); |
208 | setSelected( it.current(), TRUE); | 208 | setSelected( it.current(), TRUE); |
209 | ensureItemVisible( it.current() ); | 209 | ensureItemVisible( it.current() ); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | // setSelected( item, TRUE ); | 213 | // setSelected( item, TRUE ); |
214 | // ensureItemVisible( selectedItem() ); | 214 | // ensureItemVisible( selectedItem() ); |
215 | } | 215 | } |