summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-01-19 23:11:02 (UTC)
committer llornkcor <llornkcor>2003-01-19 23:11:02 (UTC)
commit512e600c777643230a032e89f7446b4099f54a86 (patch) (unidiff)
tree0a19e567b5acc6f44c5d5957fcaf097350f84a03
parent4e9ddbd0da3de7d0d03d7a39f05643dec07cc2cf (diff)
downloadopie-512e600c777643230a032e89f7446b4099f54a86.zip
opie-512e600c777643230a032e89f7446b4099f54a86.tar.gz
opie-512e600c777643230a032e89f7446b4099f54a86.tar.bz2
partly fix playing from audio and video views
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp11
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp22
2 files changed, 21 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 85228a9..67187f8 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -1,215 +1,216 @@
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
35class PlayListSelectionItem : public QListViewItem { 35class PlayListSelectionItem : public QListViewItem {
36public: 36public:
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
47private: 47private:
48 const DocLnk *fl; 48 const DocLnk *fl;
49}; 49};
50 50
51 51
52PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 52PlayListSelection::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( "opieplayer/background" ) ); 58// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/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 // FIXME
67} 68}
68 69
69 70
70PlayListSelection::~PlayListSelection() { 71PlayListSelection::~PlayListSelection() {
71} 72}
72 73
73 74
74// #ifdef USE_PLAYLIST_BACKGROUND 75// #ifdef USE_PLAYLIST_BACKGROUND
75void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 76void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
76// qDebug("drawBackground"); 77// qDebug("drawBackground");
77 p->fillRect( r, QBrush( white ) ); 78 p->fillRect( r, QBrush( white ) );
78// QImage logo = Resource::loadImage( "launcher/opielogo" ); 79// QImage logo = Resource::loadImage( "launcher/opielogo" );
79// if ( !logo.isNull() ) 80// if ( !logo.isNull() )
80// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 81// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
81} 82}
82// #endif 83// #endif
83 84
84 85
85void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 86void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
86 if ( event->state() == QMouseEvent::LeftButton ) { 87 if ( event->state() == QMouseEvent::LeftButton ) {
87 QListViewItem *currentItem = selectedItem(); 88 QListViewItem *currentItem = selectedItem();
88 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 89 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
89 if ( currentItem && currentItem->itemAbove() == itemUnder ) 90 if ( currentItem && currentItem->itemAbove() == itemUnder )
90 moveSelectedUp(); 91 moveSelectedUp();
91 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 92 else if ( currentItem && currentItem->itemBelow() == itemUnder )
92 moveSelectedDown(); 93 moveSelectedDown();
93 } 94 }
94} 95}
95 96
96 97
97const DocLnk *PlayListSelection::current() { 98const DocLnk *PlayListSelection::current() {
98 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 99 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
99 if ( item ) 100 if ( item )
100 return item->file(); 101 return item->file();
101 return NULL; 102 return NULL;
102} 103}
103 104
104 105
105void PlayListSelection::addToSelection( const DocLnk &lnk ) { 106void PlayListSelection::addToSelection( const DocLnk &lnk ) {
106 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); 107 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) );
107 QListViewItem *current = selectedItem(); 108 QListViewItem *current = selectedItem();
108 if ( current ) 109 if ( current )
109 item->moveItem( current ); 110 item->moveItem( current );
110 setSelected( item, TRUE ); 111 setSelected( item, TRUE );
111 ensureItemVisible( selectedItem() ); 112 ensureItemVisible( item);
112} 113}
113 114
114 115
115void PlayListSelection::removeSelected() { 116void PlayListSelection::removeSelected() {
116 QListViewItem *item = selectedItem(); 117 QListViewItem *item = selectedItem();
117 if ( item ) 118 if ( item )
118 delete item; 119 delete item;
119 setSelected( currentItem(), TRUE ); 120 setSelected( currentItem(), TRUE );
120 ensureItemVisible( selectedItem() ); 121 ensureItemVisible( selectedItem() );
121} 122}
122 123
123 124
124void PlayListSelection::moveSelectedUp() { 125void PlayListSelection::moveSelectedUp() {
125 QListViewItem *item = selectedItem(); 126 QListViewItem *item = selectedItem();
126 if ( item && item->itemAbove() ) 127 if ( item && item->itemAbove() )
127 item->itemAbove()->moveItem( item ); 128 item->itemAbove()->moveItem( item );
128 ensureItemVisible( selectedItem() ); 129 ensureItemVisible( selectedItem() );
129} 130}
130 131
131 132
132void PlayListSelection::moveSelectedDown() { 133void PlayListSelection::moveSelectedDown() {
133 QListViewItem *item = selectedItem(); 134 QListViewItem *item = selectedItem();
134 if ( item && item->itemBelow() ) 135 if ( item && item->itemBelow() )
135 item->moveItem( item->itemBelow() ); 136 item->moveItem( item->itemBelow() );
136 ensureItemVisible( selectedItem() ); 137 ensureItemVisible( selectedItem() );
137} 138}
138 139
139 140
140bool PlayListSelection::prev() { 141bool PlayListSelection::prev() {
141 QListViewItem *item = selectedItem(); 142 QListViewItem *item = selectedItem();
142 if ( item && item->itemAbove() ) 143 if ( item && item->itemAbove() )
143 setSelected( item->itemAbove(), TRUE ); 144 setSelected( item->itemAbove(), TRUE );
144 else 145 else
145 return FALSE; 146 return FALSE;
146 ensureItemVisible( selectedItem() ); 147 ensureItemVisible( selectedItem() );
147 return TRUE; 148 return TRUE;
148} 149}
149 150
150bool PlayListSelection::next() { 151bool PlayListSelection::next() {
151 QListViewItem *item = selectedItem(); 152 QListViewItem *item = selectedItem();
152 if ( item && item->itemBelow() ) 153 if ( item && item->itemBelow() )
153 setSelected( item->itemBelow(), TRUE ); 154 setSelected( item->itemBelow(), TRUE );
154 else 155 else
155 return FALSE; 156 return FALSE;
156 ensureItemVisible( selectedItem() ); 157 ensureItemVisible( selectedItem() );
157 return TRUE; 158 return TRUE;
158} 159}
159 160
160 161
161bool PlayListSelection::first() { 162bool PlayListSelection::first() {
162 QListViewItem *item = firstChild(); 163 QListViewItem *item = firstChild();
163 if ( item ) 164 if ( item )
164 setSelected( item, TRUE ); 165 setSelected( item, TRUE );
165 else 166 else
166 return FALSE; 167 return FALSE;
167 ensureItemVisible( selectedItem() ); 168 ensureItemVisible( selectedItem() );
168 return TRUE; 169 return TRUE;
169} 170}
170 171
171 172
172bool PlayListSelection::last() { 173bool PlayListSelection::last() {
173 QListViewItem *prevItem = NULL; 174 QListViewItem *prevItem = NULL;
174 QListViewItem *item = firstChild(); 175 QListViewItem *item = firstChild();
175 while ( ( item = item->nextSibling() ) ) 176 while ( ( item = item->nextSibling() ) )
176 prevItem = item; 177 prevItem = item;
177 if ( prevItem ) 178 if ( prevItem )
178 setSelected( prevItem, TRUE ); 179 setSelected( prevItem, TRUE );
179 else 180 else
180 return FALSE; 181 return FALSE;
181 ensureItemVisible( selectedItem() ); 182 ensureItemVisible( selectedItem() );
182 return TRUE; 183 return TRUE;
183} 184}
184 185
185void PlayListSelection::unSelect() 186void PlayListSelection::unSelect()
186{ 187{
187 QListViewItem *item = selectedItem(); 188 QListViewItem *item = selectedItem();
188 setSelected( currentItem(), FALSE); 189 setSelected( currentItem(), FALSE);
189} 190}
190 191
191void PlayListSelection::writeCurrent( Config& cfg ) { 192void PlayListSelection::writeCurrent( Config& cfg ) {
192 cfg.setGroup("PlayList"); 193 cfg.setGroup("PlayList");
193 QListViewItem *item = selectedItem(); 194 QListViewItem *item = selectedItem();
194 if ( item ) 195 if ( item )
195 cfg.writeEntry("current", item->text(0) ); 196 cfg.writeEntry("current", item->text(0) );
196 qDebug(item->text(0)); 197 qDebug(item->text(0));
197 198
198} 199}
199 200
200void PlayListSelection::setSelectedItem(const QString &strk ) { 201void PlayListSelection::setSelectedItem(const QString &strk ) {
201 202
202 unSelect(); 203 unSelect();
203 QListViewItemIterator it( this ); 204 QListViewItemIterator it( this );
204 for ( ; it.current(); ++it ) { 205 for ( ; it.current(); ++it ) {
205// qDebug( it.current()->text(0)); 206// qDebug( it.current()->text(0));
206 if( strk == it.current()->text(0)) { 207 if( strk == it.current()->text(0)) {
207// qDebug( "We have a match "+strk); 208// qDebug( "We have a match "+strk);
208 setSelected( it.current(), TRUE); 209 setSelected( it.current(), TRUE);
209 ensureItemVisible( it.current() ); 210 ensureItemVisible( it.current() );
210 return; 211 return;
211 } 212 }
212 } 213 }
213// setSelected( item, TRUE ); 214// setSelected( item, TRUE );
214// ensureItemVisible( selectedItem() ); 215// ensureItemVisible( selectedItem() );
215} 216}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 395037f..19c8056 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -70,438 +70,445 @@
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86static inline QString fullBaseName ( const QFileInfo &fi ) 86static inline QString fullBaseName ( const QFileInfo &fi )
87{ 87{
88 QString str = fi. fileName ( ); 88 QString str = fi. fileName ( );
89 return str. left ( str. findRev ( '.' )); 89 return str. left ( str. findRev ( '.' ));
90} 90}
91 91
92 92
93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
94// class myFileSelector { 94// class myFileSelector {
95 95
96// }; 96// };
97class PlayListWidgetPrivate { 97class PlayListWidgetPrivate {
98public: 98public:
99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
100 QFrame *playListFrame; 100 QFrame *playListFrame;
101 FileSelector *files; 101 FileSelector *files;
102 PlayListSelection *selectedFiles; 102 PlayListSelection *selectedFiles;
103 bool setDocumentUsed; 103 bool setDocumentUsed;
104 DocLnk *current; 104 DocLnk *current;
105}; 105};
106 106
107 107
108class ToolButton : public QToolButton { 108class ToolButton : public QToolButton {
109public: 109public:
110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
111 : QToolButton( parent, name ) { 111 : QToolButton( parent, name ) {
112 setTextLabel( name ); 112 setTextLabel( name );
113 setPixmap( Resource::loadPixmap( icon ) ); 113 setPixmap( Resource::loadPixmap( icon ) );
114 setAutoRaise( TRUE ); 114 setAutoRaise( TRUE );
115 setFocusPolicy( QWidget::NoFocus ); 115 setFocusPolicy( QWidget::NoFocus );
116 setToggleButton( t ); 116 setToggleButton( t );
117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
118 QPEMenuToolFocusManager::manager()->addWidget( this ); 118 QPEMenuToolFocusManager::manager()->addWidget( this );
119 } 119 }
120}; 120};
121 121
122 122
123class MenuItem : public QAction { 123class MenuItem : public QAction {
124public: 124public:
125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
126 : QAction( text, QString::null, 0, 0 ) { 126 : QAction( text, QString::null, 0, 0 ) {
127 connect( this, SIGNAL( activated() ), handler, slot ); 127 connect( this, SIGNAL( activated() ), handler, slot );
128 addTo( parent ); 128 addTo( parent );
129 } 129 }
130}; 130};
131 131
132 132
133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
134 : QMainWindow( parent, name, fl ) { 134 : QMainWindow( parent, name, fl ) {
135 135
136 d = new PlayListWidgetPrivate; 136 d = new PlayListWidgetPrivate;
137 d->setDocumentUsed = FALSE; 137 d->setDocumentUsed = FALSE;
138 d->current = NULL; 138 d->current = NULL;
139 fromSetDocument = FALSE; 139 fromSetDocument = FALSE;
140 insanityBool=FALSE; 140 insanityBool=FALSE;
141 audioScan = FALSE; 141 audioScan = FALSE;
142 videoScan = FALSE; 142 videoScan = FALSE;
143// menuTimer = new QTimer( this ,"menu timer"), 143// menuTimer = new QTimer( this ,"menu timer"),
144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
145 145
146 setBackgroundMode( PaletteButton ); 146 setBackgroundMode( PaletteButton );
147 147
148 setCaption( tr("OpiePlayer") ); 148 setCaption( tr("OpiePlayer") );
149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
150 150
151 setToolBarsMovable( FALSE ); 151 setToolBarsMovable( FALSE );
152 152
153 // Create Toolbar 153 // Create Toolbar
154 QPEToolBar *toolbar = new QPEToolBar( this ); 154 QPEToolBar *toolbar = new QPEToolBar( this );
155 toolbar->setHorizontalStretchable( TRUE ); 155 toolbar->setHorizontalStretchable( TRUE );
156 156
157 // Create Menubar 157 // Create Menubar
158 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 158 QPEMenuBar *menu = new QPEMenuBar( toolbar );
159 menu->setMargin( 0 ); 159 menu->setMargin( 0 );
160 160
161 QPEToolBar *bar = new QPEToolBar( this ); 161 QPEToolBar *bar = new QPEToolBar( this );
162 bar->setLabel( tr( "Play Operations" ) ); 162 bar->setLabel( tr( "Play Operations" ) );
163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
164// this , SLOT( addSelected()) ); 164// this , SLOT( addSelected()) );
165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
166 tbDeletePlaylist->setFlat(TRUE); 166 tbDeletePlaylist->setFlat(TRUE);
167 tbDeletePlaylist->setFixedSize(20,20); 167 tbDeletePlaylist->setFixedSize(20,20);
168 168
169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
170 this , SLOT(addSelected()) ); 170 this , SLOT(addSelected()) );
171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
172 this , SLOT(removeSelected()) ); 172 this , SLOT(removeSelected()) );
173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
174 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 174 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
175 this , SLOT( btnPlay(bool) ), TRUE ); 175 this , SLOT( btnPlay(bool) ), TRUE );
176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
179 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 179 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
180 tbDeletePlaylist->hide(); 180 tbDeletePlaylist->hide();
181 181
182 QPopupMenu *pmPlayList = new QPopupMenu( this ); 182 QPopupMenu *pmPlayList = new QPopupMenu( this );
183 menu->insertItem( tr( "File" ), pmPlayList ); 183 menu->insertItem( tr( "File" ), pmPlayList );
184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
188 pmPlayList->insertSeparator(-1); 188 pmPlayList->insertSeparator(-1);
189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
191 pmPlayList->insertSeparator(-1); 191 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
194 194
195 QPopupMenu *pmView = new QPopupMenu( this ); 195 QPopupMenu *pmView = new QPopupMenu( this );
196 menu->insertItem( tr( "View" ), pmView ); 196 menu->insertItem( tr( "View" ), pmView );
197 197
198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
199 fullScreenButton->addTo(pmView); 199 fullScreenButton->addTo(pmView);
200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
201 scaleButton->addTo(pmView); 201 scaleButton->addTo(pmView);
202 202
203 203
204 skinsMenu = new QPopupMenu( this ); 204 skinsMenu = new QPopupMenu( this );
205 menu->insertItem( tr( "Skins" ), skinsMenu ); 205 menu->insertItem( tr( "Skins" ), skinsMenu );
206 skinsMenu->isCheckable(); 206 skinsMenu->isCheckable();
207 connect( skinsMenu, SIGNAL( activated( int ) ) , 207 connect( skinsMenu, SIGNAL( activated( int ) ) ,
208 this, SLOT( skinsMenuActivated( int ) ) ); 208 this, SLOT( skinsMenuActivated( int ) ) );
209 populateSkinsMenu(); 209 populateSkinsMenu();
210 210
211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
213 213
214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
215 215
216 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 216 tabWidget = new QTabWidget( hbox6, "tabWidget" );
217 tabWidget->setTabShape(QTabWidget::Triangular); 217 tabWidget->setTabShape(QTabWidget::Triangular);
218 218
219 QWidget *pTab; 219 QWidget *pTab;
220 pTab = new QWidget( tabWidget, "pTab" ); 220 pTab = new QWidget( tabWidget, "pTab" );
221// playlistView = new QListView( pTab, "playlistview" ); 221// playlistView = new QListView( pTab, "playlistview" );
222// playlistView->setMinimumSize(236,260); 222// playlistView->setMinimumSize(236,260);
223 tabWidget->insertTab( pTab,"Playlist"); 223 tabWidget->insertTab( pTab,"Playlist");
224 224
225 225
226 // Add the playlist area 226 // Add the playlist area
227 227
228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
229 d->playListFrame = vbox3; 229 d->playListFrame = vbox3;
230 d->playListFrame ->setMinimumSize(235,260); 230 d->playListFrame ->setMinimumSize(235,260);
231 231
232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
233 233
234 d->selectedFiles = new PlayListSelection( hbox2); 234 d->selectedFiles = new PlayListSelection( hbox2);
235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
236 236
237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
238 238
239 239
240 240
241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
246 246
247 QWidget *aTab; 247 QWidget *aTab;
248 aTab = new QWidget( tabWidget, "aTab" ); 248 aTab = new QWidget( tabWidget, "aTab" );
249 audioView = new QListView( aTab, "Audioview" ); 249 audioView = new QListView( aTab, "Audioview" );
250 audioView->setMinimumSize(233,260); 250 audioView->setMinimumSize(233,260);
251 audioView->addColumn( tr("Title"),140); 251 audioView->addColumn( tr("Title"),140);
252 audioView->addColumn(tr("Size"), -1); 252 audioView->addColumn(tr("Size"), -1);
253 audioView->addColumn(tr("Media"),-1); 253 audioView->addColumn(tr("Media"),-1);
254 audioView->addColumn( tr( "Path" ), 0 ); 254 audioView->addColumn( tr( "Path" ), 0 );
255 255
256 audioView->setColumnAlignment(1, Qt::AlignRight); 256 audioView->setColumnAlignment(1, Qt::AlignRight);
257 audioView->setColumnAlignment(2, Qt::AlignRight); 257 audioView->setColumnAlignment(2, Qt::AlignRight);
258 audioView->setAllColumnsShowFocus(TRUE); 258 audioView->setAllColumnsShowFocus(TRUE);
259 259
260 audioView->setMultiSelection( TRUE ); 260 audioView->setMultiSelection( TRUE );
261 audioView->setSelectionMode( QListView::Extended); 261 audioView->setSelectionMode( QListView::Extended);
262 audioView->setSorting( 3, TRUE );
262 263
263 tabWidget->insertTab(aTab,tr("Audio")); 264 tabWidget->insertTab(aTab,tr("Audio"));
264 265
265 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 266 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
266 267
267// audioView 268// audioView
268// populateAudioView(); 269// populateAudioView();
269// videowidget 270// videowidget
270 271
271 QWidget *vTab; 272 QWidget *vTab;
272 vTab = new QWidget( tabWidget, "vTab" ); 273 vTab = new QWidget( tabWidget, "vTab" );
273 videoView = new QListView( vTab, "Videoview" ); 274 videoView = new QListView( vTab, "Videoview" );
274 videoView->setMinimumSize(233,260); 275 videoView->setMinimumSize(233,260);
275 276
276 videoView->addColumn(tr("Title"),140); 277 videoView->addColumn(tr("Title"),140);
277 videoView->addColumn(tr("Size"),-1); 278 videoView->addColumn(tr("Size"),-1);
278 videoView->addColumn(tr("Media"),-1); 279 videoView->addColumn(tr("Media"),-1);
279 videoView->addColumn(tr( "Path" ), 0 ); 280 videoView->addColumn(tr( "Path" ), 0 );
280 videoView->setColumnAlignment(1, Qt::AlignRight); 281 videoView->setColumnAlignment(1, Qt::AlignRight);
281 videoView->setColumnAlignment(2, Qt::AlignRight); 282 videoView->setColumnAlignment(2, Qt::AlignRight);
282 videoView->setAllColumnsShowFocus(TRUE); 283 videoView->setAllColumnsShowFocus(TRUE);
283 videoView->setMultiSelection( TRUE ); 284 videoView->setMultiSelection( TRUE );
284 videoView->setSelectionMode( QListView::Extended); 285 videoView->setSelectionMode( QListView::Extended);
285 286
286 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
287 288
288 tabWidget->insertTab( vTab,tr("Video")); 289 tabWidget->insertTab( vTab,tr("Video"));
289 290
290 QWidget *LTab; 291 QWidget *LTab;
291 LTab = new QWidget( tabWidget, "LTab" ); 292 LTab = new QWidget( tabWidget, "LTab" );
292 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 293 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
293 playLists->setMinimumSize(233,260); 294 playLists->setMinimumSize(233,260);
294 tabWidget->insertTab(LTab,tr("Lists")); 295 tabWidget->insertTab(LTab,tr("Lists"));
295 296
296 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 297 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
297 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 298 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
298 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 299 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
299 300
300 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 301 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
301 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 302 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
302 303
304
305///audioView
303 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 306 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
304 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
305 308
306 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 309 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
307 this,SLOT( playIt( QListViewItem *)) ); 310 this,SLOT( playIt( QListViewItem *)) );
308 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 311 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
309 312
313
314//videoView
310 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 315 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
311 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 316 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
312 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 317 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
313 this,SLOT( playIt( QListViewItem *)) ); 318 this,SLOT( playIt( QListViewItem *)) );
314 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 319 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
315 320
321
322//playlists
316 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 323 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
317 324
318 325
319 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 326 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
320 327
321// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 328// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
322 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 329 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
323 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 330 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
324 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 331 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
325 332
326 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 333 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
327 334
328 setCentralWidget( vbox5 ); 335 setCentralWidget( vbox5 );
329 336
330 Config cfg( "OpiePlayer" ); 337 Config cfg( "OpiePlayer" );
331 readConfig( cfg ); 338 readConfig( cfg );
332 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 339 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
333 loadList(DocLnk( currentPlaylist)); 340 loadList(DocLnk( currentPlaylist));
334 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); 341 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
335 342
336 initializeStates(); 343 initializeStates();
337} 344}
338 345
339 346
340PlayListWidget::~PlayListWidget() { 347PlayListWidget::~PlayListWidget() {
341 Config cfg( "OpiePlayer" ); 348 Config cfg( "OpiePlayer" );
342 writeConfig( cfg ); 349 writeConfig( cfg );
343 350
344 if ( d->current ) 351 if ( d->current )
345 delete d->current; 352 delete d->current;
346 delete d; 353 delete d;
347} 354}
348 355
349 356
350void PlayListWidget::initializeStates() { 357void PlayListWidget::initializeStates() {
351 358
352 d->tbPlay->setOn( mediaPlayerState->playing() ); 359 d->tbPlay->setOn( mediaPlayerState->playing() );
353 d->tbLoop->setOn( mediaPlayerState->looping() ); 360 d->tbLoop->setOn( mediaPlayerState->looping() );
354 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 361 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
355 setPlaylist( true); 362 setPlaylist( true);
356} 363}
357 364
358 365
359void PlayListWidget::readConfig( Config& cfg ) { 366void PlayListWidget::readConfig( Config& cfg ) {
360 cfg.setGroup("PlayList"); 367 cfg.setGroup("PlayList");
361 QString currentString = cfg.readEntry("current", "" ); 368 QString currentString = cfg.readEntry("current", "" );
362 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 369 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
363 for ( int i = 0; i < noOfFiles; i++ ) { 370 for ( int i = 0; i < noOfFiles; i++ ) {
364 QString entryName; 371 QString entryName;
365 entryName.sprintf( "File%i", i + 1 ); 372 entryName.sprintf( "File%i", i + 1 );
366 QString linkFile = cfg.readEntry( entryName ); 373 QString linkFile = cfg.readEntry( entryName );
367 DocLnk lnk( linkFile ); 374 DocLnk lnk( linkFile );
368 if ( lnk.isValid() ) { 375 if ( lnk.isValid() ) {
369 d->selectedFiles->addToSelection( lnk ); 376 d->selectedFiles->addToSelection( lnk );
370 } 377 }
371 } 378 }
372 d->selectedFiles->setSelectedItem( currentString); 379 d->selectedFiles->setSelectedItem( currentString);
373} 380}
374 381
375 382
376void PlayListWidget::writeConfig( Config& cfg ) const { 383void PlayListWidget::writeConfig( Config& cfg ) const {
377 384
378 d->selectedFiles->writeCurrent( cfg); 385 d->selectedFiles->writeCurrent( cfg);
379 cfg.setGroup("PlayList"); 386 cfg.setGroup("PlayList");
380 int noOfFiles = 0; 387 int noOfFiles = 0;
381 d->selectedFiles->first(); 388 d->selectedFiles->first();
382 do { 389 do {
383 const DocLnk *lnk = d->selectedFiles->current(); 390 const DocLnk *lnk = d->selectedFiles->current();
384 if ( lnk ) { 391 if ( lnk ) {
385 QString entryName; 392 QString entryName;
386 entryName.sprintf( "File%i", noOfFiles + 1 ); 393 entryName.sprintf( "File%i", noOfFiles + 1 );
387// qDebug(entryName); 394// qDebug(entryName);
388 cfg.writeEntry( entryName, lnk->linkFile() ); 395 cfg.writeEntry( entryName, lnk->linkFile() );
389 // if this link does exist, add it so we have the file 396 // if this link does exist, add it so we have the file
390 // next time... 397 // next time...
391 if ( !QFile::exists( lnk->linkFile() ) ) { 398 if ( !QFile::exists( lnk->linkFile() ) ) {
392 // the way writing lnks doesn't really check for out 399 // the way writing lnks doesn't really check for out
393 // of disk space, but check it anyway. 400 // of disk space, but check it anyway.
394 if ( !lnk->writeLink() ) { 401 if ( !lnk->writeLink() ) {
395 QMessageBox::critical( 0, tr("Out of space"), 402 QMessageBox::critical( 0, tr("Out of space"),
396 tr( "There was a problem saving " 403 tr( "There was a problem saving "
397 "the playlist.\n" 404 "the playlist.\n"
398 "Your playlist " 405 "Your playlist "
399 "may be missing some entries\n" 406 "may be missing some entries\n"
400 "the next time you start it." ) 407 "the next time you start it." )
401 ); 408 );
402 } 409 }
403 } 410 }
404 noOfFiles++; 411 noOfFiles++;
405 } 412 }
406 } 413 }
407 while ( d->selectedFiles->next() ); 414 while ( d->selectedFiles->next() );
408 cfg.writeEntry("NumberOfFiles", noOfFiles ); 415 cfg.writeEntry("NumberOfFiles", noOfFiles );
409} 416}
410 417
411 418
412void PlayListWidget::addToSelection( const DocLnk& lnk ) { 419void PlayListWidget::addToSelection( const DocLnk& lnk ) {
413 d->setDocumentUsed = false; 420 d->setDocumentUsed = false;
414 if ( mediaPlayerState->playlist() ) { 421 if ( mediaPlayerState->playlist() ) {
415 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 422 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
416 d->selectedFiles->addToSelection( lnk ); 423 d->selectedFiles->addToSelection( lnk );
417 } 424 }
418 else 425 else
419 mediaPlayerState->setPlaying( true); 426 mediaPlayerState->setPlaying( true);
420} 427}
421 428
422 429
423void PlayListWidget::clearList() { 430void PlayListWidget::clearList() {
424 while ( first() ) 431 while ( first() )
425 d->selectedFiles->removeSelected(); 432 d->selectedFiles->removeSelected();
426} 433}
427 434
428 435
429void PlayListWidget::addAllToList() { 436void PlayListWidget::addAllToList() {
430 DocLnkSet filesAll; 437 DocLnkSet filesAll;
431 Global::findDocuments(&filesAll, "video/*;audio/*"); 438 Global::findDocuments(&filesAll, "video/*;audio/*");
432 QListIterator<DocLnk> Adit( filesAll.children() ); 439 QListIterator<DocLnk> Adit( filesAll.children() );
433 for ( ; Adit.current(); ++Adit ) 440 for ( ; Adit.current(); ++Adit )
434 if(QFileInfo(Adit.current()->file()).exists()) 441 if(QFileInfo(Adit.current()->file()).exists())
435 d->selectedFiles->addToSelection( **Adit ); 442 d->selectedFiles->addToSelection( **Adit );
436 tabWidget->setCurrentPage(0); 443 tabWidget->setCurrentPage(0);
437 444
438 writeCurrentM3u(); 445 writeCurrentM3u();
439 d->selectedFiles->first(); 446 d->selectedFiles->first();
440} 447}
441 448
442 449
443void PlayListWidget::addAllMusicToList() { 450void PlayListWidget::addAllMusicToList() {
444 QListIterator<DocLnk> dit( files.children() ); 451 QListIterator<DocLnk> dit( files.children() );
445 for ( ; dit.current(); ++dit ) 452 for ( ; dit.current(); ++dit )
446 if(QFileInfo(dit.current()->file()).exists()) 453 if(QFileInfo(dit.current()->file()).exists())
447 d->selectedFiles->addToSelection( **dit ); 454 d->selectedFiles->addToSelection( **dit );
448 tabWidget->setCurrentPage(0); 455 tabWidget->setCurrentPage(0);
449 456
450 writeCurrentM3u(); 457 writeCurrentM3u();
451 d->selectedFiles->first(); 458 d->selectedFiles->first();
452} 459}
453 460
454 461
455void PlayListWidget::addAllVideoToList() { 462void PlayListWidget::addAllVideoToList() {
456 QListIterator<DocLnk> dit( vFiles.children() ); 463 QListIterator<DocLnk> dit( vFiles.children() );
457 for ( ; dit.current(); ++dit ) 464 for ( ; dit.current(); ++dit )
458 if(QFileInfo( dit.current()->file()).exists()) 465 if(QFileInfo( dit.current()->file()).exists())
459 d->selectedFiles->addToSelection( **dit ); 466 d->selectedFiles->addToSelection( **dit );
460 tabWidget->setCurrentPage(0); 467 tabWidget->setCurrentPage(0);
461 468
462 writeCurrentM3u(); 469 writeCurrentM3u();
463 d->selectedFiles->first(); 470 d->selectedFiles->first();
464} 471}
465 472
466 473
467void PlayListWidget::setDocument(const QString& fileref) { 474void PlayListWidget::setDocument(const QString& fileref) {
468 qDebug(fileref); 475 qDebug(fileref);
469 fromSetDocument = TRUE; 476 fromSetDocument = TRUE;
470 QFileInfo fileInfo(fileref); 477 QFileInfo fileInfo(fileref);
471 if ( !fileInfo.exists() ) { 478 if ( !fileInfo.exists() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ), 479 QMessageBox::critical( 0, tr( "Invalid File" ),
473 tr( "There was a problem in getting the file." ) ); 480 tr( "There was a problem in getting the file." ) );
474 return; 481 return;
475 } 482 }
476// qDebug("setDocument "+fileref); 483// qDebug("setDocument "+fileref);
477 QString extension = fileInfo.extension(false); 484 QString extension = fileInfo.extension(false);
478 if( extension.find( "m3u", 0, false) != -1) { //is m3u 485 if( extension.find( "m3u", 0, false) != -1) { //is m3u
479 readm3u( fileref); 486 readm3u( fileref);
480 } 487 }
481 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 488 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
482 readPls( fileref); 489 readPls( fileref);
483 } 490 }
484 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 491 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
485 clearList(); 492 clearList();
486 DocLnk lnk; 493 DocLnk lnk;
487 lnk.setName( fileInfo.baseName() ); //sets name 494 lnk.setName( fileInfo.baseName() ); //sets name
488 lnk.setFile( fileref ); //sets file name 495 lnk.setFile( fileref ); //sets file name
489 //addToSelection( lnk ); 496 //addToSelection( lnk );
490 497
491 loadList( lnk); 498 loadList( lnk);
492 d->selectedFiles->first(); 499 d->selectedFiles->first();
493 } else { 500 } else {
494 clearList(); 501 clearList();
495 DocLnk lnk; 502 DocLnk lnk;
496 lnk.setName( fileInfo.baseName() ); //sets name 503 lnk.setName( fileInfo.baseName() ); //sets name
497 lnk.setFile( fileref ); //sets file name 504 lnk.setFile( fileref ); //sets file name
498 addToSelection( lnk ); 505 addToSelection( lnk );
499// addToSelection( DocLnk( fileref ) ); 506// addToSelection( DocLnk( fileref ) );
500 d->setDocumentUsed = TRUE; 507 d->setDocumentUsed = TRUE;
501 mediaPlayerState->setPlaying( FALSE ); 508 mediaPlayerState->setPlaying( FALSE );
502 qApp->processEvents(); 509 qApp->processEvents();
503 mediaPlayerState->setPlaying( TRUE ); 510 mediaPlayerState->setPlaying( TRUE );
504 qApp->processEvents(); 511 qApp->processEvents();
505 setCaption(tr("OpiePlayer")); 512 setCaption(tr("OpiePlayer"));
506 } 513 }
507} 514}
@@ -618,402 +625,403 @@ bool PlayListWidget::next() {
618 } else { 625 } else {
619 if ( !d->selectedFiles->next() ) { 626 if ( !d->selectedFiles->next() ) {
620 if ( mediaPlayerState->looping() ) { 627 if ( mediaPlayerState->looping() ) {
621 return d->selectedFiles->first(); 628 return d->selectedFiles->first();
622 } else { 629 } else {
623 return FALSE; 630 return FALSE;
624 } 631 }
625 } 632 }
626 return TRUE; 633 return TRUE;
627 } 634 }
628 } else { 635 } else {
629 return mediaPlayerState->looping(); 636 return mediaPlayerState->looping();
630 } 637 }
631} 638}
632 639
633 640
634bool PlayListWidget::first() { 641bool PlayListWidget::first() {
635 if ( mediaPlayerState->playlist() ) 642 if ( mediaPlayerState->playlist() )
636 return d->selectedFiles->first(); 643 return d->selectedFiles->first();
637 else 644 else
638 return mediaPlayerState->looping(); 645 return mediaPlayerState->looping();
639} 646}
640 647
641 648
642bool PlayListWidget::last() { 649bool PlayListWidget::last() {
643 if ( mediaPlayerState->playlist() ) 650 if ( mediaPlayerState->playlist() )
644 return d->selectedFiles->last(); 651 return d->selectedFiles->last();
645 else 652 else
646 return mediaPlayerState->looping(); 653 return mediaPlayerState->looping();
647} 654}
648 655
649 656
650void PlayListWidget::saveList() { 657void PlayListWidget::saveList() {
651 writem3u(); 658 writem3u();
652} 659}
653 660
654void PlayListWidget::loadList( const DocLnk & lnk) { 661void PlayListWidget::loadList( const DocLnk & lnk) {
655 QString name = lnk.name(); 662 QString name = lnk.name();
656// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
657 664
658 if( name.length()>0) { 665 if( name.length()>0) {
659 setCaption("OpiePlayer: "+name); 666 setCaption("OpiePlayer: "+name);
660// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 667// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
661 clearList(); 668 clearList();
662 readm3u(lnk.file()); 669 readm3u(lnk.file());
663 tabWidget->setCurrentPage(0); 670 tabWidget->setCurrentPage(0);
664 } 671 }
665} 672}
666 673
667void PlayListWidget::setPlaylist( bool shown ) { 674void PlayListWidget::setPlaylist( bool shown ) {
668 if ( shown ) 675 if ( shown )
669 d->playListFrame->show(); 676 d->playListFrame->show();
670 else 677 else
671 d->playListFrame->hide(); 678 d->playListFrame->hide();
672} 679}
673 680
674void PlayListWidget::setView( char view ) { 681void PlayListWidget::setView( char view ) {
675 if ( view == 'l' ) 682 if ( view == 'l' )
676 showMaximized(); 683 showMaximized();
677 else 684 else
678 hide(); 685 hide();
679} 686}
680 687
681void PlayListWidget::addSelected() { 688void PlayListWidget::addSelected() {
682 qDebug("addSelected"); 689 qDebug("addSelected");
683 DocLnk lnk; 690 DocLnk lnk;
684 QString filename; 691 QString filename;
685 switch (tabWidget->currentPageIndex()) { 692 switch (tabWidget->currentPageIndex()) {
686 693
687 case 0: //playlist 694 case 0: //playlist
688 return; 695 return;
689 break; 696 break;
690 case 1: { //audio 697 case 1: { //audio
691 filename=audioView->currentItem()->text(3); 698 filename=audioView->currentItem()->text(3);
692 // d->selectedFiles->next(); 699 // d->selectedFiles->next();
693 } 700 }
694 break; 701 break;
695 702
696 case 2: { // video 703 case 2: { // video
697 filename=videoView->currentItem()->text(3); 704 filename=videoView->currentItem()->text(3);
698 // tabWidget->setCurrentPage(0); 705 // tabWidget->setCurrentPage(0);
699 706
700 } 707 }
701 break; 708 break;
702 }; 709 };
703 lnk.setName( fullBaseName ( QFileInfo(filename))); //sets name 710 lnk.setName( fullBaseName ( QFileInfo(filename))); //sets name
704 lnk.setFile( filename ); //sets file name 711 lnk.setFile( filename ); //sets file name
705 d->selectedFiles->addToSelection( lnk); 712 d->selectedFiles->addToSelection( lnk);
706 tabWidget->setCurrentPage(0); 713 tabWidget->setCurrentPage(0);
707 writeCurrentM3u(); 714 writeCurrentM3u();
708 715
709} 716}
710 717
711void PlayListWidget::removeSelected() { 718void PlayListWidget::removeSelected() {
712 d->selectedFiles->removeSelected( ); 719 d->selectedFiles->removeSelected( );
713} 720}
714 721
715void PlayListWidget::playIt( QListViewItem *) { 722void PlayListWidget::playIt( QListViewItem *) {
716// d->setDocumentUsed = FALSE; 723// d->setDocumentUsed = FALSE;
717// mediaPlayerState->curPosition =0; 724// mediaPlayerState->curPosition =0;
718 qDebug("playIt"); 725 qDebug("playIt");
719 mediaPlayerState->setPlaying(FALSE); 726 mediaPlayerState->setPlaying(FALSE);
720 mediaPlayerState->setPlaying(TRUE); 727 mediaPlayerState->setPlaying(TRUE);
721 d->selectedFiles->unSelect(); 728 d->selectedFiles->unSelect();
722} 729}
723 730
724void PlayListWidget::addToSelection( QListViewItem *it) { 731void PlayListWidget::addToSelection( QListViewItem *it) {
725 d->setDocumentUsed = FALSE; 732 d->setDocumentUsed = FALSE;
726 733
727 if(it) { 734 if(it) {
728 switch ( tabWidget->currentPageIndex()) { 735 switch ( tabWidget->currentPageIndex()) {
729 case 0: //playlist 736 case 0: //playlist
730 return; 737 return;
731 break; 738 break;
732 }; 739 };
733 // case 1: { 740 // case 1: {
734 DocLnk lnk; 741 DocLnk lnk;
735 QString filename; 742 QString filename;
736 743
737 filename=it->text(3); 744 filename=it->text(3);
738 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 745 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
739 lnk.setFile( filename ); //sets file name 746 lnk.setFile( filename ); //sets file name
740 d->selectedFiles->addToSelection( lnk); 747 d->selectedFiles->addToSelection( lnk);
741 748
742 writeCurrentM3u(); 749 writeCurrentM3u();
743 tabWidget->setCurrentPage(0); 750 tabWidget->setCurrentPage(0);
744 751
745 } 752 }
746} 753}
747 754
748void PlayListWidget::tabChanged(QWidget *) { 755void PlayListWidget::tabChanged(QWidget *) {
749 756
750 switch ( tabWidget->currentPageIndex()) { 757 switch ( tabWidget->currentPageIndex()) {
751 case 0: 758 case 0:
752 { 759 {
753 if( !tbDeletePlaylist->isHidden()) 760 if( !tbDeletePlaylist->isHidden())
754 tbDeletePlaylist->hide(); 761 tbDeletePlaylist->hide();
755 d->tbRemoveFromList->setEnabled(TRUE); 762 d->tbRemoveFromList->setEnabled(TRUE);
756 d->tbAddToList->setEnabled(FALSE); 763 d->tbAddToList->setEnabled(FALSE);
757 } 764 }
758 break; 765 break;
759 case 1: 766 case 1:
760 { 767 {
761 audioView->clear(); 768 audioView->clear();
762 populateAudioView(); 769 populateAudioView();
763 770
764 if( !tbDeletePlaylist->isHidden()) 771 if( !tbDeletePlaylist->isHidden())
765 tbDeletePlaylist->hide(); 772 tbDeletePlaylist->hide();
766 d->tbRemoveFromList->setEnabled(FALSE); 773 d->tbRemoveFromList->setEnabled(FALSE);
767 d->tbAddToList->setEnabled(TRUE); 774 d->tbAddToList->setEnabled(TRUE);
768 } 775 }
769 break; 776 break;
770 case 2: 777 case 2:
771 { 778 {
772 videoView->clear(); 779 videoView->clear();
773 populateVideoView(); 780 populateVideoView();
774 if( !tbDeletePlaylist->isHidden()) 781 if( !tbDeletePlaylist->isHidden())
775 tbDeletePlaylist->hide(); 782 tbDeletePlaylist->hide();
776 d->tbRemoveFromList->setEnabled(FALSE); 783 d->tbRemoveFromList->setEnabled(FALSE);
777 d->tbAddToList->setEnabled(TRUE); 784 d->tbAddToList->setEnabled(TRUE);
778 } 785 }
779 break; 786 break;
780 case 3: 787 case 3:
781 { 788 {
782 if( tbDeletePlaylist->isHidden()) 789 if( tbDeletePlaylist->isHidden())
783 tbDeletePlaylist->show(); 790 tbDeletePlaylist->show();
784 playLists->reread(); 791 playLists->reread();
785 } 792 }
786 break; 793 break;
787 }; 794 };
788} 795}
789 796
790void PlayListWidget::btnPlay(bool b) { 797void PlayListWidget::btnPlay(bool b) {
791 qDebug("<<<<<<<<<<<<<<<BtnPlay"); 798 qDebug("<<<<<<<<<<<<<<<BtnPlay");
792// mediaPlayerState->setPlaying(b); 799// mediaPlayerState->setPlaying(b);
793 switch ( tabWidget->currentPageIndex()) { 800 switch ( tabWidget->currentPageIndex()) {
794 case 0: 801 case 0:
795 { 802 {
796 qDebug("1"); 803 qDebug("1");
797// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 804// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
798// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 805// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
799// QMessageBox::message("Note","You are trying to play\na malformed url."); 806// QMessageBox::message("Note","You are trying to play\na malformed url.");
800// } else { 807// } else {
801 mediaPlayerState->setPlaying(b); 808 mediaPlayerState->setPlaying(b);
802 insanityBool=FALSE; 809 insanityBool=FALSE;
803 qDebug("insanity"); 810 qDebug("insanity");
804// } 811// }
805 } 812 }
806 break; 813 break;
807 case 1: 814 case 1:
808 { 815 {
809 qDebug("2"); 816 qDebug("2");
817// d->selectedFiles->unSelect();
810 addToSelection( audioView->currentItem() ); 818 addToSelection( audioView->currentItem() );
811 mediaPlayerState->setPlaying(b); 819 mediaPlayerState->setPlaying(true);
812 d->selectedFiles->removeSelected( ); 820 d->selectedFiles->removeSelected( );
813 tabWidget->setCurrentPage(1); 821 d->selectedFiles->unSelect();
814 d->selectedFiles->unSelect(); 822 tabWidget->setCurrentPage(1);
815 insanityBool=FALSE; 823 insanityBool=FALSE;
816 }// audioView->clearSelection(); 824 }// audioView->clearSelection();
817 break; 825 break;
818 case 2: 826 case 2:
819 { 827 {
820 qDebug("3"); 828 qDebug("3");
821 829
822 addToSelection( videoView->currentItem() ); 830 addToSelection( videoView->currentItem() );
823 mediaPlayerState->setPlaying(b); 831 mediaPlayerState->setPlaying(true);
824 qApp->processEvents(); 832// qApp->processEvents();
825 d->selectedFiles->removeSelected( ); 833 d->selectedFiles->removeSelected( );
826 tabWidget->setCurrentPage(2);
827 d->selectedFiles->unSelect(); 834 d->selectedFiles->unSelect();
835 tabWidget->setCurrentPage(2);
828 insanityBool=FALSE; 836 insanityBool=FALSE;
829 }// videoView->clearSelection(); 837 }// videoView->clearSelection();
830 break; 838 break;
831 }; 839 };
832 840
833} 841}
834 842
835void PlayListWidget::deletePlaylist() { 843void PlayListWidget::deletePlaylist() {
836 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 844 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
837 (tr("You really want to delete\nthis playlist?")), 845 (tr("You really want to delete\nthis playlist?")),
838 (tr("Yes")), (tr("No")), 0 )){ 846 (tr("Yes")), (tr("No")), 0 )){
839 case 0: // Yes clicked, 847 case 0: // Yes clicked,
840 QFile().remove(playLists->selectedDocument().file()); 848 QFile().remove(playLists->selectedDocument().file());
841 QFile().remove(playLists->selectedDocument().linkFile()); 849 QFile().remove(playLists->selectedDocument().linkFile());
842 playLists->reread(); 850 playLists->reread();
843 break; 851 break;
844 case 1: // Cancel 852 case 1: // Cancel
845 break; 853 break;
846 }; 854 };
847} 855}
848 856
849void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 857void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
850{ 858{
851 switch (mouse) { 859 switch (mouse) {
852 case 1: 860 case 1:
853 break; 861 break;
854 case 2:{ 862 case 2:{
855 863
856 QPopupMenu m; 864 QPopupMenu m;
857 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 865 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
858 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 866 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
859 m.insertSeparator(); 867 m.insertSeparator();
860 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 868 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
861 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 869 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
862 870
863 m.exec( QCursor::pos() ); 871 m.exec( QCursor::pos() );
864 } 872 }
865 break; 873 break;
866 }; 874 };
867} 875}
868 876
869void PlayListWidget::playSelected() 877void PlayListWidget::playSelected()
870{ 878{
871 qDebug("playSelected"); 879 qDebug("playSelected");
872 btnPlay( true); 880 btnPlay( true);
873// d->selectedFiles->unSelect(); 881// d->selectedFiles->unSelect();
874} 882}
875 883
876void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 884void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
877{ 885{
878 switch (mouse) { 886 switch (mouse) {
879 case 1: 887 case 1:
880 888
881 break; 889 break;
882 case 2:{ 890 case 2:{
883 QPopupMenu m; 891 QPopupMenu m;
884 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 892 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
885 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 893 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
886// m.insertSeparator(); 894// m.insertSeparator();
887// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 895// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
888 m.exec( QCursor::pos() ); 896 m.exec( QCursor::pos() );
889 } 897 }
890 break; 898 break;
891 }; 899 };
892 900
893} 901}
894 902
895void PlayListWidget::listDelete() { 903void PlayListWidget::listDelete() {
896 Config cfg( "OpiePlayer" ); 904 Config cfg( "OpiePlayer" );
897 cfg.setGroup("PlayList"); 905 cfg.setGroup("PlayList");
898 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 906 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
899 QString file; 907 QString file;
900// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 908// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
901 switch ( tabWidget->currentPageIndex()) { 909 switch ( tabWidget->currentPageIndex()) {
902 case 0: 910 case 0:
903 break; 911 break;
904 case 1: 912 case 1:
905 { 913 {
906 file = audioView->currentItem()->text(0); 914 file = audioView->currentItem()->text(0);
907 QListIterator<DocLnk> Pdit( files.children() ); 915 QListIterator<DocLnk> Pdit( files.children() );
908 for ( ; Pdit.current(); ++Pdit ) { 916 for ( ; Pdit.current(); ++Pdit ) {
909 if( Pdit.current()->name() == file) { 917 if( Pdit.current()->name() == file) {
910 LnkProperties prop( Pdit.current() ); 918 LnkProperties prop( Pdit.current() );
911 prop.showMaximized(); 919 prop.showMaximized();
912 prop.exec(); 920 prop.exec();
913 } 921 }
914 } 922 }
915 populateAudioView(); 923 populateAudioView();
916 } 924 }
917 break; 925 break;
918 case 2: 926 case 2:
919 { 927 {
920// file = videoView->selectedItem()->text(0); 928// file = videoView->selectedItem()->text(0);
921// for ( int i = 0; i < noOfFiles; i++ ) { 929// for ( int i = 0; i < noOfFiles; i++ ) {
922// QString entryName; 930// QString entryName;
923// entryName.sprintf( "File%i", i + 1 ); 931// entryName.sprintf( "File%i", i + 1 );
924// QString linkFile = cfg.readEntry( entryName ); 932// QString linkFile = cfg.readEntry( entryName );
925// AppLnk lnk( AppLnk(linkFile)); 933// AppLnk lnk( AppLnk(linkFile));
926// if( lnk.name() == file ) { 934// if( lnk.name() == file ) {
927// LnkProperties prop( &lnk); 935// LnkProperties prop( &lnk);
928// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 936// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
929// prop.showMaximized(); 937// prop.showMaximized();
930// prop.exec(); 938// prop.exec();
931// } 939// }
932// } 940// }
933 } 941 }
934 break; 942 break;
935 }; 943 };
936} 944}
937 945
938void PlayListWidget::scanForAudio() { 946void PlayListWidget::scanForAudio() {
939// qDebug("scan for audio"); 947// qDebug("scan for audio");
940 files.detachChildren(); 948 files.detachChildren();
941 QListIterator<DocLnk> sdit( files.children() ); 949 QListIterator<DocLnk> sdit( files.children() );
942 for ( ; sdit.current(); ++sdit ) { 950 for ( ; sdit.current(); ++sdit ) {
943 delete sdit.current(); 951 delete sdit.current();
944 } 952 }
945 Global::findDocuments( &files, audioMimes); 953 Global::findDocuments( &files, audioMimes);
946 audioScan = true; 954 audioScan = true;
947} 955}
948void PlayListWidget::scanForVideo() { 956void PlayListWidget::scanForVideo() {
949// qDebug("scan for video"); 957// qDebug("scan for video");
950 vFiles.detachChildren(); 958 vFiles.detachChildren();
951 QListIterator<DocLnk> sdit( vFiles.children() ); 959 QListIterator<DocLnk> sdit( vFiles.children() );
952 for ( ; sdit.current(); ++sdit ) { 960 for ( ; sdit.current(); ++sdit ) {
953 delete sdit.current(); 961 delete sdit.current();
954 } 962 }
955 Global::findDocuments(&vFiles, "video/*"); 963 Global::findDocuments(&vFiles, "video/*");
956 videoScan = true; 964 videoScan = true;
957} 965}
958 966
959void PlayListWidget::populateAudioView() { 967void PlayListWidget::populateAudioView() {
960 968
961 audioView->clear(); 969 audioView->clear();
962 StorageInfo storageInfo; 970 StorageInfo storageInfo;
963 const QList<FileSystem> &fs = storageInfo.fileSystems(); 971 const QList<FileSystem> &fs = storageInfo.fileSystems();
964 if(!audioScan) scanForAudio(); 972 if(!audioScan) scanForAudio();
965 973
966 QListIterator<DocLnk> dit( files.children() ); 974 QListIterator<DocLnk> dit( files.children() );
967 QListIterator<FileSystem> it ( fs ); 975 QListIterator<FileSystem> it ( fs );
968 976
969 QString storage; 977 QString storage;
970 for ( ; dit.current(); ++dit ) { 978 for ( ; dit.current(); ++dit ) {
971 for( ; it.current(); ++it ){ 979 for( ; it.current(); ++it ){
972 const QString name = (*it)->name(); 980 const QString name = (*it)->name();
973 const QString path = (*it)->path(); 981 const QString path = (*it)->path();
974 if(dit.current()->file().find(path) != -1 ) storage=name; 982 if(dit.current()->file().find(path) != -1 ) storage=name;
975 } 983 }
976 984
977 QListViewItem * newItem; 985 QListViewItem * newItem;
978 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 986 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
979 long size; 987 long size;
980 if( dit.current()->file().left(4) == "http" ) 988 if( dit.current()->file().left(4) == "http" )
981 size=0; 989 size=0;
982 else 990 else
983 size = QFile( dit.current()->file() ).size(); 991 size = QFile( dit.current()->file() ).size();
984// qDebug(dit.current()->name()); 992// qDebug(dit.current()->name());
985 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 993 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
986 QString::number(size ), storage, dit.current()->file()); 994 QString::number(size ), storage, dit.current()->file());
987 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 995 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
988 } 996 }
989 } 997 }
990 998
991} 999}
992 1000
993void PlayListWidget::populateVideoView() { 1001void PlayListWidget::populateVideoView() {
994 videoView->clear(); 1002 videoView->clear();
995 StorageInfo storageInfo; 1003 StorageInfo storageInfo;
996 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1004 const QList<FileSystem> &fs = storageInfo.fileSystems();
997 1005
998 if(!videoScan ) scanForVideo(); 1006 if(!videoScan ) scanForVideo();
999 1007
1000 QListIterator<DocLnk> Vdit( vFiles.children() ); 1008 QListIterator<DocLnk> Vdit( vFiles.children() );
1001 QListIterator<FileSystem> it ( fs ); 1009 QListIterator<FileSystem> it ( fs );
1002 videoView->clear(); 1010 videoView->clear();
1003 QString storage; 1011 QString storage;
1004 for ( ; Vdit.current(); ++Vdit ) { 1012 for ( ; Vdit.current(); ++Vdit ) {
1005 for( ; it.current(); ++it ){ 1013 for( ; it.current(); ++it ){
1006 const QString name = (*it)->name(); 1014 const QString name = (*it)->name();
1007 const QString path = (*it)->path(); 1015 const QString path = (*it)->path();
1008 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1016 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1009 } 1017 }
1010 1018
1011 QListViewItem * newItem; 1019 QListViewItem * newItem;
1012 if ( QFile( Vdit.current()->file()).exists() ) { 1020 if ( QFile( Vdit.current()->file()).exists() ) {
1013 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1021 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1014 QString::number( QFile( Vdit.current()->file() ).size() ), 1022 QString::number( QFile( Vdit.current()->file() ).size() ),
1015 storage, Vdit.current()->file()); 1023 storage, Vdit.current()->file());
1016 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1024 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1017 } 1025 }
1018 } 1026 }
1019} 1027}