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

plasmo fixes

parent 6bf950ca
...@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0) ...@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0)
find_package(ECM 1.7.0 REQUIRED NO_MODULE) find_package(ECM 1.7.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH}) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH})
set(CMAKE_CXX_STANDARD 17)
find_package(MauiKit REQUIRED) find_package(MauiKit REQUIRED)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Network WebSockets Sql QuickControls2 Xml Multimedia Widgets DBus Svg) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Network WebSockets Sql QuickControls2 Xml Multimedia Widgets DBus Svg)
......
...@@ -105,9 +105,9 @@ void AlbumsModel::setList() ...@@ -105,9 +105,9 @@ void AlbumsModel::setList()
m_Query = "select * from artists order by artist asc"; m_Query = "select * from artists order by artist asc";
//get albums data with modifier for missing images for artworks //get albums data with modifier for missing images for artworks
this->list = this->db->getDBData(m_Query, [=](FMH::MODEL &item) this->list = this->db->getDBData(m_Query, [&](FMH::MODEL &item)
{ {
if(!FMH::fileExists(item[FMH::MODEL_KEY::ARTWORK])) if(!item[FMH::MODEL_KEY::ARTWORK].isEmpty() && !FMH::fileExists(item[FMH::MODEL_KEY::ARTWORK]))
{ {
this->db->removeArtwork(FMH::MODEL_NAME[static_cast<FMH::MODEL_KEY>(this->query)], FM::toMap(item)); this->db->removeArtwork(FMH::MODEL_NAME[static_cast<FMH::MODEL_KEY>(this->query)], FM::toMap(item));
item[FMH::MODEL_KEY::ARTWORK] = ""; item[FMH::MODEL_KEY::ARTWORK] = "";
...@@ -146,7 +146,7 @@ void AlbumsModel::fetchInformation() ...@@ -146,7 +146,7 @@ void AlbumsModel::fetchInformation()
request.ontology = this->query == AlbumsModel::QUERY::ALBUMS ? PULPO::ONTOLOGY::ALBUM : PULPO::ONTOLOGY::ARTIST; request.ontology = this->query == AlbumsModel::QUERY::ALBUMS ? PULPO::ONTOLOGY::ALBUM : PULPO::ONTOLOGY::ARTIST;
request.services = {PULPO::SERVICES::LastFm, PULPO::SERVICES::Spotify, PULPO::SERVICES::MusicBrainz}; request.services = {PULPO::SERVICES::LastFm, PULPO::SERVICES::Spotify, PULPO::SERVICES::MusicBrainz};
request.info = {PULPO::INFO::ARTWORK}; request.info = {PULPO::INFO::ARTWORK};
request.callback = [=](PULPO::REQUEST request, PULPO::RESPONSES responses) request.callback = [&, index](PULPO::REQUEST request, PULPO::RESPONSES responses)
{ {
qDebug() << "DONE WITH " << request.track ; qDebug() << "DONE WITH " << request.track ;
...@@ -156,12 +156,12 @@ void AlbumsModel::fetchInformation() ...@@ -156,12 +156,12 @@ void AlbumsModel::fetchInformation()
{ {
qDebug()<<"SAVING ARTWORK FOR: " << request.track[FMH::MODEL_KEY::ALBUM]; qDebug()<<"SAVING ARTWORK FOR: " << request.track[FMH::MODEL_KEY::ALBUM];
auto downloader = new FMH::Downloader; auto downloader = new FMH::Downloader;
QObject::connect(downloader, &FMH::Downloader::fileSaved, [=](QString path) QObject::connect(downloader, &FMH::Downloader::fileSaved, [&, index, request, downloader = std::move(downloader)](QString path)
{ {
qDebug()<< "Saving artwork file to" << path; qDebug()<< "Saving artwork file to" << path;
FMH::MODEL newTrack = request.track; FMH::MODEL newTrack = request.track;
newTrack[FMH::MODEL_KEY::ARTWORK] = path; newTrack[FMH::MODEL_KEY::ARTWORK] = path;
db->insertArtwork(newTrack); this->db->insertArtwork(newTrack);
this->updateArtwork(index, path); this->updateArtwork(index, path);
downloader->deleteLater(); downloader->deleteLater();
}); });
...@@ -182,25 +182,26 @@ void AlbumsModel::fetchInformation() ...@@ -182,25 +182,26 @@ void AlbumsModel::fetchInformation()
Pulpo pulpo; Pulpo pulpo;
QEventLoop loop; QEventLoop loop;
QObject::connect(&pulpo, &Pulpo::finished, &loop, &QEventLoop::quit); QObject::connect(&pulpo, &Pulpo::finished, &loop, &QEventLoop::quit);
bool stop = false; // bool stop = false;
QObject::connect(this, &AlbumsModel::destroyed, [&]() // QObject::connect(this, &AlbumsModel::destroyed, [&]()
{ // {
qDebug()<< stop << &stop; // qDebug()<< stop << &stop;
stop = true; // stop = true;
qDebug()<< stop << &stop; // qDebug()<< stop << &stop;
}); // });
for(const auto &req : requests) for(const auto &req : requests)
{ {
if(stop)
{
loop.quit();
return;
}
pulpo.request(req); pulpo.request(req);
loop.exec(); loop.exec();
// if(stop)
// {
// loop.quit();
// return;
// }
} }
}; };
......
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