summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro11
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp455
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h69
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp207
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h126
5 files changed, 507 insertions, 361 deletions
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index 3a47c06..a83a624 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,23 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2#CONFIG = qt warn_on release
3#CONFIG = qt warn_on debug 3CONFIG = qt warn_on debug
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ 5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ 6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \
7 frame.h lib.h xinevideowidget.h volumecontrol.h\ 7 frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\
8 alphablend.h yuv2rgb.h 8 alphablend.h yuv2rgb.h
9SOURCES = main.cpp \ 9SOURCES = main.cpp \
10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ 10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\
11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \
12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ 12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\
13 playlistwidgetgui.cpp\
13 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S 14 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S
14TARGET = opieplayer2 15TARGET = opieplayer2
15INCLUDEPATH += $(OPIEDIR)/include 16INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 17DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lqpe -lpthread -lopie -lxine -lxineutils 18LIBS += -lqpe -lpthread -lopie -lxine -lxineutils
18MOC_DIR=qpeobj 19MOC_DIR=qpeobj
19OBJECTS_DIR=qpeobj 20OBJECTS_DIR=qpeobj
20 21
21INCLUDEPATH += $(OPIEDIR)/include 22#INCLUDEPATH += $(OPIEDIR)/include
22DEPENDPATH += $(OPIEDIR)/include 23#DEPENDPATH += $(OPIEDIR)/include
23 24
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 098322b..6c7f6ba 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,375 +1,195 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#define QTOPIA_INTERNAL_FSLP
3#include <qpe/qpemenubar.h>
4#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
5#include <qpe/fileselector.h>
6#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
7#include <qpe/lnkproperties.h>
8#include <qpe/storage.h> 36#include <qpe/storage.h>
9#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
10
11#include <qpe/applnk.h>
12#include <qpopupmenu.h>
13#include <qpe/config.h>
14#include <qpe/global.h> 38#include <qpe/global.h>
15#include <qpe/resource.h> 39#include <qpe/resource.h>
16#include <qaction.h> 40
17#include <qcursor.h>
18#include <qimage.h>
19#include <qfile.h>
20#include <qdir.h> 41#include <qdir.h>
21#include <qlayout.h>
22#include <qlabel.h>
23#include <qlist.h>
24#include <qlistbox.h>
25#include <qmainwindow.h>
26#include <qmessagebox.h> 42#include <qmessagebox.h>
27#include <qtoolbutton.h>
28#include <qtabwidget.h>
29#include <qlistview.h>
30#include <qpoint.h>
31#include <qlineedit.h>
32#include <qpushbutton.h>
33#include <qregexp.h> 43#include <qregexp.h>
34#include <qtextstream.h> 44#include <qtextstream.h>
35 45
36
37#include "playlistselection.h" 46#include "playlistselection.h"
38#include "playlistwidget.h" 47#include "playlistwidget.h"
39#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
40
41#include "inputDialog.h" 49#include "inputDialog.h"
42 50
51//only needed for the random play
43#include <stdlib.h> 52#include <stdlib.h>
53
44#include "audiowidget.h" 54#include "audiowidget.h"
45#include "videowidget.h" 55#include "videowidget.h"
46 56
47#define BUTTONS_ON_TOOLBAR
48#define SIDE_BUTTONS
49#define CAN_SAVE_LOAD_PLAYLISTS
50
51extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
52 58
53 59
54class PlayListWidgetPrivate {
55public:
56 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
57 QFrame *playListFrame;
58 FileSelector *files;
59 PlayListSelection *selectedFiles;
60 bool setDocumentUsed;
61 DocLnk *current;
62};
63
64
65class ToolButton : public QToolButton {
66public:
67 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
68 : QToolButton( parent, name ) {
69 setTextLabel( name );
70 setPixmap( Resource::loadPixmap( icon ) );
71 setAutoRaise( TRUE );
72 setFocusPolicy( QWidget::NoFocus );
73 setToggleButton( t );
74 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
75 QPEMenuToolFocusManager::manager()->addWidget( this );
76 }
77};
78
79
80class MenuItem : public QAction {
81public:
82 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
83 : QAction( text, QString::null, 0, 0 ) {
84 connect( this, SIGNAL( activated() ), handler, slot );
85 addTo( parent );
86 }
87};
88
89
90PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
91 : QMainWindow( parent, name, fl ) { 61 : PlayListWidgetGui( parent, name, fl ) {
92
93 d = new PlayListWidgetPrivate;
94 d->setDocumentUsed = FALSE;
95 d->current = NULL;
96 fromSetDocument = FALSE;
97 insanityBool=FALSE;
98 audioScan = FALSE;
99 videoScan = FALSE;
100
101 setBackgroundMode( PaletteButton );
102
103// setCaption( tr("OpiePlayer") );
104// setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
105
106 setToolBarsMovable( FALSE );
107
108 // Create Toolbar
109 QPEToolBar *toolbar = new QPEToolBar( this );
110 toolbar->setHorizontalStretchable( TRUE );
111
112 // Create Menubar
113 QPEMenuBar *menu = new QPEMenuBar( toolbar );
114 menu->setMargin( 0 );
115
116 QPEToolBar *bar = new QPEToolBar( this );
117 bar->setLabel( tr( "Play Operations" ) );
118
119 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
120 tbDeletePlaylist->setFlat(TRUE);
121 tbDeletePlaylist->setFixedSize(20,20);
122 62
123 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
124 this , SLOT(addSelected()) ); 64 this , SLOT(addSelected()) );
125 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
126 this , SLOT(removeSelected()) ); 66 this , SLOT(removeSelected()) );
127 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
128 this , SLOT( btnPlay(bool) ), TRUE ); 68 this , SLOT( btnPlay(bool) ), TRUE );
129 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
130 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 70 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
131 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 71 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
132 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 72 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
133 tbDeletePlaylist->hide();
134 73
135 QPopupMenu *pmPlayList = new QPopupMenu( this );
136 menu->insertItem( tr( "File" ), pmPlayList );
137 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
138 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
139 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
140 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
141 pmPlayList->insertSeparator(-1); 78 pmPlayList->insertSeparator(-1);
142 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
143 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
144 pmPlayList->insertSeparator(-1); 81 pmPlayList->insertSeparator(-1);
145 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
146 pmPlayList->insertSeparator(-1); 83 pmPlayList->insertSeparator(-1);
147 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
148 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
149 86
150 pmView = new QPopupMenu( this );
151 menu->insertItem( tr( "View" ), pmView );
152 pmView->isCheckable();
153
154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
155 88
156 Config cfg( "OpiePlayer" ); 89 Config cfg( "OpiePlayer" );
157 bool b= cfg.readBoolEntry("FullScreen", 0); 90 bool b= cfg.readBoolEntry("FullScreen", 0);
158 mediaPlayerState->setFullscreen( b ); 91 mediaPlayerState->setFullscreen( b );
159 pmView->setItemChecked( -16, b ); 92 pmView->setItemChecked( -16, b );
160 93
161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
162
163 pmView->insertSeparator(-1);
164
165 skinsMenu = new QPopupMenu( this );
166 pmView->insertItem( tr( "Skins" ), skinsMenu );
167 skinsMenu->isCheckable();
168 populateSkinsMenu();
169
170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
172
173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
174
175 tabWidget = new QTabWidget( hbox6, "tabWidget" );
176 // tabWidget->setTabShape(QTabWidget::Triangular);
177
178 QWidget *pTab;
179 pTab = new QWidget( tabWidget, "pTab" );
180 tabWidget->insertTab( pTab,"Playlist");
181
182
183 QGridLayout *Playout = new QGridLayout( pTab );
184 Playout->setSpacing( 2);
185 Playout->setMargin( 2);
186
187 // Add the playlist area
188
189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
190 d->playListFrame = vbox3;
191
192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
193
194 d->selectedFiles = new PlayListSelection( hbox2);
195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
196
197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
198
199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
200 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
201 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
202 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 97 QVBox *stretch2 = new QVBox( vbox1 );
204
205
206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
207
208 QWidget *aTab;
209 aTab = new QWidget( tabWidget, "aTab" );
210
211 QGridLayout *Alayout = new QGridLayout( aTab );
212 Alayout->setSpacing( 2);
213 Alayout->setMargin( 2);
214
215 audioView = new QListView( aTab, "Audioview" );
216 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE);
222 audioView->setSorting(0,TRUE);
223
224 audioView->setMultiSelection( TRUE );
225 audioView->setSelectionMode( QListView::Extended);
226
227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
228
229 tabWidget->insertTab(aTab,tr("Audio"));
230
231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
232
233 QWidget *vTab;
234 vTab = new QWidget( tabWidget, "vTab" );
235
236 QGridLayout *Vlayout = new QGridLayout( vTab );
237 Vlayout->setSpacing( 2);
238 Vlayout->setMargin( 2);
239
240 videoView = new QListView( vTab, "Videoview" );
241
242 videoView->addColumn(tr("Title"),140);
243 videoView->addColumn(tr("Size"),-1);
244 videoView->addColumn(tr("Media"),-1);
245 videoView->setColumnAlignment(1, Qt::AlignRight);
246 videoView->setColumnAlignment(2, Qt::AlignRight);
247 videoView->setAllColumnsShowFocus(TRUE);
248 videoView->setSorting(0,TRUE);
249
250 videoView->setMultiSelection( TRUE );
251 videoView->setSelectionMode( QListView::Extended);
252
253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
254
255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
256
257 tabWidget->insertTab( vTab,tr("Video"));
258
259 //playlists list
260 QWidget *LTab;
261 LTab = new QWidget( tabWidget, "LTab" );
262 QGridLayout *Llayout = new QGridLayout( LTab );
263 Llayout->setSpacing( 2);
264 Llayout->setMargin( 2);
265
266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
268
269 tabWidget->insertTab(LTab,tr("Lists"));
270 98
271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 99 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
272
273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 100 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
274
275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 101 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
276
277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
278
279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 103 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 105 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 106 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
284 this,SLOT( playIt( QListViewItem *)) ); 107 this,SLOT( playIt( QListViewItem *)) );
285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 110 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 111 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 112 this,SLOT( playIt( QListViewItem *)) );
290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 115 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
298 121
299 setCentralWidget( vbox5 );
300
301 readConfig( cfg ); 122 readConfig( cfg );
302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 123 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
303 loadList(DocLnk( currentPlaylist)); 124 loadList(DocLnk( currentPlaylist));
304 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 125 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
305 126
127 // see which skins are installed
128 populateSkinsMenu();
306 initializeStates(); 129 initializeStates();
307} 130}
308 131
309 132
310PlayListWidget::~PlayListWidget() { 133PlayListWidget::~PlayListWidget() {
311/* fixing symptoms and not sources is entirely stupid - zecke */ 134/* fixing symptoms and not sources is entirely stupid - zecke */
312// Config cfg( "OpiePlayer" ); 135// Config cfg( "OpiePlayer" );
313// writeConfig( cfg ); 136// writeConfig( cfg );
314
315 if ( d->current ) { 137 if ( d->current ) {
316 delete d->current; 138 delete d->current;
317 } 139 }
318 delete d; 140 delete d;
319} 141}
320 142
321 143
322void PlayListWidget::initializeStates() { 144void PlayListWidget::initializeStates() {
323
324 d->tbPlay->setOn( mediaPlayerState->playing() ); 145 d->tbPlay->setOn( mediaPlayerState->playing() );
325 d->tbLoop->setOn( mediaPlayerState->looping() ); 146 d->tbLoop->setOn( mediaPlayerState->looping() );
326 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 147 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
327 setPlaylist( true); 148 setPlaylist( true);
328} 149}
329 150
330 151
331void PlayListWidget::readConfig( Config& cfg ) { 152void PlayListWidget::readConfig( Config& cfg ) {
332 cfg.setGroup("PlayList"); 153 cfg.setGroup("PlayList");
333 QString currentString = cfg.readEntry("current", "" ); 154 QString currentString = cfg.readEntry("current", "" );
334 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 155 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
335 for ( int i = 0; i < noOfFiles; i++ ) { 156 for ( int i = 0; i < noOfFiles; i++ ) {
336 QString entryName; 157 QString entryName;
337 entryName.sprintf( "File%i", i + 1 ); 158 entryName.sprintf( "File%i", i + 1 );
338 QString linkFile = cfg.readEntry( entryName ); 159 QString linkFile = cfg.readEntry( entryName );
339 if(QFileInfo( linkFile).exists() ) { 160 if(QFileInfo( linkFile).exists() ) {
340 DocLnk lnk( linkFile ); 161 DocLnk lnk( linkFile );
341 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 162 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
342 d->selectedFiles->addToSelection( lnk ); 163 d->selectedFiles->addToSelection( lnk );
343 } 164 }
344 } 165 }
345 } 166 }
346 d->selectedFiles->setSelectedItem( currentString); 167 d->selectedFiles->setSelectedItem( currentString);
347} 168}
348 169
349 170
350void PlayListWidget::writeConfig( Config& cfg ) const { 171void PlayListWidget::writeConfig( Config& cfg ) const {
351
352 d->selectedFiles->writeCurrent( cfg); 172 d->selectedFiles->writeCurrent( cfg);
353 cfg.setGroup("PlayList"); 173 cfg.setGroup("PlayList");
354 int noOfFiles = 0; 174 int noOfFiles = 0;
355 d->selectedFiles->first(); 175 d->selectedFiles->first();
356 do { 176 do {
357 const DocLnk *lnk = d->selectedFiles->current(); 177 const DocLnk *lnk = d->selectedFiles->current();
358 if ( lnk ) { 178 if ( lnk ) {
359 QString entryName; 179 QString entryName;
360 entryName.sprintf( "File%i", noOfFiles + 1 ); 180 entryName.sprintf( "File%i", noOfFiles + 1 );
361 cfg.writeEntry( entryName, lnk->linkFile() ); 181 cfg.writeEntry( entryName, lnk->linkFile() );
362 // if this link does exist, add it so we have the file 182 // if this link does exist, add it so we have the file
363 // next time... 183 // next time...
364 if ( !QFile::exists( lnk->linkFile() ) ) { 184 if ( !QFile::exists( lnk->linkFile() ) ) {
365 // the way writing lnks doesn't really check for out 185 // the way writing lnks doesn't really check for out
366 // of disk space, but check it anyway. 186 // of disk space, but check it anyway.
367 if ( !lnk->writeLink() ) { 187 if ( !lnk->writeLink() ) {
368 QMessageBox::critical( 0, tr("Out of space"), 188 QMessageBox::critical( 0, tr("Out of space"),
369 tr( "There was a problem saving " 189 tr( "There was a problem saving "
370 "the playlist.\n" 190 "the playlist.\n"
371 "Your playlist " 191 "Your playlist "
372 "may be missing some entries\n" 192 "may be missing some entries\n"
373 "the next time you start it." ) 193 "the next time you start it." )
374 ); 194 );
375 } 195 }
@@ -379,176 +199,202 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
379 } 199 }
380 while ( d->selectedFiles->next() ); 200 while ( d->selectedFiles->next() );
381 cfg.writeEntry("NumberOfFiles", noOfFiles ); 201 cfg.writeEntry("NumberOfFiles", noOfFiles );
382} 202}
383 203
384 204
385void PlayListWidget::addToSelection( const DocLnk& lnk ) { 205void PlayListWidget::addToSelection( const DocLnk& lnk ) {
386 d->setDocumentUsed = FALSE; 206 d->setDocumentUsed = FALSE;
387 if ( mediaPlayerState->playlist() ) { 207 if ( mediaPlayerState->playlist() ) {
388 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 208 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
389 d->selectedFiles->addToSelection( lnk ); 209 d->selectedFiles->addToSelection( lnk );
390 } 210 }
391 else 211 else
392 mediaPlayerState->setPlaying( TRUE ); 212 mediaPlayerState->setPlaying( TRUE );
393} 213}
394 214
395 215
396void PlayListWidget::clearList() { 216void PlayListWidget::clearList() {
397 while ( first() ) { 217 while ( first() ) {
398 d->selectedFiles->removeSelected(); 218 d->selectedFiles->removeSelected();
399 } 219 }
400} 220}
401 221
402 222
223void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
224 switch (mouse) {
225 case 1:
226 break;
227 case 2:
228 {
229 QPopupMenu m;
230 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
231 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
232 m.exec( QCursor::pos() );
233 }
234 break;
235 }
236}
237
238
239void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
240 switch (mouse) {
241 case 1:
242 break;
243 case 2:
244 {
245 QPopupMenu m;
246 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
247 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
248 m.exec( QCursor::pos() );
249 }
250 break;
251 }
252}
253
254
403void PlayListWidget::addAllToList() { 255void PlayListWidget::addAllToList() {
404 DocLnkSet filesAll; 256 DocLnkSet filesAll;
405 Global::findDocuments(&filesAll, "video/*;audio/*"); 257 Global::findDocuments(&filesAll, "video/*;audio/*");
406 QListIterator<DocLnk> Adit( filesAll.children() ); 258 QListIterator<DocLnk> Adit( filesAll.children() );
407 for ( ; Adit.current(); ++Adit ) { 259 for ( ; Adit.current(); ++Adit ) {
408 if(QFileInfo(Adit.current()->file()).exists()) { 260 if(QFileInfo(Adit.current()->file()).exists()) {
409 d->selectedFiles->addToSelection( **Adit ); 261 d->selectedFiles->addToSelection( **Adit );
410 } 262 }
411 } 263 }
412} 264}
413 265
414 266
415void PlayListWidget::addAllMusicToList() { 267void PlayListWidget::addAllMusicToList() {
416 QListIterator<DocLnk> dit( files.children() ); 268 QListIterator<DocLnk> dit( files.children() );
417 for ( ; dit.current(); ++dit ) { 269 for ( ; dit.current(); ++dit ) {
418 if(QFileInfo(dit.current()->file()).exists()) { 270 if(QFileInfo(dit.current()->file()).exists()) {
419 d->selectedFiles->addToSelection( **dit ); 271 d->selectedFiles->addToSelection( **dit );
420 } 272 }
421 } 273 }
422} 274}
423 275
424 276
425void PlayListWidget::addAllVideoToList() { 277void PlayListWidget::addAllVideoToList() {
426 QListIterator<DocLnk> dit( vFiles.children() ); 278 QListIterator<DocLnk> dit( vFiles.children() );
427 for ( ; dit.current(); ++dit ) 279 for ( ; dit.current(); ++dit ) {
428 if(QFileInfo( dit.current()->file()).exists()) 280 if( QFileInfo( dit.current()->file() ).exists() ) {
429 d->selectedFiles->addToSelection( **dit ); 281 d->selectedFiles->addToSelection( **dit );
430} 282}
283 }
284}
431 285
432 286
433void PlayListWidget::setDocument(const QString& fileref) { 287void PlayListWidget::setDocument(const QString& fileref) {
434 qDebug(fileref); 288 //qDebug( fileref );
435 fromSetDocument = TRUE; 289 fromSetDocument = TRUE;
436 if ( fileref.isNull() ) { 290 if ( fileref.isNull() ) {
437 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 291 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
438 return; 292 return;
439 } 293 }
440 294
441 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 295 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
442 readm3u( fileref); 296 readm3u( fileref);
443 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 297 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
444 readPls( fileref); 298 readPls( fileref);
445 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 299 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
446 clearList(); 300 clearList();
447 loadList(DocLnk(fileref)); 301 loadList(DocLnk(fileref));
448 d->selectedFiles->first(); 302 d->selectedFiles->first();
449 } else { 303 } else {
450 clearList(); 304 clearList();
451 addToSelection( DocLnk( fileref ) ); 305 addToSelection( DocLnk( fileref ) );
452 d->setDocumentUsed = TRUE; 306 d->setDocumentUsed = TRUE;
453 mediaPlayerState->setPlaying( FALSE ); 307 mediaPlayerState->setPlaying( FALSE );
454 qApp->processEvents(); 308 qApp->processEvents();
455 mediaPlayerState->setPlaying( TRUE ); 309 mediaPlayerState->setPlaying( TRUE );
456 qApp->processEvents(); 310 qApp->processEvents();
457 setCaption(tr("OpiePlayer")); 311 setCaption(tr("OpiePlayer"));
458 } 312 }
459} 313}
460 314
461 315
462void PlayListWidget::setActiveWindow() {
463// qDebug("SETTING active window");
464 // When we get raised we need to ensure that it switches views
465 char origView = mediaPlayerState->view();
466 mediaPlayerState->setView( 'l' ); // invalidate
467 mediaPlayerState->setView( origView ); // now switch back
468}
469
470
471void PlayListWidget::useSelectedDocument() { 316void PlayListWidget::useSelectedDocument() {
472 d->setDocumentUsed = FALSE; 317 d->setDocumentUsed = FALSE;
473} 318}
474 319
475 320
476const DocLnk *PlayListWidget::current() { // this is fugly 321const DocLnk *PlayListWidget::current() { // this is fugly
477
478 switch (tabWidget->currentPageIndex()) { 322 switch (tabWidget->currentPageIndex()) {
479 case 0: //playlist 323 case 0: //playlist
480 { 324 {
481// qDebug("playlist"); 325// qDebug("playlist");
482 if ( mediaPlayerState->playlist() ) { 326 if ( mediaPlayerState->playlist() ) {
483 return d->selectedFiles->current(); 327 return d->selectedFiles->current();
484 } else if ( d->setDocumentUsed && d->current ) { 328 } else if ( d->setDocumentUsed && d->current ) {
485 return d->current; 329 return d->current;
486 } else { 330 } else {
487 return d->files->selected(); 331 return d->files->selected();
488 } 332 }
489 } 333 }
490 break; 334 break;
491 case 1://audio 335 case 1://audio
492 { 336 {
493// qDebug("audioView"); 337// qDebug("audioView");
494 QListIterator<DocLnk> dit( files.children() ); 338 QListIterator<DocLnk> dit( files.children() );
495 for ( ; dit.current(); ++dit ) { 339 for ( ; dit.current(); ++dit ) {
496 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 340 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
497 insanityBool=TRUE; 341 insanityBool=TRUE;
498 return dit; 342 return dit;
499 } 343 }
500 } 344 }
501 } 345 }
502 break; 346 break;
503 case 2: // video 347 case 2: // video
504 { 348 {
505// qDebug("videoView"); 349// qDebug("videoView");
506 QListIterator<DocLnk> Vdit( vFiles.children() ); 350 QListIterator<DocLnk> Vdit( vFiles.children() );
507 for ( ; Vdit.current(); ++Vdit ) { 351 for ( ; Vdit.current(); ++Vdit ) {
508 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 352 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
509 insanityBool=TRUE; 353 insanityBool=TRUE;
510 return Vdit; 354 return Vdit;
511 } 355 }
512 } 356 }
513 } 357 }
514 break; 358 break;
515 }; 359 };
516 return 0; 360 return 0;
517} 361}
518 362
363
519bool PlayListWidget::prev() { 364bool PlayListWidget::prev() {
520 if ( mediaPlayerState->playlist() ) { 365 if ( mediaPlayerState->playlist() ) {
521 if ( mediaPlayerState->shuffled() ) { 366 if ( mediaPlayerState->shuffled() ) {
522 const DocLnk *cur = current(); 367 const DocLnk *cur = current();
523 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 368 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
524 for ( int i = 0; i < j; i++ ) { 369 for ( int i = 0; i < j; i++ ) {
525 if ( !d->selectedFiles->next() ) 370 if ( !d->selectedFiles->next() )
526 d->selectedFiles->first(); 371 d->selectedFiles->first();
527 } 372 }
528 if ( cur == current() ) 373 if ( cur == current() )
529 if ( !d->selectedFiles->next() ) 374 if ( !d->selectedFiles->next() ) {
530 d->selectedFiles->first(); 375 d->selectedFiles->first();
376 }
531 return TRUE; 377 return TRUE;
532 } else { 378 } else {
533 if ( !d->selectedFiles->prev() ) { 379 if ( !d->selectedFiles->prev() ) {
534 if ( mediaPlayerState->looping() ) { 380 if ( mediaPlayerState->looping() ) {
535 return d->selectedFiles->last(); 381 return d->selectedFiles->last();
536 } else { 382 } else {
537 return FALSE; 383 return FALSE;
538 } 384 }
539 } 385 }
540 return TRUE; 386 return TRUE;
541 } 387 }
542 } else { 388 } else {
543 return mediaPlayerState->looping(); 389 return mediaPlayerState->looping();
544 } 390 }
545} 391}
546 392
547 393
548bool PlayListWidget::next() { 394bool PlayListWidget::next() {
549 if ( mediaPlayerState->playlist() ) { 395 if ( mediaPlayerState->playlist() ) {
550 if ( mediaPlayerState->shuffled() ) { 396 if ( mediaPlayerState->shuffled() ) {
551 return prev(); 397 return prev();
552 } else { 398 } else {
553 if ( !d->selectedFiles->next() ) { 399 if ( !d->selectedFiles->next() ) {
554 if ( mediaPlayerState->looping() ) { 400 if ( mediaPlayerState->looping() ) {
@@ -609,65 +455,59 @@ void PlayListWidget::saveList() {
609 config.writeEntry("CurrentPlaylist",filename); 455 config.writeEntry("CurrentPlaylist",filename);
610 setCaption(tr("OpiePlayer: ")+filename); 456 setCaption(tr("OpiePlayer: ")+filename);
611 d->selectedFiles->first(); 457 d->selectedFiles->first();
612 if(fileDlg) { 458 if(fileDlg) {
613 delete fileDlg; 459 delete fileDlg;
614 } 460 }
615} 461}
616 462
617void PlayListWidget::loadList( const DocLnk & lnk) { 463void PlayListWidget::loadList( const DocLnk & lnk) {
618 QString name= lnk.name(); 464 QString name= lnk.name();
619 // qDebug("currentList is "+name); 465 // qDebug("currentList is "+name);
620 if( name.length()>1) { 466 if( name.length()>1) {
621 setCaption("OpiePlayer: "+name); 467 setCaption("OpiePlayer: "+name);
622 // qDebug("load list "+ name+".playlist"); 468 // qDebug("load list "+ name+".playlist");
623 clearList(); 469 clearList();
624 Config cfg( name+".playlist"); 470 Config cfg( name+".playlist");
625 readConfig(cfg); 471 readConfig(cfg);
626 472
627 tabWidget->setCurrentPage(0); 473 tabWidget->setCurrentPage(0);
628 474
629 Config config( "OpiePlayer" ); 475 Config config( "OpiePlayer" );
630 config.writeEntry("CurrentPlaylist", name); 476 config.writeEntry("CurrentPlaylist", name);
631 // d->selectedFiles->first(); 477 // d->selectedFiles->first();
632 } 478 }
633
634} 479}
635 480
481
636void PlayListWidget::setPlaylist( bool shown ) { 482void PlayListWidget::setPlaylist( bool shown ) {
637 if ( shown ) { 483 if ( shown ) {
638 d->playListFrame->show(); 484 d->playListFrame->show();
639 } else { 485 } else {
640 d->playListFrame->hide(); 486 d->playListFrame->hide();
641 } 487 }
642} 488}
643 489
644void PlayListWidget::setView( char view ) {
645 if ( view == 'l' )
646 showMaximized();
647 else
648 hide();
649}
650 490
651void PlayListWidget::addSelected() { 491void PlayListWidget::addSelected() {
652 492
653 Config cfg( "OpiePlayer" ); 493 Config cfg( "OpiePlayer" );
654 cfg.setGroup("PlayList"); 494 cfg.setGroup("PlayList");
655 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 495 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
656 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 496 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
657 497
658 switch (tabWidget->currentPageIndex()) { 498 switch (tabWidget->currentPageIndex()) {
659 case 0: //playlist 499 case 0: //playlist
660 break; 500 break;
661 case 1: { //audio 501 case 1: { //audio
662 QListViewItemIterator it( audioView ); 502 QListViewItemIterator it( audioView );
663 // iterate through all items of the listview 503 // iterate through all items of the listview
664 for ( ; it.current(); ++it ) { 504 for ( ; it.current(); ++it ) {
665 if ( it.current()->isSelected() ) { 505 if ( it.current()->isSelected() ) {
666 QListIterator<DocLnk> dit( files.children() ); 506 QListIterator<DocLnk> dit( files.children() );
667 for ( ; dit.current(); ++dit ) { 507 for ( ; dit.current(); ++dit ) {
668 if( dit.current()->name() == it.current()->text(0) ) { 508 if( dit.current()->name() == it.current()->text(0) ) {
669 if(QFileInfo( dit.current()->file()).exists()) 509 if(QFileInfo( dit.current()->file()).exists())
670 d->selectedFiles->addToSelection( **dit ); 510 d->selectedFiles->addToSelection( **dit );
671 } 511 }
672 } 512 }
673 audioView->setSelected( it.current(),FALSE); 513 audioView->setSelected( it.current(),FALSE);
@@ -676,331 +516,316 @@ void PlayListWidget::addSelected() {
676 tabWidget->setCurrentPage(0); 516 tabWidget->setCurrentPage(0);
677 } 517 }
678 break; 518 break;
679 case 2: { // video 519 case 2: { // video
680 QListViewItemIterator it( videoView ); 520 QListViewItemIterator it( videoView );
681 // iterate through all items of the listview 521 // iterate through all items of the listview
682 for ( ; it.current(); ++it ) { 522 for ( ; it.current(); ++it ) {
683 if ( it.current()->isSelected() ) { 523 if ( it.current()->isSelected() ) {
684 QListIterator<DocLnk> dit( vFiles.children() ); 524 QListIterator<DocLnk> dit( vFiles.children() );
685 for ( ; dit.current(); ++dit ) { 525 for ( ; dit.current(); ++dit ) {
686 if( dit.current()->name() == it.current()->text(0) ) { 526 if( dit.current()->name() == it.current()->text(0) ) {
687 if(QFileInfo( dit.current()->file()).exists()) 527 if(QFileInfo( dit.current()->file()).exists())
688 d->selectedFiles->addToSelection( **dit ); 528 d->selectedFiles->addToSelection( **dit );
689 } 529 }
690 } 530 }
691 videoView->setSelected( it.current(),FALSE); 531 videoView->setSelected( it.current(),FALSE);
692 } 532 }
693 } 533 }
694 tabWidget->setCurrentPage(0); 534 tabWidget->setCurrentPage(0);
695 } 535 }
696 break; 536 break;
697 }; 537 };
698} 538}
699 539
540
700void PlayListWidget::removeSelected() { 541void PlayListWidget::removeSelected() {
701 d->selectedFiles->removeSelected( ); 542 d->selectedFiles->removeSelected( );
702} 543}
703 544
545
704void PlayListWidget::playIt( QListViewItem *it) { 546void PlayListWidget::playIt( QListViewItem *it) {
705 if(!it) return; 547 if(!it) return;
706 mediaPlayerState->setPlaying(FALSE); 548 mediaPlayerState->setPlaying(FALSE);
707 mediaPlayerState->setPlaying(TRUE); 549 mediaPlayerState->setPlaying(TRUE);
708 d->selectedFiles->unSelect(); 550 d->selectedFiles->unSelect();
709} 551}
710 552
553
711void PlayListWidget::addToSelection( QListViewItem *it) { 554void PlayListWidget::addToSelection( QListViewItem *it) {
712 d->setDocumentUsed = FALSE; 555 d->setDocumentUsed = FALSE;
713 556
714 if(it) { 557 if(it) {
715 switch (tabWidget->currentPageIndex()) { 558 switch (tabWidget->currentPageIndex()) {
716 case 1: { 559 case 1: {
717 QListIterator<DocLnk> dit( files.children() ); 560 QListIterator<DocLnk> dit( files.children() );
718 for ( ; dit.current(); ++dit ) { 561 for ( ; dit.current(); ++dit ) {
719 if( dit.current()->name() == it->text(0)) { 562 if( dit.current()->name() == it->text(0)) {
720 if(QFileInfo( dit.current()->file()).exists()) 563 if(QFileInfo( dit.current()->file()).exists())
721 d->selectedFiles->addToSelection( **dit ); 564 d->selectedFiles->addToSelection( **dit );
722 } 565 }
723 } 566 }
724 } 567 }
725 break; 568 break;
726 case 2: { 569 case 2: {
727 QListIterator<DocLnk> dit( vFiles.children() ); 570 QListIterator<DocLnk> dit( vFiles.children() );
728 for ( ; dit.current(); ++dit ) { 571 for ( ; dit.current(); ++dit ) {
729 if( dit.current()->name() == it->text(0)) { 572 if( dit.current()->name() == it->text(0)) {
730 if(QFileInfo( dit.current()->file()).exists()) 573 if(QFileInfo( dit.current()->file()).exists())
731 d->selectedFiles->addToSelection( **dit ); 574 d->selectedFiles->addToSelection( **dit );
732 } 575 }
733 } 576 }
734 } 577 }
735 break; 578 break;
736 case 0: 579 case 0:
737 break; 580 break;
738 }; 581 };
739 tabWidget->setCurrentPage(0); 582 tabWidget->setCurrentPage(0);
740 } 583 }
741} 584}
742 585
586
743void PlayListWidget::tabChanged(QWidget *) { 587void PlayListWidget::tabChanged(QWidget *) {
744 588
745 switch ( tabWidget->currentPageIndex()) { 589 switch ( tabWidget->currentPageIndex()) {
746 case 0: 590 case 0:
747 { 591 {
748 if( !tbDeletePlaylist->isHidden()) 592 if( !tbDeletePlaylist->isHidden() ) {
749 tbDeletePlaylist->hide(); 593 tbDeletePlaylist->hide();
594 }
750 d->tbRemoveFromList->setEnabled(TRUE); 595 d->tbRemoveFromList->setEnabled(TRUE);
751 d->tbAddToList->setEnabled(FALSE); 596 d->tbAddToList->setEnabled(FALSE);
752 } 597 }
753 break; 598 break;
754 case 1: 599 case 1:
755 { 600 {
756 audioView->clear(); 601 audioView->clear();
757 populateAudioView(); 602 populateAudioView();
758 603
759 if( !tbDeletePlaylist->isHidden()) 604 if( !tbDeletePlaylist->isHidden() ) {
760 tbDeletePlaylist->hide(); 605 tbDeletePlaylist->hide();
606 }
761 d->tbRemoveFromList->setEnabled(FALSE); 607 d->tbRemoveFromList->setEnabled(FALSE);
762 d->tbAddToList->setEnabled(TRUE); 608 d->tbAddToList->setEnabled(TRUE);
763 } 609 }
764 break; 610 break;
765 case 2: 611 case 2:
766 { 612 {
767 videoView->clear(); 613 videoView->clear();
768 populateVideoView(); 614 populateVideoView();
769 if( !tbDeletePlaylist->isHidden()) 615 if( !tbDeletePlaylist->isHidden() ) {
770 tbDeletePlaylist->hide(); 616 tbDeletePlaylist->hide();
617 }
771 d->tbRemoveFromList->setEnabled(FALSE); 618 d->tbRemoveFromList->setEnabled(FALSE);
772 d->tbAddToList->setEnabled(TRUE); 619 d->tbAddToList->setEnabled(TRUE);
773 } 620 }
774 break; 621 break;
775 case 3: 622 case 3:
776 { 623 {
777 if( tbDeletePlaylist->isHidden()) 624 if( tbDeletePlaylist->isHidden() ) {
778 tbDeletePlaylist->show(); 625 tbDeletePlaylist->show();
626 }
779 playLists->reread(); 627 playLists->reread();
780 } 628 }
781 break; 629 break;
782 }; 630 };
783} 631}
784 632
785void PlayListWidget::btnPlay(bool b) {
786 633
634void PlayListWidget::btnPlay(bool b) {
787 // mediaPlayerState->setPlaying(b); 635 // mediaPlayerState->setPlaying(b);
788 switch ( tabWidget->currentPageIndex()) { 636 switch ( tabWidget->currentPageIndex()) {
789 case 0: 637 case 0:
790 { 638 {
791 mediaPlayerState->setPlaying(b); 639 mediaPlayerState->setPlaying(b);
792 } 640 }
793 break; 641 break;
794 case 1: 642 case 1:
795 { 643 {
796 addToSelection( audioView->currentItem() ); 644 addToSelection( audioView->currentItem() );
797 mediaPlayerState->setPlaying(b); 645 mediaPlayerState->setPlaying(b);
798 d->selectedFiles->removeSelected( ); 646 d->selectedFiles->removeSelected( );
799 tabWidget->setCurrentPage(1); 647 tabWidget->setCurrentPage(1);
800 d->selectedFiles->unSelect(); 648 d->selectedFiles->unSelect();
801 insanityBool=FALSE; 649 insanityBool=FALSE;
802 }// audioView->clearSelection(); 650 }// audioView->clearSelection();
803 break; 651 break;
804 case 2: 652 case 2:
805 { 653 {
806 addToSelection( videoView->currentItem() ); 654 addToSelection( videoView->currentItem() );
807 mediaPlayerState->setPlaying(b); 655 mediaPlayerState->setPlaying(b);
808 qApp->processEvents(); 656 qApp->processEvents();
809 d->selectedFiles->removeSelected( ); 657 d->selectedFiles->removeSelected( );
810 tabWidget->setCurrentPage(2); 658 tabWidget->setCurrentPage(2);
811 d->selectedFiles->unSelect(); 659 d->selectedFiles->unSelect();
812 insanityBool=FALSE; 660 insanityBool=FALSE;
813 }// videoView->clearSelection(); 661 }// videoView->clearSelection();
814 break; 662 break;
815 }; 663 };
816 664
817} 665}
818 666
819void PlayListWidget::deletePlaylist() { 667void PlayListWidget::deletePlaylist() {
820 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 668 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
821 (tr("You really want to delete\nthis playlist?")), 669 (tr("You really want to delete\nthis playlist?")),
822 (tr("Yes")), (tr("No")), 0 )){ 670 (tr("Yes")), (tr("No")), 0 )){
823 case 0: // Yes clicked, 671 case 0: // Yes clicked,
824 QFile().remove(playLists->selected()->file()); 672 QFile().remove(playLists->selected()->file());
825 QFile().remove(playLists->selected()->linkFile()); 673 QFile().remove(playLists->selected()->linkFile());
826 playLists->reread(); 674 playLists->reread();
827 break; 675 break;
828 case 1: // Cancel 676 case 1: // Cancel
829 break; 677 break;
830 }; 678 };
831} 679}
832 680
833void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
834 switch (mouse) {
835 case 1:
836 break;
837 case 2:{
838 QPopupMenu m;
839 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
840 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
841 m.exec( QCursor::pos() );
842 }
843 break;
844 };
845}
846 681
847void PlayListWidget::playSelected() { 682void PlayListWidget::playSelected() {
848 btnPlay( TRUE); 683 btnPlay( TRUE);
849} 684}
850 685
851void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
852 switch (mouse) {
853 case 1:
854
855 break;
856 case 2:
857 {
858 QPopupMenu m;
859 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
860 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
861 m.exec( QCursor::pos() );
862 }
863 break;
864 };
865}
866
867 686
868void PlayListWidget::scanForAudio() { 687void PlayListWidget::scanForAudio() {
869// qDebug("scan for audio"); 688// qDebug("scan for audio");
870 files.detachChildren(); 689 files.detachChildren();
871 QListIterator<DocLnk> sdit( files.children() ); 690 QListIterator<DocLnk> sdit( files.children() );
872 for ( ; sdit.current(); ++sdit ) { 691 for ( ; sdit.current(); ++sdit ) {
873 delete sdit.current(); 692 delete sdit.current();
874 } 693 }
875 Global::findDocuments(&files, "audio/*"); 694 Global::findDocuments(&files, "audio/*");
876 audioScan = TRUE; 695 audioScan = TRUE;
877} 696}
878 697
879void PlayListWidget::scanForVideo() { 698void PlayListWidget::scanForVideo() {
880// qDebug("scan for video"); 699// qDebug("scan for video");
881 vFiles.detachChildren(); 700 vFiles.detachChildren();
882 QListIterator<DocLnk> sdit( vFiles.children() ); 701 QListIterator<DocLnk> sdit( vFiles.children() );
883 for ( ; sdit.current(); ++sdit ) { 702 for ( ; sdit.current(); ++sdit ) {
884 delete sdit.current(); 703 delete sdit.current();
885 } 704 }
886 Global::findDocuments(&vFiles, "video/*"); 705 Global::findDocuments(&vFiles, "video/*");
887 videoScan = TRUE; 706 videoScan = TRUE;
888} 707}
889 708
890void PlayListWidget::populateAudioView() { 709void PlayListWidget::populateAudioView() {
891
892 audioView->clear(); 710 audioView->clear();
893 StorageInfo storageInfo; 711 StorageInfo storageInfo;
894 const QList<FileSystem> &fs = storageInfo.fileSystems(); 712 const QList<FileSystem> &fs = storageInfo.fileSystems();
895 if(!audioScan) scanForAudio(); 713 if(!audioScan) {
714 scanForAudio();
715 }
896 716
897 QListIterator<DocLnk> dit( files.children() ); 717 QListIterator<DocLnk> dit( files.children() );
898 QListIterator<FileSystem> it ( fs ); 718 QListIterator<FileSystem> it ( fs );
899 719
900 QString storage; 720 QString storage;
901 for ( ; dit.current(); ++dit ) { 721 for ( ; dit.current(); ++dit ) {
902 for( ; it.current(); ++it ){ 722 for( ; it.current(); ++it ){
903 const QString name = (*it)->name(); 723 const QString name = (*it)->name();
904 const QString path = (*it)->path(); 724 const QString path = (*it)->path();
905 if(dit.current()->file().find(path) != -1 ) storage=name; 725 if(dit.current()->file().find(path) != -1 ) {
726 storage = name;
727 }
906 } 728 }
907 729
908 QListViewItem * newItem; 730 QListViewItem * newItem;
909 if ( QFile( dit.current()->file()).exists() ) { 731 if ( QFile( dit.current()->file()).exists() ) {
910 // qDebug(dit.current()->name()); 732 // qDebug(dit.current()->name());
911 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 733 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
912 QString::number( QFile( dit.current()->file()).size() ), storage); 734 QString::number( QFile( dit.current()->file()).size() ), storage);
913 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); 735 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" ));
914 } 736 }
915 } 737 }
916
917} 738}
918 739
740
919void PlayListWidget::populateVideoView() { 741void PlayListWidget::populateVideoView() {
920 videoView->clear(); 742 videoView->clear();
921 StorageInfo storageInfo; 743 StorageInfo storageInfo;
922 const QList<FileSystem> &fs = storageInfo.fileSystems(); 744 const QList<FileSystem> &fs = storageInfo.fileSystems();
923 745
924 if(!videoScan ) scanForVideo(); 746 if(!videoScan ) {
747 scanForVideo();
748 }
925 749
926 QListIterator<DocLnk> Vdit( vFiles.children() ); 750 QListIterator<DocLnk> Vdit( vFiles.children() );
927 QListIterator<FileSystem> it ( fs ); 751 QListIterator<FileSystem> it ( fs );
928 videoView->clear(); 752 videoView->clear();
929 QString storage; 753 QString storage;
930 for ( ; Vdit.current(); ++Vdit ) { 754 for ( ; Vdit.current(); ++Vdit ) {
931 for( ; it.current(); ++it ){ 755 for( ; it.current(); ++it ){
932 const QString name = (*it)->name(); 756 const QString name = (*it)->name();
933 const QString path = (*it)->path(); 757 const QString path = (*it)->path();
934 if( Vdit.current()->file().find(path) != -1 ) storage=name; 758 if( Vdit.current()->file().find(path) != -1 ) {
759 storage=name;
760 }
935 } 761 }
936 762
937 QListViewItem * newItem; 763 QListViewItem * newItem;
938 if ( QFile( Vdit.current()->file()).exists() ) { 764 if ( QFile( Vdit.current()->file()).exists() ) {
939 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 765 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
940 QString::number( QFile( Vdit.current()->file()).size() ), storage); 766 QString::number( QFile( Vdit.current()->file()).size() ), storage);
941 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); 767 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ));
942 } 768 }
943 } 769 }
944} 770}
945 771
772
946void PlayListWidget::openFile() { 773void PlayListWidget::openFile() {
947 QString filename, name; 774 QString filename, name;
948 InputDialog *fileDlg; 775 InputDialog *fileDlg;
949 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 776 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
950 fileDlg->exec(); 777 fileDlg->exec();
951 if( fileDlg->result() == 1 ) { 778 if( fileDlg->result() == 1 ) {
952 filename = fileDlg->text(); 779 filename = fileDlg->text();
953 780
954 qDebug("Selected filename is "+filename); 781 qDebug("Selected filename is "+filename);
955 if(filename.right(3) == "m3u") { 782 if(filename.right(3) == "m3u") {
956 readm3u( filename ); 783 readm3u( filename );
957 } else if(filename.right(3) == "pls") { 784 } else if(filename.right(3) == "pls") {
958 readPls( filename ); 785 readPls( filename );
959 } else { 786 } else {
960 /* FIXME ....... AUDIO/X-MPEGURL is bad*/ 787 /* FIXME ....... AUDIO/X-MPEGURL is bad*/
961 DocLnk lnk; 788 DocLnk lnk;
962
963 lnk.setName(filename); //sets file name 789 lnk.setName(filename); //sets file name
964 lnk.setFile(filename); //sets File property 790 lnk.setFile(filename); //sets File property
965 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 791 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
966 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 792 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
967 lnk.setExec("opieplayer"); 793 lnk.setExec("opieplayer");
968 lnk.setIcon("opieplayer2/MPEGPlayer"); 794 lnk.setIcon("opieplayer2/MPEGPlayer");
969 795
970 if(!lnk.writeLink()) { 796 if(!lnk.writeLink()) {
971 qDebug("Writing doclink did not work"); 797 qDebug("Writing doclink did not work");
972 } 798 }
973 d->selectedFiles->addToSelection( lnk); 799 d->selectedFiles->addToSelection( lnk);
974 } 800 }
975 } 801 }
976 if(fileDlg) { 802 if(fileDlg) {
977 delete fileDlg; 803 delete fileDlg;
978 } 804 }
979} 805}
980 806
981void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 807void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
982{
983 switch ( e->key() ) { 808 switch ( e->key() ) {
984 ////////////////////////////// Zaurus keys 809 ////////////////////////////// Zaurus keys
985 case Key_F9: //activity 810 case Key_F9: //activity
986 // if(audioUI->isHidden()) 811 // if(audioUI->isHidden())
987 // audioUI->showMaximized(); 812 // audioUI->showMaximized();
988 break; 813 break;
989 case Key_F10: //contacts 814 case Key_F10: //contacts
990 // if( videoUI->isHidden()) 815 // if( videoUI->isHidden())
991 // videoUI->showMaximized(); 816 // videoUI->showMaximized();
992 break; 817 break;
993 case Key_F11: //menu 818 case Key_F11: //menu
994 break; 819 break;
995 case Key_F12: //home 820 case Key_F12: //home
996 // doBlank(); 821 // doBlank();
997 break; 822 break;
998 case Key_F13: //mail 823 case Key_F13: //mail
999 // doUnblank(); 824 // doUnblank();
1000 break; 825 break;
1001 case Key_Q: //add to playlist 826 case Key_Q: //add to playlist
1002 addSelected(); 827 addSelected();
1003 break; 828 break;
1004 case Key_R: //remove from playlist 829 case Key_R: //remove from playlist
1005 removeSelected(); 830 removeSelected();
1006 break; 831 break;
@@ -1016,239 +841,217 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1016 break; 841 break;
1017 case Key_2: 842 case Key_2:
1018 tabWidget->setCurrentPage(1); 843 tabWidget->setCurrentPage(1);
1019 break; 844 break;
1020 case Key_3: 845 case Key_3:
1021 tabWidget->setCurrentPage(2); 846 tabWidget->setCurrentPage(2);
1022 break; 847 break;
1023 case Key_4: 848 case Key_4:
1024 tabWidget->setCurrentPage(3); 849 tabWidget->setCurrentPage(3);
1025 break; 850 break;
1026 case Key_Down: 851 case Key_Down:
1027 if ( !d->selectedFiles->next() ) 852 if ( !d->selectedFiles->next() )
1028 d->selectedFiles->first(); 853 d->selectedFiles->first();
1029 854
1030 break; 855 break;
1031 case Key_Up: 856 case Key_Up:
1032 if ( !d->selectedFiles->prev() ) 857 if ( !d->selectedFiles->prev() )
1033 // d->selectedFiles->last(); 858 // d->selectedFiles->last();
1034 859
1035 break; 860 break;
1036 861
1037 } 862 }
1038} 863}
1039 864
1040void PlayListWidget::keyPressEvent( QKeyEvent *)
1041{
1042 // qDebug("Key press");
1043 // switch ( e->key() ) {
1044 // ////////////////////////////// Zaurus keys
1045 // case Key_A: //add to playlist
1046 // qDebug("Add");
1047 // addSelected();
1048 // break;
1049 // case Key_R: //remove from playlist
1050 // removeSelected();
1051 // break;
1052 // case Key_P: //play
1053 // qDebug("Play");
1054 // playSelected();
1055 // break;
1056 // case Key_Space:
1057 // qDebug("Play");
1058 // playSelected();
1059 // break;
1060 // }
1061}
1062
1063
1064
1065void PlayListWidget::readm3u(const QString &filename) { 865void PlayListWidget::readm3u(const QString &filename) {
1066
1067 qDebug("m3u filename is "+filename); 866 qDebug("m3u filename is "+filename);
1068 QFile f(filename); 867 QFile f(filename);
1069 868
1070 if(f.open(IO_ReadOnly)) { 869 if(f.open(IO_ReadOnly)) {
1071 QTextStream t(&f); 870 QTextStream t(&f);
1072 QString s;//, first, second; 871 QString s;//, first, second;
1073 int i=0; 872 int i=0;
1074 while ( !t.atEnd()) { 873 while ( !t.atEnd()) {
1075 s=t.readLine(); 874 s=t.readLine();
1076 875
1077 if(s.find("#",0,TRUE) == -1) { 876 if(s.find("#",0,TRUE) == -1) {
1078 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 877 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1079 if(s.left(2) == "E:" || s.left(2) == "P:") { 878 if(s.left(2) == "E:" || s.left(2) == "P:") {
1080 s=s.right(s.length()-2); 879 s=s.right(s.length()-2);
1081 // if(QFile(s).exists()) {
1082 DocLnk lnk( s ); 880 DocLnk lnk( s );
1083 QFileInfo f(s); 881 QFileInfo f(s);
1084 QString name = f.baseName(); 882 QString name = f.baseName();
1085 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 883 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
1086 lnk.setName( name ); 884 lnk.setName( name );
1087 s=s.replace( QRegExp("\\"),"/"); 885 s=s.replace( QRegExp("\\"),"/");
1088 lnk.setFile( s ); 886 lnk.setFile( s );
1089 lnk.writeLink(); 887 lnk.writeLink();
1090 qDebug("add "+name); 888 qDebug("add "+name);
1091 d->selectedFiles->addToSelection( lnk); 889 d->selectedFiles->addToSelection( lnk);
1092 // }
1093 } else { // is url 890 } else { // is url
1094 s.replace(QRegExp("%20")," "); 891 s.replace(QRegExp("%20")," ");
1095 DocLnk lnk( s ); 892 DocLnk lnk( s );
1096 QString name; 893 QString name;
1097 if(name.left(4)=="http") { 894 if(name.left(4)=="http") {
1098 name = s.right( s.length() - 7); 895 name = s.right( s.length() - 7);
1099 } else { 896 } else {
1100 name = s; 897 name = s;
1101 } 898 }
1102 lnk.setName(name); 899 lnk.setName(name);
1103 if(s.at(s.length()-4) == '.') { 900 if(s.at(s.length()-4) == '.') {
1104 lnk.setFile( s); 901 lnk.setFile( s);
1105 } else { 902 } else {
1106 lnk.setFile( s+"/"); 903 lnk.setFile( s+"/");
1107 } 904 }
1108 lnk.setType("audio/x-mpegurl"); 905 lnk.setType("audio/x-mpegurl");
1109 lnk.writeLink(); 906 lnk.writeLink();
1110 d->selectedFiles->addToSelection( lnk); 907 d->selectedFiles->addToSelection( lnk);
1111 } 908 }
1112 i++; 909 i++;
1113 } 910 }
1114 } 911 }
1115 } 912 }
1116 } 913 }
1117 f.close(); 914 f.close();
1118} 915}
1119 916
1120void PlayListWidget::writem3u() { 917void PlayListWidget::writem3u() {
1121
1122 InputDialog *fileDlg; 918 InputDialog *fileDlg;
1123 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 919 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1124 fileDlg->exec(); 920 fileDlg->exec();
1125 QString filename,list; 921 QString filename,list;
1126 if( fileDlg->result() == 1 ) { 922 if( fileDlg->result() == 1 ) {
1127 filename = fileDlg->text(); 923 filename = fileDlg->text();
1128 qDebug(filename); 924 qDebug(filename);
1129 int noOfFiles = 0; 925 int noOfFiles = 0;
1130 d->selectedFiles->first(); 926 d->selectedFiles->first();
1131 do { 927 do {
1132 // we dont check for existance because of url's 928 // we dont check for existance because of url's
1133 // qDebug(d->selectedFiles->current()->file()); 929 // qDebug(d->selectedFiles->current()->file());
930
931 // so maybe we should do some net checking to ,-)
1134 list += d->selectedFiles->current()->file()+"\n"; 932 list += d->selectedFiles->current()->file()+"\n";
1135 noOfFiles++; 933 noOfFiles++;
1136 } 934 }
1137 while ( d->selectedFiles->next() ); 935 while ( d->selectedFiles->next() );
1138 qDebug(list); 936 qDebug(list);
1139 if(filename.left(1) != "/") 937 if( filename.left( 1) != "/" ) {
1140 filename=QPEApplication::documentDir()+"/"+filename; 938 filename=QPEApplication::documentDir()+"/"+filename;
1141 if(filename.right(3) != "m3u") 939 }
940 if( filename.right( 3 ) != "m3u" ) {
1142 filename=filename+".m3u"; 941 filename=filename+".m3u";
1143 942 }
1144 QFile f(filename); 943 QFile f(filename);
1145 f.open(IO_WriteOnly); 944 f.open(IO_WriteOnly);
1146 f.writeBlock(list, list.length()); 945 f.writeBlock(list, list.length());
1147 f.close(); 946 f.close();
1148 } 947 }
1149 if(fileDlg) delete fileDlg; 948 if( fileDlg ) {
949 delete fileDlg;
950 }
1150} 951}
1151 952
1152void PlayListWidget::readPls(const QString &filename) { 953void PlayListWidget::readPls(const QString &filename) {
1153 954
1154 qDebug("pls filename is "+filename); 955 qDebug("pls filename is "+filename);
1155 QFile f(filename); 956 QFile f(filename);
1156 957
1157 if(f.open(IO_ReadOnly)) { 958 if(f.open(IO_ReadOnly)) {
1158 QTextStream t(&f); 959 QTextStream t(&f);
1159 QString s;//, first, second; 960 QString s;//, first, second;
1160 int i=0; 961 int i=0;
1161 while ( !t.atEnd()) { 962 while ( !t.atEnd()) {
1162 s=t.readLine(); 963 s=t.readLine();
1163 if(s.left(4) == "File") { 964 if(s.left(4) == "File") {
1164 s=s.right(s.length() - 6); 965 s=s.right(s.length() - 6);
1165 s.replace(QRegExp("%20")," "); 966 s.replace(QRegExp("%20")," ");
1166 qDebug("adding "+s+" to playlist"); 967 qDebug("adding "+s+" to playlist");
1167 // numberofentries=2 968 // numberofentries=2
1168 // File1=http 969 // File1=http
1169 // Title 970 // Title
1170 // Length 971 // Length
1171 // Version 972 // Version
1172 // File2=http 973 // File2=http
1173 s=s.replace( QRegExp("\\"),"/"); 974 s=s.replace( QRegExp("\\"),"/");
1174 DocLnk lnk( s ); 975 DocLnk lnk( s );
1175 QFileInfo f(s); 976 QFileInfo f(s);
1176 QString name = f.baseName(); 977 QString name = f.baseName();
1177 if(name.left(4)=="http") 978 if( name.left( 4 ) == "http" ) {
1178 name = s.right( s.length() - 7); 979 name = s.right( s.length() - 7);
1179 else 980 } else {
1180 name=s; 981 name=s;
982 }
1181 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 983 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1182 lnk.setName( name); 984 lnk.setName( name);
1183 if(s.at(s.length()-4) == '.') // if this is probably a file 985 if(s.at(s.length()-4) == '.') // if this is probably a file
1184 lnk.setFile( s); 986 lnk.setFile( s);
1185 else { //if its a url 987 else { //if its a url
1186 if( name.right(1).find('/') == -1) 988 if( name.right( 1 ).find( '/' ) == -1) {
1187 s+="/"; 989 s+="/";
990 }
1188 lnk.setFile( s); 991 lnk.setFile( s);
1189 } 992 }
1190 lnk.setType("audio/x-mpegurl"); 993 lnk.setType("audio/x-mpegurl");
1191 994
1192 qDebug("DocLnk add "+name); 995 //qDebug("DocLnk add "+name);
1193 d->selectedFiles->addToSelection( lnk); 996 d->selectedFiles->addToSelection( lnk);
1194 } 997 }
1195 } 998 }
1196 i++; 999 i++;
1197 } 1000 }
1198} 1001}
1199 1002
1200void PlayListWidget::pmViewActivated(int index) { 1003void PlayListWidget::pmViewActivated(int index) {
1201// qDebug("%d", index); 1004// qDebug("%d", index);
1202 switch(index) { 1005 switch(index) {
1203 case -16: 1006 case -16:
1204 { 1007 {
1205
1206 mediaPlayerState->toggleFullscreen(); 1008 mediaPlayerState->toggleFullscreen();
1207 bool b=mediaPlayerState->fullscreen(); 1009 bool b=mediaPlayerState->fullscreen();
1208 pmView->setItemChecked( index,b); 1010 pmView->setItemChecked( index,b);
1209 Config cfg( "OpiePlayer" ); 1011 Config cfg( "OpiePlayer" );
1210 cfg.writeEntry("FullScreen", b); 1012 cfg.writeEntry("FullScreen", b);
1211
1212 } 1013 }
1213 break; 1014 break;
1214 }; 1015 };
1215} 1016}
1216 1017
1217void PlayListWidget::populateSkinsMenu() { 1018void PlayListWidget::populateSkinsMenu() {
1218 int item=0; 1019 int item=0;
1219 defaultSkinIndex=0; 1020 defaultSkinIndex=0;
1220 QString skinName; 1021 QString skinName;
1221 Config cfg( "OpiePlayer" ); 1022 Config cfg( "OpiePlayer" );
1222 cfg.setGroup("Options"); 1023 cfg.setGroup("Options");
1223 QString skin = cfg.readEntry("Skin","default"); 1024 QString skin = cfg.readEntry("Skin","default");
1224 1025
1225 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); 1026 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins");
1226 skinsDir.setFilter( QDir::Dirs); 1027 skinsDir.setFilter( QDir::Dirs);
1227 skinsDir.setSorting(QDir::Name); 1028 skinsDir.setSorting(QDir::Name);
1228 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1029 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1229 QFileInfoListIterator it( *skinslist ); 1030 QFileInfoListIterator it( *skinslist );
1230 QFileInfo *fi; 1031 QFileInfo *fi;
1231 while ( (fi=it.current()) ) { 1032 while ( (fi=it.current()) ) {
1232 skinName = fi->fileName(); 1033 skinName = fi->fileName();
1233 qDebug( fi->fileName()); 1034 qDebug( fi->fileName());
1234 if( skinName != "." && skinName != ".." && skinName !="CVS") 1035 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1235 item = skinsMenu->insertItem( fi->fileName()); 1036 item = skinsMenu->insertItem( fi->fileName());
1236 if( skinName == "default") 1037 }
1038 if( skinName == "default" ) {
1237 defaultSkinIndex = item; 1039 defaultSkinIndex = item;
1238 if( skinName == skin) 1040 }
1041 if( skinName == skin ) {
1239 skinsMenu->setItemChecked( item, TRUE); 1042 skinsMenu->setItemChecked( item, TRUE);
1240 1043 }
1241 ++it; 1044 ++it;
1242 } 1045 }
1243} 1046}
1244 1047
1245void PlayListWidget::skinsMenuActivated(int item) { 1048void PlayListWidget::skinsMenuActivated(int item) {
1246 for(uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { 1049 for(uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) {
1247 skinsMenu->setItemChecked( i, FALSE); 1050 skinsMenu->setItemChecked( i, FALSE);
1248 } 1051 }
1249 skinsMenu->setItemChecked( item, TRUE); 1052 skinsMenu->setItemChecked( item, TRUE);
1250 1053
1251 Config cfg( "OpiePlayer" ); 1054 Config cfg( "OpiePlayer" );
1252 cfg.setGroup("Options"); 1055 cfg.setGroup("Options");
1253 cfg.writeEntry("Skin", skinsMenu->text( item)); 1056 cfg.writeEntry("Skin", skinsMenu->text( item));
1254} 1057}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 8710a99..2742252 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,111 +1,120 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
3#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
4 36
5#include <qmainwindow.h> 37#include <qmainwindow.h>
6#include <qpe/applnk.h> 38#include <qpe/applnk.h>
7#include <qtabwidget.h> 39#include <qtabwidget.h>
8#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
9#include <qpushbutton.h> 41#include <qpushbutton.h>
10#include <qpopupmenu.h> 42#include <qpopupmenu.h>
11 43
12/* #include <qtimer.h> */ 44#include "playlistwidgetgui.h"
13 45
14 46
15class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
16class Config; 48class Config;
17class QListViewItem; 49class QListViewItem;
18class QListView; 50class QListView;
19class QPoint; 51class QPoint;
20class QAction; 52class QAction;
21class QLabel; 53class QLabel;
22 54
23class PlayListWidget : public QMainWindow { 55class PlayListWidget : public PlayListWidgetGui {
24 Q_OBJECT 56 Q_OBJECT
25public: 57public:
26 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
27 ~PlayListWidget(); 59 ~PlayListWidget();
28 QTabWidget * tabWidget;
29// MenuItem *fullScreenButton, *scaleButton;
30// QAction *fullScreenButton, *scaleButton;
31 DocLnkSet files; 60 DocLnkSet files;
32 DocLnkSet vFiles; 61 DocLnkSet vFiles;
33 QListView *audioView, *videoView, *playlistView;
34 QLabel *libString;
35 QPopupMenu *pmView ;
36 bool fromSetDocument; 62 bool fromSetDocument;
37 bool insanityBool; 63 bool insanityBool;
38 QString setDocFileRef; 64 QString setDocFileRef;
39 // retrieve the current playlist entry (media file link) 65 // retrieve the current playlist entry (media file link)
40 const DocLnk *current(); 66 const DocLnk *current();
41 void useSelectedDocument(); 67 void useSelectedDocument();
42/* QTimer * menuTimer; */
43 FileSelector* playLists;
44 QPushButton *tbDeletePlaylist;
45 int selected; 68 int selected;
69
46public slots: 70public slots:
47 bool first(); 71 bool first();
48 bool last(); 72 bool last();
49 bool next(); 73 bool next();
50 bool prev(); 74 bool prev();
51 void writeConfig( Config& cfg ) const; 75 void writeConfig( Config& cfg ) const;
52/* void setFullScreen(); */ 76
53/* void setScaled(); */
54protected: 77protected:
55/* void contentsMousePressEvent( QMouseEvent * e ); */
56/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
57void keyReleaseEvent( QKeyEvent *e); 78void keyReleaseEvent( QKeyEvent *e);
58void keyPressEvent( QKeyEvent *e); 79
59private: 80private:
60 int defaultSkinIndex; 81 int defaultSkinIndex;
61 QPopupMenu *skinsMenu;
62 bool audioScan, videoScan; 82 bool audioScan, videoScan;
63 void readm3u(const QString &); 83 void readm3u(const QString &);
64 void readPls(const QString &); 84 void readPls(const QString &);
65
66 void initializeStates(); 85 void initializeStates();
67 void readConfig( Config& cfg ); 86 void readConfig( Config& cfg );
68 PlayListWidgetPrivate *d; // Private implementation data
69 void populateAudioView(); 87 void populateAudioView();
70 void populateVideoView(); 88 void populateVideoView();
89
71private slots: 90private slots:
72 void populateSkinsMenu(); 91 void populateSkinsMenu();
73 void skinsMenuActivated(int); 92 void skinsMenuActivated(int);
74 void pmViewActivated(int); 93 void pmViewActivated(int);
75 void writem3u(); 94 void writem3u();
76 void scanForAudio(); 95 void scanForAudio();
77 void scanForVideo(); 96 void scanForVideo();
78 void openFile(); 97 void openFile();
79 void setDocument( const QString& fileref ); 98 void setDocument( const QString& fileref );
80 void addToSelection( const DocLnk& ); // Add a media file to the playlist 99 void addToSelection( const DocLnk& ); // Add a media file to the playlist
81 void addToSelection( QListViewItem* ); // Add a media file to the playlist 100 void addToSelection( QListViewItem* ); // Add a media file to the playlist
82 void setActiveWindow(); // need to handle this to show the right view
83 void setPlaylist( bool ); // Show/Hide the playlist 101 void setPlaylist( bool ); // Show/Hide the playlist
84 void setView( char );
85 void clearList(); 102 void clearList();
86 void addAllToList(); 103 void addAllToList();
87 void addAllMusicToList(); 104 void addAllMusicToList();
88 void addAllVideoToList(); 105 void addAllVideoToList();
89 void saveList(); // Save the playlist 106 void saveList(); // Save the playlist
90 void loadList( const DocLnk &); // Load a playlist 107 void loadList( const DocLnk &); // Load a playlist
91 void playIt( QListViewItem *); 108 void playIt( QListViewItem *);
92
93 void btnPlay(bool); 109 void btnPlay(bool);
94 void deletePlaylist(); 110 void deletePlaylist();
95 void addSelected(); 111 void addSelected();
96 void removeSelected(); 112 void removeSelected();
97 void tabChanged(QWidget*); 113 void tabChanged(QWidget*);
98 void viewPressed( int, QListViewItem *, const QPoint&, int); 114 void viewPressed( int, QListViewItem *, const QPoint&, int);
99 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 115 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
100 void playSelected(); 116 void playSelected();
101
102protected slots:
103/* void cancelMenuTimer(); */
104/* void showFileMenu(); */
105
106
107}; 117};
108 118
109
110#endif // PLAY_LIST_WIDGET_H 119#endif // PLAY_LIST_WIDGET_H
111 120
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
new file mode 100644
index 0000000..6ecd016
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -0,0 +1,207 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#include <qpe/qpemenubar.h>
35#include <qpe/qpetoolbar.h>
36#include <qpe/fileselector.h>
37#include <qpe/qpeapplication.h>
38#include <qpe/storage.h>
39#include <qpe/mimetype.h>
40#include <qpe/config.h>
41#include <qpe/global.h>
42#include <qpe/resource.h>
43
44#include <qpopupmenu.h>
45#include <qaction.h>
46#include <qcursor.h>
47#include <qdir.h>
48#include <qlayout.h>
49
50#include "playlistselection.h"
51#include "playlistwidget.h"
52#include "mediaplayerstate.h"
53#include "inputDialog.h"
54
55//only needed for the random play
56#include <stdlib.h>
57
58#include "audiowidget.h"
59#include "videowidget.h"
60#include "mediaplayerstate.h"
61
62extern MediaPlayerState *mediaPlayerState;
63
64PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl )
65 : QMainWindow( parent, name, fl ) {
66
67 d = new PlayListWidgetPrivate;
68 d->setDocumentUsed = FALSE;
69 d->current = NULL;
70
71 setBackgroundMode( PaletteButton );
72 setToolBarsMovable( FALSE );
73
74 // Create Toolbar
75 QPEToolBar *toolbar = new QPEToolBar( this );
76 toolbar->setHorizontalStretchable( TRUE );
77
78 // Create Menubar
79 QPEMenuBar *menu = new QPEMenuBar( toolbar );
80 menu->setMargin( 0 );
81
82 bar = new QPEToolBar( this );
83 bar->setLabel( tr( "Play Operations" ) );
84
85 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
86 tbDeletePlaylist->setFlat( TRUE );
87 tbDeletePlaylist->setFixedSize( 20, 20 );
88
89 tbDeletePlaylist->hide();
90
91 pmPlayList = new QPopupMenu( this );
92 menu->insertItem( tr( "File" ), pmPlayList );
93
94 pmView = new QPopupMenu( this );
95 menu->insertItem( tr( "View" ), pmView );
96 pmView->isCheckable();
97
98 skinsMenu = new QPopupMenu( this );
99 pmView->insertItem( tr( "Skins" ), skinsMenu );
100 skinsMenu->isCheckable();
101
102 vbox5 = new QVBox( this );
103 QVBox *vbox4 = new QVBox( vbox5 );
104 QHBox *hbox6 = new QHBox( vbox4 );
105
106 tabWidget = new QTabWidget( hbox6, "tabWidget" );
107
108 QWidget *pTab;
109 pTab = new QWidget( tabWidget, "pTab" );
110 tabWidget->insertTab( pTab,"Playlist");
111
112 QGridLayout *Playout = new QGridLayout( pTab );
113 Playout->setSpacing( 2);
114 Playout->setMargin( 2);
115
116 // Add the playlist area
117 QVBox *vbox3 = new QVBox( pTab );
118 d->playListFrame = vbox3;
119
120 QHBox *hbox2 = new QHBox( vbox3 );
121 d->selectedFiles = new PlayListSelection( hbox2 );
122
123 vbox1 = new QVBox( hbox2 );
124 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
125 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
126
127 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
128
129 QWidget *aTab;
130 aTab = new QWidget( tabWidget, "aTab" );
131
132 QGridLayout *Alayout = new QGridLayout( aTab );
133 Alayout->setSpacing( 2 );
134 Alayout->setMargin( 2 );
135 audioView = new QListView( aTab, "Audioview" );
136 audioView->addColumn( tr( "Title" ), 140 );
137 audioView->addColumn( tr( "Size" ), -1 );
138 audioView->addColumn( tr( "Media" ), -1 );
139 audioView->setColumnAlignment( 1, Qt::AlignRight );
140 audioView->setColumnAlignment( 2, Qt::AlignRight );
141 audioView->setAllColumnsShowFocus( TRUE );
142 audioView->setSorting( 0, TRUE );
143 audioView->setMultiSelection( TRUE );
144 audioView->setSelectionMode( QListView::Extended );
145 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
146 tabWidget->insertTab( aTab, tr( "Audio" ) );
147
148 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
149
150 QWidget *vTab;
151 vTab = new QWidget( tabWidget, "vTab" );
152
153 QGridLayout *Vlayout = new QGridLayout( vTab );
154 Vlayout->setSpacing( 2 );
155 Vlayout->setMargin( 2 );
156 videoView = new QListView( vTab, "Videoview" );
157 videoView->addColumn( tr( "Title" ), 140);
158 videoView->addColumn( tr( "Size" ), -1 );
159 videoView->addColumn(tr( "Media" ), -1 );
160 videoView->setColumnAlignment( 1, Qt::AlignRight );
161 videoView->setColumnAlignment( 2, Qt::AlignRight );
162 videoView->setAllColumnsShowFocus( TRUE );
163 videoView->setSorting( 0, TRUE );
164 videoView->setMultiSelection( TRUE );
165 videoView->setSelectionMode( QListView::Extended );
166 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
167
168 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
169
170 tabWidget->insertTab( vTab, tr( "Video" ) );
171
172 //playlists list
173 QWidget *LTab;
174 LTab = new QWidget( tabWidget, "LTab" );
175 QGridLayout *Llayout = new QGridLayout( LTab );
176 Llayout->setSpacing( 2 );
177 Llayout->setMargin( 2 );
178
179 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy
180 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
181
182 tabWidget->insertTab( LTab, tr( "Lists" ) );
183
184 setCentralWidget( vbox5 );
185}
186
187
188
189PlayListWidgetGui::~PlayListWidgetGui() {
190}
191
192void PlayListWidgetGui::setView( char view ) {
193 if ( view == 'l' )
194 showMaximized();
195 else
196 hide();
197}
198
199
200void PlayListWidgetGui::setActiveWindow() {
201 // qDebug("SETTING active window");
202 // When we get raised we need to ensure that it switches views
203 char origView = mediaPlayerState->view();
204 mediaPlayerState->setView( 'l' ); // invalidate
205 mediaPlayerState->setView( origView ); // now switch back
206}
207
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
new file mode 100644
index 0000000..4c8d737
--- a/dev/null
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
@@ -0,0 +1,126 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#ifndef PLAY_LIST_WIDGET_GUI_H
35#define PLAY_LIST_WIDGET_GUI_H
36
37#include <qmainwindow.h>
38#include <qpe/applnk.h>
39#include <qpe/resource.h>
40#include <qpe/qpemenubar.h>
41
42#include <qtabwidget.h>
43#include <qpe/fileselector.h>
44#include <qpushbutton.h>
45#include <qpopupmenu.h>
46#include <qaction.h>
47
48
49class PlayListWidgetPrivate;
50class PlayListSelection;
51
52class Config;
53class QPEToolBar;
54class QListViewItem;
55class QListView;
56class QPoint;
57class QAction;
58class QLabel;
59
60class PlayListWidgetPrivate {
61public:
62 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
63 QFrame *playListFrame;
64 FileSelector *files;
65 PlayListSelection *selectedFiles;
66 bool setDocumentUsed;
67 DocLnk *current;
68};
69
70
71class ToolButton : public QToolButton {
72public:
73 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
74 : QToolButton( parent, name ) {
75 setTextLabel( name );
76 setPixmap( Resource::loadPixmap( icon ) );
77 setAutoRaise( TRUE );
78 setFocusPolicy( QWidget::NoFocus );
79 setToggleButton( t );
80 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
81 QPEMenuToolFocusManager::manager()->addWidget( this );
82 }
83};
84
85
86class MenuItem : public QAction {
87
88public:
89 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
90 : QAction( text, QString::null, 0, 0 ) {
91 connect( this, SIGNAL( activated() ), handler, slot );
92 addTo( parent );
93 }
94};
95
96class PlayListWidgetGui : public QMainWindow {
97 Q_OBJECT
98public:
99 PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 );
100 ~PlayListWidgetGui();
101
102protected:
103 QTabWidget * tabWidget;
104 QListView *audioView, *videoView, *playlistView;
105 QLabel *libString;
106 QPopupMenu *pmView ;
107 bool fromSetDocument;
108 bool insanityBool;
109 QString setDocFileRef;
110 // retrieve the current playlist entry (media file link)
111 QPushButton *tbDeletePlaylist;
112 int selected;
113 QPopupMenu *pmPlayList;
114 FileSelector* playLists;
115 QPopupMenu *skinsMenu;
116 PlayListWidgetPrivate *d; // Private implementation data
117 QVBox *vbox1;
118 QVBox *vbox5;
119 QPEToolBar *bar;
120 void setActiveWindow(); // need to handle this to show the right view
121 void setView( char );
122
123};
124
125#endif
126