author | llornkcor <llornkcor> | 2002-02-25 01:35:47 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-25 01:35:47 (UTC) |
commit | f180c1a5e8fc889ff1fb390d5cc94cdbc5085046 (patch) (unidiff) | |
tree | 5e9ea6f1313f4c33d57fb266523c1cfbe0826756 /core/multimedia/opieplayer/playlistselection.cpp | |
parent | c0446b55fc32b7fdea9f58db06e40da703f5e8ff (diff) | |
download | opie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.zip opie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.tar.gz opie-f180c1a5e8fc889ff1fb390d5cc94cdbc5085046.tar.bz2 |
fucked up- no workie.. back out
Diffstat (limited to 'core/multimedia/opieplayer/playlistselection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index f17ab6f..a82b594 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,10 +1,10 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 | ** |
@@ -27,18 +27,17 @@ | |||
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 | |||
34 | class PlayListSelectionItem : public QListViewItem { | 33 | class PlayListSelectionItem : public QListViewItem { |
35 | public: | 34 | public: |
36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
37 | setText( 0, f->name() ); | 36 | setText( 0, f->name() ); |
38 | setPixmap( 0, f->pixmap() ); | 37 | setPixmap( 0, f->pixmap() ); |
39 | } | 38 | } |
40 | 39 | ||
41 | ~PlayListSelectionItem() { | 40 | ~PlayListSelectionItem() { |
42 | }; | 41 | }; |
43 | 42 | ||
44 | const DocLnk *file() const { return fl; } | 43 | const DocLnk *file() const { return fl; } |
@@ -68,60 +67,60 @@ PlayListSelection::~PlayListSelection() { | |||
68 | 67 | ||
69 | #ifdef USE_PLAYLIST_BACKGROUND | 68 | #ifdef USE_PLAYLIST_BACKGROUND |
70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 69 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
71 | p->fillRect( r, QBrush( white ) ); | 70 | p->fillRect( r, QBrush( white ) ); |
72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); | 71 | QImage logo = Resource::loadImage( "mpegplayer/background" ); |
73 | if ( !logo.isNull() ) | 72 | if ( !logo.isNull() ) |
74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 73 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
75 | } | 74 | } |
76 | #endif | 75 | #endif |
77 | 76 | ||
78 | 77 | ||
79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 78 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
80 | if ( event->state() == QMouseEvent::LeftButton ) { | 79 | if ( event->state() == QMouseEvent::LeftButton ) { |
81 | QListViewItem *currentItem = selectedItem(); | 80 | QListViewItem *currentItem = selectedItem(); |
82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 81 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 82 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
84 | moveSelectedUp(); | 83 | moveSelectedUp(); |
85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 84 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
86 | moveSelectedDown(); | 85 | moveSelectedDown(); |
87 | } | 86 | } |
88 | } | 87 | } |
89 | 88 | ||
90 | 89 | ||
91 | const DocLnk *PlayListSelection::current() { | 90 | const DocLnk *PlayListSelection::current() { |
92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 91 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
93 | if ( item ) | 92 | if ( item ) |
94 | return item->file(); | 93 | return item->file(); |
95 | return NULL; | 94 | return NULL; |
96 | } | 95 | } |
97 | 96 | ||
98 | 97 | ||
99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 98 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 99 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
101 | QListViewItem *current = selectedItem(); | 100 | QListViewItem *current = selectedItem(); |
102 | if ( current ) | 101 | if ( current ) |
103 | item->moveItem( current ); | 102 | item->moveItem( current ); |
104 | setSelected( item, TRUE ); | 103 | setSelected( item, TRUE ); |
105 | ensureItemVisible( selectedItem() ); | 104 | ensureItemVisible( selectedItem() ); |
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | void PlayListSelection::removeSelected() { | 108 | void PlayListSelection::removeSelected() { |
110 | QListViewItem *item = selectedItem(); | 109 | QListViewItem *item = selectedItem(); |
111 | if ( item ) | 110 | if ( item ) |
112 | delete item; | 111 | delete item; |
113 | setSelected( currentItem(), TRUE ); | 112 | setSelected( currentItem(), TRUE ); |
114 | ensureItemVisible( selectedItem() ); | 113 | ensureItemVisible( selectedItem() ); |
115 | } | 114 | } |
116 | 115 | ||
117 | 116 | ||
118 | void PlayListSelection::moveSelectedUp() { | 117 | void PlayListSelection::moveSelectedUp() { |
119 | QListViewItem *item = selectedItem(); | 118 | QListViewItem *item = selectedItem(); |
120 | if ( item && item->itemAbove() ) | 119 | if ( item && item->itemAbove() ) |
121 | item->itemAbove()->moveItem( item ); | 120 | item->itemAbove()->moveItem( item ); |
122 | ensureItemVisible( selectedItem() ); | 121 | ensureItemVisible( selectedItem() ); |
123 | } | 122 | } |
124 | 123 | ||
125 | 124 | ||
126 | void PlayListSelection::moveSelectedDown() { | 125 | void PlayListSelection::moveSelectedDown() { |
127 | QListViewItem *item = selectedItem(); | 126 | QListViewItem *item = selectedItem(); |
@@ -133,47 +132,47 @@ void PlayListSelection::moveSelectedDown() { | |||
133 | 132 | ||
134 | bool PlayListSelection::prev() { | 133 | bool PlayListSelection::prev() { |
135 | QListViewItem *item = selectedItem(); | 134 | QListViewItem *item = selectedItem(); |
136 | if ( item && item->itemAbove() ) | 135 | if ( item && item->itemAbove() ) |
137 | setSelected( item->itemAbove(), TRUE ); | 136 | setSelected( item->itemAbove(), TRUE ); |
138 | else | 137 | else |
139 | return FALSE; | 138 | return FALSE; |
140 | ensureItemVisible( selectedItem() ); | 139 | ensureItemVisible( selectedItem() ); |
141 | return TRUE; | 140 | return TRUE; |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | bool PlayListSelection::next() { | 144 | bool PlayListSelection::next() { |
146 | QListViewItem *item = selectedItem(); | 145 | QListViewItem *item = selectedItem(); |
147 | if ( item && item->itemBelow() ) | 146 | if ( item && item->itemBelow() ) |
148 | setSelected( item->itemBelow(), TRUE ); | 147 | setSelected( item->itemBelow(), TRUE ); |
149 | else | 148 | else |
150 | return FALSE; | 149 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 150 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 151 | return TRUE; |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | bool PlayListSelection::first() { | 155 | bool PlayListSelection::first() { |
157 | QListViewItem *item = firstChild(); | 156 | QListViewItem *item = firstChild(); |
158 | if ( item ) | 157 | if ( item ) |
159 | setSelected( item, TRUE ); | 158 | setSelected( item, TRUE ); |
160 | else | 159 | else |
161 | return FALSE; | 160 | return FALSE; |
162 | ensureItemVisible( selectedItem() ); | 161 | ensureItemVisible( selectedItem() ); |
163 | return TRUE; | 162 | return TRUE; |
164 | } | 163 | } |
165 | 164 | ||
166 | 165 | ||
167 | bool PlayListSelection::last() { | 166 | bool PlayListSelection::last() { |
168 | QListViewItem *prevItem = NULL; | 167 | QListViewItem *prevItem = NULL; |
169 | QListViewItem *item = firstChild(); | 168 | QListViewItem *item = firstChild(); |
170 | while ( ( item = item->nextSibling() ) ) | 169 | while ( ( item = item->nextSibling() ) ) |
171 | prevItem = item; | 170 | prevItem = item; |
172 | if ( prevItem ) | 171 | if ( prevItem ) |
173 | setSelected( prevItem, TRUE ); | 172 | setSelected( prevItem, TRUE ); |
174 | else | 173 | else |
175 | return FALSE; | 174 | return FALSE; |
176 | ensureItemVisible( selectedItem() ); | 175 | ensureItemVisible( selectedItem() ); |
177 | return TRUE; | 176 | return TRUE; |
178 | } | 177 | } |
179 | 178 | ||