forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TrackDAO - updating multi cover_art rows at once (needs more work)
- it should be done in a single query...
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1246,6 +1246,31 @@ bool TrackDAO::updateCoverArt(int trackId, int coverId) { | |
return true; | ||
} | ||
|
||
bool TrackDAO::updateCoverArt(QList<int> trackIds, QList<int> coverIds) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cardinot
Author
Owner
|
||
if (trackIds.isEmpty() || coverIds.isEmpty()) { | ||
return false; | ||
} | ||
|
||
// TODO: it should be done in a single query | ||
QSqlQuery query(m_database); | ||
for (int i=0; i<trackIds.size(); i++) { | ||
qDebug() << coverIds.at(i) << trackIds.at(i); | ||
query.prepare("UPDATE library SET cover_art=:coverId WHERE id=:trackId"); | ||
query.bindValue(":coverId", coverIds.at(i)); | ||
query.bindValue(":trackId", trackIds.at(i)); | ||
|
||
if (!query.exec()) { | ||
LOG_FAILED_QUERY(query) << "couldn't update library.cover_art"; | ||
return false; | ||
} | ||
} | ||
|
||
// we also need to update the cover_art column in the tablemodel. | ||
// TODO: we should create a new signal with a better name, updateTracksInBTC? | ||
emit(tracksAdded(trackIds.toSet())); | ||
return true; | ||
} | ||
|
||
// Mark all the tracks in the library as invalid. | ||
// That means we'll need to later check that those tracks actually | ||
// (still) exist as part of the library scanning procedure. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use a
QSet<QPair<int,int> >
. That avoids duplicates and you don't need to check that both lists are of equal length