From 2a0e04d96e01af4d1bc97c8fb300ad9f6dfa2b14 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Sat, 1 Mar 2008 05:58:58 +0000 Subject: [PATCH] not completely bug free implementation of new playlist loading behavior git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@862 6778bc44-b910-0410-a7a0-be141de4315d --- src/qprojectM/QPlaylistModel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/qprojectM/QPlaylistModel.cpp b/src/qprojectM/QPlaylistModel.cpp index c03f9535d..d5c51dbcf 100644 --- a/src/qprojectM/QPlaylistModel.cpp +++ b/src/qprojectM/QPlaylistModel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "QXmlPlaylistHandler.hpp" @@ -296,6 +297,20 @@ bool QPlaylistModel::writePlaylist ( const QString & file ) { bool QPlaylistModel::readPlaylist ( const QString & file ) { + if (QFileInfo(file).isDir()) { + + if (!QDir(file).isReadable()) { + QMessageBox::warning (0, "Playlist Directory Error", QString(tr("There was a problem trying to open the playlist directory \"%1\". You may not have permission to open the directory.")).arg(file)); + return false; + } + + foreach (QFileInfo info, QDir(file).entryInfoList()) { + if (info.fileName().toLower().contains(".prjm") || info.fileName().toLower().contains(".milk")) + appendRow(info.absoluteFilePath(), info.fileName(), 3); + } + return true; + } + QFile qfile(file); if (!qfile.open(QIODevice::ReadOnly)) { QMessageBox::warning (0, "Playlist File Error", QString(tr("There was a problem trying to open the playlist \"%1\". The file may no longer exist or you may not have permission to read the file.")).arg(file)); @@ -304,7 +319,6 @@ bool QPlaylistModel::readPlaylist ( const QString & file ) XmlReadFunctor readFunctor(*this); - if (QXmlPlaylistHandler::readPlaylist(&qfile, readFunctor) != QXmlStreamReader::NoError) { QMessageBox::warning ( 0, "Playlist Parse Error", QString(tr("There was a problem trying to parse the playlist \"%1\". Some of your playlist items may have loaded correctly, but don't expect miracles.")).arg(file)); }