summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/playlistwidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6c4d07f..3bd04bc 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,50 +1,50 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50 50
@@ -97,64 +97,65 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
97 QVBox *stretch2 = new QVBox( vbox1 ); 97 QVBox *stretch2 = new QVBox( vbox1 );
98 98
99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); 99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) );
100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); 100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) );
101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); 101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) );
102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
107 this,SLOT( playIt( QListViewItem *) ) ); 107 this,SLOT( playIt( QListViewItem *) ) );
108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
112 this,SLOT( playIt( QListViewItem *) ) ); 112 this,SLOT( playIt( QListViewItem *) ) );
113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); 115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) );
116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
121 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) );
121 122
122 readConfig( cfg ); 123 readConfig( cfg );
123 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 124 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
124 loadList(DocLnk( currentPlaylist ) ); 125 loadList(DocLnk( currentPlaylist ) );
125 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 126 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
126 127
127 // see which skins are installed 128 // see which skins are installed
128 videoScan=FALSE; 129 videoScan=FALSE;
129 audioScan=FALSE; 130 audioScan=FALSE;
130 populateSkinsMenu(); 131 populateSkinsMenu();
131 initializeStates(); 132 initializeStates();
132} 133}
133 134
134 135
135PlayListWidget::~PlayListWidget() { 136PlayListWidget::~PlayListWidget() {
136 // WTF?!@?! 137 // WTF?!@?!
137 138
138 if ( d->current ) { 139 if ( d->current ) {
139 delete d->current; 140 delete d->current;
140 } 141 }
141 delete d; 142 delete d;
142} 143}
143 144
144 145
145void PlayListWidget::initializeStates() { 146void PlayListWidget::initializeStates() {
146 d->tbPlay->setOn( mediaPlayerState->playing() ); 147 d->tbPlay->setOn( mediaPlayerState->playing() );
147 d->tbLoop->setOn( mediaPlayerState->looping() ); 148 d->tbLoop->setOn( mediaPlayerState->looping() );
148 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 149 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
149 setPlaylist( true ); 150 setPlaylist( true );
150} 151}
151 152
152 153
153void PlayListWidget::readConfig( Config& cfg ) { 154void PlayListWidget::readConfig( Config& cfg ) {
154 cfg.setGroup( "PlayList" ); 155 cfg.setGroup( "PlayList" );
155 QString currentString = cfg.readEntry( "current", "" ); 156 QString currentString = cfg.readEntry( "current", "" );
156 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 157 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
157 for ( int i = 0; i < noOfFiles; i++ ) { 158 for ( int i = 0; i < noOfFiles; i++ ) {
158 QString entryName; 159 QString entryName;
159 entryName.sprintf( "File%i", i + 1 ); 160 entryName.sprintf( "File%i", i + 1 );
160 QString linkFile = cfg.readEntry( entryName ); 161 QString linkFile = cfg.readEntry( entryName );
@@ -712,49 +713,49 @@ void PlayListWidget::populateAudioView() {
712 StorageInfo storageInfo; 713 StorageInfo storageInfo;
713 const QList<FileSystem> &fs = storageInfo.fileSystems(); 714 const QList<FileSystem> &fs = storageInfo.fileSystems();
714 if(!audioScan) { 715 if(!audioScan) {
715 scanForAudio(); 716 scanForAudio();
716 } 717 }
717 718
718 QListIterator<DocLnk> dit( files.children() ); 719 QListIterator<DocLnk> dit( files.children() );
719 QListIterator<FileSystem> it ( fs ); 720 QListIterator<FileSystem> it ( fs );
720 721
721 QString storage; 722 QString storage;
722 for ( ; dit.current(); ++dit ) { 723 for ( ; dit.current(); ++dit ) {
723 for( ; it.current(); ++it ){ 724 for( ; it.current(); ++it ){
724 const QString name = (*it)->name(); 725 const QString name = (*it)->name();
725 const QString path = (*it)->path(); 726 const QString path = (*it)->path();
726 if(dit.current()->file().find(path) != -1 ) { 727 if(dit.current()->file().find(path) != -1 ) {
727 storage = name; 728 storage = name;
728 } 729 }
729 } 730 }
730 731
731 QListViewItem * newItem; 732 QListViewItem * newItem;
732 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 733 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
733 long size; 734 long size;
734 if( dit.current()->file().left(4) == "http" ) 735 if( dit.current()->file().left(4) == "http" )
735 size=0; 736 size=0;
736 else 737 else
737 size = QFile( dit.current()->file() ).size(); 738 size = QFile( dit.current()->file() ).size();
738 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage); 739 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage);
739 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 740 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
740 } 741 }
741 } 742 }
742} 743}
743 744
744 745
745void PlayListWidget::populateVideoView() { 746void PlayListWidget::populateVideoView() {
746 videoView->clear(); 747 videoView->clear();
747 StorageInfo storageInfo; 748 StorageInfo storageInfo;
748 const QList<FileSystem> &fs = storageInfo.fileSystems(); 749 const QList<FileSystem> &fs = storageInfo.fileSystems();
749 750
750 if(!videoScan ) { 751 if(!videoScan ) {
751 scanForVideo(); 752 scanForVideo();
752 } 753 }
753 754
754 QListIterator<DocLnk> Vdit( vFiles.children() ); 755 QListIterator<DocLnk> Vdit( vFiles.children() );
755 QListIterator<FileSystem> it ( fs ); 756 QListIterator<FileSystem> it ( fs );
756 videoView->clear(); 757 videoView->clear();
757 QString storage; 758 QString storage;
758 for ( ; Vdit.current(); ++Vdit ) { 759 for ( ; Vdit.current(); ++Vdit ) {
759 for( ; it.current(); ++it ) { 760 for( ; it.current(); ++it ) {
760 const QString name = (*it)->name(); 761 const QString name = (*it)->name();
@@ -913,49 +914,49 @@ void PlayListWidget::readm3u( const QString &filename ) {
913 i++; 914 i++;
914 } 915 }
915 } 916 }
916 } 917 }
917 } 918 }
918 f.close(); 919 f.close();
919} 920}
920 921
921void PlayListWidget::writem3u() { 922void PlayListWidget::writem3u() {
922 InputDialog *fileDlg; 923 InputDialog *fileDlg;
923 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 924 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
924 fileDlg->exec(); 925 fileDlg->exec();
925 QString filename, list; 926 QString filename, list;
926 if( fileDlg->result() == 1 ) { 927 if( fileDlg->result() == 1 ) {
927 filename = fileDlg->text(); 928 filename = fileDlg->text();
928 qDebug( filename ); 929 qDebug( filename );
929 int noOfFiles = 0; 930 int noOfFiles = 0;
930 d->selectedFiles->first(); 931 d->selectedFiles->first();
931 do { 932 do {
932 // we dont check for existance because of url's 933 // we dont check for existance because of url's
933 // qDebug(d->selectedFiles->current()->file()); 934 // qDebug(d->selectedFiles->current()->file());
934 935
935 // so maybe we should do some net checking to ,-) 936 // so maybe we should do some net checking to ,-)
936 // no, cause it takes to long... 937 // no, cause it takes to long...
937 938
938 list += d->selectedFiles->current()->file() + "\n"; 939 list += d->selectedFiles->current()->file() + "\n";
939 noOfFiles++; 940 noOfFiles++;
940 } 941 }
941 while ( d->selectedFiles->next() ); 942 while ( d->selectedFiles->next() );
942 qDebug( list ); 943 qDebug( list );
943 if( filename.left( 1) != "/" ) { 944 if( filename.left( 1) != "/" ) {
944 filename=QPEApplication::documentDir() + "/" + filename; 945 filename=QPEApplication::documentDir() + "/" + filename;
945 } 946 }
946 if( filename.right( 3 ) != "m3u" ) { 947 if( filename.right( 3 ) != "m3u" ) {
947 filename=filename+".m3u"; 948 filename=filename+".m3u";
948 } 949 }
949 QFile f( filename ); 950 QFile f( filename );
950 f.open( IO_WriteOnly ); 951 f.open( IO_WriteOnly );
951 f.writeBlock( list, list.length() ); 952 f.writeBlock( list, list.length() );
952 f.close(); 953 f.close();
953 } 954 }
954 if( fileDlg ) { 955 if( fileDlg ) {
955 delete fileDlg; 956 delete fileDlg;
956 } 957 }
957} 958}
958 959
959void PlayListWidget::readPls( const QString &filename ) { 960void PlayListWidget::readPls( const QString &filename ) {
960 961
961 qDebug( "pls filename is " + filename ); 962 qDebug( "pls filename is " + filename );