Ticket #3142: metadata-const.patch

File metadata-const.patch, 9.3 KB (added by myth@…, 13 years ago)

patch with Metadata fixes.

  • mythplugins/mythmusic/mythmusic/metadata.cpp

     
    158158    QString sqldir = sqlfilepath.section( '/', 0, -2);
    159159    QString sqlfilename = sqlfilepath.section( '/', -1 ) ;
    160160
    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();
    171162
    172163    MSqlQuery query(MSqlQuery::InitCon());
    173164
     
    456447  return rv;
    457448}
    458449
     450void 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");
    459462
     463}
     464
    460465inline void Metadata::setCompilationFormatting(bool cd)
    461466{
    462467    QString format_artist, format_title;
  • mythplugins/mythmusic/mythmusic/metadata.h

     
    2020             int lyear = 0, int ltracknum = 0, int llength = 0, int lid = 0,
    2121             int lrating = 0, int lplaycount = 0, QString llastplay = "",
    2222             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   
    5051    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        }
    7656
    7757    Metadata& operator=(Metadata *rhs);
    7858
    79     QString Artist() { return m_artist; }
     59    QString Artist() const { return m_artist; }
    8060    void setArtist(const QString &lartist) { m_artist = lartist; m_formattedartist = m_formattedtitle = ""; }
    8161   
    82     QString CompilationArtist() { return m_compilation_artist; }
     62    QString CompilationArtist() const { return m_compilation_artist; }
    8363    void setCompilationArtist(const QString &lcompilation_artist) { m_compilation_artist = lcompilation_artist; m_formattedartist = m_formattedtitle = ""; }
    8464   
    85     QString Album() { return m_album; }
     65    QString Album() const { return m_album; }
    8666    void setAlbum(const QString &lalbum) { m_album = lalbum; m_formattedartist = m_formattedtitle = ""; }
    8767
    88     QString Title() { return m_title; }
     68    QString Title() const { return m_title; }
    8969    void setTitle(const QString &ltitle) { m_title = ltitle; }
    9070
    9171    QString FormatArtist();
    9272    QString FormatTitle();
     73    QString FormatInfo();
    9374
    94     QString Genre() { return m_genre; }
     75    QString Genre() const { return m_genre; }
    9576    void setGenre(const QString &lgenre) { m_genre = lgenre; }
    9677
    9778    void setDirectoryId(int ldirectoryid) { m_directoryid = ldirectoryid; }
     
    10384    void setGenreId(int lgenreid) { m_genreid = lgenreid; }
    10485    int getGenreId() { return m_genreid; }
    10586
    106     int Year() { return m_year; }
     87    int Year() const { return m_year; }
    10788    void setYear(int lyear) { m_year = lyear; }
    10889
    109     int Track() { return m_tracknum; }
     90    int Track() const { return m_tracknum; }
    11091    void setTrack(int ltrack) { m_tracknum = ltrack; }
    11192
    112     int Length() { return m_length; }
     93    int Length() const { return m_length; }
    11394    void setLength(int llength) { m_length = llength; }
    11495
    115     int Playcount() { return m_playcount; }
     96    int Playcount() const { return m_playcount; }
    11697    void setPlaycount(int lplaycount) { m_playcount = lplaycount; }
    11798
    118     unsigned int ID() { return m_id; }
     99    unsigned int ID() const { return m_id; }
    119100    void setID(int lid) { m_id = lid; }
    120    
     101
    121102    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
    124105    QString Format() const { return m_format; }
    125106    void setFormat(const QString &lformat) { m_format = lformat; }
     107
     108    QByteArray AlbumArt() const;
     109    void setAlbumArt(const QByteArray &data);
    126110   
    127     int Rating() { return m_rating; }
     111    int Rating() const { return m_rating; }
     112
    128113    void decRating();
    129114    void incRating();
    130115    void setRating(int lrating) { m_rating = lrating; }
    131116
    132117    double LastPlay();
    133     QString LastPlayStr() { return m_lastplay; }
     118    QString LastPlayStr() const { return m_lastplay; }
    134119    void setLastPlay();
    135120
    136     int PlayCount() { return m_playcount; }
     121    int PlayCount() const { return m_playcount; }
    137122    void incPlayCount();
    138123
    139     bool isVisible() { return m_show; }
     124    bool isVisible() const { return m_show; }
    140125    void setVisible(bool visible) { m_show = visible; }
    141126
    142127    // track is part of a compilation album
    143     bool Compilation() { return m_compilation; }
     128    bool Compilation() const { return m_compilation; }
    144129    void setCompilation(bool state) { m_compilation = state; m_formattedartist = m_formattedtitle = ""; }
    145     bool determineIfCompilation(bool m_cd = false);
     130    bool determineIfCompilation(bool cd = false);
    146131
    147132    bool isInDatabase(void);
    148133    void dumpToDatabase(void);
     134    void removeFromDatabase(void);
    149135    void setField(const QString &field, const QString &data);
    150136    void getField(const QString& field, QString *data);
    151137    void persist();
    152138    bool hasChanged(){return m_changed;}
    153139    int compare (Metadata *other);
    154     static void setArtistAndTrackFormats();
    155140
     141    MythThemedDialog *createEditorDialog (void);
     142
     143    static void setArtistAndTrackFormats();
    156144    static void SetStartdir(const QString &dir);
    157145
    158146    static QStringList fillFieldList(QString field);
     
    160148  private:
    161149    void setCompilationFormatting(bool cd = false);
    162150    QString formatReplaceSymbols(const QString &format);
     151    void checkEmptyFields(void);
    163152
    164153    QString m_artist;
    165154    QString m_compilation_artist;
     
    302291    QString     getLabel(int an_id, bool *error_flag);
    303292    Metadata*   getMetadata(int an_id);
    304293    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; }
    307296    void        save();
    308297    bool        startLoading(void);
    309298    void        resync();   //  After a CD rip, for example