diff options
author | Uwe Klotz <uwe_klotz@web.de> | 2017-10-28 19:32:55 +0200 |
---|---|---|
committer | Uwe Klotz <uwe_klotz@web.de> | 2017-11-06 22:27:20 +0100 |
commit | 820d086b8114c537f53e9f10fe2a17e2794e050c (patch) | |
tree | 0b9ad6a7826abec8a45826828cdf30958601b2a1 /src/track/trackmetadata.h | |
parent | 57772839d27b489ec58ac52b023c93179bfd8d35 (diff) |
Use new album/track info classes for storing track metadata
Diffstat (limited to 'src/track/trackmetadata.h')
-rw-r--r-- | src/track/trackmetadata.h | 188 |
1 files changed, 22 insertions, 166 deletions
diff --git a/src/track/trackmetadata.h b/src/track/trackmetadata.h index e5da6e2b9f..5983d28845 100644 --- a/src/track/trackmetadata.h +++ b/src/track/trackmetadata.h @@ -1,150 +1,25 @@ -#ifndef MIXXX_TRACKMETADATA_H -#define MIXXX_TRACKMETADATA_H +#pragma once #include <QDateTime> -#include "track/bpm.h" -#include "track/replaygain.h" -#include "sources/audiosource.h" -#include "util/duration.h" +#include "track/albuminfo.h" +#include "track/trackinfo.h" + namespace mixxx { -// DTO for track metadata properties. Must not be subclassed (no virtual destructor)! class TrackMetadata final { -public: - const QString& getArtist() const { - return m_artist; - } - void setArtist(QString artist) { - m_artist = artist; - } - - const QString& getTitle() const { - return m_title; - } - void setTitle(QString title) { - m_title = title; - } - - const QString& getAlbum() const { - return m_album; - } - void setAlbum(QString album) { - m_album = album; - } - - const QString& getAlbumArtist() const { - return m_albumArtist; - } - void setAlbumArtist(QString albumArtist) { - m_albumArtist = albumArtist; - } - - const QString& getGenre() const { - return m_genre; - } - void setGenre(QString genre) { - m_genre = genre; - } + PROPERTY_SET_BYVAL_GET_BYREF(AlbumInfo, albumInfo, AlbumInfo) + PROPERTY_SET_BYVAL_GET_BYREF(TrackInfo, trackInfo, TrackInfo) - const QString& getComment() const { - return m_comment; - } - void setComment(QString comment) { - m_comment = comment; - } - - // year, date or date/time formatted according to ISO 8601 - const QString& getYear() const { - return m_year; - } - void setYear(QString year) { - m_year = year; - } - - const QString& getTrackNumber() const { - return m_trackNumber; - } - void setTrackNumber(QString trackNumber) { - m_trackNumber = trackNumber; - } - const QString& getTrackTotal() const { - return m_trackTotal; - } - void setTrackTotal(QString trackTotal) { - m_trackTotal = trackTotal; - } - - const QString& getComposer() const { - return m_composer; - } - void setComposer(QString composer) { - m_composer = composer; - } - - const QString& getGrouping() const { - return m_grouping; - } - void setGrouping(QString grouping) { - m_grouping = grouping; - } - - const QString& getKey() const { - return m_key; - } - void setKey(QString key) { - m_key = key; - } - - AudioSignal::ChannelCount getChannels() const { - return m_channels; - } - void setChannels(AudioSignal::ChannelCount channels) { - m_channels = channels; - } - - AudioSignal::SampleRate getSampleRate() const { - return m_sampleRate; - } - void setSampleRate(AudioSignal::SampleRate sampleRate) { - m_sampleRate = sampleRate; - } - - AudioSource::Bitrate getBitrate() const { - return m_bitrate; - } - void setBitrate(AudioSource::Bitrate bitrate) { - m_bitrate = bitrate; - } - - Duration getDuration() const { - return m_duration; - } - void setDuration(Duration duration) { - m_duration = duration; - } +public: + TrackMetadata() = default; + TrackMetadata(TrackMetadata&&) = default; + TrackMetadata(const TrackMetadata&) = default; + /*non-virtual*/ ~TrackMetadata() = default; - // beats / minute - Bpm getBpm() const { - return m_bpm; - } - void setBpm(Bpm bpm) { - m_bpm = bpm; - } - void resetBpm() { - m_bpm.resetValue(); - } - - const ReplayGain& getReplayGain() const { - return m_replayGain; - } - void setReplayGain(const ReplayGain& replayGain) { - m_replayGain = replayGain; - } - void resetReplayGain() { - m_replayGain = ReplayGain(); - } + TrackMetadata& operator=(TrackMetadata&&) = default; + TrackMetadata& operator=(const TrackMetadata&) = default; // Parse an format date/time values according to ISO 8601 static QDate parseDate(QString str) { @@ -162,42 +37,23 @@ public: // Parse and format the calendar year (for simplified display) static constexpr int kCalendarYearInvalid = 0; - static int parseCalendarYear(QString year, bool* pValid = 0); - static QString formatCalendarYear(QString year, bool* pValid = 0); + static int parseCalendarYear(QString year, bool* pValid = nullptr); + static QString formatCalendarYear(QString year, bool* pValid = nullptr); static QString reformatYear(QString year); - -private: - // String fields (in alphabetical order) - QString m_album; - QString m_albumArtist; - QString m_artist; - QString m_comment; - QString m_composer; - QString m_genre; - QString m_grouping; - QString m_key; - QString m_title; - QString m_trackNumber; - QString m_trackTotal; - QString m_year; - - Duration m_duration; - Bpm m_bpm; - ReplayGain m_replayGain; - - AudioSignal::ChannelCount m_channels; - AudioSignal::SampleRate m_sampleRate; - AudioSource::Bitrate m_bitrate; }; -bool operator==(const TrackMetadata& lhs, const TrackMetadata& rhs); +inline +bool operator==(const TrackMetadata& lhs, const TrackMetadata& rhs) { + return (lhs.getAlbumInfo() == rhs.getAlbumInfo()) && + (lhs.getTrackInfo() == rhs.getTrackInfo()); +} inline bool operator!=(const TrackMetadata& lhs, const TrackMetadata& rhs) { return !(lhs == rhs); } -} +} // namespace mixxx -#endif // MIXXX_TRACKMETADATA_H +Q_DECLARE_METATYPE(mixxx::TrackMetadata) |