Skip to content

Commit

Permalink
fixes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavbhatt committed Sep 23, 2019
1 parent 098e665 commit 4738a3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 11 additions & 7 deletions mainwindow.cpp
Expand Up @@ -3113,13 +3113,17 @@ void MainWindow::queueShowOption(QListWidget *queue){

});
connect(clearUnCached,&QAction::triggered,[=](){
for (int i=0; i<queue->count();i++) {
QString songIdFromWidget = static_cast<QLineEdit*>(queue->itemWidget(queue->item(i))->findChild<QLineEdit*>("songId"))->text().trimmed();
if(!store_manager->isDownloaded(songIdFromWidget) /*&& !trackIsBeingProcessed(songIdFromWidget)*/){
store_manager->removeFromQueue(songIdFromWidget);
queue->removeItemWidget(queue->item(i));
if(queue->item(i) != nullptr){
delete queue->item(i);
while (hasUnCachedTracks(queue)) {
for (int i=0; i<queue->count();i++) {
QString songIdFromWidget = static_cast<QLineEdit*>(queue->itemWidget(queue->item(i))->findChild<QLineEdit*>("songId"))->text().trimmed();
songIdFromWidget.remove("<br>").trimmed();
if(!store_manager->isDownloaded(songIdFromWidget) /*&& !trackIsBeingProcessed(songIdFromWidget)*/){
store_manager->removeFromQueue(songIdFromWidget);
//queue->removeItemWidget(queue->item(i));
QListWidgetItem *item= queue->takeItem(i);
if(item != nullptr){
delete item;
}
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions store.cpp
Expand Up @@ -572,13 +572,11 @@ bool store::isDownloaded(QString trackId){
QSqlQuery query;
query.exec("SELECT downloaded FROM tracks WHERE trackId = '"+trackId+"'");
bool downloaded = false;
if(query.record().count()>0){
while(query.next()){
if(query.value("downloaded").toString().trimmed()=="1"){
downloaded = true;
}else{
downloaded = false;
}
while(query.next()){
if(query.value("downloaded").toString().trimmed()=="1"){
downloaded = true;
}else{
downloaded = false;
}
}
return downloaded;
Expand Down

0 comments on commit 4738a3b

Please sign in to comment.