Commit 2a3507a6 authored by camilo higuita's avatar camilo higuita

start using std algorithms

parent ad2354dd
......@@ -201,13 +201,13 @@ void AlbumsModel::fetchInformation()
for(const auto &req : requests)
{
pulpo.request(req);
loop.exec();
if(stop)
{
loop.quit();
return;
}
pulpo.request(req);
loop.exec();
}
};
......
......@@ -10,29 +10,33 @@
namespace FLoader
{
inline QStringList getPathContents(QStringList urls, QString path)
{
if(!FMH::fileExists(path))
return urls;
if (QFileInfo(path).isDir())
{
QDirIterator it(path, QStringList() << FMH::FILTER_LIST[FMH::FILTER_TYPE::AUDIO] << "*.m4a", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
urls << it.next();
}else if (QFileInfo(path).isFile())
urls << path;
return urls;
}
// returns the number of new items added to the collection db
inline uint getTracks(const QStringList& paths)
{
QStringList urls;
auto db = CollectionDB::getInstance();
const auto urls = std::accumulate(paths.begin(), paths.end(), QStringList(), getPathContents);
for(const auto &path : paths)
{
if(!FMH::fileExists(path))
continue;
if (QFileInfo(path).isDir())
{
if(FMH::fileExists(path))
db->addFolder(path);
QDirIterator it(path, QStringList() << FMH::FILTER_LIST[FMH::FILTER_TYPE::AUDIO] << "*.m4a", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
urls << it.next();
}else if (QFileInfo(path).isFile())
urls << path;
}
uint newTracks = 0;
......@@ -40,7 +44,7 @@ inline uint getTracks(const QStringList& paths)
return newTracks;
TagInfo info;
for(auto url : urls)
for(const auto &url : urls)
{
if(db->check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS], FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url))
continue;
......
......@@ -20,9 +20,6 @@ BabeTable
// property bool autoSuggestions : bae.loadSetting("AUTOSUGGESTIONS", "BABE", false) === "true" ? true : false
property bool autoSuggestions : false
Layout.fillHeight: true
Layout.fillWidth: true
trackNumberVisible: false
headBar.visible: true
headBarExit: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment