-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.cpp | 28 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.h | 2 |
2 files changed, 15 insertions, 15 deletions
diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp index b9b9401..4dd3126 100644 --- a/core/apps/embeddedkonsole/playlistselection.cpp +++ b/core/apps/embeddedkonsole/playlistselection.cpp | |||
@@ -1,161 +1,161 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 <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 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 37 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
38 | : QListView( parent, name ) | 38 | : QListView( parent, name ) |
39 | { | 39 | { |
40 | setAllColumnsShowFocus( TRUE ); | 40 | setAllColumnsShowFocus( TRUE ); |
41 | addColumn( tr( "Command Selection" ) ); | 41 | addColumn( tr( "Command Selection" ) ); |
42 | header()->hide(); | 42 | header()->hide(); |
43 | setSorting( -1, FALSE ); | 43 | setSorting( -1, FALSE ); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | PlayListSelection::~PlayListSelection() { | 47 | PlayListSelection::~PlayListSelection() { |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | 51 | ||
52 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 52 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
53 | if ( event->state() == QMouseEvent::LeftButton ) { | 53 | if ( event->state() == QMouseEvent::LeftButton ) { |
54 | QListViewItem *currentItem = selectedItem(); | 54 | QListViewItem *currentItem = selectedItem(); |
55 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 55 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
56 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 56 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
57 | moveSelectedUp(); | 57 | moveSelectedUp(); |
58 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 58 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
59 | moveSelectedDown(); | 59 | moveSelectedDown(); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | const QString *PlayListSelection::current() { | 64 | const QString *PlayListSelection::current() { |
65 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 65 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
66 | if ( item ) | 66 | if ( item ) |
67 | return item->file(); | 67 | return item->file(); |
68 | return NULL; | 68 | return NULL; |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { | 72 | void PlayListSelection::addToSelection( QListViewItem *lnk ) { |
73 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); | 73 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); |
74 | QListViewItem *current = selectedItem(); | 74 | QListViewItem *current = selectedItem(); |
75 | if ( current ) | 75 | if ( current ) |
76 | item->moveItem( current ); | 76 | item->moveItem( current ); |
77 | setSelected( item, TRUE ); | 77 | setSelected( item, TRUE ); |
78 | ensureItemVisible( selectedItem() ); | 78 | ensureItemVisible( selectedItem() ); |
79 | } | 79 | } |
80 | 80 | ||
81 | void PlayListSelection::addStringToSelection (const QString & lnk) { | 81 | void PlayListSelection::addStringToSelection (const QString & lnk) { |
82 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); | 82 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); |
83 | QListViewItem *current = selectedItem(); | 83 | QListViewItem *current = selectedItem(); |
84 | if ( current ) | 84 | if ( current ) |
85 | item->moveItem( current ); | 85 | item->moveItem( current ); |
86 | setSelected( item, TRUE ); | 86 | setSelected( item, TRUE ); |
87 | ensureItemVisible( selectedItem() ); | 87 | ensureItemVisible( selectedItem() ); |
88 | 88 | ||
89 | } | 89 | } |
90 | void PlayListSelection::removeSelected() { | 90 | void PlayListSelection::removeSelected() { |
91 | qDebug("removeSelected()"); | 91 | qDebug("removeSelected()"); |
92 | QListViewItem *item = selectedItem(); | 92 | QListViewItem *item = selectedItem(); |
93 | if ( item ) | 93 | if ( item ) |
94 | delete item; | 94 | delete item; |
95 | setSelected( currentItem(), TRUE ); | 95 | setSelected( currentItem(), TRUE ); |
96 | ensureItemVisible( selectedItem() ); | 96 | ensureItemVisible( selectedItem() ); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void PlayListSelection::moveSelectedUp() { | 100 | void PlayListSelection::moveSelectedUp() { |
101 | QListViewItem *item = selectedItem(); | 101 | QListViewItem *item = selectedItem(); |
102 | if ( item && item->itemAbove() ) | 102 | if ( item && item->itemAbove() ) |
103 | item->itemAbove()->moveItem( item ); | 103 | item->itemAbove()->moveItem( item ); |
104 | ensureItemVisible( selectedItem() ); | 104 | ensureItemVisible( selectedItem() ); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void PlayListSelection::moveSelectedDown() { | 108 | void PlayListSelection::moveSelectedDown() { |
109 | QListViewItem *item = selectedItem(); | 109 | QListViewItem *item = selectedItem(); |
110 | if ( item && item->itemBelow() ) | 110 | if ( item && item->itemBelow() ) |
111 | item->moveItem( item->itemBelow() ); | 111 | item->moveItem( item->itemBelow() ); |
112 | ensureItemVisible( selectedItem() ); | 112 | ensureItemVisible( selectedItem() ); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | bool PlayListSelection::prev() { | 116 | bool PlayListSelection::prev() { |
117 | QListViewItem *item = selectedItem(); | 117 | QListViewItem *item = selectedItem(); |
118 | if ( item && item->itemAbove() ) | 118 | if ( item && item->itemAbove() ) |
119 | setSelected( item->itemAbove(), TRUE ); | 119 | setSelected( item->itemAbove(), TRUE ); |
120 | else | 120 | else |
121 | return FALSE; | 121 | return FALSE; |
122 | ensureItemVisible( selectedItem() ); | 122 | ensureItemVisible( selectedItem() ); |
123 | return TRUE; | 123 | return TRUE; |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | bool PlayListSelection::next() { | 127 | bool PlayListSelection::next() { |
128 | QListViewItem *item = selectedItem(); | 128 | QListViewItem *item = selectedItem(); |
129 | if ( item && item->itemBelow() ) | 129 | if ( item && item->itemBelow() ) |
130 | setSelected( item->itemBelow(), TRUE ); | 130 | setSelected( item->itemBelow(), TRUE ); |
131 | else | 131 | else |
132 | return FALSE; | 132 | return FALSE; |
133 | ensureItemVisible( selectedItem() ); | 133 | ensureItemVisible( selectedItem() ); |
134 | return TRUE; | 134 | return TRUE; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | bool PlayListSelection::first() { | 138 | bool PlayListSelection::first() { |
139 | QListViewItem *item = firstChild(); | 139 | QListViewItem *item = firstChild(); |
140 | if ( item ) | 140 | if ( item ) |
141 | setSelected( item, TRUE ); | 141 | setSelected( item, TRUE ); |
142 | else | 142 | else |
143 | return FALSE; | 143 | return FALSE; |
144 | ensureItemVisible( selectedItem() ); | 144 | ensureItemVisible( selectedItem() ); |
145 | return TRUE; | 145 | return TRUE; |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | bool PlayListSelection::last() { | 149 | bool PlayListSelection::last() { |
150 | QListViewItem *prevItem = NULL; | 150 | QListViewItem *prevItem = NULL; |
151 | QListViewItem *item = firstChild(); | 151 | QListViewItem *item = firstChild(); |
152 | while ( ( item = item->nextSibling() ) ) | 152 | while ( ( item = item->nextSibling() ) ) |
153 | prevItem = item; | 153 | prevItem = item; |
154 | if ( prevItem ) | 154 | if ( prevItem ) |
155 | setSelected( prevItem, TRUE ); | 155 | setSelected( prevItem, TRUE ); |
156 | else | 156 | else |
157 | return FALSE; | 157 | return FALSE; |
158 | ensureItemVisible( selectedItem() ); | 158 | ensureItemVisible( selectedItem() ); |
159 | return TRUE; | 159 | return TRUE; |
160 | } | 160 | } |
161 | 161 | ||
diff --git a/core/apps/embeddedkonsole/playlistselection.h b/core/apps/embeddedkonsole/playlistselection.h index c307f14..f340124 100644 --- a/core/apps/embeddedkonsole/playlistselection.h +++ b/core/apps/embeddedkonsole/playlistselection.h | |||
@@ -1,74 +1,74 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qlist.h> | 24 | #include <qlist.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | 27 | ||
28 | class PlayListSelectionItem : public QListViewItem { | 28 | class PlayListSelectionItem : public QListViewItem { |
29 | public: | 29 | public: |
30 | PlayListSelectionItem( QListView *parent, QString *f ) : QListViewItem( parent ), fl( f ) { | 30 | PlayListSelectionItem( QListView *parent, QString *f ) : QListViewItem( parent ), fl( f ) { |
31 | setText(0, *f ); | 31 | setText(0, *f ); |
32 | } | 32 | } |
33 | 33 | ||
34 | ~PlayListSelectionItem() { | 34 | ~PlayListSelectionItem() { |
35 | }; | 35 | }; |
36 | 36 | ||
37 | const QString *file() const { return fl; } | 37 | const QString *file() const { return fl; } |
38 | 38 | ||
39 | private: | 39 | private: |
40 | const QString *fl; | 40 | const QString *fl; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | class PlayListSelection : public QListView { | 43 | class PlayListSelection : public QListView { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | PlayListSelection( QWidget *parent, const char *name=0 ); | 46 | PlayListSelection( QWidget *parent, const char *name=0 ); |
47 | ~PlayListSelection(); | 47 | ~PlayListSelection(); |
48 | 48 | ||
49 | const QString *current(); // retrieve the current playlist entry (media file link) | 49 | const QString *current(); // retrieve the current playlist entry (media file link) |
50 | 50 | ||
51 | public slots: | 51 | public slots: |
52 | void addToSelection( QListViewItem * ); // Add a media file to the playlist | 52 | void addToSelection( QListViewItem * ); // Add a media file to the playlist |
53 | void addStringToSelection ( const QString &); | 53 | void addStringToSelection ( const QString &); |
54 | void removeSelected(); // Remove a media file from the playlist | 54 | void removeSelected(); // Remove a media file from the playlist |
55 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 55 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
56 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 56 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
57 | bool prev(); | 57 | bool prev(); |
58 | bool next(); | 58 | bool next(); |
59 | bool first(); | 59 | bool first(); |
60 | bool last(); | 60 | bool last(); |
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 63 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
64 | 64 | ||
65 | 65 | ||
66 | private: | 66 | private: |
67 | QStringList selectedList; | 67 | QStringList selectedList; |
68 | QString *cmd; | 68 | QString *cmd; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | #endif // PLAY_LIST_SELECTION_H | 72 | #endif // PLAY_LIST_SELECTION_H |
73 | 73 | ||
74 | 74 | ||