Add directory contents in order

This commit is contained in:
David Sansome 2009-12-24 22:44:12 +00:00
parent 66478974cd
commit 3659fabeaf
2 changed files with 8 additions and 10 deletions

View File

@ -165,9 +165,10 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
return true; return true;
} }
QModelIndex Playlist::InsertPaths(const QList<QUrl>& urls, int after) { QModelIndex Playlist::InsertPaths(QList<QUrl> urls, int after) {
SongList songs; SongList songs;
foreach (const QUrl& url, urls) { for (int i=0 ; i<urls.count() ; ++i) {
QUrl url(urls[i]);
if (url.scheme() != "file") if (url.scheme() != "file")
continue; continue;
@ -183,16 +184,13 @@ QModelIndex Playlist::InsertPaths(const QList<QUrl>& urls, int after) {
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable, QDir::Files | QDir::NoDotAndDotDot | QDir::Readable,
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
QList<QUrl> new_urls;
while (it.hasNext()) { while (it.hasNext()) {
QString path(it.next()); QString path(it.next());
new_urls << QUrl::fromLocalFile(path);
Song song;
song.InitFromFile(path, -1);
if (!song.is_valid())
continue;
songs << song;
} }
qSort(new_urls);
urls << new_urls;
} else { } else {
Song song; Song song;
song.InitFromFile(filename, -1); song.InitFromFile(filename, -1);

View File

@ -49,7 +49,7 @@ class Playlist : public QAbstractListModel {
// Changing the playlist // Changing the playlist
QModelIndex InsertItems(const QList<PlaylistItem*>& items, int after = -1); QModelIndex InsertItems(const QList<PlaylistItem*>& items, int after = -1);
QModelIndex InsertSongs(const SongList& items, int after = -1); QModelIndex InsertSongs(const SongList& items, int after = -1);
QModelIndex InsertPaths(const QList<QUrl>& urls, int after = -1); QModelIndex InsertPaths(QList<QUrl> urls, int after = -1);
void StopAfter(int row); void StopAfter(int row);
// QAbstractListModel // QAbstractListModel