Ticket #3142: metadata-const.patch
File metadata-const.patch, 9.3 KB (added by , 17 years ago) |
---|
-
mythplugins/mythmusic/mythmusic/metadata.cpp
158 158 QString sqldir = sqlfilepath.section( '/', 0, -2); 159 159 QString sqlfilename = sqlfilepath.section( '/', -1 ) ; 160 160 161 if (m_artist == "") 162 m_artist = QObject::tr("Unknown Artist"); 163 if (m_compilation_artist == "") 164 m_compilation_artist = m_artist; // This should be the same as Artist if blank. 165 if (m_album == "") 166 m_album = QObject::tr("Unknown Album"); 167 if (m_title == "") 168 m_title = m_filename; 169 if (m_genre == "") 170 m_genre = QObject::tr("Unknown Genre"); 161 checkEmptyFields(); 171 162 172 163 MSqlQuery query(MSqlQuery::InitCon()); 173 164 … … 456 447 return rv; 457 448 } 458 449 450 void Metadata::checkEmptyFields() 451 { 452 if (m_artist == "") 453 m_artist = QObject::tr("Unknown Artist"); 454 if (m_compilation_artist == "") 455 m_compilation_artist = m_artist; // This should be the same as Artist if blank. 456 if (m_album == "") 457 m_album = QObject::tr("Unknown Album"); 458 if (m_title == "") 459 m_title = m_filename; 460 if (m_genre == "") 461 m_genre = QObject::tr("Unknown Genre"); 459 462 463 } 464 460 465 inline void Metadata::setCompilationFormatting(bool cd) 461 466 { 462 467 QString format_artist, format_title; -
mythplugins/mythmusic/mythmusic/metadata.h
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 22 bool lcompilation = false, QString lformat="") 23 { 24 m_filename = lfilename; 25 m_artist = lartist; 26 m_compilation_artist = lcompilation_artist; 27 m_album = lalbum; 28 m_title = ltitle; 29 m_formattedartist = ""; 30 m_formattedtitle = ""; 31 m_genre = lgenre; 32 m_year = lyear; 33 m_tracknum = ltracknum; 34 m_length = llength; 35 m_id = lid; 36 m_rating = lrating; 37 m_playcount = lplaycount; 38 m_lastplay = llastplay; 39 m_compilation = lcompilation; 40 m_changed = false; 41 m_show = true; 42 m_format = lformat; 43 44 m_directoryid = -1; 45 m_artistid = -1; 46 m_albumid = -1; 47 m_genreid = -1; 48 } 49 23 : m_artist(lartist), 24 m_compilation_artist(lcompilation_artist), 25 m_album(lalbum), 26 m_title(ltitle), 27 m_formattedartist(""), 28 m_formattedtitle(""), 29 m_genre(lgenre), 30 m_format(lformat), 31 m_year(lyear), 32 m_tracknum(ltracknum), 33 m_length(llength), 34 m_rating(lrating), 35 m_directoryid(-1), 36 m_artistid(-1), 37 m_compartistid(-1), 38 m_albumid(-1), 39 m_genreid(-1), 40 m_lastplay(llastplay), 41 m_playcount(lplaycount), 42 m_compilation(lcompilation), 43 m_id(lid), 44 m_filename(lfilename), 45 m_changed(false), 46 m_show(true) 47 { 48 checkEmptyFields(); 49 } 50 50 51 Metadata(const Metadata &other) 51 { 52 *this = other; 53 m_changed = false; 54 /* 55 filename = other.filename; 56 artist = other.artist; 57 compilation_artist = other.compilation_artist; 58 album = other.album; 59 title = other.title; 60 formattedartist = other.formattedartist; 61 formattedtitle = other.formattedtitle; 62 genre = other.genre; 63 year = other.year; 64 tracknum = other.tracknum; 65 length = other.length; 66 id = other.id; 67 rating = other.rating; 68 lastplay = other.lastplay; 69 playcount = other.playcount; 70 compilation = other.compilation; 71 show = other.show; 72 changed = false; 73 format = other.format; 74 */ 75 } 52 { 53 *this = other; 54 m_changed = false; 55 } 76 56 77 57 Metadata& operator=(Metadata *rhs); 78 58 79 QString Artist() { return m_artist; }59 QString Artist() const { return m_artist; } 80 60 void setArtist(const QString &lartist) { m_artist = lartist; m_formattedartist = m_formattedtitle = ""; } 81 61 82 QString CompilationArtist() { return m_compilation_artist; }62 QString CompilationArtist() const { return m_compilation_artist; } 83 63 void setCompilationArtist(const QString &lcompilation_artist) { m_compilation_artist = lcompilation_artist; m_formattedartist = m_formattedtitle = ""; } 84 64 85 QString Album() { return m_album; }65 QString Album() const { return m_album; } 86 66 void setAlbum(const QString &lalbum) { m_album = lalbum; m_formattedartist = m_formattedtitle = ""; } 87 67 88 QString Title() { return m_title; }68 QString Title() const { return m_title; } 89 69 void setTitle(const QString <itle) { m_title = ltitle; } 90 70 91 71 QString FormatArtist(); 92 72 QString FormatTitle(); 73 QString FormatInfo(); 93 74 94 QString Genre() { return m_genre; }75 QString Genre() const { return m_genre; } 95 76 void setGenre(const QString &lgenre) { m_genre = lgenre; } 96 77 97 78 void setDirectoryId(int ldirectoryid) { m_directoryid = ldirectoryid; } … … 103 84 void setGenreId(int lgenreid) { m_genreid = lgenreid; } 104 85 int getGenreId() { return m_genreid; } 105 86 106 int Year() { return m_year; }87 int Year() const { return m_year; } 107 88 void setYear(int lyear) { m_year = lyear; } 108 89 109 int Track() { return m_tracknum; }90 int Track() const { return m_tracknum; } 110 91 void setTrack(int ltrack) { m_tracknum = ltrack; } 111 92 112 int Length() { return m_length; }93 int Length() const { return m_length; } 113 94 void setLength(int llength) { m_length = llength; } 114 95 115 int Playcount() { return m_playcount; }96 int Playcount() const { return m_playcount; } 116 97 void setPlaycount(int lplaycount) { m_playcount = lplaycount; } 117 98 118 unsigned int ID() { return m_id; }99 unsigned int ID() const { return m_id; } 119 100 void setID(int lid) { m_id = lid; } 120 101 121 102 QString Filename() const { return m_filename; } 122 void setFilename( QString &lfilename) { m_filename = lfilename; }123 103 void setFilename(const QString &lfilename) { m_filename = lfilename; } 104 124 105 QString Format() const { return m_format; } 125 106 void setFormat(const QString &lformat) { m_format = lformat; } 107 108 QByteArray AlbumArt() const; 109 void setAlbumArt(const QByteArray &data); 126 110 127 int Rating() { return m_rating; } 111 int Rating() const { return m_rating; } 112 128 113 void decRating(); 129 114 void incRating(); 130 115 void setRating(int lrating) { m_rating = lrating; } 131 116 132 117 double LastPlay(); 133 QString LastPlayStr() { return m_lastplay; }118 QString LastPlayStr() const { return m_lastplay; } 134 119 void setLastPlay(); 135 120 136 int PlayCount() { return m_playcount; }121 int PlayCount() const { return m_playcount; } 137 122 void incPlayCount(); 138 123 139 bool isVisible() { return m_show; }124 bool isVisible() const { return m_show; } 140 125 void setVisible(bool visible) { m_show = visible; } 141 126 142 127 // track is part of a compilation album 143 bool Compilation() { return m_compilation; }128 bool Compilation() const { return m_compilation; } 144 129 void setCompilation(bool state) { m_compilation = state; m_formattedartist = m_formattedtitle = ""; } 145 bool determineIfCompilation(bool m_cd = false);130 bool determineIfCompilation(bool cd = false); 146 131 147 132 bool isInDatabase(void); 148 133 void dumpToDatabase(void); 134 void removeFromDatabase(void); 149 135 void setField(const QString &field, const QString &data); 150 136 void getField(const QString& field, QString *data); 151 137 void persist(); 152 138 bool hasChanged(){return m_changed;} 153 139 int compare (Metadata *other); 154 static void setArtistAndTrackFormats();155 140 141 MythThemedDialog *createEditorDialog (void); 142 143 static void setArtistAndTrackFormats(); 156 144 static void SetStartdir(const QString &dir); 157 145 158 146 static QStringList fillFieldList(QString field); … … 160 148 private: 161 149 void setCompilationFormatting(bool cd = false); 162 150 QString formatReplaceSymbols(const QString &format); 151 void checkEmptyFields(void); 163 152 164 153 QString m_artist; 165 154 QString m_compilation_artist; … … 302 291 QString getLabel(int an_id, bool *error_flag); 303 292 Metadata* getMetadata(int an_id); 304 293 bool updateMetadata(int an_id, Metadata *the_track); 305 int count() { return m_numPcs; }306 int countLoaded() { return m_numLoaded; }294 int count() const { return m_numPcs; } 295 int countLoaded() const { return m_numLoaded; } 307 296 void save(); 308 297 bool startLoading(void); 309 298 void resync(); // After a CD rip, for example