Ticket #1919: mythmusic_schema_mythmusic.diff
| File mythmusic_schema_mythmusic.diff, 74.3 KB (added by Colin Guthrie <mythtv@…>, 6 years ago) |
|---|
-
mythmusic/mythmusic/playbackbox.cpp
541 541 return; 542 542 543 543 closePlaylistPopup(); 544 updatePlaylistFromQuickPlaylist("ORDER BY artist , album, tracknum");544 updatePlaylistFromQuickPlaylist("ORDER BY artist_name, album_name, track"); 545 545 } 546 546 547 547 void PlaybackBoxMusic::fromCD() … … 597 597 return; 598 598 599 599 QString value = formattedFieldValue(curMeta->Artist().utf8()); 600 QString whereClause = "WHERE artist = " + value +601 " ORDER BY album , tracknum";600 QString whereClause = "WHERE artist_name = " + value + 601 " ORDER BY album_name, track"; 602 602 603 603 closePlaylistPopup(); 604 604 updatePlaylistFromQuickPlaylist(whereClause); … … 610 610 return; 611 611 612 612 QString value = formattedFieldValue(curMeta->Album().utf8()); 613 QString whereClause = "WHERE album = " + value +614 " ORDER BY track num";613 QString whereClause = "WHERE album_name = " + value + 614 " ORDER BY track"; 615 615 closePlaylistPopup(); 616 616 updatePlaylistFromQuickPlaylist(whereClause); 617 617 } … … 623 623 624 624 QString value = formattedFieldValue(curMeta->Genre().utf8()); 625 625 QString whereClause = "WHERE genre = " + value + 626 " ORDER BY artist , album, tracknum";626 " ORDER BY artist_name, album_name, track"; 627 627 closePlaylistPopup(); 628 628 updatePlaylistFromQuickPlaylist(whereClause); 629 629 } … … 635 635 636 636 QString value = formattedFieldValue(curMeta->Year()); 637 637 QString whereClause = "WHERE year = " + value + 638 " ORDER BY artist , album, tracknum";638 " ORDER BY artist_name, album_name, track"; 639 639 closePlaylistPopup(); 640 640 updatePlaylistFromQuickPlaylist(whereClause); 641 641 } -
mythmusic/mythmusic/search.cpp
66 66 67 67 void SearchDialog::runQuery(QString searchText) 68 68 { 69 // This method will perform a search in the 'musicmetadata' tableand fill69 // This method will perform a search in the various music_* tables and fill 70 70 // the 'listbox' widget with the results. 71 71 // The following columns are searched: filename, artist, album, title. 72 72 // To facilitate usage with a remote, two search modes exist and … … 103 103 104 104 MSqlQuery query(MSqlQuery::InitCon()); 105 105 106 QString queryString("SELECT filename, artist, album, title, intid " 107 "FROM musicmetadata "); 106 QString queryString("SELECT filename, artist_name, album_name, name, song_id " 107 "FROM music_songs " 108 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 109 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "); 108 110 109 111 QStringList list = QStringList::split(QRegExp("[>,]"), searchText); 110 112 whereClause = ""; … … 117 119 QString stxt = list[i]; 118 120 whereClause += (i) ? " AND ( " : "WHERE ("; 119 121 whereClause += 120 "filename LIKE '%" + stxt + "%' OR "121 "artist LIKE '%" + stxt + "%' OR "122 "album LIKE '%" + stxt + "%' OR "123 " title LIKE '%" + stxt + "%')";122 "filename LIKE '%" + stxt + "%' OR " 123 "artist_name LIKE '%" + stxt + "%' OR " 124 "album_name LIKE '%" + stxt + "%' OR " 125 "name LIKE '%" + stxt + "%')"; 124 126 } 125 127 VERBOSE(VB_GENERAL, QString("alpha whereClause " + whereClause )); 126 128 } … … 131 133 QString stxt = list[i].stripWhiteSpace(); 132 134 whereClause += (i) ? " AND ( " : "WHERE ("; 133 135 whereClause += 134 "filename REGEXP '" + stxt + "' OR "135 "artist REGEXP '" + stxt + "' OR "136 "album REGEXP '" + stxt + "' OR "137 " titleREGEXP '" + stxt + "')";136 "filename REGEXP '" + stxt + "' OR " 137 "artist_name REGEXP '" + stxt + "' OR " 138 "album_name REGEXP '" + stxt + "' OR " 139 "name REGEXP '" + stxt + "')"; 138 140 } 139 141 VERBOSE(VB_GENERAL,QString("numeric whereClause " + whereClause )); 140 142 } 141 143 } 142 144 143 145 queryString += whereClause; 144 queryString += " ORDER BY artist , album, title, intid, filename ";146 queryString += " ORDER BY artist_name, album_name, name, song_id, filename "; 145 147 146 148 query.prepare(queryString); 147 149 … … 217 219 void SearchDialog::itemSelected(int i) 218 220 { 219 221 unsigned int id = ((SearchListBoxItem*)listbox->item(i))->getId(); 220 whereClause = QString("WHERE intid='%1';").arg(id);222 whereClause = QString("WHERE song_id='%1';").arg(id); 221 223 done(0); 222 224 } 223 225 -
mythmusic/mythmusic/playlist.h
83 83 void loadPlaylist(QString a_name, QString a_host); 84 84 void loadPlaylistByID(int id, QString a_host); 85 85 86 void savePlaylist(QString a_name); 87 void saveNewPlaylist(QString a_host); 86 void savePlaylist(QString a_name, QString a_host); 88 87 89 88 void putYourselfOnTheListView(UIListGenericTree *a_parent); 90 89 -
mythmusic/mythmusic/cdrip.h
38 38 void reject(); 39 39 40 40 private: 41 void fillComboBox (MythComboBox &, const QString &);42 43 41 int ripTrack(QString &cddevice, Encoder *encoder, int tracknum); 44 42 static QString fixFileToken(QString token); 45 43 void handleFileTokens(QString &filename, Metadata *track); -
mythmusic/mythmusic/metadata.cpp
31 31 32 32 Metadata& Metadata::operator=(Metadata *rhs) 33 33 { 34 artist = rhs-> Artist();35 compilation_artist = rhs-> CompilationArtist();36 album = rhs-> Album();37 title = rhs-> Title();38 formattedartist = rhs-> FormatArtist();39 formattedtitle = rhs-> FormatTitle();40 genre = rhs-> Genre();41 year = rhs-> Year();42 tracknum = rhs-> Track();43 length = rhs-> Length();44 rating = rhs-> Rating();45 lastplay = rhs-> LastPlayStr();46 playcount = rhs-> Playcount();47 compilation = rhs-> Compilation();48 id = rhs-> ID();49 filename = rhs-> Filename();50 changed = rhs-> hasChanged();34 artist = rhs->artist; 35 compilation_artist = rhs->compilation_artist; 36 album = rhs->album; 37 title = rhs->title; 38 formattedartist = rhs->formattedartist; 39 formattedtitle = rhs->formattedtitle; 40 genre = rhs->genre; 41 year = rhs->year; 42 tracknum = rhs->tracknum; 43 length = rhs->length; 44 rating = rhs->rating; 45 lastplay = rhs->lastplay; 46 playcount = rhs->playcount; 47 compilation = rhs->compilation; 48 id = rhs->id; 49 filename = rhs->filename; 50 changed = rhs->changed; 51 51 52 52 return *this; 53 53 } … … 62 62 void Metadata::persist() 63 63 { 64 64 MSqlQuery query(MSqlQuery::InitCon()); 65 query.prepare("UPDATE music metadataset rating = :RATING , "66 " playcount= :PLAYCOUNT , lastplay = :LASTPLAY "67 "where intid = :ID ;");65 query.prepare("UPDATE music_songs set rating = :RATING , " 66 "numplays = :PLAYCOUNT , lastplay = :LASTPLAY " 67 "where song_id = :ID ;"); 68 68 query.bindValue(":RATING", rating); 69 69 query.bindValue(":PLAYCOUNT", playcount); 70 70 query.bindValue(":LASTPLAY", lastplay); … … 100 100 sqlfilename.remove(0, m_startdir.length()); 101 101 102 102 MSqlQuery query(MSqlQuery::InitCon()); 103 query.prepare("SELECT artist,compilation_artist,album,title,genre,year,tracknum," 104 "length,intid,rating,playcount,lastplay,compilation,format FROM " 105 "musicmetadata WHERE filename = :FILENAME ;"); 103 query.prepare("SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, " 104 "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, " 105 "music_songs.track, music_songs.length, music_songs.song_id, music_songs.rating, " 106 "music_songs.numplays, music_songs.lastplay, music_albums.compilation, " 107 "music_songs.format " 108 "FROM music_songs " 109 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 110 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 111 "LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id " 112 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " 113 "WHERE music_songs.filename = :FILENAME ;"); 106 114 query.bindValue(":FILENAME", sqlfilename.utf8()); 107 115 108 116 if (query.exec() && query.isActive() && query.size() > 0) … … 150 158 // Don't update the database if a song with the exact same 151 159 // metadata is already there 152 160 MSqlQuery query(MSqlQuery::InitCon()); 153 query.prepare("SELECT filename FROM musicmetadata WHERE " 154 "( ( artist = :ARTIST ) AND " 155 "( compilation_artist = :COMPILATION_ARTIST ) " 156 "( album = :ALBUM ) AND ( title = :TITLE ) " 157 "AND ( genre = :GENRE ) AND " 158 "( year = :YEAR ) AND ( tracknum = :TRACKNUM ) " 159 "AND ( length = :LENGTH ) " 160 "AND ( format = :FORMAT) );"); 161 query.prepare("SELECT music_songs.filename " 162 "FROM music_songs " 163 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 164 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 165 "LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id " 166 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " 167 "WHERE music_artists.artist_name = :ARTIST" 168 " AND music_comp_artists.artist_name = :COMPILATION_ARTIST" 169 " AND music_albums.album_name = :ALBUM" 170 " AND music_songs.name = :TITLE" 171 " AND music_genres.genre = :GENRE" 172 " AND music_songs.year = :YEAR" 173 " AND music_songs.track = :TRACKNUM" 174 " AND music_songs.length = :LENGTH" 175 " AND music_songs.format = :FORMAT ;"); 176 161 177 query.bindValue(":ARTIST", artist.utf8()); 162 178 query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8()); 163 179 query.bindValue(":ALBUM", album.utf8()); … … 171 187 if (query.exec() && query.isActive() && query.size() > 0) 172 188 return; 173 189 174 query.prepare("INSERT INTO musicmetadata " 175 "(artist, compilation_artist, album, title, " 176 " genre, year, tracknum, length, " 177 " filename, compilation, date_added, date_modified, " 178 " format ) " 179 "VALUES " 180 "(:ARTIST, :COMPILATION_ARTIST,:ALBUM, :TITLE, " 181 " :GENRE, :YEAR, :TRACKNUM, :LENGTH, " 182 " :FILENAME,:COMPILATION, :DATE_ADDED,:DATE_MOD," 183 " :FORMAT)"); 190 // Load the artist id or insert it and get the id 191 unsigned int artistId; 192 query.prepare("SELECT artist_id FROM music_artists " 193 "WHERE artist_name = :ARTIST ;"); 184 194 query.bindValue(":ARTIST", artist.utf8()); 185 query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8()); 195 196 if (!query.exec() || !query.isActive()) 197 { 198 MythContext::DBError("music select artist id", query); 199 return; 200 } 201 if (query.size() > 0) 202 { 203 query.next(); 204 artistId = query.value(0).toInt(); 205 } 206 else 207 { 208 query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);"); 209 query.bindValue(":ARTIST", artist.utf8()); 210 211 if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) 212 { 213 MythContext::DBError("music insert artist", query); 214 return; 215 } 216 artistId = query.lastInsertId().toInt(); 217 } 218 219 // Compilation Artist 220 unsigned int compilationArtistId; 221 query.prepare("SELECT artist_id FROM music_artists " 222 "WHERE artist_name = :ARTIST ;"); 223 query.bindValue(":ARTIST", compilation_artist.utf8()); 224 if (!query.exec() || !query.isActive()) 225 { 226 MythContext::DBError("music select compilation artist id", query); 227 return; 228 } 229 if (query.size() > 0) 230 { 231 query.next(); 232 compilationArtistId = query.value(0).toInt(); 233 } 234 else 235 { 236 query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);"); 237 query.bindValue(":ARTIST", compilation_artist.utf8()); 238 239 if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) 240 { 241 MythContext::DBError("music insert compilation artist", query); 242 return; 243 } 244 compilationArtistId = query.lastInsertId().toInt(); 245 } 246 247 // Album 248 unsigned int albumId; 249 query.prepare("SELECT album_id FROM music_albums " 250 "WHERE artist_id = :COMP_ARTIST_ID " 251 " AND album_name = :ALBUM ;"); 252 query.bindValue(":COMP_ARTIST_ID", compilationArtistId); 186 253 query.bindValue(":ALBUM", album.utf8()); 254 if (!query.exec() || !query.isActive()) 255 { 256 MythContext::DBError("music select album id", query); 257 return; 258 } 259 if (query.size() > 0) 260 { 261 query.next(); 262 albumId = query.value(0).toInt(); 263 } 264 else 265 { 266 query.prepare("INSERT INTO music_albums (artist_id, album_name, compilation, year) VALUES (:COMP_ARTIST_ID, :ALBUM, :COMPILATION, :YEAR);"); 267 query.bindValue(":COMP_ARTIST_ID", compilationArtistId); 268 query.bindValue(":ALBUM", album.utf8()); 269 query.bindValue(":COMPILATION", compilation); 270 query.bindValue(":YEAR", year); 271 272 if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) 273 { 274 MythContext::DBError("music insert album", query); 275 return; 276 } 277 albumId = query.lastInsertId().toInt(); 278 } 279 280 // Genres 281 unsigned int genreId; 282 query.prepare("SELECT genre_id FROM music_genres " 283 "WHERE genre = :GENRE ;"); 284 query.bindValue(":GENRE", genre.utf8()); 285 if (!query.exec() || !query.isActive()) 286 { 287 MythContext::DBError("music select genre id", query); 288 return; 289 } 290 if (query.size() > 0) 291 { 292 query.next(); 293 genreId = query.value(0).toInt(); 294 } 295 else 296 { 297 query.prepare("INSERT INTO music_genres (genre) VALUES (:GENRE);"); 298 query.bindValue(":GENRE", genre.utf8()); 299 300 if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0) 301 { 302 MythContext::DBError("music insert genre", query); 303 return; 304 } 305 genreId = query.lastInsertId().toInt(); 306 } 307 308 // We have all the id's now. We can insert it. 309 QString strQuery; 310 if (id < 1) 311 { 312 strQuery = "INSERT INTO music_songs (" 313 " artist_id, album_id, name, genre_id," 314 " year, track, length, filename," 315 " rating, format, date_entered, date_modified ) " 316 "VALUES (" 317 " :ARTIST, :ALBUM, :TITLE, :GENRE," 318 " :YEAR, :TRACKNUM, :LENGTH, :FILENAME," 319 " :RATING, :FORMAT, :DATE_ADD, :DATE_MOD );"; 320 } 321 else 322 { 323 strQuery = "UPDATE music_songs SET" 324 " artist_id = :ARTIST" 325 ", album_id = :ALBUM" 326 ", name = :TITLE" 327 ", genre_id = :GENRE" 328 ", year = :YEAR" 329 ", track = :TRACKNUM" 330 ", length = :LENGTH" 331 ", filename = :FILENAME" 332 ", rating = :RATING" 333 ", format = :FORMAT" 334 ", date_modified = :DATE_MOD " 335 "WHERE song_id= :ID ;"; 336 } 337 338 query.prepare(strQuery); 339 /* 340 query.prepare("INSERT INTO music_songs " 341 " (artist_id, album_id, name," 342 " genre_id, year, track, length," 343 " filename, date_entered, date_modified," 344 " format, size, bitrate) " 345 "VALUES " 346 " (:ARTIST, :ALBUM, :TITLE," 347 " :GENRE, :YEAR, :TRACKNUM, :LENGTH," 348 " :FILENAME, :DATE_ADDED, :DATE_MOD," 349 " :FORMAT, :FILESIZE, :BITRATE)" 350 ); 351 */ 352 query.bindValue(":ARTIST", artistId); 353 query.bindValue(":ALBUM", albumId); 187 354 query.bindValue(":TITLE", title.utf8()); 188 query.bindValue(":GENRE", genre .utf8());355 query.bindValue(":GENRE", genreId); 189 356 query.bindValue(":YEAR", year); 190 357 query.bindValue(":TRACKNUM", tracknum); 191 358 query.bindValue(":LENGTH", length); 192 359 query.bindValue(":FILENAME", sqlfilename.utf8()); 193 query.bindValue(":COMPILATION", compilation); 194 query.bindValue(":DATE_ADDED", QDateTime::currentDateTime()); 195 query.bindValue(":DATE_MOD", QDateTime::currentDateTime()); 360 query.bindValue(":RATING", rating); 196 361 query.bindValue(":FORMAT", format); 197 362 query.bindValue(":DATE_MOD", QDateTime::currentDateTime()); 363 364 if (id < 1) 365 query.bindValue(":DATE_ADDED", QDateTime::currentDateTime()); 366 else 367 query.bindValue(":ID", id); 368 198 369 query.exec(); 199 370 200 // easiest way to ensure we've got 'id' filled.201 fillData();371 if (id < 1 && query.isActive() && 1 == query.numRowsAffected()) 372 id = query.lastInsertId().toInt(); 202 373 } 203 374 204 375 // Default values for formats … … 328 499 } 329 500 330 501 331 void Metadata::updateDatabase()332 {333 // only save to DB if something changed334 //if (!hasChanged())335 // return;336 337 if (artist == "")338 artist = QObject::tr("Unknown Artist");339 if (album == "")340 album = QObject::tr("Unknown Album");341 if (title == "")342 title = filename;343 if (genre == "")344 genre = QObject::tr("Unknown Genre");345 346 MSqlQuery query(MSqlQuery::InitCon());347 348 query.prepare("UPDATE musicmetadata "349 "SET artist = :ARTIST, "350 " album = :ALBUM, "351 " title = :TITLE, "352 " genre = :GENRE, "353 " year = :YEAR, "354 " tracknum = :TRACKNUM, "355 " rating = :RATING, "356 " date_modified = :DATE_MODIFIED, "357 " compilation = :COMPILATION, "358 " compilation_artist = :COMPILATION_ARTIST, "359 " format = :FORMAT "360 "WHERE intid = :ID;");361 query.bindValue(":ARTIST", artist.utf8());362 query.bindValue(":ALBUM", album.utf8());363 query.bindValue(":TITLE", title.utf8());364 query.bindValue(":GENRE", genre.utf8());365 query.bindValue(":YEAR", year);366 query.bindValue(":TRACKNUM", tracknum);367 query.bindValue(":RATING", rating);368 query.bindValue(":DATE_MODIFIED", QDateTime::currentDateTime());369 query.bindValue(":COMPILATION", compilation);370 query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8());371 query.bindValue(":FORMAT", format);372 query.bindValue(":ID", id);373 374 if (!query.exec())375 MythContext::DBError("Update musicmetadata", query);376 }377 378 379 502 void Metadata::setField(const QString &field, const QString &data) 380 503 { 381 504 if (field == "artist") … … 426 549 } 427 550 } 428 551 429 void Metadata::fillData()430 {431 if (title == "")432 return;433 434 QString thequery = "SELECT artist,compilation_artist,album,title,genre,year,tracknum,length,"435 "filename,intid,rating,playcount,lastplay,compilation,format "436 "FROM musicmetadata WHERE title = :TITLE";437 438 if (album != "")439 thequery += " AND album = :ALBUM";440 if (artist != "")441 thequery += " AND artist = :ARTIST";442 if (compilation_artist != "")443 thequery += " AND compilation_artist = :COMPILATION_ARTIST";444 445 thequery += ";";446 447 MSqlQuery query(MSqlQuery::InitCon());448 query.prepare(thequery);449 query.bindValue(":TITLE", title.utf8());450 query.bindValue(":ALBUM", album.utf8());451 query.bindValue(":ARTIST", artist.utf8());452 query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8());453 454 if (query.exec() && query.isActive() && query.size() > 0)455 {456 query.next();457 458 artist = QString::fromUtf8(query.value(0).toString());459 compilation_artist = QString::fromUtf8(query.value(1).toString());460 album = QString::fromUtf8(query.value(2).toString());461 title = QString::fromUtf8(query.value(3).toString());462 genre = QString::fromUtf8(query.value(4).toString());463 year = query.value(5).toInt();464 tracknum = query.value(6).toInt();465 length = query.value(7).toInt();466 filename = QString::fromUtf8(query.value(8).toString());467 id = query.value(9).toUInt();468 rating = query.value(10).toInt();469 playcount = query.value(11).toInt();470 lastplay = query.value(12).toString();471 compilation = (query.value(13).toInt() > 0);472 format = query.value(14).toString();473 474 if (!filename.contains("://"))475 filename = m_startdir + filename;476 }477 }478 479 void Metadata::fillDataFromID()480 {481 if (id == 0)482 return;483 484 MSqlQuery query(MSqlQuery::InitCon());485 query.prepare("SELECT title,artist,compilation_artist,album,title,genre,year,tracknum,"486 "length,filename,rating,playcount,lastplay,compilation,format FROM "487 "musicmetadata WHERE intid = :ID ;");488 query.bindValue(":ID", id);489 490 if (query.exec() && query.isActive() && query.numRowsAffected() > 0)491 {492 query.next();493 494 title = QString::fromUtf8(query.value(0).toString());495 artist = QString::fromUtf8(query.value(1).toString());496 compilation_artist = QString::fromUtf8(query.value(2).toString());497 album = QString::fromUtf8(query.value(3).toString());498 title = QString::fromUtf8(query.value(4).toString());499 genre = QString::fromUtf8(query.value(5).toString());500 year = query.value(6).toInt();501 tracknum = query.value(7).toInt();502 length = query.value(8).toInt();503 filename = QString::fromUtf8(query.value(9).toString());504 rating = query.value(10).toInt();505 playcount = query.value(11).toInt();506 lastplay = query.value(12).toString();507 compilation = (query.value(13).toInt() > 0);508 format = query.value(14).toString();509 510 if (!filename.contains("://"))511 filename = m_startdir + filename;512 }513 }514 515 552 void Metadata::decRating() 516 553 { 517 554 if (rating > 0) … … 553 590 changed = true; 554 591 } 555 592 593 QStringList Metadata::fillFieldList(QString field) 594 { 595 QStringList searchList; 596 searchList.clear(); 597 598 MSqlQuery query(MSqlQuery::InitCon()); 599 if ("artist" == field || "compilation_artist" == field) 600 { 601 query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;"); 602 } 603 else if ("album" == field) 604 { 605 query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;"); 606 } 607 else if ("title" == field) 608 { 609 query.prepare("SELECT name FROM music_songs ORDER BY name;"); 610 } 611 else if ("genre" == field) 612 { 613 query.prepare("SELECT genre FROM music_genres ORDER BY genre;"); 614 } 615 else 616 { 617 return searchList; 618 } 619 620 if (query.exec() && query.isActive() && query.size()) 621 { 622 while (query.next()) 623 { 624 searchList << QString::fromUtf8(query.value(0).toString()); 625 } 626 } 627 return searchList; 628 } 629 556 630 MetadataLoadingThread::MetadataLoadingThread(AllMusic *parent_ptr) 557 631 { 558 632 parent = parent_ptr; … … 648 722 void AllMusic::resync() 649 723 { 650 724 done_loading = false; 651 QString aquery = "SELECT intid, artist, compilation_artist, album, title, genre, "652 "year, tracknum, length, filename, rating, "653 "lastplay, playcount, compilation, format "654 "FROM musicmetadata "655 "ORDER BY intid;";656 725 726 QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, " 727 "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, " 728 "music_songs.track, music_songs.length, music_songs.filename, " 729 "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_albums.compilation, " 730 "music_songs.format " 731 "FROM music_songs " 732 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 733 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 734 "LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id " 735 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id " 736 "ORDER BY music_songs.song_id;"; 737 657 738 QString filename, artist, album, title; 658 739 659 740 MSqlQuery query(MSqlQuery::InitCon()); … … 696 777 query.value(7).toInt(), 697 778 query.value(8).toInt(), 698 779 query.value(0).toInt(), 699 query.value(10).toInt(), 700 query.value(1 2).toInt(),701 query.value(1 1).toString(),702 (query.value(13).toInt() > 0), 703 query.value(14).toString()); 704 780 query.value(10).toInt(), //rating 781 query.value(11).toInt(), //playcount 782 query.value(12).toString(), //lastplay 783 (query.value(13).toInt() > 0), //compilation 784 query.value(14).toString()); //format 785 705 786 // Don't delete temp, as PtrList now owns it 706 787 all_music.append(temp); 707 788 -
mythmusic/mythmusic/dbcheck.cpp
9 9 #include "mythtv/mythcontext.h" 10 10 #include "mythtv/mythdbcon.h" 11 11 12 const QString currentDatabaseVersion = "100 5";12 const QString currentDatabaseVersion = "1006"; 13 13 14 14 static void UpdateDBVersionNumber(const QString &newnumber) 15 15 { … … 323 323 324 324 performActualUpdate(updates, "1005", dbver); 325 325 } 326 327 328 if (dbver == "1005") 329 { 330 const QString updates[] = { 331 "CREATE TABLE music_albums (" 332 " album_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY," 333 " artist_id int(11) unsigned NOT NULL default '0'," 334 " album_name varchar(255) NOT NULL default ''," 335 " year smallint(6) NOT NULL default '0'," 336 " compilation tinyint(1) unsigned NOT NULL default '0'," 337 " INDEX idx_album_name(album_name)" 338 ");", 339 "CREATE TABLE music_artists (" 340 " artist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY," 341 " artist_name varchar(255) NOT NULL default ''," 342 " INDEX idx_artist_name(artist_name)" 343 ");", 344 "CREATE TABLE music_genres (" 345 " genre_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY," 346 " genre varchar(25) NOT NULL default ''," 347 " INDEX idx_genre(genre)" 348 ");", 349 "CREATE TABLE music_playlists (" 350 " playlist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY," 351 " playlist_name varchar(255) NOT NULL default ''," 352 " playlist_songs text NOT NULL default ''," 353 " last_accessed timestamp NOT NULL," 354 " length int(11) unsigned NOT NULL default '0'," 355 " songcount smallint(8) unsigned NOT NULL default '0'," 356 " hostname VARCHAR(255) NOT NULL default ''" 357 ");", 358 "CREATE TABLE music_songs (" 359 " song_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY," 360 " filename text NOT NULL default ''," 361 " name varchar(255) NOT NULL default ''," 362 " track smallint(6) unsigned NOT NULL default '0'," 363 " artist_id int(11) unsigned NOT NULL default '0'," 364 " album_id int(11) unsigned NOT NULL default '0'," 365 " genre_id int(11) unsigned NOT NULL default '0'," 366 " year smallint(6) NOT NULL default '0'," 367 " length int(11) unsigned NOT NULL default '0'," 368 " numplays int(11) unsigned NOT NULL default '0'," 369 " rating tinyint(4) unsigned NOT NULL default '0'," 370 " lastplay timestamp NOT NULL," 371 " date_entered datetime default NULL," 372 " date_modified datetime default NULL," 373 " format varchar(4) NOT NULL default '0'," 374 " mythdigest VARCHAR(255)," 375 " size BIGINT(20) unsigned," 376 " description VARCHAR(255)," 377 " comment VARCHAR(255)," 378 " disc_count SMALLINT(5) UNSIGNED DEFAULT '0'," 379 " disc_number SMALLINT(5) UNSIGNED DEFAULT '0'," 380 " track_count SMALLINT(5) UNSIGNED DEFAULT '0'," 381 " start_time INT(10) UNSIGNED DEFAULT '0'," 382 " stop_time INT(10) UNSIGNED," 383 " eq_preset VARCHAR(255)," 384 " relative_volume TINYINT DEFAULT '0'," 385 " bpm SMALLINT(5) UNSIGNED," 386 " INDEX idx_name(name)," 387 " INDEX idx_mythdigest(mythdigest)" 388 ");", 389 "CREATE TABLE music_stats (" 390 " num_artists smallint(5) unsigned NOT NULL default '0'," 391 " num_albums smallint(5) unsigned NOT NULL default '0'," 392 " num_songs mediumint(8) unsigned NOT NULL default '0'," 393 " num_genres tinyint(3) unsigned NOT NULL default '0'," 394 " total_time varchar(12) NOT NULL default '0'," 395 " total_size varchar(10) NOT NULL default '0'" 396 ");", 397 "RENAME TABLE smartplaylist TO music_smartplaylists;", 398 "RENAME TABLE smartplaylistitem TO music_smartplaylist_items;", 399 "RENAME TABLE smartplaylistcategory TO music_smartplaylist_categories;", 400 // Run necessary SQL to migrate the table structure 401 "CREATE TEMPORARY TABLE tmp_artists" 402 " SELECT DISTINCT artist FROM musicmetadata;", 403 "INSERT INTO tmp_artists" 404 " SELECT DISTINCT compilation_artist" 405 " FROM musicmetadata" 406 " WHERE compilation_artist<>artist;", 407 "INSERT INTO music_artists (artist_name) SELECT DISTINCT artist FROM tmp_artists;", 408 "INSERT INTO music_albums (artist_id, album_name, year, compilation) " 409 " SELECT artist_id, album, ROUND(AVG(year)) AS year, IF(SUM(compilation),1,0) AS compilation" 410 " FROM musicmetadata" 411 " LEFT JOIN music_artists ON compilation_artist=artist_name" 412 " GROUP BY artist_id, album;", 413 "INSERT INTO music_genres (genre) SELECT DISTINCT genre FROM musicmetadata;", 414 "INSERT INTO music_songs " 415 " (song_id, artist_id, album_id, genre_id, year, lastplay," 416 " date_entered, date_modified, name, track, length, size, numplays," 417 " rating, filename)" 418 " SELECT intid, ma.artist_id, mb.album_id, mg.genre_id, mmd.year, lastplay," 419 " date_added, date_modified, title, tracknum, length, IFNULL(size,0), playcount," 420 " rating, filename" 421 " FROM musicmetadata AS mmd" 422 " LEFT JOIN music_artists AS ma ON mmd.artist=ma.artist_name" 423 " LEFT JOIN music_artists AS mc ON mmd.compilation_artist=mc.artist_name" 424 " LEFT JOIN music_albums AS mb ON mmd.album=mb.album_name AND mc.artist_id=mb.artist_id" 425 " LEFT JOIN music_genres AS mg ON mmd.genre=mg.genre;", 426 "INSERT INTO music_playlists" 427 " (playlist_id,playlist_name,playlist_songs,hostname)" 428 " SELECT playlistid, name, songlist, hostname" 429 " FROM musicplaylist;", 430 // Set all playlists to be global by killing the hostname 431 "UPDATE music_playlists" 432 " SET hostname=''" 433 " WHERE playlist_name='default_playlist_storage'" 434 " OR playlist_name='backup_playlist_storage';", 435 //"DROP TABLE musicmetadata;", 436 //"DROP TABLE musicplaylist;", 437 //RENAME TABLE music_smartplaylists TO smartplaylist;RENAME TABLE music_smartplaylist_categories TO smartplaylistcategory;RENAME TABLE music_smartplaylist_items TO smartplaylistitem; DROP TABLE music_albums; DROP TABLE music_artists; DROP TABLE music_genres; DROP TABLE music_playlists; DROP TABLE music_songs; DROP TABLE music_stats;UPDATE settings SET data=1005 WHERE value='MusicDBSchemaVer'; 438 "" 439 }; 440 performActualUpdate(updates, "1006", dbver); 441 } 326 442 } 327 443 -
mythmusic/mythmusic/playlist.cpp
35 35 if (index_value > 0) // Normal Track 36 36 label = all_available_music->getLabel(index_value, &bad_reference); 37 37 else if (index_value < 0) 38 label = grandparent->getPlaylistName( index_value, bad_reference);38 label = grandparent->getPlaylistName( (-1 * index_value), bad_reference); 39 39 else 40 40 { 41 41 cerr << "playlist.o: Not sure how I got 0 as a track number, but " … … 69 69 { 70 70 // XXX SPEED THIS UP 71 71 // Should be a straight lookup against cached index 72 bool result = false;73 72 Track *it; 74 73 75 74 for (it = songs.first(); it; it = songs.next()) 76 75 { 77 76 if (it->getValue() == a_track_id && it->getCDFlag() == cd_flag) 78 77 { 79 re sult =true;78 return true; 80 79 } 81 80 } 82 81 83 return result;82 return false; 84 83 } 85 84 86 85 void Playlist::copyTracks(Playlist *to_ptr, bool update_display) … … 327 326 all_other_playlists->clear(); 328 327 329 328 MSqlQuery query(MSqlQuery::InitCon()); 330 query.prepare("SELECT playlistid FROM musicplaylist " 331 "WHERE name != :DEFAULT " 332 "AND name != :BACKUP " 333 "AND hostname = :HOST ORDER BY playlistid ;"); 329 query.prepare("SELECT playlist_id FROM music_playlists " 330 "WHERE playlist_name != :DEFAULT" 331 " AND playlist_name != :BACKUP " 332 " AND (hostname = '' OR hostname = :HOST) " 333 "ORDER BY playlist_id;"); 334 334 query.bindValue(":DEFAULT", "default_playlist_storage"); 335 335 query.bindValue(":BACKUP", "backup_playlist_storage"); 336 336 query.bindValue(":HOST", my_host); … … 469 469 } 470 470 471 471 MSqlQuery query(MSqlQuery::InitCon()); 472 query.prepare("SELECT playlistid, name, songlist FROM " 473 "musicplaylist WHERE name = :NAME AND " 474 "hostname = :HOST ;"); 475 query.bindValue(":NAME", a_name); 472 473 if (name == "default_playlist_storage" || name == "backup_playlist_storage") 474 { 475 query.prepare("SELECT playlist_id, playlist_name, playlist_songs " 476 "FROM music_playlists " 477 "WHERE playlist_name = :NAME" 478 " AND hostname = :HOST;"); 479 } 480 else 481 { 482 // Technically this is never called as this function is only used to load 483 // the default/backup playlists. 484 query.prepare("SELECT playlist_id, playlist_name, playlist_songs " 485 "FROM music_playlists " 486 "WHERE playlist_name = :NAME" 487 " AND (hostname = '' OR hostname = :HOST);"); 488 } 489 query.bindValue(":NAME", a_name.utf8()); 476 490 query.bindValue(":HOST", a_host); 477 491 478 492 if (query.exec() && query.size() > 0) 479 493 { 480 494 while (query.next()) 481 495 { 482 this->playlistid = query.value(0).toInt();483 this->name = QString::fromUtf8(query.value(1).toString());484 this->raw_songlist = query.value(2).toString();496 playlistid = query.value(0).toInt(); 497 name = QString::fromUtf8(query.value(1).toString()); 498 raw_songlist = query.value(2).toString(); 485 499 } 486 500 if (name == "default_playlist_storage") 487 501 name = "the user should never see this"; … … 490 504 } 491 505 else 492 506 { 493 name = a_name; 494 saveNewPlaylist(a_host); 507 // Asked me to load a playlist I can't find so let's create a new one :) 508 playlistid = 0; // Be safe just in case we call load over the top 509 // of an existing playlist 510 raw_songlist = ""; 511 savePlaylist(a_name, a_host); 495 512 changed = true; 496 513 } 497 514 } … … 499 516 void Playlist::loadPlaylistByID(int id, QString a_host) 500 517 { 501 518 MSqlQuery query(MSqlQuery::InitCon()); 502 query.prepare("SELECT playlistid, name, songlist FROM " 503 "musicplaylist WHERE playlistid = :ID AND " 504 "hostname = :HOST ;"); 519 query.prepare("SELECT playlist_id, playlist_name, playlist_songs " 520 "FROM music_playlists " 521 "WHERE playlist_id = :ID" 522 " AND (hostname = '' OR hostname = :HOST);"); 505 523 query.bindValue(":ID", id); 506 524 query.bindValue(":HOST", a_host); 507 525 … … 509 527 510 528 while (query.next()) 511 529 { 512 this->playlistid = query.value(0).toInt();513 this->name = QString::fromUtf8(query.value(1).toString());514 this->raw_songlist = query.value(2).toString();530 playlistid = query.value(0).toInt(); 531 name = QString::fromUtf8(query.value(1).toString()); 532 raw_songlist = query.value(2).toString(); 515 533 } 516 534 517 535 if (name == "default_playlist_storage") … … 570 588 571 589 void Playlist::fillSonglistFromSongs() 572 590 { 573 bool first = true; 574 QString a_list; 591 QString a_list = ""; 575 592 Track *it; 576 593 for (it = songs.first(); it; it = songs.next()) 577 594 { 578 595 if (!it->getCDFlag()) 579 596 { 580 if (first) 581 { 582 first = false; 583 a_list = QString("%1").arg(it->getValue()); 584 } 585 else 586 a_list += QString(",%1").arg(it->getValue()); 597 a_list += QString(",%1").arg(it->getValue()); 587 598 } 588 599 } 589 600 590 raw_songlist = a_list; 601 raw_songlist = ""; 602 if (a_list.length() > 1) 603 raw_songlist = a_list.remove(0, 1); 591 604 } 592 605 593 606 void Playlist::fillSonglistFromQuery(QString whereClause, … … 604 617 605 618 QString theQuery; 606 619 607 theQuery = "SELECT intid FROM musicmetadata "; 620 theQuery = "SELECT song_id FROM music_songs " 621 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 622 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 623 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "; 608 624 609 625 if (whereClause.length() > 0) 610 626 theQuery += whereClause; … … 719 735 int limitTo; 720 736 721 737 query.prepare("SELECT smartplaylistid, matchtype, orderby, limitto " 722 "FROM smartplaylistWHERE categoryid = :CATEGORYID AND name = :NAME;");738 "FROM music_smartplaylists WHERE categoryid = :CATEGORYID AND name = :NAME;"); 723 739 query.bindValue(":NAME", name.utf8()); 724 740 query.bindValue(":CATEGORYID", categoryID); 725 741 726 742 if (query.exec()) 727 743 { 728 if (query.isActive() && query. numRowsAffected() > 0)744 if (query.isActive() && query.size() > 0) 729 745 { 730 746 query.first(); 731 747 ID = query.value(0).toInt(); … … 749 765 QString whereClause = "WHERE "; 750 766 751 767 query.prepare("SELECT field, operator, value1, value2 " 752 "FROM smartplaylistitemWHERE smartplaylistid = :ID;");768 "FROM music_smartplaylist_items WHERE smartplaylistid = :ID;"); 753 769 query.bindValue(":ID", ID); 754 770 query.exec(); 755 if (query.isActive() && query. numRowsAffected() > 0)771 if (query.isActive() && query.size() > 0) 756 772 { 757 773 bool bFirst = true; 758 774 while (query.next()) … … 770 786 } 771 787 } 772 788 } 773 789 774 790 // add order by clause 775 791 whereClause += getOrderBySQL(orderBy); 776 792 777 793 // add limit 778 794 if (limitTo > 0) 779 whereClause += " LIMIT " + QString::number(limitTo); 795 whereClause += " LIMIT " + QString::number(limitTo); 780 796 781 797 fillSonglistFromQuery(whereClause, removeDuplicates, insertOption, currentTrackID); 782 798 } 783 784 void Playlist::savePlaylist(QString a_name )799 800 void Playlist::savePlaylist(QString a_name, QString a_host) 785 801 { 786 name = name.simplifyWhiteSpace();802 name = a_name.simplifyWhiteSpace(); 787 803 if (name.length() < 1) 788 return;789 790 fillSonglistFromSongs();791 792 MSqlQuery query(MSqlQuery::InitCon());793 query.prepare("SELECT NULL FROM musicplaylist WHERE playlistid = :ID ;");794 query.bindValue(":ID", playlistid);795 796 if (query.exec() && query.isActive() && query.size() > 0)797 804 { 798 query.prepare("UPDATE musicplaylist SET songlist = :LIST , "799 "name = :NAME WHERE playlistid = :ID ;");800 query.bindValue(":LIST", raw_songlist);801 query.bindValue(":NAME", a_name.utf8());802 query.bindValue(":ID", playlistid);803 }804 else805 {806 query.prepare("INSERT INTO musicplaylist (name,songlist) "807 "VALUES(:NAME, :LIST);");808 query.bindValue(":LIST", raw_songlist);809 query.bindValue(":NAME", a_name.utf8());810 }811 812 query.exec();813 }814 815 void Playlist::saveNewPlaylist(QString a_host)816 {817 name = name.simplifyWhiteSpace();818 if(name.length() < 1)819 {820 805 cerr << "playlist.o: Not going to save a playlist with no name" << endl ; 821 806 return; 822 807 } 823 808 824 if (a_host.length() < 1)809 if (a_host.length() < 1) 825 810 { 826 811 cerr << "playlist.o: Not going to save a playlist with no hostname" << endl; 827 812 return; 828 813 } 814 if (name.length() < 1) 815 return; 829 816 830 817 fillSonglistFromSongs(); 831 832 818 MSqlQuery query(MSqlQuery::InitCon()); 833 query.prepare("INSERT musicplaylist (name, hostname) "834 "VALUES(:NAME, :HOST);");835 query.bindValue(":NAME", name.utf8());836 query.bindValue(":HOST", a_host);837 819 838 query.exec(); 839 840 query.prepare("SELECT playlistid FROM musicplaylist WHERE " 841 "name = :NAME AND hostname = :HOST ;"); 842 query.bindValue(":NAME", name.utf8()); 843 query.bindValue(":HOST", a_host); 844 845 if (query.exec() && query.isActive() && query.size() > 0) 820 int songcount = 0, playtime = 0, an_int; 821 QStringList list = QStringList::split(",", raw_songlist); 822 QStringList::iterator it = list.begin(); 823 for (; it != list.end(); it++) 846 824 { 847 while(query.next()) 825 an_int = QString(*it).toInt(); 826 if (an_int != 0) 848 827 { 849 // If multiple rows with same name, 850 // make sure we get the last one 851 playlistid = query.value(0).toInt(); 828 songcount++; 829 if (an_int > 0) 830 { 831 query.prepare("SELECT length FROM music_songs WHERE song_id = :ID ;"); 832 } 833 else 834 { 835 query.prepare("SELECT length FROM music_playlists WHERE playlist_id = :ID ;"); 836 an_int *= -1; 837 } 838 query.bindValue(":ID", an_int); 839 query.exec(); 840 if (query.size() > 0) 841 { 842 query.next(); 843 playtime += query.value(0).toInt(); 844 } 852 845 } 853 846 } 847 848 bool save_host = ("default_playlist_storage" == a_name || "backup_playlist_storage" == a_name); 849 if (playlistid > 0) 850 { 851 QString str_query = "UPDATE music_playlists SET playlist_songs = :LIST," 852 " playlist_name = :NAME, songcount = :SONGCOUNT, length = :PLAYTIME"; 853 if (save_host) 854 str_query += ", hostname = :HOSTNAME"; 855 str_query += " WHERE playlist_id = :ID ;"; 856 857 query.prepare(str_query); 858 query.bindValue(":ID", playlistid); 859 } 854 860 else 855 861 { 856 MythContext::DBError("playlist insert", query); 862 QString str_query = "INSERT INTO music_playlists" 863 " (playlist_name, playlist_songs, songcount, length"; 864 if (save_host) 865 str_query += ", hostname"; 866 str_query += ") VALUES(:NAME, :LIST, :SONGCOUNT, :PLAYTIME"; 867 if (save_host) 868 str_query += ", :HOSTNAME"; 869 str_query += ");"; 870 871 query.prepare(str_query); 857 872 } 873 query.bindValue(":LIST", raw_songlist); 874 query.bindValue(":NAME", a_name.utf8()); 875 query.bindValue(":SONGCOUNT", songcount); 876 query.bindValue(":PLAYTIME", playtime); 877 if (save_host) 878 query.bindValue(":HOSTNAME", a_host); 879 880 if (!query.exec() || (playlistid < 1 && query.numRowsAffected() < 1)) 881 { 882 MythContext::DBError("Problem saving playlist", query); 883 } 884 885 if (playlistid < 1) 886 playlistid = query.lastInsertId().toInt(); 858 887 } 859 888 860 889 QString Playlist::removeDuplicateTracks(const QString &new_songlist) 861 890 { 862 raw_songlist = raw_songlist.remove(' ');891 raw_songlist.remove(' '); 863 892 864 893 QStringList curList = QStringList::split(",", raw_songlist); 865 894 QStringList newList = QStringList::split(",", new_songlist); … … 1095 1124 if(a_list->hasChanged()) 1096 1125 { 1097 1126 a_list->fillSonglistFromSongs(); 1098 a_list->savePlaylist(a_list->getName() );1127 a_list->savePlaylist(a_list->getName(), my_host); 1099 1128 } 1100 1129 } 1101 1102 active_playlist->savePlaylist("default_playlist_storage" );1103 backup_playlist->savePlaylist("backup_playlist_storage" );1130 1131 active_playlist->savePlaylist("default_playlist_storage", my_host); 1132 backup_playlist->savePlaylist("backup_playlist_storage", my_host); 1104 1133 } 1105 1134 1106 1135 void PlaylistsContainer::createNewPlaylist(QString name) 1107 1136 { 1108 1137 Playlist *new_list = new Playlist(all_available_music); 1109 1138 new_list->setParent(this); 1110 new_list->setName(name); 1111 1139 1112 1140 // Need to touch the database to get persistent ID 1113 new_list->save NewPlaylist(my_host);1141 new_list->savePlaylist(name, my_host); 1114 1142 new_list->Changed(); 1115 1143 all_other_playlists->append(new_list); 1116 1144 //if(my_widget) … … 1123 1151 { 1124 1152 Playlist *new_list = new Playlist(all_available_music); 1125 1153 new_list->setParent(this); 1126 new_list->setName(name); 1154 1127 1155 // Need to touch the database to get persistent ID 1128 new_list->save NewPlaylist(my_host);1156 new_list->savePlaylist(name, my_host); 1129 1157 new_list->Changed(); 1130 1158 all_other_playlists->append(new_list); 1131 1159 active_playlist->copyTracks(new_list, false); … … 1196 1224 void PlaylistsContainer::renamePlaylist(int index, QString new_name) 1197 1225 { 1198 1226 Playlist *list_to_rename = getPlaylist(index); 1199 if (list_to_rename)1227 if (list_to_rename) 1200 1228 { 1201 1229 list_to_rename->setName(new_name); 1202 1230 list_to_rename->Changed(); … … 1237 1265 } 1238 1266 1239 1267 MSqlQuery query(MSqlQuery::InitCon()); 1240 query.prepare("DELETE FROM music playlist WHERE playlistid = :ID ;");1268 query.prepare("DELETE FROM music_playlists WHERE playlist_id = :ID ;"); 1241 1269 query.bindValue(":ID", kill_me); 1242 1270 1243 if ( query.exec() || query.size() < 1)1271 if (!query.exec() || query.numRowsAffected() < 1) 1244 1272 { 1245 1273 MythContext::DBError("playlist delete", query); 1246 1274 } … … 1261 1289 Playlist *a_list; 1262 1290 for(a_list = all_other_playlists->last(); a_list; a_list = all_other_playlists->prev()) 1263 1291 { 1264 if (a_list->getID() * -1== index)1292 if (a_list->getID() == index) 1265 1293 { 1266 1294 return a_list->getName(); 1267 1295 } … … 1538 1566 level_down->computeSize(child_MB, child_sec); 1539 1567 size_in_MB += child_MB; 1540 1568 size_in_sec += child_sec; 1541 }1569 } 1542 1570 } 1543 1571 } 1544 1572 } -
mythmusic/mythmusic/cdrip.cpp
104 104 // which totally messes up the rest of the page. 105 105 artistedit->setMaximumWidth((int)(0.7 * screenwidth)); 106 106 107 fillComboBox(*artistedit, "artist"); 108 107 QStringList strlist = Metadata::fillFieldList("artist"); 108 artistedit->insertStringList(strlist); 109 109 110 QLabel *albuml = new QLabel(tr("Album: "), firstdiag); 110 111 albuml->setBackgroundOrigin(WindowOrigin); 111 112 albumedit = new MythLineEdit(firstdiag); … … 114 115 QLabel *genrelabel = new QLabel(tr("Genre: "), firstdiag); 115 116 genrelabel->setBackgroundOrigin(WindowOrigin); 116 117 genreedit = new MythComboBox(true, firstdiag); 117 fillComboBox (*genreedit, "genre"); 118 strlist = Metadata::fillFieldList("genre"); 119 genreedit->insertStringList(strlist); 118 120 119 121 120 122 compilation = new MythCheckBox(firstdiag); … … 196 198 197 199 length = track->Length() / 1000; 198 200 199 QString title = track->Title();200 newTune = isNewTune(artistname, albumname, title);201 QString title = track->Title(); 202 newTune = isNewTune(artistname, albumname, title); 201 203 202 if (newTune)203 {204 min = length / 60;204 if (newTune) 205 { 206 min = length / 60; 205 207 sec = length % 60; 206 208 207 table->setNumRows(row + 1);208 209 table->setRowHeight(row, (int)(30 * hmult));210 211 label.sprintf("%d", trackno + 1);212 table->setText(row, 0, label);213 214 table->setText(row, 1, track->Title());215 216 table->setText(row, 2, track->Artist());217 218 label.sprintf("%02d:%02d", min, sec);219 table->setText(row, 3, label);220 221 row++;222 }209 table->setNumRows(row + 1); 210 211 table->setRowHeight(row, (int)(30 * hmult)); 212 213 label.sprintf("%d", trackno + 1); 214 table->setText(row, 0, label); 215 216 table->setText(row, 1, track->Title()); 217 218 table->setText(row, 2, track->Artist()); 219 220 label.sprintf("%02d:%02d", min, sec); 221 table->setText(row, 3, label); 222 223 row++; 224 } 223 225 delete track; 224 226 } 225 227 } … … 283 285 { 284 286 if (gContext->GetNumSetting("OnlyImportNewMusic",1)) 285 287 { 286 MSqlQuery query(MSqlQuery::InitCon()); 287 QString queryString("SELECT filename, artist, album, title, intid " 288 "FROM musicmetadata WHERE artist REGEXP \'"); 289 QString token = artist; 290 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString(".")); 288 MSqlQuery query(MSqlQuery::InitCon()); 289 QString queryString("SELECT filename, artist_name, album_name, name, song_id " 290 "FROM music_songs " 291 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 292 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 293 "WHERE artist_name REGEXP \'"); 294 QString token = artist; 295 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString(".")); 291 296 292 queryString += token + "\' AND " + "albumREGEXP \'";293 token = album;294 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));295 queryString += token + "\' AND " + "title REGEXP \'";296 token = title;297 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));298 queryString += token + "\' ORDER BY artist, album, title, intid, filename";299 query.prepare(queryString);300 301 bool has_entries = true;302 if (!query.exec() || !query.isActive())303 {304 MythContext::DBError("Search music database", query);305 has_entries = false;306 }307 if (query.numRowsAffected() > 0)308 {309 return false;310 }297 queryString += token + "\' AND " + "album_name REGEXP \'"; 298 token = album; 299 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString(".")); 300 queryString += token + "\' AND " + "name REGEXP \'"; 301 token = title; 302 token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString(".")); 303 queryString += token + "\' ORDER BY artist_name, album_name, name, song_id, filename"; 304 query.prepare(queryString); 305 306 bool has_entries = true; 307 if (!query.exec() || !query.isActive()) 308 { 309 MythContext::DBError("Search music database", query); 310 has_entries = false; 311 } 312 if (query.numRowsAffected() > 0) 313 { 314 return false; 315 } 311 316 } 312 317 return true; 313 318 } … … 524 529 delete decoder; 525 530 } 526 531 527 void Ripper::fillComboBox(MythComboBox &box, const QString &db_column)528 {529 QString querystr = QString("SELECT DISTINCT %1 FROM musicmetadata;")530 .arg(db_column);531 532 MSqlQuery query(MSqlQuery::InitCon());533 query.exec(querystr);534 535 QValueList<QString> list;536 537 if (query.isActive() && query.size() > 0)538 {539 while (query.next())540 {541 list.push_front(query.value(0).toString());542 }543 }544 545 QStringList strlist(list);546 547 strlist.sort();548 549 box.insertStringList(strlist);550 }551 552 532 void Ripper::handleFileTokens(QString &filename, Metadata *track) 553 533 { 554 534 QString original = filename; -
mythmusic/mythmusic/smartplaylist.cpp
13 13 using namespace std; 14 14 15 15 #include "smartplaylist.h" 16 #include "metadata.h" 16 17 17 18 #include <mythtv/mythcontext.h> 18 19 #include <mythtv/dialogbox.h> … … 33 34 static SmartPLField SmartPLFields[] = 34 35 { 35 36 { "", "", ftString, 0, 0, 0 }, 36 { "Artist", "artist", ftString, 0, 0, 0 }, 37 { "Album", "album", ftString, 0, 0, 0 }, 38 { "Title", "title", ftString, 0, 0, 0 }, 39 { "Genre", "genre", ftString, 0, 0, 0 }, 40 { "Year", "year", ftNumeric, 1900, 2099, 2000 }, 41 { "Track No.", "tracknum", ftNumeric, 0, 99, 0 }, 42 { "Rating", "rating", ftNumeric, 0, 10, 0 }, 43 { "Play Count", "playcount", ftNumeric, 0, 9999, 0 }, 44 { "Compilation", "compilation", ftBoolean, 0, 0, 0 }, 45 { "Comp. Artist", "compilation_artist", ftString, 0, 0, 0 }, 46 { "Last Play", "FROM_DAYS(TO_DAYS(lastplay))", ftDate, 0, 0, 0 }, 47 { "Date Imported", "FROM_DAYS(TO_DAYS(date_added))", ftDate, 0, 0, 0 }, 48 }; 37 { "Artist", "music_artists.artist_name", ftString, 0, 0, 0 }, 38 { "Album", "music_songs.album_name", ftString, 0, 0, 0 }, 39 { "Title", "music_songs.name", ftString, 0, 0, 0 }, 40 { "Genre", "music_genres.genre", ftString, 0, 0, 0 }, 41 { "Year", "music_songs.year", ftNumeric, 1900, 2099, 2000 }, 42 { "Track No.", "music_songs.track", ftNumeric, 0, 99, 0 }, 43 { "Rating", "music_songs.rating", ftNumeric, 0, 10, 0 }, 44 { "Play Count", "music_songs.numplays", ftNumeric, 0, 9999, 0 }, 45 { "Compilation", "music_albums.compilation", ftBoolean, 0, 0, 0 }, 46 { "Comp. Artist", "music_comp_artists.artist_name", ftString, 0, 0, 0 }, 47 { "Last Play", "FROM_DAYS(TO_DAYS(music_songs.lastplay))", 48 ftDate, 0, 0, 0 }, 49 { "Date Imported", "FROM_DAYS(TO_DAYS(music_songs.date_added))", 50 ftDate, 0, 0, 0 }, 51 }; 49 52 50 53 struct SmartPLOperator 51 54 { … … 644 647 value = searchDialog->getResult(); 645 648 res = true; 646 649 } 647 650 648 651 delete searchDialog; 649 650 return res;651 }652 652 653 void SmartPLCriteriaRow::fillSearchList(QString field) 654 { 655 searchList.clear(); 656 657 MSqlQuery query(MSqlQuery::InitCon()); 658 QString querystr; 659 querystr = QString("SELECT DISTINCT %1 FROM musicmetadata ORDER BY %2").arg(field).arg(field); 660 661 query.exec(querystr); 662 if (query.isActive() && query.numRowsAffected()) 663 { 664 while (query.next()) 665 { 666 searchList << QString::fromUtf8(query.value(0).toString()); 667 } 668 } 653 return res; 669 654 } 670 655 671 656 void SmartPLCriteriaRow::searchArtist(MythRemoteLineEdit *editor) 672 657 { 673 658 QString s; 674 675 fillSearchList("artist");676 659 660 searchList = Metadata::fillFieldList("artist"); 661 677 662 s = editor->text(); 678 663 if (showList(tr("Select an Artist"), s)) 679 664 { … … 684 669 void SmartPLCriteriaRow::searchCompilationArtist(MythRemoteLineEdit *editor) 685 670 { 686 671 QString s; 687 688 fillSearchList("compilation_artist");689 672 673 searchList = Metadata::fillFieldList("compilation_artist"); 674 690 675 s = editor->text(); 691 676 if (showList(tr("Select a Compilation Artist"), s)) 692 677 { … … 697 682 void SmartPLCriteriaRow::searchAlbum(MythRemoteLineEdit *editor) 698 683 { 699 684 QString s; 700 701 fillSearchList("album");702 685 686 searchList = Metadata::fillFieldList("album"); 687 703 688 s = editor->text(); 704 689 if (showList(tr("Select an Album"), s)) 705 690 { … … 711 696 { 712 697 QString s; 713 698 714 fillSearchList("genre");699 searchList = Metadata::fillFieldList("genre"); 715 700 716 701 s = editor->text(); 717 702 if (showList(tr("Select a Genre"), s)) … … 724 709 { 725 710 QString s; 726 711 727 fillSearchList("title");712 searchList = Metadata::fillFieldList("title"); 728 713 729 714 s = editor->text(); 730 715 if (showList(tr("Select a Title"), s)) … … 815 800 } 816 801 817 802 MSqlQuery query(MSqlQuery::InitCon()); 818 query.prepare("INSERT INTO smartplaylistitem(smartplaylistid, field, operator,"803 query.prepare("INSERT INTO music_smartplaylist_items (smartplaylistid, field, operator," 819 804 " value1, value2)" 820 805 "VALUES (:SMARTPLAYLISTID, :FIELD, :OPERATOR, :VALUE1, :VALUE2);"); 821 806 query.bindValue(":SMARTPLAYLISTID", smartPlaylistID); … … 1130 1115 { 1131 1116 bPlaylistIsValid = true; 1132 1117 1133 QString sql = "select count(*) from music metadata";1118 QString sql = "select count(*) from music_songs "; 1134 1119 sql += getWhereClause(); 1135 1120 1136 1121 MSqlQuery query(MSqlQuery::InitCon()); … … 1177 1162 1178 1163 MSqlQuery query(MSqlQuery::InitCon()); 1179 1164 // insert new smartplaylist 1180 query.prepare("INSERT INTO smartplaylist(name, categoryid, matchtype, orderby, limitto) "1165 query.prepare("INSERT INTO music_smartplaylists (name, categoryid, matchtype, orderby, limitto) " 1181 1166 "VALUES (:NAME, :CATEGORYID, :MATCHTYPE, :ORDERBY, :LIMIT);"); 1182 1167 query.bindValue(":NAME", name.utf8()); 1183 1168 query.bindValue(":CATEGORYID", categoryid); … … 1193 1178 1194 1179 // get smartplaylistid 1195 1180 int ID; 1196 query.prepare("SELECT smartplaylistid FROM smartplaylist"1181 query.prepare("SELECT smartplaylistid FROM music_smartplaylists " 1197 1182 "WHERE categoryid = :CATEGORYID AND name = :NAME;"); 1198 1183 query.bindValue(":CATEGORYID", categoryid); 1199 1184 query.bindValue(":NAME", name.utf8()); … … 1252 1237 MSqlQuery query(MSqlQuery::InitCon()); 1253 1238 int ID; 1254 1239 1255 query.prepare("SELECT smartplaylistid, name, categoryid, matchtype, orderby, limitto " 1256 "FROM smartplaylistWHERE name = :NAME AND categoryid = :CATEGORYID;");1240 query.prepare("SELECT smartplaylistid, name, categoryid, matchtype, orderby, limitto " 1241 "FROM music_smartplaylists WHERE name = :NAME AND categoryid = :CATEGORYID;"); 1257 1242 query.bindValue(":NAME", name.utf8()); 1258 1243 query.bindValue(":CATEGORYID", categoryid); 1259 1244 if (query.exec()) … … 1284 1269 SmartPLCriteriaRow *row; 1285 1270 uint rowCount; 1286 1271 1287 query.prepare("SELECT field, operator, value1, value2 " 1288 "FROM smartplaylistitemWHERE smartplaylistid = :ID "1272 query.prepare("SELECT field, operator, value1, value2 " 1273 "FROM music_smartplaylist_items WHERE smartplaylistid = :ID " 1289 1274 "ORDER BY smartplaylistitemid;"); 1290 1275 query.bindValue(":ID", ID); 1291 1276 if (!query.exec()) … … 1392 1377 // insert new smartplaylistcategory 1393 1378 1394 1379 MSqlQuery query(MSqlQuery::InitCon()); 1395 query.prepare("INSERT INTO smartplaylistcategory(name) "1380 query.prepare("INSERT INTO music_smartplaylist_categories (name) " 1396 1381 "VALUES (:NAME);"); 1397 1382 query.bindValue(":NAME", categoryEdit->text().utf8()); 1398 1383 … … 1438 1423 1439 1424 // change the category 1440 1425 MSqlQuery query(MSqlQuery::InitCon()); 1441 query.prepare("UPDATE smartplaylistcategorySET name = :NEW_CATEGORY "1426 query.prepare("UPDATE music_smartplaylist_categories SET name = :NEW_CATEGORY " 1442 1427 "WHERE name = :OLD_CATEGORY;"); 1443 1428 query.bindValue(":OLD_CATEGORY", categoryCombo->currentText().utf8()); 1444 1429 query.bindValue(":NEW_CATEGORY", categoryEdit->text().utf8()); … … 1458 1443 QString SmartPlaylistEditor::getSQL(QString fields) 1459 1444 { 1460 1445 QString sql, whereClause, orderByClause, limitClause; 1461 1462 sql = "SELECT " + fields + " FROM musicmetadata "; 1446 sql = "SELECT " + fields + " FROM music_songs " 1447 "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id " 1448 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id " 1449 "LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id " 1450 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "; 1451 1463 1452 whereClause = getWhereClause(); 1464 1453 orderByClause = getOrderByClause(); 1465 1454 if (limitSpinEdit->value() > 0) … … 1506 1495 1507 1496 void SmartPlaylistEditor::showResultsClicked(void) 1508 1497 { 1509 QString sql = getSQL(" intid, artist, album, title, genre, year, tracknum");1510 1498 QString sql = getSQL("song_id, music_artists.artist_name, album_name, name, genre, year, track"); 1499 1511 1500 SmartPLResultViewer *resultViewer = new SmartPLResultViewer(gContext->GetMainWindow(), "resultviewer"); 1512 1501 resultViewer->setSQL(sql); 1513 1502 resultViewer->exec(); … … 1535 1524 categoryCombo->clear(); 1536 1525 MSqlQuery query(MSqlQuery::InitCon()); 1537 1526 1538 if (query.exec("SELECT name FROM smartplaylistcategoryORDER BY name;"))1527 if (query.exec("SELECT name FROM music_smartplaylist_categories ORDER BY name;")) 1539 1528 { 1540 1529 if (query.isActive() && query.numRowsAffected() > 0) 1541 1530 { … … 1563 1552 1564 1553 // get playlist ID 1565 1554 int ID; 1566 query.prepare("SELECT smartplaylistid FROM smartplaylistWHERE name = :NAME "1555 query.prepare("SELECT smartplaylistid FROM music_smartplaylists WHERE name = :NAME " 1567 1556 "AND categoryid = :CATEGORYID;"); 1568 1557 query.bindValue(":NAME", name.utf8()); 1569 1558 query.bindValue(":CATEGORYID", categoryid); … … 1588 1577 } 1589 1578 1590 1579 //delete smartplaylist items 1591 query.prepare("DELETE FROM smartplaylistitemWHERE smartplaylistid = :ID;");1580 query.prepare("DELETE FROM music_smartplaylist_items WHERE smartplaylistid = :ID;"); 1592 1581 query.bindValue(":ID", ID); 1593 1582 if (!query.exec()) 1594 1583 MythContext::DBError("Delete smartplaylist items", query); 1595 1584 1596 1585 //delete smartplaylist 1597 query.prepare("DELETE FROM smartplaylistWHERE smartplaylistid = :ID;");1586 query.prepare("DELETE FROM music_smartplaylists WHERE smartplaylistid = :ID;"); 1598 1587 query.bindValue(":ID", ID); 1599 1588 if (!query.exec()) 1600 1589 MythContext::DBError("Delete smartplaylist", query); … … 1608 1597 { 1609 1598 int categoryid = SmartPlaylistEditor::lookupCategoryID(category); 1610 1599 MSqlQuery query(MSqlQuery::InitCon()); 1611 1600 1612 1601 //delete all smartplaylists with the selected category 1613 query.prepare("SELECT name FROM smartplaylist"1602 query.prepare("SELECT name FROM music_smartplaylists " 1614 1603 "WHERE categoryid = :CATEGORYID;"); 1615 1604 query.bindValue(":CATEGORYID", categoryid); 1616 1605 if (!query.exec()) … … 1629 1618 } 1630 1619 1631 1620 // delete the category 1632 query.prepare("DELETE FROM smartplaylistcategoryWHERE categoryid = :ID;");1621 query.prepare("DELETE FROM music_smartplaylist_categories WHERE categoryid = :ID;"); 1633 1622 query.bindValue(":ID", categoryid); 1634 1623 if (!query.exec()) 1635 1624 MythContext::DBError("Delete smartplaylist category", query); … … 1639 1628 1640 1629 // static function to lookup the categoryid given its name 1641 1630 int SmartPlaylistEditor::lookupCategoryID(QString category) 1642 { 1631 { 1643 1632 int ID; 1644 1633 MSqlQuery query(MSqlQuery::InitCon()); 1645 query.prepare("SELECT categoryid FROM smartplaylistcategory"1634 query.prepare("SELECT categoryid FROM music_smartplaylist_categories " 1646 1635 "WHERE name = :CATEGORY;"); 1647 1636 query.bindValue(":CATEGORY", category.utf8()); 1648 1637 1649 1638 if (query.exec()) 1650 { 1639 { 1651 1640 if (query.isActive() && query.numRowsAffected() > 0) 1652 1641 { 1653 1642 query.first(); … … 2023 2012 categoryCombo->clear(); 2024 2013 MSqlQuery query(MSqlQuery::InitCon()); 2025 2014 2026 if (query.exec("SELECT name FROM smartplaylistcategoryORDER BY name;"))2015 if (query.exec("SELECT name FROM music_smartplaylist_categories ORDER BY name;")) 2027 2016 { 2028 2017 if (query.isActive() && query.numRowsAffected() > 0) 2029 2018 { … … 2044 2033 2045 2034 listbox->clear(); 2046 2035 2047 MSqlQuery query(MSqlQuery::InitCon()); 2048 query.prepare("SELECT name FROM smartplaylistWHERE categoryid = :CATEGORYID "2036 MSqlQuery query(MSqlQuery::InitCon()); 2037 query.prepare("SELECT name FROM music_smartplaylists WHERE categoryid = :CATEGORYID " 2049 2038 "ORDER BY name;"); 2050 2039 query.bindValue(":CATEGORYID", categoryid); 2051 2040 -
mythmusic/mythmusic/metadata.h
42 42 format = lformat; 43 43 } 44 44 45 Metadata(const Metadata &other) 45 Metadata(const Metadata &other) 46 46 { 47 *this = other; 48 changed = false; 49 /* 47 50 filename = other.filename; 48 51 artist = other.artist; 49 52 compilation_artist = other.compilation_artist; … … 63 66 show = other.show; 64 67 changed = false; 65 68 format = other.format; 69 */ 66 70 } 67 71 68 72 Metadata& operator=(Metadata *rhs); … … 125 129 bool Compilation() { return compilation; } 126 130 void setCompilation(bool state) { compilation = state; formattedartist = formattedtitle = ""; } 127 131 bool determineIfCompilation(bool cd = false); 128 132 129 133 bool isInDatabase(void); 130 134 void dumpToDatabase(void); 131 void updateDatabase(void);132 135 void setField(const QString &field, const QString &data); 133 136 void getField(const QString& field, QString *data); 134 void fillData();135 void fillDataFromID();136 137 void persist(); 137 138 bool hasChanged(){return changed;} 138 139 int compare (Metadata *other); … … 140 141 141 142 static void SetStartdir(const QString &dir); 142 143 144 static QStringList fillFieldList(QString field); 145 143 146 private: 144 147 void setCompilationFormatting(bool cd = false); 145 148 QString formatReplaceSymbols(const QString &format); -
mythmusic/mythmusic/editmetadata.cpp
4 4 #include "editmetadata.h" 5 5 #include "decoder.h" 6 6 #include "genres.h" 7 #include "metadata.h" 7 8 8 9 EditMetadataDialog::EditMetadataDialog(Metadata *source_metadata, 9 10 MythMainWindow *parent, … … 357 358 value = searchDialog->getResult(); 358 359 res = true; 359 360 } 360 361 361 362 delete searchDialog; 362 363 setActiveWindow(); 363 364 return res;365 }366 364 367 void EditMetadataDialog::fillSearchList(QString field) 368 { 369 searchList.clear(); 370 371 QString querystr; 372 querystr = QString("SELECT DISTINCT %1 FROM musicmetadata ORDER BY %2").arg(field).arg(field); 373 374 MSqlQuery query(MSqlQuery::InitCon()); 375 query.exec(querystr); 376 377 if (query.isActive() && query.size()) 378 { 379 while (query.next()) 380 { 381 searchList << QString::fromUtf8(query.value(0).toString()); 382 } 383 } 365 return res; 384 366 } 385 367 386 368 void EditMetadataDialog::searchArtist() 387 369 { 388 370 QString s; 389 390 fillSearchList("artist");391 371 372 searchList = Metadata::fillFieldList("artist"); 373 392 374 s = m_metadata->Artist(); 393 375 if (showList(tr("Select an Artist"), s)) 394 376 { … … 400 382 void EditMetadataDialog::searchCompilationArtist() 401 383 { 402 384 QString s; 403 404 fillSearchList("compilation_artist");405 385 386 searchList = Metadata::fillFieldList("compilation_artist"); 387 406 388 s = m_metadata->CompilationArtist(); 407 389 if (showList(tr("Select a Compilation Artist"), s)) 408 390 { … … 414 396 void EditMetadataDialog::searchAlbum() 415 397 { 416 398 QString s; 417 418 fillSearchList("album");419 399 400 searchList = Metadata::fillFieldList("album"); 401 420 402 s = m_metadata->Album(); 421 403 if (showList(tr("Select an Album"), s)) 422 404 { … … 430 412 QString s; 431 413 432 414 // load genre list 415 /* 433 416 searchList.clear(); 434 417 for (int x = 0; x < genre_table_size; x++) 435 418 searchList.push_back(QString(genre_table[x])); 436 419 searchList.sort(); 420 */ 421 searchList = Metadata::fillFieldList("genre"); 437 422 438 423 s = m_metadata->Genre(); 439 424 if (showList(tr("Select a Genre"), s)) … … 491 476 { 492 477 cancelPopup(); 493 478 494 m_metadata-> updateDatabase();479 m_metadata->dumpToDatabase(); 495 480 *m_sourceMetadata = m_metadata; 496 481 done(1); 497 482 } -
mythmusic/mythmusic/smartplaylist.h
72 72 void value2ButtonClicked(void); 73 73 74 74 private: 75 void fillSearchList(QString field);76 75 bool showList(QString caption, QString &value); 77 76 void searchGenre(MythRemoteLineEdit *editor); 78 77 void searchArtist(MythRemoteLineEdit *editor); -
mythmusic/mythmusic/main.cpp
91 91 // We know that the filename will not contain :// as the SQL limits this 92 92 sqlfilename.remove(0, directory.length()); 93 93 MSqlQuery query(MSqlQuery::InitCon()); 94 query.prepare("DELETE FROM music metadataWHERE "94 query.prepare("DELETE FROM music_songs WHERE " 95 95 "filename = :NAME ;"); 96 96 query.bindValue(":NAME", sqlfilename.utf8()); 97 97 query.exec(); … … 110 110 { 111 111 disk_meta->setID(db_meta->ID()); 112 112 disk_meta->setRating(db_meta->Rating()); 113 disk_meta-> updateDatabase();113 disk_meta->dumpToDatabase(); 114 114 } 115 115 116 116 if (disk_meta) … … 261 261 262 262 MSqlQuery query(MSqlQuery::InitCon()); 263 263 query.exec("SELECT filename, date_modified " 264 "FROM music metadata"264 "FROM music_songs " 265 265 "WHERE filename NOT LIKE ('%://%')"); 266 266 267 267 int counter = 0; … … 561 561 562 562 563 563 MSqlQuery count_query(MSqlQuery::InitCon()); 564 count_query.exec("SELECT COUNT(*) FROM music metadata;");564 count_query.exec("SELECT COUNT(*) FROM music_songs;"); 565 565 566 566 bool musicdata_exists = false; 567 567 if (count_query.isActive()) -
mythmusic/mythmusic/editmetadata.h
6 6 7 7 #include <mythtv/mythdialogs.h> 8 8 9 #include "metadata.h" 9 class Metadata; 10 10 11 11 class UIPhoneEntry; 12 12 … … 45 45 void checkClicked(bool state); 46 46 private: 47 47 48 void fillSearchList(QString field);49 48 bool showList(QString caption, QString &value); 50 49 51 50 Metadata *m_metadata, *m_sourceMetadata ; -
mythmusic/mythmusic/metaiomp4.cpp
348 348 genre, 349 349 year, 350 350 tracknum, 351 length ,352 0, 0, 0, "",353 compilation);351 length); 352 353 retdata->setCompilation(compilation); 354 354 355 355 //retdata->setComposer(writer); 356 356 //retdata->setComment(comment);
