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;
}
QModelIndex Playlist::InsertPaths(const QList<QUrl>& urls, int after) {
QModelIndex Playlist::InsertPaths(QList<QUrl> urls, int after) {
SongList songs;
foreach (const QUrl& url, urls) {
for (int i=0 ; i<urls.count() ; ++i) {
QUrl url(urls[i]);
if (url.scheme() != "file")
continue;
@ -183,16 +184,13 @@ QModelIndex Playlist::InsertPaths(const QList<QUrl>& urls, int after) {
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable,
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
QList<QUrl> new_urls;
while (it.hasNext()) {
QString path(it.next());
Song song;
song.InitFromFile(path, -1);
if (!song.is_valid())
continue;
songs << song;
new_urls << QUrl::fromLocalFile(path);
}
qSort(new_urls);
urls << new_urls;
} else {
Song song;
song.InitFromFile(filename, -1);

View File

@ -49,7 +49,7 @@ class Playlist : public QAbstractListModel {
// Changing the playlist
QModelIndex InsertItems(const QList<PlaylistItem*>& 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);
// QAbstractListModel