Drag & drop directories
This commit is contained in:
parent
0e2f542fcb
commit
cca66d4e21
|
@ -6,6 +6,8 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
@ -162,12 +164,36 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
|
||||||
if (url.scheme() != "file")
|
if (url.scheme() != "file")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Song song;
|
QString filename(url.toLocalFile());
|
||||||
song.InitFromFile(url.toLocalFile(), -1);
|
QFileInfo info(filename);
|
||||||
if (!song.is_valid())
|
|
||||||
|
if (!info.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
songs << song;
|
if (info.isDir()) {
|
||||||
|
// Add all the songs in the directory
|
||||||
|
QDirIterator it(filename,
|
||||||
|
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable,
|
||||||
|
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString path(it.next());
|
||||||
|
|
||||||
|
Song song;
|
||||||
|
song.InitFromFile(path, -1);
|
||||||
|
if (!song.is_valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
songs << song;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Song song;
|
||||||
|
song.InitFromFile(filename, -1);
|
||||||
|
if (!song.is_valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
songs << song;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertSongs(songs, row);
|
InsertSongs(songs, row);
|
||||||
|
|
Loading…
Reference in New Issue