-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 11 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 21 |
2 files changed, 23 insertions, 9 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index 039f3b1..3541e5f 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -43,12 +43,19 @@ | |||
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qcstring.h> | 47 | #include <qcstring.h> |
48 | 48 | ||
49 | static inline QString fullBaseName ( const QFileInfo &fi ) | ||
50 | { | ||
51 | QString str = fi. fileName ( ); | ||
52 | return str. left ( str. findRev ( '.' )); | ||
53 | } | ||
54 | |||
55 | |||
49 | //extern PlayListWidget *playList; | 56 | //extern PlayListWidget *playList; |
50 | 57 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 58 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 59 | : QStringList (){ |
53 | //qDebug("<<<<<<<new m3u "+filePath); | 60 | //qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 61 | f.setName(filePath); |
@@ -65,13 +72,13 @@ void Om3u::readM3u() { | |||
65 | s=t.readLine(); | 72 | s=t.readLine(); |
66 | qDebug(s); | 73 | qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 74 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 75 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 76 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 77 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 78 | QString name = fullBaseName ( f ); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 79 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 80 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 81 | append(s); |
75 | // qDebug(s); | 82 | // qDebug(s); |
76 | } else { // is url | 83 | } else { // is url |
77 | s.replace( QRegExp( "%20" )," " ); | 84 | s.replace( QRegExp( "%20" )," " ); |
@@ -102,13 +109,13 @@ void Om3u::readPls() { //it's a pls file | |||
102 | // Title | 109 | // Title |
103 | // Length | 110 | // Length |
104 | // Version | 111 | // Version |
105 | // File2=http | 112 | // File2=http |
106 | s = s.replace( QRegExp( "\\" ), "/" ); | 113 | s = s.replace( QRegExp( "\\" ), "/" ); |
107 | QFileInfo f( s ); | 114 | QFileInfo f( s ); |
108 | QString name = f.baseName(); | 115 | QString name = fullBaseName ( f ); |
109 | if( name.left( 4 ) == "http" ) { | 116 | if( name.left( 4 ) == "http" ) { |
110 | name = s.right( s.length() - 7); | 117 | name = s.right( s.length() - 7); |
111 | } else { | 118 | } else { |
112 | name = s; | 119 | name = s; |
113 | } | 120 | } |
114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 121 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index c28548c..8b25a4c 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -80,12 +80,19 @@ | |||
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | ||
87 | { | ||
88 | QString str = fi. fileName ( ); | ||
89 | return str. left ( str. findRev ( '.' )); | ||
90 | } | ||
91 | |||
92 | |||
86 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
87 | // class myFileSelector { | 94 | // class myFileSelector { |
88 | 95 | ||
89 | // }; | 96 | // }; |
90 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
91 | public: | 98 | public: |
@@ -321,13 +328,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
321 | setCentralWidget( vbox5 ); | 328 | setCentralWidget( vbox5 ); |
322 | 329 | ||
323 | Config cfg( "OpiePlayer" ); | 330 | Config cfg( "OpiePlayer" ); |
324 | readConfig( cfg ); | 331 | readConfig( cfg ); |
325 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 332 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
326 | loadList(DocLnk( currentPlaylist)); | 333 | loadList(DocLnk( currentPlaylist)); |
327 | setCaption(tr("OpiePlayer: ")+ QFileInfo(currentPlaylist).baseName()); | 334 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
328 | 335 | ||
329 | initializeStates(); | 336 | initializeStates(); |
330 | } | 337 | } |
331 | 338 | ||
332 | 339 | ||
333 | PlayListWidget::~PlayListWidget() { | 340 | PlayListWidget::~PlayListWidget() { |
@@ -678,13 +685,13 @@ void PlayListWidget::addSelected() { | |||
678 | filename=videoView->currentItem()->text(3); | 685 | filename=videoView->currentItem()->text(3); |
679 | // tabWidget->setCurrentPage(0); | 686 | // tabWidget->setCurrentPage(0); |
680 | 687 | ||
681 | } | 688 | } |
682 | break; | 689 | break; |
683 | }; | 690 | }; |
684 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 691 | lnk.setName( fullBaseName ( QFileInfo(filename))); //sets name |
685 | lnk.setFile( filename ); //sets file name | 692 | lnk.setFile( filename ); //sets file name |
686 | d->selectedFiles->addToSelection( lnk); | 693 | d->selectedFiles->addToSelection( lnk); |
687 | tabWidget->setCurrentPage(0); | 694 | tabWidget->setCurrentPage(0); |
688 | writeCurrentM3u(); | 695 | writeCurrentM3u(); |
689 | 696 | ||
690 | } | 697 | } |
@@ -713,13 +720,13 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
713 | }; | 720 | }; |
714 | // case 1: { | 721 | // case 1: { |
715 | DocLnk lnk; | 722 | DocLnk lnk; |
716 | QString filename; | 723 | QString filename; |
717 | 724 | ||
718 | filename=it->text(3); | 725 | filename=it->text(3); |
719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 726 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
720 | lnk.setFile( filename ); //sets file name | 727 | lnk.setFile( filename ); //sets file name |
721 | d->selectedFiles->addToSelection( lnk); | 728 | d->selectedFiles->addToSelection( lnk); |
722 | 729 | ||
723 | writeCurrentM3u(); | 730 | writeCurrentM3u(); |
724 | tabWidget->setCurrentPage(0); | 731 | tabWidget->setCurrentPage(0); |
725 | 732 | ||
@@ -1035,13 +1042,13 @@ void PlayListWidget::openFile() { | |||
1035 | else if( filename.right( 3) == "m3u" ) { | 1042 | else if( filename.right( 3) == "m3u" ) { |
1036 | readm3u( filename ); | 1043 | readm3u( filename ); |
1037 | 1044 | ||
1038 | } else if( filename.right(3) == "pls" ) { | 1045 | } else if( filename.right(3) == "pls" ) { |
1039 | readPls( filename ); | 1046 | readPls( filename ); |
1040 | } else { | 1047 | } else { |
1041 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 1048 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1042 | lnk.setFile( filename ); //sets file name | 1049 | lnk.setFile( filename ); //sets file name |
1043 | d->selectedFiles->addToSelection( lnk); | 1050 | d->selectedFiles->addToSelection( lnk); |
1044 | writeCurrentM3u(); | 1051 | writeCurrentM3u(); |
1045 | } | 1052 | } |
1046 | } | 1053 | } |
1047 | 1054 | ||
@@ -1071,13 +1078,13 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
1071 | lnk.setFile( s+"/"); //if url with no extension | 1078 | lnk.setFile( s+"/"); //if url with no extension |
1072 | else | 1079 | else |
1073 | lnk.setFile( s ); //sets file name | 1080 | lnk.setFile( s ); //sets file name |
1074 | 1081 | ||
1075 | } else { | 1082 | } else { |
1076 | // if( QFileInfo( s ).exists() ) { | 1083 | // if( QFileInfo( s ).exists() ) { |
1077 | lnk.setName( QFileInfo(s).baseName()); | 1084 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1078 | // if(s.right(4) == '.') {//if regular file | 1085 | // if(s.right(4) == '.') {//if regular file |
1079 | if(s.left(1) != "/") { | 1086 | if(s.left(1) != "/") { |
1080 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1087 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1081 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1088 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1082 | lnk.setIcon("SoundPlayer"); | 1089 | lnk.setIcon("SoundPlayer"); |
1083 | } else { | 1090 | } else { |
@@ -1097,13 +1104,13 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
1097 | 1104 | ||
1098 | // m3uList->write(); | 1105 | // m3uList->write(); |
1099 | m3uList->close(); | 1106 | m3uList->close(); |
1100 | if(m3uList) delete m3uList; | 1107 | if(m3uList) delete m3uList; |
1101 | 1108 | ||
1102 | d->selectedFiles->setSelectedItem( s); | 1109 | d->selectedFiles->setSelectedItem( s); |
1103 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 1110 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1104 | 1111 | ||
1105 | } | 1112 | } |
1106 | 1113 | ||
1107 | /* | 1114 | /* |
1108 | reads pls and adds files/urls to playlist */ | 1115 | reads pls and adds files/urls to playlist */ |
1109 | void PlayListWidget::readPls( const QString &filename ) { | 1116 | void PlayListWidget::readPls( const QString &filename ) { |
@@ -1116,13 +1123,13 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
1116 | 1123 | ||
1117 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1124 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1118 | s = *it; | 1125 | s = *it; |
1119 | // s.replace( QRegExp( "%20" )," " ); | 1126 | // s.replace( QRegExp( "%20" )," " ); |
1120 | DocLnk lnk( s ); | 1127 | DocLnk lnk( s ); |
1121 | QFileInfo f( s ); | 1128 | QFileInfo f( s ); |
1122 | QString name = f.baseName(); | 1129 | QString name = fullBaseName ( f); |
1123 | 1130 | ||
1124 | if( name.left( 4 ) == "http" ) { | 1131 | if( name.left( 4 ) == "http" ) { |
1125 | name = s.right( s.length() - 7); | 1132 | name = s.right( s.length() - 7); |
1126 | } else { | 1133 | } else { |
1127 | name = s; | 1134 | name = s; |
1128 | } | 1135 | } |