Skip to content

Commit

Permalink
Track: Emit changed signals for all properties on metadata import
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed May 29, 2021
1 parent cadecf7 commit 978ab2c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ void Track::replaceMetadataFromSource(
if (colorModified) {
emit colorUpdated(newColor);
}

emitMetadataChanged();
}

// TODO: Import Serato metadata within the locking scope and not
Expand All @@ -240,6 +242,7 @@ bool Track::mergeExtraMetadataFromSource(
}
markDirtyAndUnlock(&lock);
// Modified
emitMetadataChanged();
return true;
}

Expand Down Expand Up @@ -314,6 +317,8 @@ bool Track::replaceRecord(
if (oldColor != newColor) {
emit colorUpdated(newColor);
}

emitMetadataChanged();
return true;
}

Expand Down Expand Up @@ -444,6 +449,26 @@ void Track::emitBeatsAndBpmUpdated(
emit bpmTextChanged();
}

void Track::emitMetadataChanged() {
emit artistChanged(getArtist());
emit titleChanged(getTitle());
emit albumChanged(getAlbum());
emit albumArtistChanged(getAlbumArtist());
emit genreChanged(getGenre());
emit composerChanged(getComposer());
emit groupingChanged(getGrouping());
emit yearChanged(getYear());
emit trackNumberChanged(getTrackNumber());
emit trackTotalChanged(getTrackTotal());
emit commentChanged(getComment());
emit bpmTextChanged();
emit timesPlayedChanged();
emit durationChanged();
emit infoChanged();
emit keysUpdated();
emit bpmUpdated(getBpm());
}

void Track::setMetadataSynchronized(bool metadataSynchronized) {
QMutexLocker lock(&m_qMutex);
if (compareAndSet(m_record.ptrMetadataSynchronized(), metadataSynchronized)) {
Expand Down
3 changes: 3 additions & 0 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ class Track : public QObject {
void afterBeatsAndBpmUpdated(QMutexLocker* pLock);
void emitBeatsAndBpmUpdated(mixxx::Bpm newBpm);

/// Emits a changed signal for each Q_PROPERTY
void emitMetadataChanged();

/// Sets beats and returns a boolean to indicate if BPM/Beats were updated.
/// Only supposed to be called while the caller guards this a lock.
bool setBeatsWhileLocked(mixxx::BeatsPointer pBeats);
Expand Down

0 comments on commit 978ab2c

Please sign in to comment.