summaryrefslogtreecommitdiff
path: root/noncore/multimedia
Unidiff
Diffstat (limited to 'noncore/multimedia') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp64
2 files changed, 47 insertions, 46 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 0be727b..039f3b1 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -47,21 +47,15 @@
47#include <qcstring.h> 47#include <qcstring.h>
48 48
49//extern PlayListWidget *playList; 49//extern PlayListWidget *playList;
50 50
51Om3u::Om3u( const QString &filePath, int mode) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
53//filePath is path name to m3u
54//qDebug("<<<<<<<new m3u "+filePath); 53//qDebug("<<<<<<<new m3u "+filePath);
55 f.setName(filePath); 54 f.setName(filePath);
56// if(f.exists()) 55 f.open(mode);
57// f.open( IO_ReadWrite);
58// else
59// f.open( IO_ReadWrite | IO_Truncate);
60 f.open(mode);
61
62} 56}
63 57
64Om3u::~Om3u(){} 58Om3u::~Om3u(){}
65 59
66void Om3u::readM3u() { 60void Om3u::readM3u() {
67// qDebug("<<<<<<reading m3u "+f.name()); 61// qDebug("<<<<<<reading m3u "+f.name());
@@ -128,36 +122,39 @@ void Om3u::readPls() { //it's a pls file
128 } 122 }
129 } 123 }
130 } 124 }
131} 125}
132 126
133void Om3u::write() { //writes list to m3u file 127void Om3u::write() { //writes list to m3u file
134 QString list; 128 QString list;
129 if(count()>0) {
135 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 130 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
136 qDebug(*it); 131 qDebug(*it);
137 list += *it+"\n"; 132 list += *it+"\n";
138 } 133 }
139 f.writeBlock( list, list.length() ); 134 f.writeBlock( list, list.length() );
135 }
140// f.close(); 136// f.close();
141} 137}
142 138
143void Om3u::add(const QString &filePath) { //adds to m3u file 139void Om3u::add(const QString &filePath) { //adds to m3u file
144 append(filePath); 140 append(filePath);
145} 141}
146 142
147void Om3u::remove(const QString &filePath) { //removes from m3u list 143void Om3u::remove(const QString &filePath) { //removes from m3u list
148 QString list, currentFile; 144 QString list, currentFile;
145 if(count()>0) {
149 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 146 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
150 currentFile=*it; 147 currentFile=*it;
151// qDebug(*it); 148 // qDebug(*it);
152 149
153 if( filePath != currentFile) 150 if( filePath != currentFile)
154 list += currentFile+"\n"; 151 list += currentFile+"\n";
155 } 152 }
156 f.writeBlock( list, list.length() ); 153 f.writeBlock( list, list.length() );
157 154 }
158} 155}
159 156
160void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 157void Om3u::deleteFile(const QString &filePath) {//deletes m3u file
161 f.close(); 158 f.close();
162 f.remove(); 159 f.remove();
163 160
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index e28efd0..f9192e8 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -182,25 +182,27 @@ void PlayListWidget::writeDefaultPlaylist() {
182 182
183 Config config( "OpiePlayer" ); 183 Config config( "OpiePlayer" );
184 config.setGroup( "PlayList" ); 184 config.setGroup( "PlayList" );
185 QString filename=QPEApplication::documentDir() + "/default.m3u"; 185 QString filename=QPEApplication::documentDir() + "/default.m3u";
186 QString currentString = config.readEntry( "CurrentPlaylist", filename); 186 QString currentString = config.readEntry( "CurrentPlaylist", filename);
187 if( currentString == filename) { 187 if( currentString == filename) {
188 Om3u *m3uList; 188 Om3u *m3uList;
189// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 189 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
190 if( d->selectedFiles->first() ) {
190 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 191 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
191 d->selectedFiles->first();
192 do { 192 do {
193// qDebug(d->selectedFiles->current()->file()); 193 // qDebug(d->selectedFiles->current()->file());
194 m3uList->add( d->selectedFiles->current()->file() ); 194 m3uList->add( d->selectedFiles->current()->file() );
195 } 195 }
196 while ( d->selectedFiles->next() ); 196 while ( d->selectedFiles->next() );
197 197
198 m3uList->write(); 198 m3uList->write();
199 m3uList->close(); 199 m3uList->close();
200 if(m3uList) delete m3uList; 200 if(m3uList) delete m3uList;
201
202 }
201 } 203 }
202} 204}
203 205
204void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
205 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
206 if ( mediaPlayerState->playlist() ) { 208 if ( mediaPlayerState->playlist() ) {
@@ -850,26 +852,29 @@ void PlayListWidget::readPls( const QString &filename ) {
850void PlayListWidget::writeCurrentM3u() { 852void PlayListWidget::writeCurrentM3u() {
851 qDebug("writing to current m3u"); 853 qDebug("writing to current m3u");
852 Config cfg( "OpiePlayer" ); 854 Config cfg( "OpiePlayer" );
853 cfg.setGroup("PlayList"); 855 cfg.setGroup("PlayList");
854 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 856 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
855 857
858 if( d->selectedFiles->first()) {
856 Om3u *m3uList; 859 Om3u *m3uList;
857 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 860 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
858 d->selectedFiles->first(); 861
862
859 qDebug( d->selectedFiles->current()->file()); 863 qDebug( d->selectedFiles->current()->file());
860 do { 864 do {
861 qDebug( d->selectedFiles->current()->file()); 865 qDebug( d->selectedFiles->current()->file());
862 m3uList->add( d->selectedFiles->current()->file() ); 866 m3uList->add( d->selectedFiles->current()->file() );
863 } 867 }
864 while ( d->selectedFiles->next() ); 868 while ( d->selectedFiles->next() );
865 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 869 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
866 m3uList->write(); 870 m3uList->write();
867 m3uList->close(); 871 m3uList->close();
868 872
869 if(m3uList) delete m3uList; 873 if(m3uList) delete m3uList;
874 }
870} 875}
871 876
872 /* 877 /*
873 writes current playlist to m3u file */ 878 writes current playlist to m3u file */
874void PlayListWidget::writem3u() { 879void PlayListWidget::writem3u() {
875 InputDialog *fileDlg; 880 InputDialog *fileDlg;
@@ -887,46 +892,45 @@ void PlayListWidget::writem3u() {
887 } 892 }
888 893
889 if( name.right( 3 ) != "m3u" ) { 894 if( name.right( 3 ) != "m3u" ) {
890 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 895 filename = QPEApplication::documentDir() + "/" +name+".m3u";
891 } 896 }
892 897
898 if( d->selectedFiles->first()) {
893 m3uList = new Om3u(filename, IO_ReadWrite); 899 m3uList = new Om3u(filename, IO_ReadWrite);
894
895 d->selectedFiles->first();
896 900
897 do { 901 do {
898 m3uList->add( d->selectedFiles->current()->file()); 902 m3uList->add( d->selectedFiles->current()->file());
899 } 903 }
900 while ( d->selectedFiles->next() ); 904 while ( d->selectedFiles->next() );
901// qDebug( list ); 905 // qDebug( list );
902 m3uList->write(); 906 m3uList->write();
903 m3uList->close(); 907 m3uList->close();
904 if(m3uList) delete m3uList; 908 if(m3uList) delete m3uList;
905 909
906 if(fileDlg) delete fileDlg; 910 if(fileDlg) delete fileDlg;
907 911
908 DocLnk lnk; 912 DocLnk lnk;
909 lnk.setFile( filename); 913 lnk.setFile( filename);
910 lnk.setIcon("opieplayer2/playlist2"); 914 lnk.setIcon("opieplayer2/playlist2");
911 lnk.setName( name); //sets file name 915 lnk.setName( name); //sets file name
912 916
913// qDebug(filename); 917 // qDebug(filename);
914 Config config( "OpiePlayer" ); 918 Config config( "OpiePlayer" );
915 config.setGroup( "PlayList" ); 919 config.setGroup( "PlayList" );
916 920
917 config.writeEntry("CurrentPlaylist",filename); 921 config.writeEntry("CurrentPlaylist",filename);
918 currentPlayList=filename; 922 currentPlayList=filename;
919 923
920 if(!lnk.writeLink()) { 924 if(!lnk.writeLink()) {
921 qDebug("Writing doclink did not work"); 925 qDebug("Writing doclink did not work");
922 } 926 }
923 927
924 setCaption(tr("OpiePlayer: ") + name); 928 setCaption(tr("OpiePlayer: ") + name);
929 }
925 } 930 }
926
927} 931}
928 932
929void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 933void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
930 switch ( e->key() ) { 934 switch ( e->key() ) {
931 ////////////////////////////// Zaurus keys 935 ////////////////////////////// Zaurus keys
932 case Key_F9: //activity 936 case Key_F9: //activity