From c45b27f6118d142ad590c25d5a73b46c672a6ab7 Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 7 May 2019 11:12:46 -0500 Subject: convert Cue::CueType to enum class --- src/track/cue.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 1d27df21c6..3110634c85 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -24,7 +24,7 @@ Cue::Cue(TrackId trackId) m_iId(-1), m_trackId(trackId), m_source(UNKNOWN), - m_type(INVALID), + m_type(Cue::Type::Invalid), m_samplePosition(-1.0), m_length(0.0), m_iHotCue(-1), @@ -33,7 +33,7 @@ Cue::Cue(TrackId trackId) DEBUG_ASSERT(!m_label.isNull()); } -Cue::Cue(int id, TrackId trackId, Cue::CueSource source, Cue::CueType type, double position, double length, +Cue::Cue(int id, TrackId trackId, Cue::CueSource source, Cue::Type type, double position, double length, int hotCue, QString label, PredefinedColorPointer color) : m_bDirty(false), m_iId(id), @@ -87,12 +87,12 @@ void Cue::setSource(CueSource source) { emit(updated()); } -Cue::CueType Cue::getType() const { +Cue::Type Cue::getType() const { QMutexLocker lock(&m_mutex); return m_type; } -void Cue::setType(Cue::CueType type) { +void Cue::setType(Cue::Type type) { QMutexLocker lock(&m_mutex); m_type = type; m_bDirty = true; -- cgit v1.2.3 From 580c20b045a6c820bddb895eb65f677bf9a938a9 Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 7 May 2019 11:50:22 -0500 Subject: convert Cue::CueSource to enum class --- src/track/cue.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 3110634c85..14ddf3a401 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -23,7 +23,7 @@ Cue::Cue(TrackId trackId) : m_bDirty(false), m_iId(-1), m_trackId(trackId), - m_source(UNKNOWN), + m_source(Cue::Source::Unknown), m_type(Cue::Type::Invalid), m_samplePosition(-1.0), m_length(0.0), @@ -33,7 +33,7 @@ Cue::Cue(TrackId trackId) DEBUG_ASSERT(!m_label.isNull()); } -Cue::Cue(int id, TrackId trackId, Cue::CueSource source, Cue::Type type, double position, double length, +Cue::Cue(int id, TrackId trackId, Cue::Source source, Cue::Type type, double position, double length, int hotCue, QString label, PredefinedColorPointer color) : m_bDirty(false), m_iId(id), @@ -74,12 +74,12 @@ void Cue::setTrackId(TrackId trackId) { emit(updated()); } -Cue::CueSource Cue::getSource() const { +Cue::Source Cue::getSource() const { QMutexLocker lock(&m_mutex); return m_source; } -void Cue::setSource(CueSource source) { +void Cue::setSource(Cue::Source source) { QMutexLocker lock(&m_mutex); m_source = source; m_bDirty = true; -- cgit v1.2.3 From 107c61d270ebd6350825fa3a2a67d9ed5ed24dbb Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 12 Aug 2019 15:34:30 -0500 Subject: remove useless tracking of automatic vs manually placed cues This was introduced in PR #1242 but is no longer used. --- src/track/cue.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 14ddf3a401..dec0d8f1c4 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -23,7 +23,6 @@ Cue::Cue(TrackId trackId) : m_bDirty(false), m_iId(-1), m_trackId(trackId), - m_source(Cue::Source::Unknown), m_type(Cue::Type::Invalid), m_samplePosition(-1.0), m_length(0.0), @@ -33,12 +32,11 @@ Cue::Cue(TrackId trackId) DEBUG_ASSERT(!m_label.isNull()); } -Cue::Cue(int id, TrackId trackId, Cue::Source source, Cue::Type type, double position, double length, +Cue::Cue(int id, TrackId trackId, Cue::Type type, double position, double length, int hotCue, QString label, PredefinedColorPointer color) : m_bDirty(false), m_iId(id), m_trackId(trackId), - m_source(source), m_type(type), m_samplePosition(position), m_length(length), @@ -74,19 +72,6 @@ void Cue::setTrackId(TrackId trackId) { emit(updated()); } -Cue::Source Cue::getSource() const { - QMutexLocker lock(&m_mutex); - return m_source; -} - -void Cue::setSource(Cue::Source source) { - QMutexLocker lock(&m_mutex); - m_source = source; - m_bDirty = true; - lock.unlock(); - emit(updated()); -} - Cue::Type Cue::getType() const { QMutexLocker lock(&m_mutex); return m_type; @@ -190,6 +175,5 @@ double Cue::getEndPosition() const { } bool operator==(const CuePosition& lhs, const CuePosition& rhs) { - return lhs.getPosition() == rhs.getPosition() && - lhs.getSource() == rhs.getSource(); + return lhs.getPosition() == rhs.getPosition(); } -- cgit v1.2.3 From 0a2fda2fc2841dadb4a9624930cafbabb0cacc4d Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 22 Oct 2019 03:13:58 -0500 Subject: Cue: rename setPosition to setStartPosition --- src/track/cue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index dec0d8f1c4..85ddeb144b 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -90,7 +90,7 @@ double Cue::getPosition() const { return m_samplePosition; } -void Cue::setPosition(double samplePosition) { +void Cue::setStartPosition(double samplePosition) { QMutexLocker lock(&m_mutex); m_samplePosition = samplePosition; m_bDirty = true; -- cgit v1.2.3 From 4970f0b76da59574c984400dbe37fd7544c5ce5a Mon Sep 17 00:00:00 2001 From: Be Date: Tue, 22 Oct 2019 03:39:12 -0500 Subject: Cue: add setEndPosition method It is easier to think about a start and end point than a start point and length. This new method allows hiding the length as an implementation detail of the database format. --- src/track/cue.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 85ddeb144b..db49b6756d 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -24,7 +24,7 @@ Cue::Cue(TrackId trackId) m_iId(-1), m_trackId(trackId), m_type(Cue::Type::Invalid), - m_samplePosition(-1.0), + m_sampleStartPosition(-1.0), m_length(0.0), m_iHotCue(-1), m_label(kDefaultLabel), @@ -38,7 +38,7 @@ Cue::Cue(int id, TrackId trackId, Cue::Type type, double position, double length m_iId(id), m_trackId(trackId), m_type(type), - m_samplePosition(position), + m_sampleStartPosition(position), m_length(length), m_iHotCue(hotCue), m_label(label), @@ -87,12 +87,26 @@ void Cue::setType(Cue::Type type) { double Cue::getPosition() const { QMutexLocker lock(&m_mutex); - return m_samplePosition; + return m_sampleStartPosition; } void Cue::setStartPosition(double samplePosition) { QMutexLocker lock(&m_mutex); - m_samplePosition = samplePosition; + m_sampleStartPosition = samplePosition; + m_bDirty = true; + lock.unlock(); + emit(updated()); +} + +void Cue::setEndPosition(double samplePosition) { + QMutexLocker lock(&m_mutex); + if (samplePosition == -1.0) { + m_length = 0; + } else if (m_sampleStartPosition == -1.0) { + m_length = samplePosition; + } else { + m_length = samplePosition - m_sampleStartPosition; + } m_bDirty = true; lock.unlock(); emit(updated()); @@ -165,12 +179,12 @@ void Cue::setDirty(bool dirty) { double Cue::getEndPosition() const { QMutexLocker lock(&m_mutex); - if (m_samplePosition == -1.0) { + if (m_sampleStartPosition == -1.0) { return m_length; } else if (m_length == 0.0) { return -1.0; } else { - return m_samplePosition + m_length; + return m_sampleStartPosition + m_length; } } -- cgit v1.2.3 From 082e2e6065c5da9d0924ce1e40191763cd752d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 10 Nov 2019 02:35:22 +0100 Subject: Fix a bug where outro end was passed the end of the track, because not updated lenght info when updating outro start. --- src/track/cue.cpp | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'src/track/cue.cpp') diff --git a/src/track/cue.cpp b/src/track/cue.cpp index db49b6756d..f4d8711f85 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -24,8 +24,8 @@ Cue::Cue(TrackId trackId) m_iId(-1), m_trackId(trackId), m_type(Cue::Type::Invalid), - m_sampleStartPosition(-1.0), - m_length(0.0), + m_sampleStartPosition(Cue::kNoPosition), + m_sampleEndPosition(Cue::kNoPosition), m_iHotCue(-1), m_label(kDefaultLabel), m_color(Color::kPredefinedColorsSet.noColor) { @@ -39,13 +39,20 @@ Cue::Cue(int id, TrackId trackId, Cue::Type type, double position, double length m_trackId(trackId), m_type(type), m_sampleStartPosition(position), - m_length(length), m_iHotCue(hotCue), m_label(label), m_color(color) { DEBUG_ASSERT(!m_label.isNull()); + if (length) { + if (position != Cue::kNoPosition) { + m_sampleEndPosition = position + length; + } else { + m_sampleEndPosition = length; + } + } else { + m_sampleEndPosition = Cue::kNoPosition; + } } - int Cue::getId() const { QMutexLocker lock(&m_mutex); return m_iId; @@ -100,13 +107,7 @@ void Cue::setStartPosition(double samplePosition) { void Cue::setEndPosition(double samplePosition) { QMutexLocker lock(&m_mutex); - if (samplePosition == -1.0) { - m_length = 0; - } else if (m_sampleStartPosition == -1.0) { - m_length = samplePosition; - } else { - m_length = samplePosition - m_sampleStartPosition; - } + m_sampleEndPosition = samplePosition; m_bDirty = true; lock.unlock(); emit(updated()); @@ -114,15 +115,13 @@ void Cue::setEndPosition(double samplePosition) { double Cue::getLength() const { QMutexLocker lock(&m_mutex); - return m_length; -} - -void Cue::setLength(double length) { - QMutexLocker lock(&m_mutex); - m_length = length; - m_bDirty = true; - lock.unlock(); - emit(updated()); + if (m_sampleEndPosition == Cue::kNoPosition) { + return 0; + } + if (m_sampleStartPosition == Cue::kNoPosition) { + return m_sampleEndPosition; + } + return m_sampleEndPosition - m_sampleStartPosition; } int Cue::getHotCue() const { @@ -179,13 +178,7 @@ void Cue::setDirty(bool dirty) { double Cue::getEndPosition() const { QMutexLocker lock(&m_mutex); - if (m_sampleStartPosition == -1.0) { - return m_length; - } else if (m_length == 0.0) { - return -1.0; - } else { - return m_sampleStartPosition + m_length; - } + return m_sampleEndPosition; } bool operator==(const CuePosition& lhs, const CuePosition& rhs) { -- cgit v1.2.3