Diffstat (limited to 'core/multimedia/opieplayer/playlistselection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index fbfb946..f17ab6f 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -13,167 +13,167 @@ | |||
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 <qpainter.h> | 22 | #include <qpainter.h> |
23 | #include <qimage.h> | 23 | #include <qimage.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | 28 | ||
29 | #include "playlistselection.h" | 29 | #include "playlistselection.h" |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | 33 | ||
34 | class PlayListSelectionItem : public QListViewItem { | 34 | class PlayListSelectionItem : public QListViewItem { |
35 | public: | 35 | public: |
36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
37 | setText( 0, f->name() ); | 37 | setText( 0, f->name() ); |
38 | setPixmap( 0, f->pixmap() ); | 38 | setPixmap( 0, f->pixmap() ); |
39 | } | 39 | } |
40 | 40 | ||
41 | ~PlayListSelectionItem() { | 41 | ~PlayListSelectionItem() { |
42 | }; | 42 | }; |
43 | 43 | ||
44 | const DocLnk *file() const { return fl; } | 44 | const DocLnk *file() const { return fl; } |
45 | 45 | ||
46 | private: | 46 | private: |
47 | const DocLnk *fl; | 47 | const DocLnk *fl; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 51 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
52 | : QListView( parent, name ) | 52 | : QListView( parent, name ) |
53 | { | 53 | { |
54 | #ifdef USE_PLAYLIST_BACKGROUND | 54 | #ifdef USE_PLAYLIST_BACKGROUND |
55 | setStaticBackground( TRUE ); | 55 | setStaticBackground( TRUE ); |
56 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 56 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
57 | #endif | 57 | #endif |
58 | setAllColumnsShowFocus( TRUE ); | 58 | setAllColumnsShowFocus( TRUE ); |
59 | addColumn( tr( "Playlist Selection" ) ); | 59 | addColumn( tr( "Playlist Selection" ) ); |
60 | header()->hide(); | 60 | header()->hide(); |
61 | setSorting( -1, FALSE ); | 61 | setSorting( -1, FALSE ); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | PlayListSelection::~PlayListSelection() { | 65 | PlayListSelection::~PlayListSelection() { |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | #ifdef USE_PLAYLIST_BACKGROUND | 69 | #ifdef USE_PLAYLIST_BACKGROUND |
70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
71 | p->fillRect( r, QBrush( white ) ); | 71 | p->fillRect( r, QBrush( white ) ); |
72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); | 72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); |
73 | if ( !logo.isNull() ) | 73 | if ( !logo.isNull() ) |
74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
75 | } | 75 | } |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | 78 | ||
79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
80 | if ( event->state() == QMouseEvent::LeftButton ) { | 80 | if ( event->state() == QMouseEvent::LeftButton ) { |
81 | QListViewItem *currentItem = selectedItem(); | 81 | QListViewItem *currentItem = selectedItem(); |
82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
84 | moveSelectedUp(); | 84 | moveSelectedUp(); |
85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
86 | moveSelectedDown(); | 86 | moveSelectedDown(); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | const DocLnk *PlayListSelection::current() { | 91 | const DocLnk *PlayListSelection::current() { |
92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
93 | if ( item ) | 93 | if ( item ) |
94 | return item->file(); | 94 | return item->file(); |
95 | return NULL; | 95 | return NULL; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
101 | QListViewItem *current = selectedItem(); | 101 | QListViewItem *current = selectedItem(); |
102 | if ( current ) | 102 | if ( current ) |
103 | item->moveItem( current ); | 103 | item->moveItem( current ); |
104 | setSelected( item, TRUE ); | 104 | setSelected( item, TRUE ); |
105 | ensureItemVisible( selectedItem() ); | 105 | ensureItemVisible( selectedItem() ); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void PlayListSelection::removeSelected() { | 109 | void PlayListSelection::removeSelected() { |
110 | QListViewItem *item = selectedItem(); | 110 | QListViewItem *item = selectedItem(); |
111 | if ( item ) | 111 | if ( item ) |
112 | delete item; | 112 | delete item; |
113 | setSelected( currentItem(), TRUE ); | 113 | setSelected( currentItem(), TRUE ); |
114 | ensureItemVisible( selectedItem() ); | 114 | ensureItemVisible( selectedItem() ); |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | void PlayListSelection::moveSelectedUp() { | 118 | void PlayListSelection::moveSelectedUp() { |
119 | QListViewItem *item = selectedItem(); | 119 | QListViewItem *item = selectedItem(); |
120 | if ( item && item->itemAbove() ) | 120 | if ( item && item->itemAbove() ) |
121 | item->itemAbove()->moveItem( item ); | 121 | item->itemAbove()->moveItem( item ); |
122 | ensureItemVisible( selectedItem() ); | 122 | ensureItemVisible( selectedItem() ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void PlayListSelection::moveSelectedDown() { | 126 | void PlayListSelection::moveSelectedDown() { |
127 | QListViewItem *item = selectedItem(); | 127 | QListViewItem *item = selectedItem(); |
128 | if ( item && item->itemBelow() ) | 128 | if ( item && item->itemBelow() ) |
129 | item->moveItem( item->itemBelow() ); | 129 | item->moveItem( item->itemBelow() ); |
130 | ensureItemVisible( selectedItem() ); | 130 | ensureItemVisible( selectedItem() ); |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | bool PlayListSelection::prev() { | 134 | bool PlayListSelection::prev() { |
135 | QListViewItem *item = selectedItem(); | 135 | QListViewItem *item = selectedItem(); |
136 | if ( item && item->itemAbove() ) | 136 | if ( item && item->itemAbove() ) |
137 | setSelected( item->itemAbove(), TRUE ); | 137 | setSelected( item->itemAbove(), TRUE ); |
138 | else | 138 | else |
139 | return FALSE; | 139 | return FALSE; |
140 | ensureItemVisible( selectedItem() ); | 140 | ensureItemVisible( selectedItem() ); |
141 | return TRUE; | 141 | return TRUE; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | bool PlayListSelection::next() { | 145 | bool PlayListSelection::next() { |
146 | QListViewItem *item = selectedItem(); | 146 | QListViewItem *item = selectedItem(); |
147 | if ( item && item->itemBelow() ) | 147 | if ( item && item->itemBelow() ) |
148 | setSelected( item->itemBelow(), TRUE ); | 148 | setSelected( item->itemBelow(), TRUE ); |
149 | else | 149 | else |
150 | return FALSE; | 150 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 151 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 152 | return TRUE; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | bool PlayListSelection::first() { | 156 | bool PlayListSelection::first() { |
157 | QListViewItem *item = firstChild(); | 157 | QListViewItem *item = firstChild(); |
158 | if ( item ) | 158 | if ( item ) |
159 | setSelected( item, TRUE ); | 159 | setSelected( item, TRUE ); |
160 | else | 160 | else |
161 | return FALSE; | 161 | return FALSE; |
162 | ensureItemVisible( selectedItem() ); | 162 | ensureItemVisible( selectedItem() ); |
163 | return TRUE; | 163 | return TRUE; |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | bool PlayListSelection::last() { | 167 | bool PlayListSelection::last() { |
168 | QListViewItem *prevItem = NULL; | 168 | QListViewItem *prevItem = NULL; |
169 | QListViewItem *item = firstChild(); | 169 | QListViewItem *item = firstChild(); |
170 | while ( ( item = item->nextSibling() ) ) | 170 | while ( ( item = item->nextSibling() ) ) |
171 | prevItem = item; | 171 | prevItem = item; |
172 | if ( prevItem ) | 172 | if ( prevItem ) |
173 | setSelected( prevItem, TRUE ); | 173 | setSelected( prevItem, TRUE ); |
174 | else | 174 | else |
175 | return FALSE; | 175 | return FALSE; |
176 | ensureItemVisible( selectedItem() ); | 176 | ensureItemVisible( selectedItem() ); |
177 | return TRUE; | 177 | return TRUE; |
178 | } | 178 | } |
179 | 179 | ||