+
+int DbStorage::getArtistsCount() {
+ QSqlQuery *query = _get_artists_count_query;
+ query->exec();
+ if (query->next()) {
+ return query->value(0).toInt();
+ }
+ return 0;
+}
+
+int DbStorage::getAlbumsCount() {
+ QSqlQuery *query = _get_albums_count_query;
+ query->exec();
+ if (query->next()) {
+ return query->value(0).toInt();
+ }
+ return 0;
+}
+
+int DbStorage::getTracksCount() {
+ QSqlQuery *query = _get_tracks_count_query;
+ query->exec();
+ if (query->next()) {
+ return query->value(0).toInt();
+ }
+ return 0;
+}
+
+void DbStorage::deleteTracksFrom(QString path) {
+ QSqlQuery *query = _check_directory_query;
+ query->bindValue(":path", path);
+ query->exec();
+ if (query->next()) {
+ int id = query->value(0).toInt();
+ query = _remove_tracks_from_query;
+ query->bindValue(":directory_id", id);
+ query->exec();
+ query = _remove_directory_query;
+ query->bindValue(":path", path);
+ query->exec();
+ _cleanup();
+ }
+}
+
+void DbStorage::checkTracksFrom(QString path) {
+ QSqlQuery *query = _check_directory_query;
+ query->bindValue(":path", path);
+ query->exec();
+ if (query->next()) {
+ int id = query->value(0).toInt();
+ query = _get_tracks_source_from_query;
+ query->bindValue(":directory_id", id);
+ query->exec();
+ while (query->next()) {
+ QString source = query->value(0).toString();
+ if (!QFile::exists(source)) {
+ Track track(TrackMetadata(), source); // removeTrack uses only source field, so
+ removeTrack(track); // we can use this method
+ }
+ }
+ _cleanup();
+ }
+}