diff --exclude='Makefile*' --exclude='*svn*' -ru ../observable/mythplugins/mythmusic/mythmusic/metadata.cpp mythplugins/mythmusic/mythmusic/metadata.cpp
old
|
new
|
|
119 | 119 | MythContext::DBError("music persist", query); |
120 | 120 | } |
121 | 121 | |
| 122 | int Metadata::compare(Metadata *other) |
| 123 | { |
| 124 | if (format == "cast") |
| 125 | { |
| 126 | int artist_cmp = qstrcmp (Artist(), other->Artist()); |
| 127 | int title_cmp = qstrcmp (Title(), other->Title()); |
| 128 | |
| 129 | if (artist_cmp == 0) |
| 130 | return title_cmp; |
| 131 | |
| 132 | return artist_cmp; |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | return (Track() - other->Track()); |
| 137 | } |
| 138 | } |
| 139 | |
122 | 140 | bool Metadata::isInDatabase(QString startdir) |
123 | 141 | { |
124 | 142 | bool retval = false; |
… |
… |
|
128 | 146 | |
129 | 147 | MSqlQuery query(MSqlQuery::InitCon()); |
130 | 148 | query.prepare("SELECT artist,compilation_artist,album,title,genre,year,tracknum," |
131 | | "length,intid,rating,playcount,lastplay,compilation FROM " |
| 149 | "length,intid,rating,playcount,lastplay,compilation,format FROM " |
132 | 150 | "musicmetadata WHERE filename = :FILENAME ;"); |
133 | 151 | query.bindValue(":FILENAME", sqlfilename.utf8()); |
134 | 152 | |
… |
… |
|
149 | 167 | playcount = query.value(10).toInt(); |
150 | 168 | lastplay = query.value(11).toString(); |
151 | 169 | compilation = (query.value(12).toInt() > 0); |
| 170 | format = query.value(13).toString(); |
152 | 171 | |
153 | 172 | retval = true; |
154 | 173 | } |
… |
… |
|
181 | 200 | "( album = :ALBUM ) AND ( title = :TITLE ) " |
182 | 201 | "AND ( genre = :GENRE ) AND " |
183 | 202 | "( year = :YEAR ) AND ( tracknum = :TRACKNUM ) " |
184 | | "AND ( length = :LENGTH ) );"); |
| 203 | "AND ( length = :LENGTH ) " |
| 204 | "AND ( format = :FORMAT) );"); |
185 | 205 | query.bindValue(":ARTIST", artist.utf8()); |
186 | 206 | query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8()); |
187 | 207 | query.bindValue(":ALBUM", album.utf8()); |
… |
… |
|
190 | 210 | query.bindValue(":YEAR", year); |
191 | 211 | query.bindValue(":TRACKNUM", tracknum); |
192 | 212 | query.bindValue(":LENGTH", length); |
| 213 | query.bindValue(":FORMAT", format); |
193 | 214 | |
194 | 215 | if (query.exec() && query.isActive() && query.size() > 0) |
195 | 216 | return; |
… |
… |
|
197 | 218 | query.prepare("INSERT INTO musicmetadata " |
198 | 219 | "(artist, compilation_artist, album, title, " |
199 | 220 | " genre, year, tracknum, length, " |
200 | | " filename, compilation, date_added, date_modified) " |
| 221 | " filename, compilation, date_added, date_modified, " |
| 222 | " format ) " |
201 | 223 | "VALUES " |
202 | 224 | "(:ARTIST, :COMPILATION_ARTIST,:ALBUM, :TITLE, " |
203 | 225 | " :GENRE, :YEAR, :TRACKNUM, :LENGTH, " |
204 | | " :FILENAME,:COMPILATION, :DATE_ADDED,:DATE_MOD)"); |
| 226 | " :FILENAME,:COMPILATION, :DATE_ADDED,:DATE_MOD," |
| 227 | " :FORMAT)"); |
205 | 228 | query.bindValue(":ARTIST", artist.utf8()); |
206 | 229 | query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8()); |
207 | 230 | query.bindValue(":ALBUM", album.utf8()); |
… |
… |
|
214 | 237 | query.bindValue(":COMPILATION", compilation); |
215 | 238 | query.bindValue(":DATE_ADDED", QDateTime::currentDateTime()); |
216 | 239 | query.bindValue(":DATE_MOD", QDateTime::currentDateTime()); |
| 240 | query.bindValue(":FORMAT", format); |
217 | 241 | |
218 | 242 | query.exec(); |
219 | 243 | |
… |
… |
|
376 | 400 | " rating = :RATING, " |
377 | 401 | " date_modified = :DATE_MODIFIED, " |
378 | 402 | " compilation = :COMPILATION, " |
379 | | " compilation_artist = :COMPILATION_ARTIST " |
| 403 | " compilation_artist = :COMPILATION_ARTIST, " |
| 404 | " format = :FORMAT " |
380 | 405 | "WHERE intid = :ID;"); |
381 | 406 | query.bindValue(":ARTIST", artist.utf8()); |
382 | 407 | query.bindValue(":ALBUM", album.utf8()); |
… |
… |
|
388 | 413 | query.bindValue(":DATE_MODIFIED", QDateTime::currentDateTime()); |
389 | 414 | query.bindValue(":COMPILATION", compilation); |
390 | 415 | query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8()); |
| 416 | query.bindValue(":FORMAT", format); |
391 | 417 | query.bindValue(":ID", id); |
392 | 418 | |
393 | 419 | if (!query.exec()) |
… |
… |
|
538 | 564 | return; |
539 | 565 | |
540 | 566 | QString thequery = "SELECT artist,compilation_artist,album,title,genre,year,tracknum,length," |
541 | | "filename,intid,rating,playcount,lastplay,compilation " |
| 567 | "filename,intid,rating,playcount,lastplay,compilation,format " |
542 | 568 | "FROM musicmetadata WHERE title = :TITLE"; |
543 | 569 | |
544 | 570 | if (album != "") |
… |
… |
|
575 | 601 | playcount = query.value(11).toInt(); |
576 | 602 | lastplay = query.value(12).toString(); |
577 | 603 | compilation = (query.value(13).toInt() > 0); |
| 604 | format = query.value(14).toString(); |
578 | 605 | |
579 | 606 | if (!filename.contains("://")) |
580 | 607 | filename = m_startdir + filename; |
… |
… |
|
588 | 615 | |
589 | 616 | MSqlQuery query(MSqlQuery::InitCon()); |
590 | 617 | query.prepare("SELECT title,artist,compilation_artist,album,title,genre,year,tracknum," |
591 | | "length,filename,rating,playcount,lastplay,compilation FROM " |
| 618 | "length,filename,rating,playcount,lastplay,compilation,format FROM " |
592 | 619 | "musicmetadata WHERE intid = :ID ;"); |
593 | 620 | query.bindValue(":ID", id); |
594 | 621 | |
… |
… |
|
610 | 637 | playcount = query.value(11).toInt(); |
611 | 638 | lastplay = query.value(12).toString(); |
612 | 639 | compilation = (query.value(13).toInt() > 0); |
| 640 | format = query.value(14).toString(); |
613 | 641 | |
614 | 642 | if (!filename.contains("://")) |
615 | 643 | filename = m_startdir + filename; |
… |
… |
|
758 | 786 | done_loading = false; |
759 | 787 | QString aquery = "SELECT intid, artist, compilation_artist, album, title, genre, " |
760 | 788 | "year, tracknum, length, filename, rating, " |
761 | | "lastplay, playcount, compilation FROM musicmetadata " |
| 789 | "lastplay, playcount, compilation, format " |
| 790 | "FROM musicmetadata " |
762 | 791 | "ORDER BY intid;"; |
763 | 792 | |
764 | 793 | QString filename; |
… |
… |
|
797 | 826 | query.value(10).toInt(), |
798 | 827 | query.value(12).toInt(), |
799 | 828 | query.value(11).toString(), |
800 | | (query.value(13).toInt() > 0)); |
801 | | |
| 829 | (query.value(13).toInt() > 0), |
| 830 | query.value(14).toString()); |
| 831 | |
802 | 832 | // Don't delete temp, as PtrList now owns it |
803 | 833 | all_music.append(temp); |
804 | 834 | |
… |
… |
|
1503 | 1533 | int MetadataPtrList::compareItems(QPtrCollection::Item item1, |
1504 | 1534 | QPtrCollection::Item item2) |
1505 | 1535 | { |
1506 | | return ((Metadata*)item1)->Track() - ((Metadata*)item2)->Track(); |
| 1536 | return ((Metadata*)item1)->compare((Metadata*)item2); |
1507 | 1537 | } |
1508 | 1538 | |
1509 | 1539 | int MusicNodePtrList::compareItems (QPtrCollection::Item item1, |
diff --exclude='Makefile*' --exclude='*svn*' -ru ../observable/mythplugins/mythmusic/mythmusic/metadata.h mythplugins/mythmusic/mythmusic/metadata.h
old
|
new
|
|
19 | 19 | QString lalbum = "", QString ltitle = "", QString lgenre = "", |
20 | 20 | int lyear = 0, int ltracknum = 0, int llength = 0, int lid = 0, |
21 | 21 | int lrating = 0, int lplaycount = 0, QString llastplay = "", |
22 | | bool lcompilation = false) |
| 22 | bool lcompilation = false, QString lformat="") |
23 | 23 | { |
24 | 24 | filename = lfilename; |
25 | 25 | artist = lartist; |
… |
… |
|
39 | 39 | compilation = lcompilation; |
40 | 40 | changed = false; |
41 | 41 | show = true; |
| 42 | format = lformat; |
42 | 43 | } |
43 | 44 | |
44 | 45 | Metadata(const Metadata &other) |
… |
… |
|
61 | 62 | compilation = other.compilation; |
62 | 63 | show = other.show; |
63 | 64 | changed = false; |
| 65 | format = other.format; |
64 | 66 | } |
65 | 67 | |
66 | 68 | Metadata& operator=(Metadata *rhs); |
… |
… |
|
101 | 103 | QString Filename() const { return filename; } |
102 | 104 | void setFilename(QString &lfilename) { filename = lfilename; } |
103 | 105 | |
| 106 | QString Format() const { return format; } |
| 107 | void setFormat(const QString &lformat) { format = lformat; } |
| 108 | |
104 | 109 | int Rating() { return rating; } |
105 | 110 | void decRating(); |
106 | 111 | void incRating(); |
… |
… |
|
131 | 136 | void fillDataFromID(); |
132 | 137 | void persist(); |
133 | 138 | bool hasChanged(){return changed;} |
| 139 | int compare (Metadata *other); |
134 | 140 | static void setArtistAndTrackFormats(); |
135 | 141 | |
136 | 142 | static void SetStartdir(const QString &dir); |
… |
… |
|
146 | 152 | QString formattedartist; |
147 | 153 | QString formattedtitle; |
148 | 154 | QString genre; |
| 155 | QString format; |
149 | 156 | int year; |
150 | 157 | int tracknum; |
151 | 158 | int length; |