summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-11 00:17:09 (UTC)
committer sandman <sandman>2002-12-11 00:17:09 (UTC)
commit6c71f5ccd9506234a317d9ff3d119613c457e769 (patch) (side-by-side diff)
treef78a9d2a0981dbb446096bf072ca5decaa5e1d59
parente9d1213578b83f8380c4681186246a2b32ae6375 (diff)
downloadopie-6c71f5ccd9506234a317d9ff3d119613c457e769.zip
opie-6c71f5ccd9506234a317d9ff3d119613c457e769.tar.gz
opie-6c71f5ccd9506234a317d9ff3d119613c457e769.tar.bz2
fix for a stupid bug .. op1 wants to strip the extension, but instead
stripps everything after the first '.'. So filenames like "02. foobar.mp3" become "02"
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/om3u.cpp11
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp21
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
@@ -41,16 +41,23 @@
#include <qdir.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qcstring.h>
+static inline QString fullBaseName ( const QFileInfo &fi )
+{
+ QString str = fi. fileName ( );
+ return str. left ( str. findRev ( '.' ));
+}
+
+
//extern PlayListWidget *playList;
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
f.open(mode);
}
@@ -63,17 +70,17 @@ void Om3u::readM3u() {
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
- QString name = f.baseName();
+ QString name = fullBaseName ( f );
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
s.replace( QRegExp( "%20" )," " );
QString name;
// if( name.left( 4 ) == "http" ) {
@@ -100,17 +107,17 @@ void Om3u::readPls() { //it's a pls file
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
- QString name = f.baseName();
+ QString name = fullBaseName ( f );
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
if( s.at( s.length() - 4) == '.') // if this is probably a file
append(s);
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
@@ -78,16 +78,23 @@
#define BUTTONS_ON_TOOLBAR
#define SIDE_BUTTONS
#define CAN_SAVE_LOAD_PLAYLISTS
extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern MediaPlayerState *mediaPlayerState;
+static inline QString fullBaseName ( const QFileInfo &fi )
+{
+ QString str = fi. fileName ( );
+ return str. left ( str. findRev ( '.' ));
+}
+
+
QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
// class myFileSelector {
// };
class PlayListWidgetPrivate {
public:
QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
QFrame *playListFrame;
@@ -319,17 +326,17 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
setCentralWidget( vbox5 );
Config cfg( "OpiePlayer" );
readConfig( cfg );
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
loadList(DocLnk( currentPlaylist));
- setCaption(tr("OpiePlayer: ")+ QFileInfo(currentPlaylist).baseName());
+ setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
initializeStates();
}
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
@@ -676,17 +683,17 @@ void PlayListWidget::addSelected() {
case 2: { // video
filename=videoView->currentItem()->text(3);
// tabWidget->setCurrentPage(0);
}
break;
};
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setName( fullBaseName ( QFileInfo(filename))); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
tabWidget->setCurrentPage(0);
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
@@ -711,17 +718,17 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
return;
break;
};
// case 1: {
DocLnk lnk;
QString filename;
filename=it->text(3);
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
writeCurrentM3u();
tabWidget->setCurrentPage(0);
}
}
@@ -1033,17 +1040,17 @@ void PlayListWidget::openFile() {
writeCurrentM3u();
}
else if( filename.right( 3) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
} else {
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
writeCurrentM3u();
}
}
if( fileDlg ) {
delete fileDlg;
@@ -1069,17 +1076,17 @@ void PlayListWidget::readm3u( const QString &filename ) {
lnk.setIcon("opieplayer2/musicfile");
if(s.right(4) != '.' || s.right(5) != '.')
lnk.setFile( s+"/"); //if url with no extension
else
lnk.setFile( s ); //sets file name
} else {
// if( QFileInfo( s ).exists() ) {
- lnk.setName( QFileInfo(s).baseName());
+ lnk.setName( fullBaseName ( QFileInfo(s)));
// if(s.right(4) == '.') {//if regular file
if(s.left(1) != "/") {
// qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
lnk.setIcon("SoundPlayer");
} else {
// qDebug("set link2 "+s);
lnk.setFile( s);
@@ -1095,17 +1102,17 @@ void PlayListWidget::readm3u( const QString &filename ) {
config.write();
currentPlayList=filename;
// m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
d->selectedFiles->setSelectedItem( s);
- setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
+ setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
qDebug( "pls filename is " + filename );
@@ -1114,17 +1121,17 @@ void PlayListWidget::readPls( const QString &filename ) {
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
- QString name = f.baseName();
+ QString name = fullBaseName ( f);
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );