summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-21 20:42:09 (UTC)
committer harlekin <harlekin>2002-08-21 20:42:09 (UTC)
commit462117a0f60287d5309932937c24da3ab1292476 (patch) (unidiff)
tree1877224879c5d953b257712171637de87a2966dc
parent10739e8b7d203e56ef30011770f6d12d8b0bb270 (diff)
downloadopie-462117a0f60287d5309932937c24da3ab1292476.zip
opie-462117a0f60287d5309932937c24da3ab1292476.tar.gz
opie-462117a0f60287d5309932937c24da3ab1292476.tar.bz2
started taking playlistwidget apart, also made gui a bit more beautiful
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro29
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp1631
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h71
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp207
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h126
5 files changed, 1105 insertions, 959 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 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S 13 playlistwidgetgui.cpp\
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,792 +1,640 @@
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 62
93 d = new PlayListWidgetPrivate; 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
94 d->setDocumentUsed = FALSE; 64 this , SLOT(addSelected() ) );
95 d->current = NULL; 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
96 fromSetDocument = FALSE; 66 this , SLOT(removeSelected() ) );
97 insanityBool=FALSE; 67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
98 audioScan = FALSE; 68 this , SLOT( btnPlay( bool) ), TRUE );
99 videoScan = FALSE; 69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
100 70 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
101 setBackgroundMode( PaletteButton ); 71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
102 72 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
103// setCaption( tr("OpiePlayer") ); 73
104// setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
105 75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
106 setToolBarsMovable( FALSE ); 76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
107 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
108 // Create Toolbar 78 pmPlayList->insertSeparator(-1);
109 QPEToolBar *toolbar = new QPEToolBar( this ); 79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
110 toolbar->setHorizontalStretchable( TRUE ); 80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
111 81 pmPlayList->insertSeparator(-1);
112 // Create Menubar 82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
113 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 83 pmPlayList->insertSeparator(-1);
114 menu->setMargin( 0 ); 84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
115 85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
116 QPEToolBar *bar = new QPEToolBar( this ); 86
117 bar->setLabel( tr( "Play Operations" ) ); 87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
118 88
119 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 89 Config cfg( "OpiePlayer" );
120 tbDeletePlaylist->setFlat(TRUE); 90 bool b= cfg.readBoolEntry("FullScreen", 0);
121 tbDeletePlaylist->setFixedSize(20,20); 91 mediaPlayerState->setFullscreen( b );
122 92 pmView->setItemChecked( -16, b );
123 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 93
124 this , SLOT(addSelected()) ); 94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) );
125 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) );
126 this , SLOT(removeSelected()) ); 96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) );
127 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 97 QVBox *stretch2 = new QVBox( vbox1 );
128 this , SLOT( btnPlay(bool) ), TRUE ); 98
129 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) );
130 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) );
131 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) );
132 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
133 tbDeletePlaylist->hide(); 103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
134 104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
135 QPopupMenu *pmPlayList = new QPopupMenu( this ); 105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
136 menu->insertItem( tr( "File" ), pmPlayList ); 106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
137 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 107 this,SLOT( playIt( QListViewItem *) ) );
138 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
139 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
140 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
141 pmPlayList->insertSeparator(-1); 111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
142 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 112 this,SLOT( playIt( QListViewItem *) ) );
143 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
144 pmPlayList->insertSeparator(-1); 114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
145 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) );
146 pmPlayList->insertSeparator(-1); 116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
147 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
148 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
149 119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
150 pmView = new QPopupMenu( this ); 120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
151 menu->insertItem( tr( "View" ), pmView ); 121
152 pmView->isCheckable(); 122 readConfig( cfg );
153 123 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 124 loadList(DocLnk( currentPlaylist ) );
155 125 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
156 Config cfg( "OpiePlayer" ); 126
157 bool b= cfg.readBoolEntry("FullScreen", 0); 127 // see which skins are installed
158 mediaPlayerState->setFullscreen( b ); 128 populateSkinsMenu();
159 pmView->setItemChecked( -16, b ); 129 initializeStates();
160
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()) );
201 (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()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
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
271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
272
273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
274
275 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)),
280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
284 this,SLOT( playIt( QListViewItem *)) );
285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) );
290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
298
299 setCentralWidget( vbox5 );
300
301 readConfig( cfg );
302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
303 loadList(DocLnk( currentPlaylist));
304 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
305
306 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 137 if ( d->current ) {
315 if ( d->current ) { 138 delete d->current;
316 delete d->current; 139 }
317 } 140 delete d;
318 delete d;
319} 141}
320 142
321 143
322void PlayListWidget::initializeStates() { 144void PlayListWidget::initializeStates() {
323 145 d->tbPlay->setOn( mediaPlayerState->playing() );
324 d->tbPlay->setOn( mediaPlayerState->playing() ); 146 d->tbLoop->setOn( mediaPlayerState->looping() );
325 d->tbLoop->setOn( mediaPlayerState->looping() ); 147 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
326 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 148 setPlaylist( true );
327 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 }
165 }
344 } 166 }
345 } 167 d->selectedFiles->setSelectedItem( currentString );
346 d->selectedFiles->setSelectedItem( currentString);
347} 168}
348 169
349 170
350void PlayListWidget::writeConfig( Config& cfg ) const { 171void PlayListWidget::writeConfig( Config& cfg ) const {
351 172 d->selectedFiles->writeCurrent( cfg );
352 d->selectedFiles->writeCurrent( cfg); 173 cfg.setGroup( "PlayList" );
353 cfg.setGroup("PlayList"); 174 int noOfFiles = 0;
354 int noOfFiles = 0; 175 d->selectedFiles->first();
355 d->selectedFiles->first(); 176 do {
356 do { 177 const DocLnk *lnk = d->selectedFiles->current();
357 const DocLnk *lnk = d->selectedFiles->current(); 178 if ( lnk ) {
358 if ( lnk ) { 179 QString entryName;
359 QString entryName; 180 entryName.sprintf( "File%i", noOfFiles + 1 );
360 entryName.sprintf( "File%i", noOfFiles + 1 ); 181 cfg.writeEntry( entryName, lnk->linkFile() );
361 cfg.writeEntry( entryName, lnk->linkFile() ); 182 // if this link does exist, add it so we have the file
362 // if this link does exist, add it so we have the file 183 // next time...
363 // next time... 184 if ( !QFile::exists( lnk->linkFile() ) ) {
364 if ( !QFile::exists( lnk->linkFile() ) ) { 185 // the way writing lnks doesn't really check for out
365 // the way writing lnks doesn't really check for out 186 // of disk space, but check it anyway.
366 // of disk space, but check it anyway. 187 if ( !lnk->writeLink() ) {
367 if ( !lnk->writeLink() ) { 188 QMessageBox::critical( 0, tr("Out of space"),
368 QMessageBox::critical( 0, tr("Out of space"), 189 tr( "There was a problem saving "
369 tr( "There was a problem saving " 190 "the playlist.\n"
370 "the playlist.\n" 191 "Your playlist "
371 "Your playlist " 192 "may be missing some entries\n"
372 "may be missing some entries\n" 193 "the next time you start it." )
373 "the next time you start it." ) 194 );
374 ); 195 }
196 }
197 noOfFiles++;
375 } 198 }
376 }
377 noOfFiles++;
378 } 199 }
379 } 200 while ( d->selectedFiles->next() );
380 while ( d->selectedFiles->next() ); 201 cfg.writeEntry("NumberOfFiles", noOfFiles );
381 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
403void PlayListWidget::addAllToList() { 223void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
404 DocLnkSet filesAll; 224 switch (mouse) {
405 Global::findDocuments(&filesAll, "video/*;audio/*"); 225 case 1:
406 QListIterator<DocLnk> Adit( filesAll.children() ); 226 break;
407 for ( ; Adit.current(); ++Adit ) { 227 case 2:
408 if(QFileInfo(Adit.current()->file()).exists()) { 228 {
409 d->selectedFiles->addToSelection( **Adit ); 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;
410 } 235 }
411 }
412} 236}
413 237
414 238
415void PlayListWidget::addAllMusicToList() { 239void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
416 QListIterator<DocLnk> dit( files.children() ); 240 switch (mouse) {
417 for ( ; dit.current(); ++dit ) { 241 case 1:
418 if(QFileInfo(dit.current()->file()).exists()) { 242 break;
419 d->selectedFiles->addToSelection( **dit ); 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;
420 } 251 }
421 }
422} 252}
423 253
424 254
425void PlayListWidget::addAllVideoToList() { 255void PlayListWidget::addAllToList() {
426 QListIterator<DocLnk> dit( vFiles.children() ); 256 DocLnkSet filesAll;
427 for ( ; dit.current(); ++dit ) 257 Global::findDocuments(&filesAll, "video/*;audio/*");
428 if(QFileInfo( dit.current()->file()).exists()) 258 QListIterator<DocLnk> Adit( filesAll.children() );
429 d->selectedFiles->addToSelection( **dit ); 259 for ( ; Adit.current(); ++Adit ) {
260 if( QFileInfo( Adit.current()->file() ).exists() ) {
261 d->selectedFiles->addToSelection( **Adit );
262 }
263 }
430} 264}
431 265
432 266
433void PlayListWidget::setDocument(const QString& fileref) { 267void PlayListWidget::addAllMusicToList() {
434 qDebug(fileref); 268 QListIterator<DocLnk> dit( files.children() );
435 fromSetDocument = TRUE; 269 for ( ; dit.current(); ++dit ) {
436 if ( fileref.isNull() ) { 270 if( QFileInfo(dit.current()->file() ).exists() ) {
437 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 271 d->selectedFiles->addToSelection( **dit );
438 return; 272 }
439 } 273 }
274}
440 275
441 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 276
442 readm3u( fileref); 277void PlayListWidget::addAllVideoToList() {
443 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 278 QListIterator<DocLnk> dit( vFiles.children() );
444 readPls( fileref); 279 for ( ; dit.current(); ++dit ) {
445 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 280 if( QFileInfo( dit.current()->file() ).exists() ) {
446 clearList(); 281 d->selectedFiles->addToSelection( **dit );
447 loadList(DocLnk(fileref)); 282 }
448 d->selectedFiles->first(); 283 }
449 } else {
450 clearList();
451 addToSelection( DocLnk( fileref ) );
452 d->setDocumentUsed = TRUE;
453 mediaPlayerState->setPlaying( FALSE );
454 qApp->processEvents();
455 mediaPlayerState->setPlaying( TRUE );
456 qApp->processEvents();
457 setCaption(tr("OpiePlayer"));
458 }
459} 284}
460 285
461 286
462void PlayListWidget::setActiveWindow() { 287void PlayListWidget::setDocument( const QString& fileref ) {
463// qDebug("SETTING active window"); 288 //qDebug( fileref );
464 // When we get raised we need to ensure that it switches views 289 fromSetDocument = TRUE;
465 char origView = mediaPlayerState->view(); 290 if ( fileref.isNull() ) {
466 mediaPlayerState->setView( 'l' ); // invalidate 291 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
467 mediaPlayerState->setView( origView ); // now switch back 292 return;
293 }
294
295 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
296 readm3u( fileref );
297 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
298 readPls( fileref );
299 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
300 clearList();
301 loadList( DocLnk( fileref ) );
302 d->selectedFiles->first();
303 } else {
304 clearList();
305 addToSelection( DocLnk( fileref ) );
306 d->setDocumentUsed = TRUE;
307 mediaPlayerState->setPlaying( FALSE );
308 qApp->processEvents();
309 mediaPlayerState->setPlaying( TRUE );
310 qApp->processEvents();
311 setCaption( tr("OpiePlayer") );
312 }
468} 313}
469 314
470 315
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 322 switch ( tabWidget->currentPageIndex() ) {
478 switch (tabWidget->currentPageIndex()) { 323 case 0: //playlist
479 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;
343 }
499 } 344 }
500 }
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;
355 }
511 } 356 }
512 }
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();
531 return TRUE; 376 }
532 } else { 377 return TRUE;
533 if ( !d->selectedFiles->prev() ) {
534 if ( mediaPlayerState->looping() ) {
535 return d->selectedFiles->last();
536 } else { 378 } else {
537 return FALSE; 379 if ( !d->selectedFiles->prev() ) {
380 if ( mediaPlayerState->looping() ) {
381 return d->selectedFiles->last();
382 } else {
383 return FALSE;
384 }
385 }
386 return TRUE;
538 } 387 }
539 } 388 } else {
540 return TRUE; 389 return mediaPlayerState->looping();
541 }
542 } else {
543 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 {
553 if ( !d->selectedFiles->next() ) {
554 if ( mediaPlayerState->looping() ) {
555 return d->selectedFiles->first();
556 } else { 398 } else {
557 return FALSE; 399 if ( !d->selectedFiles->next() ) {
400 if ( mediaPlayerState->looping() ) {
401 return d->selectedFiles->first();
402 } else {
403 return FALSE;
404 }
405 }
406 return TRUE;
558 } 407 }
559 } 408 } else {
560 return TRUE; 409 return mediaPlayerState->looping();
561 } 410 }
562 } else {
563 return mediaPlayerState->looping();
564 }
565} 411}
566 412
567 413
568bool PlayListWidget::first() { 414bool PlayListWidget::first() {
569 if ( mediaPlayerState->playlist() ) 415 if ( mediaPlayerState->playlist() )
570 return d->selectedFiles->first(); 416 return d->selectedFiles->first();
571 else 417 else
572 return mediaPlayerState->looping(); 418 return mediaPlayerState->looping();
573} 419}
574 420
575 421
576bool PlayListWidget::last() { 422bool PlayListWidget::last() {
577 if ( mediaPlayerState->playlist() ) 423 if ( mediaPlayerState->playlist() )
578 return d->selectedFiles->last(); 424 return d->selectedFiles->last();
579 else 425 else
580 return mediaPlayerState->looping(); 426 return mediaPlayerState->looping();
581} 427}
582 428
583 429
584void PlayListWidget::saveList() { 430void PlayListWidget::saveList() {
585 431
586 QString filename; 432 QString filename;
587 InputDialog *fileDlg = 0l; 433 InputDialog *fileDlg = 0l;
588 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 434 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
589 fileDlg->exec(); 435 fileDlg->exec();
590 if( fileDlg->result() == 1 ) { 436 if( fileDlg->result() == 1 ) {
591 if ( d->current ) 437 if ( d->current )
592 delete d->current; 438 delete d->current;
593 filename = fileDlg->text();//+".playlist"; 439 filename = fileDlg->text();//+".playlist";
594 // qDebug("saving playlist "+filename+".playlist"); 440 // qDebug("saving playlist "+filename+".playlist");
595 Config cfg( filename +".playlist"); 441 Config cfg( filename +".playlist");
596 writeConfig( cfg ); 442 writeConfig( cfg );
597 443
598 DocLnk lnk; 444 DocLnk lnk;
599 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 445 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
600 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 446 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
601 lnk.setIcon("opieplayer2/playlist2"); 447 lnk.setIcon("opieplayer2/playlist2");
602 lnk.setName( filename); //sets file name 448 lnk.setName( filename); //sets file name
603 // qDebug(filename); 449 // qDebug(filename);
604 if(!lnk.writeLink()) { 450 if(!lnk.writeLink()) {
605 qDebug("Writing doclink did not work"); 451 qDebug("Writing doclink did not work");
452 }
453 }
454 Config config( "OpiePlayer" );
455 config.writeEntry("CurrentPlaylist",filename);
456 setCaption(tr("OpiePlayer: ")+filename);
457 d->selectedFiles->first();
458 if(fileDlg) {
459 delete fileDlg;
606 } 460 }
607 }
608 Config config( "OpiePlayer" );
609 config.writeEntry("CurrentPlaylist",filename);
610 setCaption(tr("OpiePlayer: ")+filename);
611 d->selectedFiles->first();
612 if(fileDlg) {
613 delete fileDlg;
614 }
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 }
512 }
513 audioView->setSelected( it.current(),FALSE);
514 }
672 } 515 }
673 audioView->setSelected( it.current(),FALSE); 516 tabWidget->setCurrentPage(0);
674 }
675 } 517 }
676 tabWidget->setCurrentPage(0); 518 break;
677 } 519 case 2: { // video
678 break; 520 QListViewItemIterator it( videoView );
679 case 2: { // video
680 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 }
533 }
534 tabWidget->setCurrentPage(0);
693 } 535 }
694 tabWidget->setCurrentPage(0);
695 }
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
711void PlayListWidget::addToSelection( QListViewItem *it) {
712 d->setDocumentUsed = FALSE;
713 553
714 if(it) { 554void PlayListWidget::addToSelection( QListViewItem *it) {
715 switch (tabWidget->currentPageIndex()) { 555 d->setDocumentUsed = FALSE;
716 case 1: { 556
717 QListIterator<DocLnk> dit( files.children() ); 557 if(it) {
718 for ( ; dit.current(); ++dit ) { 558 switch (tabWidget->currentPageIndex()) {
719 if( dit.current()->name() == it->text(0)) { 559 case 1: {
720 if(QFileInfo( dit.current()->file()).exists()) 560 QListIterator<DocLnk> dit( files.children() );
721 d->selectedFiles->addToSelection( **dit ); 561 for ( ; dit.current(); ++dit ) {
722 } 562 if( dit.current()->name() == it->text(0)) {
563 if(QFileInfo( dit.current()->file()).exists())
564 d->selectedFiles->addToSelection( **dit );
565 }
723 } 566 }
724 }
725 break;
726 case 2: {
727 QListIterator<DocLnk> dit( vFiles.children() );
728 for ( ; dit.current(); ++dit ) {
729 if( dit.current()->name() == it->text(0)) {
730 if(QFileInfo( dit.current()->file()).exists())
731 d->selectedFiles->addToSelection( **dit );
732 } 567 }
733 } 568 break;
569 case 2: {
570 QListIterator<DocLnk> dit( vFiles.children() );
571 for ( ; dit.current(); ++dit ) {
572 if( dit.current()->name() == it->text(0)) {
573 if(QFileInfo( dit.current()->file()).exists())
574 d->selectedFiles->addToSelection( **dit );
575 }
576 }
577 }
578 break;
579 case 0:
580 break;
581 };
582 tabWidget->setCurrentPage(0);
734 } 583 }
735 break;
736 case 0:
737 break;
738 };
739 tabWidget->setCurrentPage(0);
740 }
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();
750 d->tbRemoveFromList->setEnabled(TRUE); 594 }
751 d->tbAddToList->setEnabled(FALSE); 595 d->tbRemoveFromList->setEnabled(TRUE);
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();
761 d->tbRemoveFromList->setEnabled(FALSE); 606 }
762 d->tbAddToList->setEnabled(TRUE); 607 d->tbRemoveFromList->setEnabled(FALSE);
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();
771 d->tbRemoveFromList->setEnabled(FALSE); 617 }
772 d->tbAddToList->setEnabled(TRUE); 618 d->tbRemoveFromList->setEnabled(FALSE);
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();
779 playLists->reread(); 626 }
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 }
@@ -827,44 +675,15 @@ void PlayListWidget::deletePlaylist() {
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}
850
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} 684}
866 685
867 686
868void PlayListWidget::scanForAudio() { 687void PlayListWidget::scanForAudio() {
869// qDebug("scan for audio"); 688// qDebug("scan for audio");
870 files.detachChildren(); 689 files.detachChildren();
@@ -885,104 +704,110 @@ void PlayListWidget::scanForVideo() {
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() {
710 audioView->clear();
711 StorageInfo storageInfo;
712 const QList<FileSystem> &fs = storageInfo.fileSystems();
713 if(!audioScan) {
714 scanForAudio();
715 }
891 716
892 audioView->clear(); 717 QListIterator<DocLnk> dit( files.children() );
893 StorageInfo storageInfo; 718 QListIterator<FileSystem> it ( fs );
894 const QList<FileSystem> &fs = storageInfo.fileSystems();
895 if(!audioScan) scanForAudio();
896
897 QListIterator<DocLnk> dit( files.children() );
898 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 ) {
906 } 726 storage = name;
727 }
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" ) );
736 }
914 } 737 }
915 }
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 ) {
925 747 scanForVideo();
926 QListIterator<DocLnk> Vdit( vFiles.children() );
927 QListIterator<FileSystem> it ( fs );
928 videoView->clear();
929 QString storage;
930 for ( ; Vdit.current(); ++Vdit ) {
931 for( ; it.current(); ++it ){
932 const QString name = (*it)->name();
933 const QString path = (*it)->path();
934 if( Vdit.current()->file().find(path) != -1 ) storage=name;
935 } 748 }
936 749
937 QListViewItem * newItem; 750 QListIterator<DocLnk> Vdit( vFiles.children() );
938 if ( QFile( Vdit.current()->file()).exists() ) { 751 QListIterator<FileSystem> it ( fs );
939 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 752 videoView->clear();
940 QString::number( QFile( Vdit.current()->file()).size() ), storage); 753 QString storage;
941 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); 754 for ( ; Vdit.current(); ++Vdit ) {
755 for( ; it.current(); ++it ) {
756 const QString name = (*it)->name();
757 const QString path = (*it)->path();
758 if( Vdit.current()->file().find(path) != -1 ) {
759 storage=name;
760 }
761 }
762
763 QListViewItem * newItem;
764 if ( QFile( Vdit.current()->file() ).exists() ) {
765 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
766 QString::number( QFile( Vdit.current()->file() ).size() ), storage );
767 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
768 }
942 } 769 }
943 }
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 789 lnk.setName( filename ); //sets file name
963 lnk.setName(filename); //sets file name 790 lnk.setFile( filename ); //sets File property
964 lnk.setFile(filename); //sets File property 791 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
965 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 792 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
966 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 793 lnk.setExec( "opieplayer" );
967 lnk.setExec("opieplayer"); 794 lnk.setIcon( "opieplayer2/MPEGPlayer" );
968 lnk.setIcon("opieplayer2/MPEGPlayer"); 795
969 796 if( !lnk.writeLink() ) {
970 if(!lnk.writeLink()) { 797 qDebug( "Writing doclink did not work" );
971 qDebug("Writing doclink did not work"); 798 }
972 } 799 d->selectedFiles->addToSelection( lnk );
973 d->selectedFiles->addToSelection( lnk); 800 }
801 }
802 if( fileDlg ) {
803 delete fileDlg;
974 } 804 }
975 }
976 if(fileDlg) {
977 delete fileDlg;
978 }
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;
@@ -1009,22 +834,22 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1009 // playSelected(); 834 // playSelected();
1010 // break; 835 // break;
1011 case Key_Space: 836 case Key_Space:
1012 // playSelected(); puh 837 // playSelected(); puh
1013 break; 838 break;
1014 case Key_1: 839 case Key_1:
1015 tabWidget->setCurrentPage(0); 840 tabWidget->setCurrentPage( 0 );
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;
@@ -1034,221 +859,199 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1034 859
1035 break; 860 break;
1036 861
1037 } 862 }
1038} 863}
1039 864
1040void PlayListWidget::keyPressEvent( QKeyEvent *) 865void PlayListWidget::readm3u( const QString &filename ) {
1041{ 866 qDebug( "m3u filename is " + filename );
1042 // qDebug("Key press"); 867 QFile f( filename );
1043 // switch ( e->key() ) { 868
1044 // ////////////////////////////// Zaurus keys 869 if( f.open( IO_ReadOnly ) ) {
1045 // case Key_A: //add to playlist 870 QTextStream t(&f);
1046 // qDebug("Add"); 871 QString s;//, first, second;
1047 // addSelected(); 872 int i=0;
1048 // break; 873 while ( !t.atEnd() ) {
1049 // case Key_R: //remove from playlist 874 s=t.readLine();
1050 // removeSelected(); 875
1051 // break; 876 if( s.find( "#", 0, TRUE) == -1 ) {
1052 // case Key_P: //play 877 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat
1053 // qDebug("Play"); 878 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
1054 // playSelected(); 879 s = s.right( s.length() -2 );
1055 // break; 880 DocLnk lnk( s );
1056 // case Key_Space: 881 QFileInfo f( s );
1057 // qDebug("Play"); 882 QString name = f.baseName();
1058 // playSelected(); 883 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
1059 // break; 884 lnk.setName( name );
1060 // } 885 s=s.replace( QRegExp( "\\" ), "/" );
1061} 886 lnk.setFile( s );
1062 887 lnk.writeLink();
1063 888 qDebug( "add " + name);
1064 889 d->selectedFiles->addToSelection( lnk );
1065void PlayListWidget::readm3u(const QString &filename) { 890 } else { // is url
1066 891 s.replace( QRegExp( "%20" )," " );
1067 qDebug("m3u filename is "+filename); 892 DocLnk lnk( s );
1068 QFile f(filename); 893 QString name;
1069 894 if( name.left( 4 ) == "http" ) {
1070 if(f.open(IO_ReadOnly)) { 895 name = s.right( s.length() - 7 );
1071 QTextStream t(&f); 896 } else {
1072 QString s;//, first, second; 897 name = s;
1073 int i=0; 898 }
1074 while ( !t.atEnd()) { 899 lnk.setName( name );
1075 s=t.readLine(); 900 if( s.at( s.length() - 4) == '.' ) {
1076 901 lnk.setFile( s );
1077 if(s.find("#",0,TRUE) == -1) { 902 } else {
1078 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 903 lnk.setFile( s + "/" );
1079 if(s.left(2) == "E:" || s.left(2) == "P:") { 904 }
1080 s=s.right(s.length()-2); 905 lnk.setType( "audio/x-mpegurl" );
1081 // if(QFile(s).exists()) { 906 lnk.writeLink();
1082 DocLnk lnk( s ); 907 d->selectedFiles->addToSelection( lnk );
1083 QFileInfo f(s); 908 }
1084 QString name = f.baseName(); 909 i++;
1085 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 910 }
1086 lnk.setName( name );
1087 s=s.replace( QRegExp("\\"),"/");
1088 lnk.setFile( s );
1089 lnk.writeLink();
1090 qDebug("add "+name);
1091 d->selectedFiles->addToSelection( lnk);
1092 // }
1093 } else { // is url
1094 s.replace(QRegExp("%20")," ");
1095 DocLnk lnk( s );
1096 QString name;
1097 if(name.left(4)=="http") {
1098 name = s.right( s.length() - 7);
1099 } else {
1100 name = s;
1101 } 911 }
1102 lnk.setName(name);
1103 if(s.at(s.length()-4) == '.') {
1104 lnk.setFile( s);
1105 } else {
1106 lnk.setFile( s+"/");
1107 }
1108 lnk.setType("audio/x-mpegurl");
1109 lnk.writeLink();
1110 d->selectedFiles->addToSelection( lnk);
1111 }
1112 i++;
1113 } 912 }
1114 }
1115 } 913 }
1116 } 914 f.close();
1117 f.close();
1118} 915}
1119 916
1120void PlayListWidget::writem3u() { 917void PlayListWidget::writem3u() {
1121 918 InputDialog *fileDlg;
1122 InputDialog *fileDlg; 919 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1123 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 920 fileDlg->exec();
1124 fileDlg->exec(); 921 QString filename, list;
1125 QString filename,list; 922 if( fileDlg->result() == 1 ) {
1126 if( fileDlg->result() == 1 ) { 923 filename = fileDlg->text();
1127 filename = fileDlg->text(); 924 qDebug( filename );
1128 qDebug(filename); 925 int noOfFiles = 0;
1129 int noOfFiles = 0; 926 d->selectedFiles->first();
1130 d->selectedFiles->first(); 927 do {
1131 do { 928 // we dont check for existance because of url's
1132 // we dont check for existance because of url's 929 // qDebug(d->selectedFiles->current()->file());
1133 // qDebug(d->selectedFiles->current()->file()); 930
1134 list += d->selectedFiles->current()->file()+"\n"; 931 // so maybe we should do some net checking to ,-)
1135 noOfFiles++; 932 list += d->selectedFiles->current()->file() + "\n";
933 noOfFiles++;
934 }
935 while ( d->selectedFiles->next() );
936 qDebug( list );
937 if( filename.left( 1) != "/" ) {
938 filename=QPEApplication::documentDir() + "/" + filename;
939 }
940 if( filename.right( 3 ) != "m3u" ) {
941 filename=filename+".m3u";
942 }
943 QFile f( filename );
944 f.open( IO_WriteOnly );
945 f.writeBlock( list, list.length() );
946 f.close();
947 }
948 if( fileDlg ) {
949 delete fileDlg;
1136 } 950 }
1137 while ( d->selectedFiles->next() );
1138 qDebug(list);
1139 if(filename.left(1) != "/")
1140 filename=QPEApplication::documentDir()+"/"+filename;
1141 if(filename.right(3) != "m3u")
1142 filename=filename+".m3u";
1143
1144 QFile f(filename);
1145 f.open(IO_WriteOnly);
1146 f.writeBlock(list, list.length());
1147 f.close();
1148 }
1149 if(fileDlg) delete fileDlg;
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;
1181 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 982 }
1182 lnk.setName( name); 983 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1183 if(s.at(s.length()-4) == '.') // if this is probably a file 984 lnk.setName( name );
1184 lnk.setFile( s); 985 if( s.at( s.length() - 4) == '.') // if this is probably a file
1185 else { //if its a url 986 lnk.setFile( s );
1186 if( name.right(1).find('/') == -1) 987 else { //if its a url
1187 s+="/"; 988 if( name.right( 1 ).find( '/' ) == -1) {
1188 lnk.setFile( s); 989 s += "/";
990 }
991 lnk.setFile( s );
992 }
993 lnk.setType( "audio/x-mpegurl" );
994
995 //qDebug("DocLnk add "+name);
996 d->selectedFiles->addToSelection( lnk );
997 }
1189 } 998 }
1190 lnk.setType("audio/x-mpegurl"); 999 i++;
1191
1192 qDebug("DocLnk add "+name);
1193 d->selectedFiles->addToSelection( lnk);
1194 }
1195 } 1000 }
1196 i++;
1197 }
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 1008 mediaPlayerState->toggleFullscreen();
1206 mediaPlayerState->toggleFullscreen(); 1009 bool b=mediaPlayerState->fullscreen();
1207 bool b=mediaPlayerState->fullscreen(); 1010 pmView->setItemChecked( index, b);
1208 pmView->setItemChecked( index,b); 1011 Config cfg( "OpiePlayer" );
1209 Config cfg( "OpiePlayer" ); 1012 cfg.writeEntry( "FullScreen", b );
1210 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 }
1237 defaultSkinIndex = item; 1038 if( skinName == "default" ) {
1238 if( skinName == skin) 1039 defaultSkinIndex = item;
1239 skinsMenu->setItemChecked( item, TRUE); 1040 }
1240 1041 if( skinName == skin ) {
1241 ++it; 1042 skinsMenu->setItemChecked( item, TRUE );
1242 } 1043 }
1044 ++it;
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 ); */ 78 void keyReleaseEvent( QKeyEvent *e);
56/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 79
57void keyReleaseEvent( QKeyEvent *e);
58void keyPressEvent( QKeyEvent *e);
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