author | llornkcor <llornkcor> | 2002-04-10 20:16:48 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 20:16:48 (UTC) |
commit | 5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac (patch) (unidiff) | |
tree | af7abddaeb16b6167d975968f62a521d8e6231dc | |
parent | 5cf7797af9fb965916f5017f84898516157c4620 (diff) | |
download | opie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.zip opie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.tar.gz opie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.tar.bz2 |
added ability to remember position in the playlist you were last at startup and when opening playlists
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 12 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 8f3711a..3c47256 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,203 +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( "mpegplayer/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 | |||
202 | unSelect(); | ||
203 | QListViewItemIterator it( this ); | ||
204 | for ( ; it.current(); ++it ) { | ||
205 | // qDebug( it.current()->text(0)); | ||
206 | if( strk == it.current()->text(0)) { | ||
207 | // qDebug( "We have a match "+strk); | ||
208 | setSelected( it.current(), TRUE); | ||
209 | ensureItemVisible( it.current() ); | ||
210 | return; | ||
211 | } | ||
212 | } | ||
201 | // setSelected( item, TRUE ); | 213 | // setSelected( item, TRUE ); |
202 | // ensureItemVisible( selectedItem() ); | 214 | // ensureItemVisible( selectedItem() ); |
203 | } | 215 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 63df715..0764c01 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,967 +1,969 @@ | |||
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 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 27 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
29 | 29 | ||
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | #include <qaction.h> | 34 | #include <qaction.h> |
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlist.h> | 40 | #include <qlist.h> |
41 | #include <qlistbox.h> | 41 | #include <qlistbox.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
45 | #include <qtabwidget.h> | 45 | #include <qtabwidget.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qpoint.h> | 47 | #include <qpoint.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
50 | 50 | ||
51 | //#include <qtimer.h> | 51 | //#include <qtimer.h> |
52 | 52 | ||
53 | #include "playlistselection.h" | 53 | #include "playlistselection.h" |
54 | #include "playlistwidget.h" | 54 | #include "playlistwidget.h" |
55 | #include "mediaplayerstate.h" | 55 | #include "mediaplayerstate.h" |
56 | 56 | ||
57 | #include "inputDialog.h" | 57 | #include "inputDialog.h" |
58 | 58 | ||
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | 60 | ||
61 | #define BUTTONS_ON_TOOLBAR | 61 | #define BUTTONS_ON_TOOLBAR |
62 | #define SIDE_BUTTONS | 62 | #define SIDE_BUTTONS |
63 | #define CAN_SAVE_LOAD_PLAYLISTS | 63 | #define CAN_SAVE_LOAD_PLAYLISTS |
64 | 64 | ||
65 | extern MediaPlayerState *mediaPlayerState; | 65 | extern MediaPlayerState *mediaPlayerState; |
66 | 66 | ||
67 | // class myFileSelector { | 67 | // class myFileSelector { |
68 | 68 | ||
69 | // }; | 69 | // }; |
70 | class PlayListWidgetPrivate { | 70 | class PlayListWidgetPrivate { |
71 | public: | 71 | public: |
72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
73 | QFrame *playListFrame; | 73 | QFrame *playListFrame; |
74 | FileSelector *files; | 74 | FileSelector *files; |
75 | PlayListSelection *selectedFiles; | 75 | PlayListSelection *selectedFiles; |
76 | bool setDocumentUsed; | 76 | bool setDocumentUsed; |
77 | DocLnk *current; | 77 | DocLnk *current; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | class ToolButton : public QToolButton { | 81 | class ToolButton : public QToolButton { |
82 | public: | 82 | public: |
83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
84 | : QToolButton( parent, name ) { | 84 | : QToolButton( parent, name ) { |
85 | setTextLabel( name ); | 85 | setTextLabel( name ); |
86 | setPixmap( Resource::loadPixmap( icon ) ); | 86 | setPixmap( Resource::loadPixmap( icon ) ); |
87 | setAutoRaise( TRUE ); | 87 | setAutoRaise( TRUE ); |
88 | setFocusPolicy( QWidget::NoFocus ); | 88 | setFocusPolicy( QWidget::NoFocus ); |
89 | setToggleButton( t ); | 89 | setToggleButton( t ); |
90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
91 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 91 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
92 | } | 92 | } |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | class MenuItem : public QAction { | 96 | class MenuItem : public QAction { |
97 | public: | 97 | public: |
98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
99 | : QAction( text, QString::null, 0, 0 ) { | 99 | : QAction( text, QString::null, 0, 0 ) { |
100 | connect( this, SIGNAL( activated() ), handler, slot ); | 100 | connect( this, SIGNAL( activated() ), handler, slot ); |
101 | addTo( parent ); | 101 | addTo( parent ); |
102 | } | 102 | } |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
107 | : QMainWindow( parent, name, fl ) { | 107 | : QMainWindow( parent, name, fl ) { |
108 | 108 | ||
109 | d = new PlayListWidgetPrivate; | 109 | d = new PlayListWidgetPrivate; |
110 | d->setDocumentUsed = FALSE; | 110 | d->setDocumentUsed = FALSE; |
111 | d->current = NULL; | 111 | d->current = NULL; |
112 | fromSetDocument = FALSE; | 112 | fromSetDocument = FALSE; |
113 | insanityBool=FALSE; | 113 | insanityBool=FALSE; |
114 | // menuTimer = new QTimer( this ,"menu timer"), | 114 | // menuTimer = new QTimer( this ,"menu timer"), |
115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
116 | 116 | ||
117 | setBackgroundMode( PaletteButton ); | 117 | setBackgroundMode( PaletteButton ); |
118 | 118 | ||
119 | setCaption( tr("OpiePlayer") ); | 119 | setCaption( tr("OpiePlayer") ); |
120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
121 | 121 | ||
122 | setToolBarsMovable( FALSE ); | 122 | setToolBarsMovable( FALSE ); |
123 | 123 | ||
124 | // Create Toolbar | 124 | // Create Toolbar |
125 | QPEToolBar *toolbar = new QPEToolBar( this ); | 125 | QPEToolBar *toolbar = new QPEToolBar( this ); |
126 | toolbar->setHorizontalStretchable( TRUE ); | 126 | toolbar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | // Create Menubar | 128 | // Create Menubar |
129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
130 | menu->setMargin( 0 ); | 130 | menu->setMargin( 0 ); |
131 | 131 | ||
132 | QPEToolBar *bar = new QPEToolBar( this ); | 132 | QPEToolBar *bar = new QPEToolBar( this ); |
133 | bar->setLabel( tr( "Play Operations" ) ); | 133 | bar->setLabel( tr( "Play Operations" ) ); |
134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", | 134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
135 | // this , SLOT( addSelected()) ); | 135 | // this , SLOT( addSelected()) ); |
136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
137 | tbDeletePlaylist->setFlat(TRUE); | 137 | tbDeletePlaylist->setFlat(TRUE); |
138 | tbDeletePlaylist->setFixedSize(20,20); | 138 | tbDeletePlaylist->setFixedSize(20,20); |
139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
140 | 140 | ||
141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
142 | this , SLOT(addSelected()) ); | 142 | this , SLOT(addSelected()) ); |
143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
144 | this , SLOT(removeSelected()) ); | 144 | this , SLOT(removeSelected()) ); |
145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
147 | this , SLOT( btnPlay(bool) ), TRUE ); | 147 | this , SLOT( btnPlay(bool) ), TRUE ); |
148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | 148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", |
149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | 150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", |
151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
152 | tbDeletePlaylist->hide(); | 152 | tbDeletePlaylist->hide(); |
153 | 153 | ||
154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
155 | menu->insertItem( tr( "File" ), pmPlayList ); | 155 | menu->insertItem( tr( "File" ), pmPlayList ); |
156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
162 | 162 | ||
163 | QPopupMenu *pmView = new QPopupMenu( this ); | 163 | QPopupMenu *pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
165 | 165 | ||
166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
168 | fullScreenButton->addTo(pmView); | 168 | fullScreenButton->addTo(pmView); |
169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
171 | scaleButton->addTo(pmView); | 171 | scaleButton->addTo(pmView); |
172 | 172 | ||
173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
175 | 175 | ||
176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
177 | 177 | ||
178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
179 | tabWidget->setTabShape(QTabWidget::Triangular); | 179 | tabWidget->setTabShape(QTabWidget::Triangular); |
180 | 180 | ||
181 | QWidget *pTab; | 181 | QWidget *pTab; |
182 | pTab = new QWidget( tabWidget, "pTab" ); | 182 | pTab = new QWidget( tabWidget, "pTab" ); |
183 | // playlistView = new QListView( pTab, "playlistview" ); | 183 | // playlistView = new QListView( pTab, "playlistview" ); |
184 | // playlistView->setMinimumSize(236,260); | 184 | // playlistView->setMinimumSize(236,260); |
185 | tabWidget->insertTab( pTab,"Playlist"); | 185 | tabWidget->insertTab( pTab,"Playlist"); |
186 | 186 | ||
187 | 187 | ||
188 | // Add the playlist area | 188 | // Add the playlist area |
189 | 189 | ||
190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
191 | d->playListFrame = vbox3; | 191 | d->playListFrame = vbox3; |
192 | d->playListFrame ->setMinimumSize(235,260); | 192 | d->playListFrame ->setMinimumSize(235,260); |
193 | 193 | ||
194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
195 | 195 | ||
196 | d->selectedFiles = new PlayListSelection( hbox2); | 196 | d->selectedFiles = new PlayListSelection( hbox2); |
197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
198 | 198 | ||
199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
202 | 202 | ||
203 | 203 | ||
204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
209 | 209 | ||
210 | QWidget *aTab; | 210 | QWidget *aTab; |
211 | aTab = new QWidget( tabWidget, "aTab" ); | 211 | aTab = new QWidget( tabWidget, "aTab" ); |
212 | audioView = new QListView( aTab, "Audioview" ); | 212 | audioView = new QListView( aTab, "Audioview" ); |
213 | audioView->setMinimumSize(233,260); | 213 | audioView->setMinimumSize(233,260); |
214 | audioView->addColumn( tr("Title"),140); | 214 | audioView->addColumn( tr("Title"),140); |
215 | audioView->addColumn(tr("Size"), -1); | 215 | audioView->addColumn(tr("Size"), -1); |
216 | audioView->addColumn(tr("Media"),-1); | 216 | audioView->addColumn(tr("Media"),-1); |
217 | audioView->setColumnAlignment(1, Qt::AlignRight); | 217 | audioView->setColumnAlignment(1, Qt::AlignRight); |
218 | audioView->setColumnAlignment(2, Qt::AlignRight); | 218 | audioView->setColumnAlignment(2, Qt::AlignRight); |
219 | audioView->setAllColumnsShowFocus(TRUE); | 219 | audioView->setAllColumnsShowFocus(TRUE); |
220 | // audioView->setMultiSelection( TRUE ); | 220 | // audioView->setMultiSelection( TRUE ); |
221 | // audioView->setSelectionMode( QListView::Extended); | 221 | // audioView->setSelectionMode( QListView::Extended); |
222 | 222 | ||
223 | tabWidget->insertTab(aTab,tr("Audio")); | 223 | tabWidget->insertTab(aTab,tr("Audio")); |
224 | 224 | ||
225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
228 | 228 | ||
229 | 229 | ||
230 | // audioView | 230 | // audioView |
231 | populateAudioView(); | 231 | populateAudioView(); |
232 | // videowidget | 232 | // videowidget |
233 | 233 | ||
234 | QWidget *vTab; | 234 | QWidget *vTab; |
235 | vTab = new QWidget( tabWidget, "vTab" ); | 235 | vTab = new QWidget( tabWidget, "vTab" ); |
236 | videoView = new QListView( vTab, "Videoview" ); | 236 | videoView = new QListView( vTab, "Videoview" ); |
237 | videoView->setMinimumSize(233,260); | 237 | videoView->setMinimumSize(233,260); |
238 | 238 | ||
239 | videoView->addColumn(tr("Title"),140); | 239 | videoView->addColumn(tr("Title"),140); |
240 | videoView->addColumn(tr("Size"),-1); | 240 | videoView->addColumn(tr("Size"),-1); |
241 | videoView->addColumn(tr("Media"),-1); | 241 | videoView->addColumn(tr("Media"),-1); |
242 | videoView->setColumnAlignment(1, Qt::AlignRight); | 242 | videoView->setColumnAlignment(1, Qt::AlignRight); |
243 | videoView->setColumnAlignment(2, Qt::AlignRight); | 243 | videoView->setColumnAlignment(2, Qt::AlignRight); |
244 | videoView->setAllColumnsShowFocus(TRUE); | 244 | videoView->setAllColumnsShowFocus(TRUE); |
245 | // videoView->setMultiSelection( TRUE ); | 245 | // videoView->setMultiSelection( TRUE ); |
246 | // videoView->setSelectionMode( QListView::Extended); | 246 | // videoView->setSelectionMode( QListView::Extended); |
247 | 247 | ||
248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | 251 | ||
252 | tabWidget->insertTab( vTab,tr("Video")); | 252 | tabWidget->insertTab( vTab,tr("Video")); |
253 | 253 | ||
254 | 254 | ||
255 | //playlists list | 255 | //playlists list |
256 | QWidget *LTab; | 256 | QWidget *LTab; |
257 | LTab = new QWidget( tabWidget, "LTab" ); | 257 | LTab = new QWidget( tabWidget, "LTab" ); |
258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
259 | playLists->setMinimumSize(233,260);; | 259 | playLists->setMinimumSize(233,260);; |
260 | tabWidget->insertTab(LTab,tr("Lists")); | 260 | tabWidget->insertTab(LTab,tr("Lists")); |
261 | 261 | ||
262 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 262 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
264 | 264 | ||
265 | 265 | ||
266 | // add the library area | 266 | // add the library area |
267 | 267 | ||
268 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 268 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
269 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 269 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
270 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 270 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
271 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 271 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
272 | 272 | ||
273 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 273 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
275 | 275 | ||
276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
278 | 278 | ||
279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
284 | 284 | ||
285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
287 | 287 | ||
288 | setCentralWidget( vbox5 ); | 288 | setCentralWidget( vbox5 ); |
289 | 289 | ||
290 | Config cfg( "MediaPlayer" ); | 290 | Config cfg( "MediaPlayer" ); |
291 | readConfig( cfg ); | 291 | readConfig( cfg ); |
292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
293 | // qDebug("currentList is "+currentPlaylist); | 293 | // qDebug("currentList is "+currentPlaylist); |
294 | loadList(DocLnk( currentPlaylist)); | 294 | loadList(DocLnk( currentPlaylist)); |
295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
296 | 296 | ||
297 | initializeStates(); | 297 | initializeStates(); |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | PlayListWidget::~PlayListWidget() { | 301 | PlayListWidget::~PlayListWidget() { |
302 | Config cfg( "MediaPlayer" ); | 302 | Config cfg( "MediaPlayer" ); |
303 | writeConfig( cfg ); | 303 | writeConfig( cfg ); |
304 | 304 | ||
305 | 305 | ||
306 | if ( d->current ) | 306 | if ( d->current ) |
307 | delete d->current; | 307 | delete d->current; |
308 | delete d; | 308 | delete d; |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void PlayListWidget::initializeStates() { | 312 | void PlayListWidget::initializeStates() { |
313 | 313 | ||
314 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 314 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
315 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 315 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
320 | // setPlaylist( mediaPlayerState->playlist() ); | 320 | // setPlaylist( mediaPlayerState->playlist() ); |
321 | setPlaylist( true); | 321 | setPlaylist( true); |
322 | d->selectedFiles->first(); | 322 | // d->selectedFiles->first(); |
323 | |||
323 | } | 324 | } |
324 | 325 | ||
325 | 326 | ||
326 | void PlayListWidget::readConfig( Config& cfg ) { | 327 | void PlayListWidget::readConfig( Config& cfg ) { |
327 | cfg.setGroup("PlayList"); | 328 | cfg.setGroup("PlayList"); |
328 | QString currentString = cfg.readEntry("current", "" ); | 329 | QString currentString = cfg.readEntry("current", "" ); |
329 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
330 | for ( int i = 0; i < noOfFiles; i++ ) { | 331 | for ( int i = 0; i < noOfFiles; i++ ) { |
331 | QString entryName; | 332 | QString entryName; |
332 | entryName.sprintf( "File%i", i + 1 ); | 333 | entryName.sprintf( "File%i", i + 1 ); |
333 | QString linkFile = cfg.readEntry( entryName ); | 334 | QString linkFile = cfg.readEntry( entryName ); |
334 | DocLnk lnk( linkFile ); | 335 | DocLnk lnk( linkFile ); |
335 | if ( lnk.isValid() ) { | 336 | if ( lnk.isValid() ) { |
336 | d->selectedFiles->addToSelection( lnk ); | 337 | d->selectedFiles->addToSelection( lnk ); |
337 | } | 338 | } |
338 | } | 339 | } |
340 | d->selectedFiles->setSelectedItem( currentString); | ||
339 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 341 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
340 | } | 342 | } |
341 | 343 | ||
342 | 344 | ||
343 | void PlayListWidget::writeConfig( Config& cfg ) const { | 345 | void PlayListWidget::writeConfig( Config& cfg ) const { |
344 | 346 | ||
345 | d->selectedFiles->writeCurrent( cfg); | 347 | d->selectedFiles->writeCurrent( cfg); |
346 | cfg.setGroup("PlayList"); | 348 | cfg.setGroup("PlayList"); |
347 | int noOfFiles = 0; | 349 | int noOfFiles = 0; |
348 | d->selectedFiles->first(); | 350 | d->selectedFiles->first(); |
349 | do { | 351 | do { |
350 | const DocLnk *lnk = d->selectedFiles->current(); | 352 | const DocLnk *lnk = d->selectedFiles->current(); |
351 | if ( lnk ) { | 353 | if ( lnk ) { |
352 | QString entryName; | 354 | QString entryName; |
353 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 355 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
354 | qDebug(entryName); | 356 | // qDebug(entryName); |
355 | cfg.writeEntry( entryName, lnk->linkFile() ); | 357 | cfg.writeEntry( entryName, lnk->linkFile() ); |
356 | // if this link does exist, add it so we have the file | 358 | // if this link does exist, add it so we have the file |
357 | // next time... | 359 | // next time... |
358 | if ( !QFile::exists( lnk->linkFile() ) ) { | 360 | if ( !QFile::exists( lnk->linkFile() ) ) { |
359 | // the way writing lnks doesn't really check for out | 361 | // the way writing lnks doesn't really check for out |
360 | // of disk space, but check it anyway. | 362 | // of disk space, but check it anyway. |
361 | if ( !lnk->writeLink() ) { | 363 | if ( !lnk->writeLink() ) { |
362 | QMessageBox::critical( 0, tr("Out of space"), | 364 | QMessageBox::critical( 0, tr("Out of space"), |
363 | tr( "There was a problem saving " | 365 | tr( "There was a problem saving " |
364 | "the playlist.\n" | 366 | "the playlist.\n" |
365 | "Your playlist " | 367 | "Your playlist " |
366 | "may be missing some entries\n" | 368 | "may be missing some entries\n" |
367 | "the next time you start it." ) | 369 | "the next time you start it." ) |
368 | ); | 370 | ); |
369 | } | 371 | } |
370 | } | 372 | } |
371 | noOfFiles++; | 373 | noOfFiles++; |
372 | } | 374 | } |
373 | } | 375 | } |
374 | while ( d->selectedFiles->next() ); | 376 | while ( d->selectedFiles->next() ); |
375 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
376 | } | 378 | } |
377 | 379 | ||
378 | 380 | ||
379 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
380 | // qDebug("add"); | 382 | // qDebug("add"); |
381 | d->setDocumentUsed = FALSE; | 383 | d->setDocumentUsed = FALSE; |
382 | if ( mediaPlayerState->playlist() ) | 384 | if ( mediaPlayerState->playlist() ) |
383 | d->selectedFiles->addToSelection( lnk ); | 385 | d->selectedFiles->addToSelection( lnk ); |
384 | else | 386 | else |
385 | mediaPlayerState->setPlaying( TRUE ); | 387 | mediaPlayerState->setPlaying( TRUE ); |
386 | } | 388 | } |
387 | 389 | ||
388 | 390 | ||
389 | void PlayListWidget::clearList() { | 391 | void PlayListWidget::clearList() { |
390 | while ( first() ) | 392 | while ( first() ) |
391 | d->selectedFiles->removeSelected(); | 393 | d->selectedFiles->removeSelected(); |
392 | } | 394 | } |
393 | 395 | ||
394 | 396 | ||
395 | void PlayListWidget::addAllToList() { | 397 | void PlayListWidget::addAllToList() { |
396 | DocLnkSet filesAll; | 398 | DocLnkSet filesAll; |
397 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 399 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
398 | QListIterator<DocLnk> Adit( filesAll.children() ); | 400 | QListIterator<DocLnk> Adit( filesAll.children() ); |
399 | for ( ; Adit.current(); ++Adit ) | 401 | for ( ; Adit.current(); ++Adit ) |
400 | d->selectedFiles->addToSelection( **Adit ); | 402 | d->selectedFiles->addToSelection( **Adit ); |
401 | } | 403 | } |
402 | 404 | ||
403 | 405 | ||
404 | void PlayListWidget::addAllMusicToList() { | 406 | void PlayListWidget::addAllMusicToList() { |
405 | // DocLnkSet files; | 407 | // DocLnkSet files; |
406 | // Global::findDocuments(&files, "audio/*"); | 408 | // Global::findDocuments(&files, "audio/*"); |
407 | QListIterator<DocLnk> dit( files.children() ); | 409 | QListIterator<DocLnk> dit( files.children() ); |
408 | for ( ; dit.current(); ++dit ) | 410 | for ( ; dit.current(); ++dit ) |
409 | d->selectedFiles->addToSelection( **dit ); | 411 | d->selectedFiles->addToSelection( **dit ); |
410 | } | 412 | } |
411 | 413 | ||
412 | 414 | ||
413 | void PlayListWidget::addAllVideoToList() { | 415 | void PlayListWidget::addAllVideoToList() { |
414 | QListIterator<DocLnk> dit( vFiles.children() ); | 416 | QListIterator<DocLnk> dit( vFiles.children() ); |
415 | for ( ; dit.current(); ++dit ) | 417 | for ( ; dit.current(); ++dit ) |
416 | d->selectedFiles->addToSelection( **dit ); | 418 | d->selectedFiles->addToSelection( **dit ); |
417 | } | 419 | } |
418 | 420 | ||
419 | 421 | ||
420 | void PlayListWidget::setDocument(const QString& fileref) { | 422 | void PlayListWidget::setDocument(const QString& fileref) { |
421 | fromSetDocument = TRUE; | 423 | fromSetDocument = TRUE; |
422 | if ( fileref.isNull() ) { | 424 | if ( fileref.isNull() ) { |
423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
424 | return; | 426 | return; |
425 | } | 427 | } |
426 | // qDebug("setDocument "+fileref); | 428 | // qDebug("setDocument "+fileref); |
427 | if(fileref.find("playlist",0,TRUE) == -1) { | 429 | if(fileref.find("playlist",0,TRUE) == -1) { |
428 | clearList(); | 430 | clearList(); |
429 | addToSelection( DocLnk( fileref ) ); | 431 | addToSelection( DocLnk( fileref ) ); |
430 | d->setDocumentUsed = TRUE; | 432 | d->setDocumentUsed = TRUE; |
431 | mediaPlayerState->setPlaying( FALSE ); | 433 | mediaPlayerState->setPlaying( FALSE ); |
432 | qApp->processEvents(); | 434 | qApp->processEvents(); |
433 | mediaPlayerState->setPlaying( TRUE ); | 435 | mediaPlayerState->setPlaying( TRUE ); |
434 | qApp->processEvents(); | 436 | qApp->processEvents(); |
435 | setCaption(tr("OpiePlayer")); | 437 | setCaption(tr("OpiePlayer")); |
436 | 438 | ||
437 | } else { //is playlist | 439 | } else { //is playlist |
438 | clearList(); | 440 | clearList(); |
439 | loadList(DocLnk(fileref)); | 441 | loadList(DocLnk(fileref)); |
440 | d->selectedFiles->first(); | 442 | d->selectedFiles->first(); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | 445 | ||
444 | 446 | ||
445 | void PlayListWidget::setActiveWindow() { | 447 | void PlayListWidget::setActiveWindow() { |
446 | // When we get raised we need to ensure that it switches views | 448 | // When we get raised we need to ensure that it switches views |
447 | char origView = mediaPlayerState->view(); | 449 | char origView = mediaPlayerState->view(); |
448 | mediaPlayerState->setView( 'l' ); // invalidate | 450 | mediaPlayerState->setView( 'l' ); // invalidate |
449 | mediaPlayerState->setView( origView ); // now switch back | 451 | mediaPlayerState->setView( origView ); // now switch back |
450 | } | 452 | } |
451 | 453 | ||
452 | 454 | ||
453 | void PlayListWidget::useSelectedDocument() { | 455 | void PlayListWidget::useSelectedDocument() { |
454 | d->setDocumentUsed = FALSE; | 456 | d->setDocumentUsed = FALSE; |
455 | } | 457 | } |
456 | 458 | ||
457 | 459 | ||
458 | const DocLnk *PlayListWidget::current() { // this is fugly | 460 | const DocLnk *PlayListWidget::current() { // this is fugly |
459 | 461 | ||
460 | // if( fromSetDocument) { | 462 | // if( fromSetDocument) { |
461 | // qDebug("from setDoc"); | 463 | // qDebug("from setDoc"); |
462 | // DocLnkSet files; | 464 | // DocLnkSet files; |
463 | // Global::findDocuments(&files, "video/*;audio/*"); | 465 | // Global::findDocuments(&files, "video/*;audio/*"); |
464 | // QListIterator<DocLnk> dit( files.children() ); | 466 | // QListIterator<DocLnk> dit( files.children() ); |
465 | // for ( ; dit.current(); ++dit ) { | 467 | // for ( ; dit.current(); ++dit ) { |
466 | // if(dit.current()->linkFile() == setDocFileRef) { | 468 | // if(dit.current()->linkFile() == setDocFileRef) { |
467 | // qDebug(setDocFileRef); | 469 | // qDebug(setDocFileRef); |
468 | // return dit; | 470 | // return dit; |
469 | // } | 471 | // } |
470 | // } | 472 | // } |
471 | // } else | 473 | // } else |
472 | // qDebug("current"); | 474 | // qDebug("current"); |
473 | // switch (tabWidget->currentPageIndex()) { | 475 | // switch (tabWidget->currentPageIndex()) { |
474 | // case 0: //playlist | 476 | // case 0: //playlist |
475 | // { | 477 | // { |
476 | qDebug("playlist"); | 478 | // qDebug("playlist"); |
477 | if ( mediaPlayerState->playlist() ) { | 479 | if ( mediaPlayerState->playlist() ) { |
478 | return d->selectedFiles->current(); | 480 | return d->selectedFiles->current(); |
479 | } | 481 | } |
480 | else if ( d->setDocumentUsed && d->current ) { | 482 | else if ( d->setDocumentUsed && d->current ) { |
481 | return d->current; | 483 | return d->current; |
482 | } else { | 484 | } else { |
483 | return d->files->selected(); | 485 | return d->files->selected(); |
484 | } | 486 | } |
485 | // } | 487 | // } |
486 | // break; | 488 | // break; |
487 | // case 1://audio | 489 | // case 1://audio |
488 | // { | 490 | // { |
489 | // qDebug("audioView"); | 491 | // qDebug("audioView"); |
490 | // Global::findDocuments(&files, "audio/*"); | 492 | // Global::findDocuments(&files, "audio/*"); |
491 | // QListIterator<DocLnk> dit( files.children() ); | 493 | // QListIterator<DocLnk> dit( files.children() ); |
492 | // for ( ; dit.current(); ++dit ) { | 494 | // for ( ; dit.current(); ++dit ) { |
493 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 495 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
494 | // qDebug("here"); | 496 | // qDebug("here"); |
495 | // insanityBool=TRUE; | 497 | // insanityBool=TRUE; |
496 | // return dit; | 498 | // return dit; |
497 | // } | 499 | // } |
498 | // } | 500 | // } |
499 | // } | 501 | // } |
500 | // break; | 502 | // break; |
501 | // case 2: // video | 503 | // case 2: // video |
502 | // { | 504 | // { |
503 | // qDebug("videoView"); | 505 | // qDebug("videoView"); |
504 | // Global::findDocuments(&vFiles, "video/*"); | 506 | // Global::findDocuments(&vFiles, "video/*"); |
505 | // QListIterator<DocLnk> Vdit( vFiles.children() ); | 507 | // QListIterator<DocLnk> Vdit( vFiles.children() ); |
506 | // for ( ; Vdit.current(); ++Vdit ) { | 508 | // for ( ; Vdit.current(); ++Vdit ) { |
507 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 509 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
508 | // insanityBool=TRUE; | 510 | // insanityBool=TRUE; |
509 | // return Vdit; | 511 | // return Vdit; |
510 | // } | 512 | // } |
511 | // } | 513 | // } |
512 | // } | 514 | // } |
513 | // break; | 515 | // break; |
514 | // }; | 516 | // }; |
515 | // return 0; | 517 | // return 0; |
516 | } | 518 | } |
517 | 519 | ||
518 | bool PlayListWidget::prev() { | 520 | bool PlayListWidget::prev() { |
519 | if ( mediaPlayerState->playlist() ) { | 521 | if ( mediaPlayerState->playlist() ) { |
520 | if ( mediaPlayerState->shuffled() ) { | 522 | if ( mediaPlayerState->shuffled() ) { |
521 | const DocLnk *cur = current(); | 523 | const DocLnk *cur = current(); |
522 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 524 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
523 | for ( int i = 0; i < j; i++ ) { | 525 | for ( int i = 0; i < j; i++ ) { |
524 | if ( !d->selectedFiles->next() ) | 526 | if ( !d->selectedFiles->next() ) |
525 | d->selectedFiles->first(); | 527 | d->selectedFiles->first(); |
526 | } | 528 | } |
527 | if ( cur == current() ) | 529 | if ( cur == current() ) |
528 | if ( !d->selectedFiles->next() ) | 530 | if ( !d->selectedFiles->next() ) |
529 | d->selectedFiles->first(); | 531 | d->selectedFiles->first(); |
530 | return TRUE; | 532 | return TRUE; |
531 | } else { | 533 | } else { |
532 | if ( !d->selectedFiles->prev() ) { | 534 | if ( !d->selectedFiles->prev() ) { |
533 | if ( mediaPlayerState->looping() ) { | 535 | if ( mediaPlayerState->looping() ) { |
534 | return d->selectedFiles->last(); | 536 | return d->selectedFiles->last(); |
535 | } else { | 537 | } else { |
536 | return FALSE; | 538 | return FALSE; |
537 | } | 539 | } |
538 | } | 540 | } |
539 | return TRUE; | 541 | return TRUE; |
540 | } | 542 | } |
541 | } else { | 543 | } else { |
542 | return mediaPlayerState->looping(); | 544 | return mediaPlayerState->looping(); |
543 | } | 545 | } |
544 | } | 546 | } |
545 | 547 | ||
546 | 548 | ||
547 | bool PlayListWidget::next() { | 549 | bool PlayListWidget::next() { |
548 | if ( mediaPlayerState->playlist() ) { | 550 | if ( mediaPlayerState->playlist() ) { |
549 | if ( mediaPlayerState->shuffled() ) { | 551 | if ( mediaPlayerState->shuffled() ) { |
550 | return prev(); | 552 | return prev(); |
551 | } else { | 553 | } else { |
552 | if ( !d->selectedFiles->next() ) { | 554 | if ( !d->selectedFiles->next() ) { |
553 | if ( mediaPlayerState->looping() ) { | 555 | if ( mediaPlayerState->looping() ) { |
554 | return d->selectedFiles->first(); | 556 | return d->selectedFiles->first(); |
555 | } else { | 557 | } else { |
556 | return FALSE; | 558 | return FALSE; |
557 | } | 559 | } |
558 | } | 560 | } |
559 | return TRUE; | 561 | return TRUE; |
560 | } | 562 | } |
561 | } else { | 563 | } else { |
562 | return mediaPlayerState->looping(); | 564 | return mediaPlayerState->looping(); |
563 | } | 565 | } |
564 | } | 566 | } |
565 | 567 | ||
566 | 568 | ||
567 | bool PlayListWidget::first() { | 569 | bool PlayListWidget::first() { |
568 | if ( mediaPlayerState->playlist() ) | 570 | if ( mediaPlayerState->playlist() ) |
569 | return d->selectedFiles->first(); | 571 | return d->selectedFiles->first(); |
570 | else | 572 | else |
571 | return mediaPlayerState->looping(); | 573 | return mediaPlayerState->looping(); |
572 | } | 574 | } |
573 | 575 | ||
574 | 576 | ||
575 | bool PlayListWidget::last() { | 577 | bool PlayListWidget::last() { |
576 | if ( mediaPlayerState->playlist() ) | 578 | if ( mediaPlayerState->playlist() ) |
577 | return d->selectedFiles->last(); | 579 | return d->selectedFiles->last(); |
578 | else | 580 | else |
579 | return mediaPlayerState->looping(); | 581 | return mediaPlayerState->looping(); |
580 | } | 582 | } |
581 | 583 | ||
582 | 584 | ||
583 | void PlayListWidget::saveList() { | 585 | void PlayListWidget::saveList() { |
584 | 586 | ||
585 | QString filename; | 587 | QString filename; |
586 | InputDialog *fileDlg; | 588 | InputDialog *fileDlg; |
587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 589 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
588 | fileDlg->exec(); | 590 | fileDlg->exec(); |
589 | if( fileDlg->result() == 1 ) { | 591 | if( fileDlg->result() == 1 ) { |
590 | if ( d->current ) | 592 | if ( d->current ) |
591 | delete d->current; | 593 | delete d->current; |
592 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 594 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
593 | // qDebug("saving playlist "+filename+".playlist"); | 595 | // qDebug("saving playlist "+filename+".playlist"); |
594 | Config cfg( filename +".playlist"); | 596 | Config cfg( filename +".playlist"); |
595 | writeConfig( cfg ); | 597 | writeConfig( cfg ); |
596 | 598 | ||
597 | // qDebug("same name so delete lnk??"); | 599 | // qDebug("same name so delete lnk??"); |
598 | // if( playLists->selected()->name() == filename) { | 600 | // if( playLists->selected()->name() == filename) { |
599 | 601 | ||
600 | // qDebug("same name so delete lnk"); | 602 | // qDebug("same name so delete lnk"); |
601 | // QFile().remove(playLists->selected()->file()); | 603 | // QFile().remove(playLists->selected()->file()); |
602 | // QFile().remove(playLists->selected()->linkFile()); | 604 | // QFile().remove(playLists->selected()->linkFile()); |
603 | // playLists->reread(); | 605 | // playLists->reread(); |
604 | // } | 606 | // } |
605 | // qDebug("new doclnk"); | 607 | // qDebug("new doclnk"); |
606 | DocLnk lnk; | 608 | DocLnk lnk; |
607 | // lnk.setComment( ""); | 609 | // lnk.setComment( ""); |
608 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 610 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
609 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 611 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
610 | lnk.setIcon("mpegplayer/playlist2"); | 612 | lnk.setIcon("mpegplayer/playlist2"); |
611 | lnk.setName( filename); //sets file name | 613 | lnk.setName( filename); //sets file name |
612 | qDebug(filename); | 614 | // qDebug(filename); |
613 | if(!lnk.writeLink()) | 615 | if(!lnk.writeLink()) |
614 | qDebug("Writing doclink did not work"); | 616 | qDebug("Writing doclink did not work"); |
615 | } | 617 | } |
616 | Config config( "MediaPlayer" ); | 618 | Config config( "MediaPlayer" ); |
617 | config.writeEntry("CurrentPlaylist",filename); | 619 | config.writeEntry("CurrentPlaylist",filename); |
618 | setCaption(tr("OpiePlayer: ")+filename); | 620 | setCaption(tr("OpiePlayer: ")+filename); |
619 | d->selectedFiles->first(); | 621 | d->selectedFiles->first(); |
620 | if(fileDlg) | 622 | if(fileDlg) |
621 | delete fileDlg; | 623 | delete fileDlg; |
622 | } | 624 | } |
623 | 625 | ||
624 | void PlayListWidget::loadList( const DocLnk & lnk) { | 626 | void PlayListWidget::loadList( const DocLnk & lnk) { |
625 | QString name= lnk.name(); | 627 | QString name= lnk.name(); |
626 | // qDebug("currentList is "+name); | 628 | // qDebug("currentList is "+name); |
627 | if( name.length()>1) { | 629 | if( name.length()>1) { |
628 | setCaption("OpiePlayer: "+name); | 630 | setCaption("OpiePlayer: "+name); |
629 | // qDebug("load list "+ name+".playlist"); | 631 | // qDebug("load list "+ name+".playlist"); |
630 | clearList(); | 632 | clearList(); |
631 | Config cfg( name+".playlist"); | 633 | Config cfg( name+".playlist"); |
632 | readConfig(cfg); | 634 | readConfig(cfg); |
633 | 635 | ||
634 | tabWidget->setCurrentPage(0); | 636 | tabWidget->setCurrentPage(0); |
635 | 637 | ||
636 | Config config( "MediaPlayer" ); | 638 | Config config( "MediaPlayer" ); |
637 | config.writeEntry("CurrentPlaylist", name); | 639 | config.writeEntry("CurrentPlaylist", name); |
638 | // d->selectedFiles->first(); | 640 | // d->selectedFiles->first(); |
639 | } | 641 | } |
640 | 642 | ||
641 | } | 643 | } |
642 | 644 | ||
643 | void PlayListWidget::setPlaylist( bool shown ) { | 645 | void PlayListWidget::setPlaylist( bool shown ) { |
644 | if ( shown ) | 646 | if ( shown ) |
645 | d->playListFrame->show(); | 647 | d->playListFrame->show(); |
646 | else | 648 | else |
647 | d->playListFrame->hide(); | 649 | d->playListFrame->hide(); |
648 | } | 650 | } |
649 | 651 | ||
650 | void PlayListWidget::setView( char view ) { | 652 | void PlayListWidget::setView( char view ) { |
651 | if ( view == 'l' ) | 653 | if ( view == 'l' ) |
652 | showMaximized(); | 654 | showMaximized(); |
653 | else | 655 | else |
654 | hide(); | 656 | hide(); |
655 | } | 657 | } |
656 | 658 | ||
657 | void PlayListWidget::addSelected() { | 659 | void PlayListWidget::addSelected() { |
658 | 660 | ||
659 | Config cfg( "MediaPlayer" ); | 661 | Config cfg( "MediaPlayer" ); |
660 | cfg.setGroup("PlayList"); | 662 | cfg.setGroup("PlayList"); |
661 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 663 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
662 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 664 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
663 | 665 | ||
664 | switch (tabWidget->currentPageIndex()) { | 666 | switch (tabWidget->currentPageIndex()) { |
665 | case 0: //playlist | 667 | case 0: //playlist |
666 | break; | 668 | break; |
667 | case 1: { //audio | 669 | case 1: { //audio |
668 | for ( int i = 0; i < noOfFiles; i++ ) { | 670 | for ( int i = 0; i < noOfFiles; i++ ) { |
669 | QString entryName; | 671 | QString entryName; |
670 | entryName.sprintf( "File%i", i + 1 ); | 672 | entryName.sprintf( "File%i", i + 1 ); |
671 | QString linkFile = cfg.readEntry( entryName ); | 673 | QString linkFile = cfg.readEntry( entryName ); |
672 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 674 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
673 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 675 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
674 | tr("This is all ready in your playlist.\nContinue?"), | 676 | tr("This is all ready in your playlist.\nContinue?"), |
675 | tr("Yes"),tr("No"),0,0,1); | 677 | tr("Yes"),tr("No"),0,0,1); |
676 | if (result !=0) | 678 | if (result !=0) |
677 | return; | 679 | return; |
678 | } | 680 | } |
679 | } | 681 | } |
680 | addToSelection( audioView->selectedItem() ); | 682 | addToSelection( audioView->selectedItem() ); |
681 | tabWidget->setCurrentPage(1); | 683 | tabWidget->setCurrentPage(1); |
682 | } | 684 | } |
683 | break; | 685 | break; |
684 | case 2: { // video | 686 | case 2: { // video |
685 | for ( int i = 0; i < noOfFiles; i++ ) { | 687 | for ( int i = 0; i < noOfFiles; i++ ) { |
686 | QString entryName; | 688 | QString entryName; |
687 | entryName.sprintf( "File%i", i + 1 ); | 689 | entryName.sprintf( "File%i", i + 1 ); |
688 | QString linkFile = cfg.readEntry( entryName ); | 690 | QString linkFile = cfg.readEntry( entryName ); |
689 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 691 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
690 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 692 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
691 | tr("This is all ready in your playlist.\nContinue?"), | 693 | tr("This is all ready in your playlist.\nContinue?"), |
692 | tr("Yes"),tr("No"),0,0,1); | 694 | tr("Yes"),tr("No"),0,0,1); |
693 | if (result !=0) | 695 | if (result !=0) |
694 | return; | 696 | return; |
695 | } | 697 | } |
696 | } | 698 | } |
697 | addToSelection( videoView->selectedItem() ); | 699 | addToSelection( videoView->selectedItem() ); |
698 | tabWidget->setCurrentPage(2); | 700 | tabWidget->setCurrentPage(2); |
699 | } | 701 | } |
700 | break; | 702 | break; |
701 | }; | 703 | }; |
702 | } | 704 | } |
703 | 705 | ||
704 | void PlayListWidget::removeSelected() { | 706 | void PlayListWidget::removeSelected() { |
705 | d->selectedFiles->removeSelected( ); | 707 | d->selectedFiles->removeSelected( ); |
706 | } | 708 | } |
707 | 709 | ||
708 | void PlayListWidget::playIt( QListViewItem *it) { | 710 | void PlayListWidget::playIt( QListViewItem *it) { |
709 | // d->setDocumentUsed = FALSE; | 711 | // d->setDocumentUsed = FALSE; |
710 | mediaPlayerState->setPlaying(TRUE); | 712 | mediaPlayerState->setPlaying(TRUE); |
711 | } | 713 | } |
712 | 714 | ||
713 | void PlayListWidget::addToSelection( QListViewItem *it) { | 715 | void PlayListWidget::addToSelection( QListViewItem *it) { |
714 | d->setDocumentUsed = FALSE; | 716 | d->setDocumentUsed = FALSE; |
715 | 717 | ||
716 | if(it) { | 718 | if(it) { |
717 | switch (tabWidget->currentPageIndex()) { | 719 | switch (tabWidget->currentPageIndex()) { |
718 | case 1: { | 720 | case 1: { |
719 | QListIterator<DocLnk> dit( files.children() ); | 721 | QListIterator<DocLnk> dit( files.children() ); |
720 | for ( ; dit.current(); ++dit ) { | 722 | for ( ; dit.current(); ++dit ) { |
721 | if( dit.current()->name() == it->text(0)) { | 723 | if( dit.current()->name() == it->text(0)) { |
722 | d->selectedFiles->addToSelection( **dit ); | 724 | d->selectedFiles->addToSelection( **dit ); |
723 | } | 725 | } |
724 | } | 726 | } |
725 | } | 727 | } |
726 | break; | 728 | break; |
727 | case 2: { | 729 | case 2: { |
728 | QListIterator<DocLnk> dit( vFiles.children() ); | 730 | QListIterator<DocLnk> dit( vFiles.children() ); |
729 | for ( ; dit.current(); ++dit ) { | 731 | for ( ; dit.current(); ++dit ) { |
730 | if( dit.current()->name() == it->text(0)) { | 732 | if( dit.current()->name() == it->text(0)) { |
731 | d->selectedFiles->addToSelection( **dit ); | 733 | d->selectedFiles->addToSelection( **dit ); |
732 | } | 734 | } |
733 | } | 735 | } |
734 | } | 736 | } |
735 | break; | 737 | break; |
736 | case 0: | 738 | case 0: |
737 | break; | 739 | break; |
738 | }; | 740 | }; |
739 | tabWidget->setCurrentPage(0); | 741 | tabWidget->setCurrentPage(0); |
740 | } | 742 | } |
741 | } | 743 | } |
742 | 744 | ||
743 | void PlayListWidget::tabChanged(QWidget *widg) { | 745 | void PlayListWidget::tabChanged(QWidget *widg) { |
744 | 746 | ||
745 | switch ( tabWidget->currentPageIndex()) { | 747 | switch ( tabWidget->currentPageIndex()) { |
746 | case 0: | 748 | case 0: |
747 | { | 749 | { |
748 | if( !tbDeletePlaylist->isHidden()) | 750 | if( !tbDeletePlaylist->isHidden()) |
749 | tbDeletePlaylist->hide(); | 751 | tbDeletePlaylist->hide(); |
750 | d->tbRemoveFromList->setEnabled(TRUE); | 752 | d->tbRemoveFromList->setEnabled(TRUE); |
751 | d->tbAddToList->setEnabled(FALSE); | 753 | d->tbAddToList->setEnabled(FALSE); |
752 | } | 754 | } |
753 | break; | 755 | break; |
754 | case 1: | 756 | case 1: |
755 | { | 757 | { |
756 | if( !tbDeletePlaylist->isHidden()) | 758 | if( !tbDeletePlaylist->isHidden()) |
757 | tbDeletePlaylist->hide(); | 759 | tbDeletePlaylist->hide(); |
758 | d->tbRemoveFromList->setEnabled(FALSE); | 760 | d->tbRemoveFromList->setEnabled(FALSE); |
759 | d->tbAddToList->setEnabled(TRUE); | 761 | d->tbAddToList->setEnabled(TRUE); |
760 | } | 762 | } |
761 | break; | 763 | break; |
762 | case 2: | 764 | case 2: |
763 | { | 765 | { |
764 | if( !tbDeletePlaylist->isHidden()) | 766 | if( !tbDeletePlaylist->isHidden()) |
765 | tbDeletePlaylist->hide(); | 767 | tbDeletePlaylist->hide(); |
766 | d->tbRemoveFromList->setEnabled(FALSE); | 768 | d->tbRemoveFromList->setEnabled(FALSE); |
767 | d->tbAddToList->setEnabled(TRUE); | 769 | d->tbAddToList->setEnabled(TRUE); |
768 | } | 770 | } |
769 | break; | 771 | break; |
770 | case 3: | 772 | case 3: |
771 | { | 773 | { |
772 | if( tbDeletePlaylist->isHidden()) | 774 | if( tbDeletePlaylist->isHidden()) |
773 | tbDeletePlaylist->show(); | 775 | tbDeletePlaylist->show(); |
774 | playLists->reread(); | 776 | playLists->reread(); |
775 | } | 777 | } |
776 | break; | 778 | break; |
777 | }; | 779 | }; |
778 | } | 780 | } |
779 | 781 | ||
780 | 782 | ||
781 | 783 | ||
782 | void PlayListWidget::btnPlay(bool b) { | 784 | void PlayListWidget::btnPlay(bool b) { |
783 | 785 | ||
784 | // mediaPlayerState->setPlaying(b); | 786 | // mediaPlayerState->setPlaying(b); |
785 | switch ( tabWidget->currentPageIndex()) { | 787 | switch ( tabWidget->currentPageIndex()) { |
786 | case 0: | 788 | case 0: |
787 | { | 789 | { |
788 | mediaPlayerState->setPlaying(b); | 790 | mediaPlayerState->setPlaying(b); |
789 | } | 791 | } |
790 | break; | 792 | break; |
791 | case 1: | 793 | case 1: |
792 | { | 794 | { |
793 | addToSelection( audioView->selectedItem() ); | 795 | addToSelection( audioView->selectedItem() ); |
794 | mediaPlayerState->setPlaying(b); | 796 | mediaPlayerState->setPlaying(b); |
795 | // qApp->processEvents(); | 797 | // qApp->processEvents(); |
796 | d->selectedFiles->removeSelected( ); | 798 | d->selectedFiles->removeSelected( ); |
797 | tabWidget->setCurrentPage(1); | 799 | tabWidget->setCurrentPage(1); |
798 | audioView->clearSelection(); | 800 | audioView->clearSelection(); |
799 | // d->selectedFiles->unSelect(); | 801 | // d->selectedFiles->unSelect(); |
800 | // mediaPlayerState->setPlaying(FALSE); | 802 | // mediaPlayerState->setPlaying(FALSE); |
801 | } | 803 | } |
802 | break; | 804 | break; |
803 | case 2: | 805 | case 2: |
804 | { | 806 | { |
805 | addToSelection( videoView->selectedItem() ); | 807 | addToSelection( videoView->selectedItem() ); |
806 | mediaPlayerState->setPlaying(b); | 808 | mediaPlayerState->setPlaying(b); |
807 | qApp->processEvents(); | 809 | qApp->processEvents(); |
808 | d->selectedFiles->removeSelected( ); | 810 | d->selectedFiles->removeSelected( ); |
809 | tabWidget->setCurrentPage(2); | 811 | tabWidget->setCurrentPage(2); |
810 | videoView->clearSelection(); | 812 | videoView->clearSelection(); |
811 | // d->selectedFiles->unSelect(); | 813 | // d->selectedFiles->unSelect(); |
812 | // mediaPlayerState->setPlaying(FALSE); | 814 | // mediaPlayerState->setPlaying(FALSE); |
813 | } | 815 | } |
814 | break; | 816 | break; |
815 | }; | 817 | }; |
816 | } | 818 | } |
817 | 819 | ||
818 | void PlayListWidget::deletePlaylist() { | 820 | void PlayListWidget::deletePlaylist() { |
819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 821 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
820 | (tr("You really want to delete\nthis playlist?")), | 822 | (tr("You really want to delete\nthis playlist?")), |
821 | (tr("Yes")), (tr("No")), 0 )){ | 823 | (tr("Yes")), (tr("No")), 0 )){ |
822 | case 0: // Yes clicked, | 824 | case 0: // Yes clicked, |
823 | QFile().remove(playLists->selected()->file()); | 825 | QFile().remove(playLists->selected()->file()); |
824 | QFile().remove(playLists->selected()->linkFile()); | 826 | QFile().remove(playLists->selected()->linkFile()); |
825 | playLists->reread(); | 827 | playLists->reread(); |
826 | break; | 828 | break; |
827 | case 1: // Cancel | 829 | case 1: // Cancel |
828 | break; | 830 | break; |
829 | }; | 831 | }; |
830 | 832 | ||
831 | } | 833 | } |
832 | 834 | ||
833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 835 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
834 | { | 836 | { |
835 | switch (mouse) { | 837 | switch (mouse) { |
836 | case 1: | 838 | case 1: |
837 | break; | 839 | break; |
838 | case 2:{ | 840 | case 2:{ |
839 | QPopupMenu m; | 841 | QPopupMenu m; |
840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 842 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 843 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
842 | m.insertSeparator(); | 844 | m.insertSeparator(); |
843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 845 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
844 | m.exec( QCursor::pos() ); | 846 | m.exec( QCursor::pos() ); |
845 | } | 847 | } |
846 | break; | 848 | break; |
847 | }; | 849 | }; |
848 | } | 850 | } |
849 | 851 | ||
850 | void PlayListWidget::playSelected() | 852 | void PlayListWidget::playSelected() |
851 | { | 853 | { |
852 | btnPlay( TRUE); | 854 | btnPlay( TRUE); |
853 | } | 855 | } |
854 | 856 | ||
855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 857 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
856 | { | 858 | { |
857 | switch (mouse) { | 859 | switch (mouse) { |
858 | case 1: | 860 | case 1: |
859 | break; | 861 | break; |
860 | case 2:{ | 862 | case 2:{ |
861 | QPopupMenu m; | 863 | QPopupMenu m; |
862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 864 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 865 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
864 | // m.insertSeparator(); | 866 | // m.insertSeparator(); |
865 | m.exec( QCursor::pos() ); | 867 | m.exec( QCursor::pos() ); |
866 | } | 868 | } |
867 | break; | 869 | break; |
868 | }; | 870 | }; |
869 | 871 | ||
870 | } | 872 | } |
871 | 873 | ||
872 | void PlayListWidget::listDelete() { | 874 | void PlayListWidget::listDelete() { |
873 | Config cfg( "MediaPlayer" ); | 875 | Config cfg( "MediaPlayer" ); |
874 | cfg.setGroup("PlayList"); | 876 | cfg.setGroup("PlayList"); |
875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 877 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
876 | QString file; | 878 | QString file; |
877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 879 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
878 | switch ( tabWidget->currentPageIndex()) { | 880 | switch ( tabWidget->currentPageIndex()) { |
879 | case 0: | 881 | case 0: |
880 | break; | 882 | break; |
881 | case 1: | 883 | case 1: |
882 | { | 884 | { |
883 | file = audioView->selectedItem()->text(0); | 885 | file = audioView->selectedItem()->text(0); |
884 | // Global::findDocuments(&files, "audio/*"); | 886 | // Global::findDocuments(&files, "audio/*"); |
885 | // AppLnkSet appFiles; | 887 | // AppLnkSet appFiles; |
886 | QListIterator<DocLnk> dit( files.children() ); | 888 | QListIterator<DocLnk> dit( files.children() ); |
887 | for ( ; dit.current(); ++dit ) { | 889 | for ( ; dit.current(); ++dit ) { |
888 | if( dit.current()->name() == file) { | 890 | if( dit.current()->name() == file) { |
889 | qDebug(file); | 891 | // qDebug(file); |
890 | LnkProperties prop( dit.current() ); | 892 | LnkProperties prop( dit.current() ); |
891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 893 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
892 | prop.showMaximized(); | 894 | prop.showMaximized(); |
893 | prop.exec(); | 895 | prop.exec(); |
894 | } | 896 | } |
895 | } | 897 | } |
896 | populateAudioView(); | 898 | populateAudioView(); |
897 | } | 899 | } |
898 | break; | 900 | break; |
899 | case 2: | 901 | case 2: |
900 | { | 902 | { |
901 | // file = videoView->selectedItem()->text(0); | 903 | // file = videoView->selectedItem()->text(0); |
902 | // for ( int i = 0; i < noOfFiles; i++ ) { | 904 | // for ( int i = 0; i < noOfFiles; i++ ) { |
903 | // QString entryName; | 905 | // QString entryName; |
904 | // entryName.sprintf( "File%i", i + 1 ); | 906 | // entryName.sprintf( "File%i", i + 1 ); |
905 | // QString linkFile = cfg.readEntry( entryName ); | 907 | // QString linkFile = cfg.readEntry( entryName ); |
906 | // AppLnk lnk( AppLnk(linkFile)); | 908 | // AppLnk lnk( AppLnk(linkFile)); |
907 | // if( lnk.name() == file ) { | 909 | // if( lnk.name() == file ) { |
908 | // LnkProperties prop( &lnk); | 910 | // LnkProperties prop( &lnk); |
909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 911 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
910 | // prop.showMaximized(); | 912 | // prop.showMaximized(); |
911 | // prop.exec(); | 913 | // prop.exec(); |
912 | // } | 914 | // } |
913 | // } | 915 | // } |
914 | } | 916 | } |
915 | break; | 917 | break; |
916 | }; | 918 | }; |
917 | } | 919 | } |
918 | 920 | ||
919 | void PlayListWidget::populateAudioView() { | 921 | void PlayListWidget::populateAudioView() { |
920 | // if(files) | 922 | // if(files) |
921 | // files.~DocLnkSet(); | 923 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | 924 | StorageInfo storageInfo; |
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
924 | 926 | ||
925 | Global::findDocuments(&files, "audio/*"); | 927 | Global::findDocuments(&files, "audio/*"); |
926 | QListIterator<DocLnk> dit( files.children() ); | 928 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | 929 | QListIterator<FileSystem> it ( fs ); |
928 | audioView->clear(); | 930 | audioView->clear(); |
929 | QString storage; | 931 | QString storage; |
930 | for ( ; dit.current(); ++dit ) { | 932 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | 933 | for( ; it.current(); ++it ){ |
932 | const QString name = (*it)->name(); | 934 | const QString name = (*it)->name(); |
933 | const QString path = (*it)->path(); | 935 | const QString path = (*it)->path(); |
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | 936 | if(dit.current()->file().find(path) != -1 ) storage=name; |
935 | } | 937 | } |
936 | 938 | ||
937 | QListViewItem * newItem; | 939 | QListViewItem * newItem; |
938 | if ( QFile( dit.current()->file()).exists() ) { | 940 | if ( QFile( dit.current()->file()).exists() ) { |
939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 941 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 942 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
941 | } | 943 | } |
942 | } | 944 | } |
943 | } | 945 | } |
944 | 946 | ||
945 | void PlayListWidget::populateVideoView() { | 947 | void PlayListWidget::populateVideoView() { |
946 | StorageInfo storageInfo; | 948 | StorageInfo storageInfo; |
947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 949 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
948 | 950 | ||
949 | Global::findDocuments(&vFiles, "video/*"); | 951 | Global::findDocuments(&vFiles, "video/*"); |
950 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 952 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
951 | QListIterator<FileSystem> it ( fs ); | 953 | QListIterator<FileSystem> it ( fs ); |
952 | videoView->clear(); | 954 | videoView->clear(); |
953 | QString storage; | 955 | QString storage; |
954 | for ( ; Vdit.current(); ++Vdit ) { | 956 | for ( ; Vdit.current(); ++Vdit ) { |
955 | for( ; it.current(); ++it ){ | 957 | for( ; it.current(); ++it ){ |
956 | const QString name = (*it)->name(); | 958 | const QString name = (*it)->name(); |
957 | const QString path = (*it)->path(); | 959 | const QString path = (*it)->path(); |
958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 960 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
959 | } | 961 | } |
960 | 962 | ||
961 | QListViewItem * newItem; | 963 | QListViewItem * newItem; |
962 | if ( QFile( Vdit.current()->file()).exists() ) { | 964 | if ( QFile( Vdit.current()->file()).exists() ) { |
963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 965 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 966 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
965 | } | 967 | } |
966 | } | 968 | } |
967 | } | 969 | } |