summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/playlistselection.cpp
authorllornkcor <llornkcor>2002-02-03 18:23:27 (UTC)
committer llornkcor <llornkcor>2002-02-03 18:23:27 (UTC)
commit09c3eed0c594f4c93157faf5269ef4d975a310ca (patch) (unidiff)
tree9034282b1376e00baadc4405d1c24c1067d6bcb9 /core/apps/embeddedkonsole/playlistselection.cpp
parentbbbccc44398fc92dcbb148def8d30f2e78f71aa5 (diff)
downloadopie-09c3eed0c594f4c93157faf5269ef4d975a310ca.zip
opie-09c3eed0c594f4c93157faf5269ef4d975a310ca.tar.gz
opie-09c3eed0c594f4c93157faf5269ef4d975a310ca.tar.bz2
merged in Marks commandlist edit dialog
Diffstat (limited to 'core/apps/embeddedkonsole/playlistselection.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/playlistselection.cpp161
1 files changed, 161 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp
new file mode 100644
index 0000000..b9b9401
--- a/dev/null
+++ b/core/apps/embeddedkonsole/playlistselection.cpp
@@ -0,0 +1,161 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qpe/applnk.h>
21#include <qpe/resource.h>
22#include <qpainter.h>
23#include <qimage.h>
24#include <qheader.h>
25#include <qlistview.h>
26#include <qlist.h>
27#include <qpixmap.h>
28
29#include "playlistselection.h"
30
31#include <stdlib.h>
32
33
34
35
36
37PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
38 : QListView( parent, name )
39{
40 setAllColumnsShowFocus( TRUE );
41 addColumn( tr( "Command Selection" ) );
42 header()->hide();
43 setSorting( -1, FALSE );
44}
45
46
47PlayListSelection::~PlayListSelection() {
48}
49
50
51
52void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
53 if ( event->state() == QMouseEvent::LeftButton ) {
54 QListViewItem *currentItem = selectedItem();
55 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
56 if ( currentItem && currentItem->itemAbove() == itemUnder )
57 moveSelectedUp();
58 else if ( currentItem && currentItem->itemBelow() == itemUnder )
59 moveSelectedDown();
60 }
61}
62
63
64const QString *PlayListSelection::current() {
65 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
66 if ( item )
67 return item->file();
68 return NULL;
69}
70
71
72void PlayListSelection::addToSelection( QListViewItem *lnk ) {
73PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) );
74 QListViewItem *current = selectedItem();
75 if ( current )
76 item->moveItem( current );
77 setSelected( item, TRUE );
78 ensureItemVisible( selectedItem() );
79}
80
81void PlayListSelection::addStringToSelection (const QString & lnk) {
82 PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) );
83 QListViewItem *current = selectedItem();
84 if ( current )
85 item->moveItem( current );
86 setSelected( item, TRUE );
87 ensureItemVisible( selectedItem() );
88
89}
90void PlayListSelection::removeSelected() {
91 qDebug("removeSelected()");
92 QListViewItem *item = selectedItem();
93 if ( item )
94 delete item;
95 setSelected( currentItem(), TRUE );
96 ensureItemVisible( selectedItem() );
97}
98
99
100void PlayListSelection::moveSelectedUp() {
101 QListViewItem *item = selectedItem();
102 if ( item && item->itemAbove() )
103 item->itemAbove()->moveItem( item );
104 ensureItemVisible( selectedItem() );
105}
106
107
108void PlayListSelection::moveSelectedDown() {
109 QListViewItem *item = selectedItem();
110 if ( item && item->itemBelow() )
111 item->moveItem( item->itemBelow() );
112 ensureItemVisible( selectedItem() );
113}
114
115
116bool PlayListSelection::prev() {
117 QListViewItem *item = selectedItem();
118 if ( item && item->itemAbove() )
119 setSelected( item->itemAbove(), TRUE );
120 else
121 return FALSE;
122 ensureItemVisible( selectedItem() );
123 return TRUE;
124}
125
126
127bool PlayListSelection::next() {
128 QListViewItem *item = selectedItem();
129 if ( item && item->itemBelow() )
130 setSelected( item->itemBelow(), TRUE );
131 else
132 return FALSE;
133 ensureItemVisible( selectedItem() );
134 return TRUE;
135}
136
137
138bool PlayListSelection::first() {
139 QListViewItem *item = firstChild();
140 if ( item )
141 setSelected( item, TRUE );
142 else
143 return FALSE;
144 ensureItemVisible( selectedItem() );
145 return TRUE;
146}
147
148
149bool PlayListSelection::last() {
150 QListViewItem *prevItem = NULL;
151 QListViewItem *item = firstChild();
152 while ( ( item = item->nextSibling() ) )
153 prevItem = item;
154 if ( prevItem )
155 setSelected( prevItem, TRUE );
156 else
157 return FALSE;
158 ensureItemVisible( selectedItem() );
159 return TRUE;
160}
161