File indexing completed on 2024-06-02 04:50:52

0001 #include "metadataeditor.h"
0002 
0003 MetadataEditor::MetadataEditor(QObject *parent) : QObject(parent)
0004   , m_tag(new TagInfo(this))
0005 {
0006     connect(this, &MetadataEditor::urlChanged, this, &MetadataEditor::getData);
0007 }
0008 
0009 QUrl MetadataEditor::url() const
0010 {
0011     return this->m_url;
0012 }
0013 
0014 QString MetadataEditor::title() const
0015 {
0016     return this->m_title;
0017 }
0018 
0019 QString MetadataEditor::artist() const
0020 {
0021     return this->m_artist;
0022 }
0023 
0024 QString MetadataEditor::album() const
0025 {
0026     return this->m_album;
0027 }
0028 
0029 QString MetadataEditor::genre() const
0030 {
0031     return this->m_genre;
0032 }
0033 
0034 int MetadataEditor::track() const
0035 {
0036     return this->m_track;
0037 }
0038 
0039 QString MetadataEditor::comment() const
0040 {
0041     return m_comment;
0042 }
0043 
0044 int MetadataEditor::year() const
0045 {
0046     return m_year;
0047 }
0048 
0049 void MetadataEditor::setUrl(QUrl url)
0050 {
0051     if (m_url == url)
0052         return;
0053 
0054     m_url = url;
0055     emit urlChanged(m_url);
0056 }
0057 
0058 void MetadataEditor::setTitle(QString title)
0059 {
0060     if (m_title == title)
0061         return;
0062 
0063     m_title = title;
0064     m_tag->setTitle(m_title);
0065     emit titleChanged(m_title);
0066 }
0067 
0068 void MetadataEditor::setArtist(QString artist)
0069 {
0070     if (m_artist == artist)
0071         return;
0072 
0073     m_artist = artist;
0074     m_tag->setArtist(m_artist);
0075     emit artistChanged(m_artist);
0076 }
0077 
0078 void MetadataEditor::setAlbum(QString album)
0079 {
0080     if (m_album == album)
0081         return;
0082 
0083     m_album = album;
0084     m_tag->setAlbum(m_album);
0085     emit albumChanged(m_album);
0086 }
0087 
0088 void MetadataEditor::setTrack(int track)
0089 {
0090     if (m_track == track)
0091         return;
0092 
0093     m_track = track;
0094     m_tag->setTrack(m_track);
0095     emit trackChanged(m_track);
0096 }
0097 
0098 void MetadataEditor::setGenre(QString genre)
0099 {
0100     if (m_genre == genre)
0101         return;
0102 
0103     m_genre = genre;
0104     m_tag->setGenre(m_genre);
0105     emit genreChanged(m_genre);
0106 }
0107 
0108 void MetadataEditor::setComment(QString comment)
0109 {
0110     if (m_comment == comment)
0111         return;
0112 
0113     m_comment = comment;
0114     m_tag->setComment(m_comment);
0115     emit commentChanged(m_comment);
0116 }
0117 
0118 void MetadataEditor::setYear(int year)
0119 {
0120     if (m_year == year)
0121         return;
0122 
0123     m_year = year;
0124     m_tag->setYear(m_year);
0125     emit yearChanged(m_year);
0126 }
0127 
0128 void MetadataEditor::getData()
0129 {
0130     m_tag->setFile(this->m_url.toLocalFile());
0131 
0132     m_title = m_tag->getTitle();
0133     emit this->titleChanged(m_title);
0134 
0135     m_artist = m_tag->getArtist();
0136     emit this->artistChanged(m_artist);
0137 
0138     m_album = m_tag->getAlbum();
0139     emit this->albumChanged(m_album);
0140 
0141     m_genre = m_tag->getGenre();
0142     emit this->genreChanged(m_genre);
0143 
0144     m_track = m_tag->getTrack();
0145     emit this->trackChanged(m_track);
0146 
0147     m_year = m_tag->getYear();
0148     emit this->yearChanged(m_year);
0149 
0150     m_comment = m_tag->getComment();
0151     emit this->commentChanged(m_comment);
0152 }