-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command for clearing waveform to track's context menu #1197
Changes from 1 commit
1c354e3
162a899
511b31f
3228d77
399d6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,6 +455,10 @@ void WTrackTableView::createActions() { | |
connect(m_pClearBeatsAction, SIGNAL(triggered()), | ||
this, SLOT(slotClearBeats())); | ||
|
||
m_pClearWaveformAction = new QAction(tr("Clear Waveform"), this); | ||
connect(m_pClearWaveformAction, SIGNAL(triggered()), | ||
this, SLOT(slotClearWaveform())); | ||
|
||
m_pReplayGainResetAction = new QAction(tr("Reset ReplayGain"), this); | ||
connect(m_pReplayGainResetAction, SIGNAL(triggered()), | ||
this, SLOT(slotReplayGainReset())); | ||
|
@@ -929,6 +933,8 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { | |
m_pBPMMenu->addAction(m_pClearBeatsAction); | ||
} | ||
|
||
m_pMenu->addAction(m_pClearWaveformAction); | ||
|
||
m_pMenu->addAction(m_pReplayGainResetAction); | ||
|
||
m_pMenu->addSeparator(); | ||
|
@@ -1606,6 +1612,25 @@ void WTrackTableView::slotClearBeats() { | |
} | ||
} | ||
|
||
void WTrackTableView::slotClearWaveform() { | ||
TrackModel* trackModel = getTrackModel(); | ||
if (trackModel == nullptr) { | ||
return; | ||
} | ||
|
||
AnalysisDao& analysisDao = m_pTrackCollection->getAnalysisDAO(); | ||
QModelIndexList indices = selectionModel()->selectedRows(); | ||
for (const QModelIndex& index : indices) { | ||
TrackPointer pTrack = trackModel->getTrack(index); | ||
if (!pTrack) { | ||
continue; | ||
} | ||
analysisDao.deleteAnalysesForTrack(pTrack->getId()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this delete the all analysis data? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhm Well, by looking at the AnalysisDao code, AnalysisDao is used just for storing waveforms, so this indeed is only clearing track's waveforms. |
||
pTrack->setWaveform(WaveformPointer()); | ||
pTrack->setWaveformSummary(WaveformPointer()); | ||
} | ||
} | ||
|
||
void WTrackTableView::slotReplayGainReset() { | ||
QModelIndexList indices = selectionModel()->selectedRows(); | ||
TrackModel* trackModel = getTrackModel(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,11 +184,25 @@ void WWaveformViewer::slotTrackLoaded(TrackPointer track) { | |
} | ||
|
||
void WWaveformViewer::slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack) { | ||
Q_UNUSED(pNewTrack); | ||
Q_UNUSED(pOldTrack); | ||
if (pOldTrack) { | ||
disconnect(pOldTrack.get(), SIGNAL(waveformUpdated()), | ||
this, SLOT(slotWaveformUpdated())); | ||
} | ||
|
||
if (m_waveformWidget) { | ||
m_waveformWidget->setTrack(TrackPointer()); | ||
} | ||
|
||
if (pNewTrack) { | ||
connect(pNewTrack.get(), SIGNAL(waveformUpdated()), | ||
this, SLOT(slotWaveformUpdated())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the track was just cleared above. Can we move this to slotTrackLoaded, to keep symmetry? |
||
} | ||
} | ||
|
||
void WWaveformViewer::slotWaveformUpdated() { | ||
if (m_waveformWidget) { | ||
m_waveformWidget->setTrack(m_waveformWidget->getTrackInfo()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What dos this line? Can we replace it by a member function with a nice name? |
||
} | ||
} | ||
|
||
void WWaveformViewer::onZoomChange(double zoom) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ownership of m_pWaveformSourceImage is unclear. This is not your fault, but we should fix it here, because this PR builds on top of this situation.
I think the best solution is to move m_pWaveformSourceImage into the inherited classes and put it into a std::unique_ptr
this WOverview should have a abstract
virtual void invalidateImage() = 0
, that is then implemented in the Inherited classes to actually clear the Image.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have decided to take a (slightly) different approach with this and make this QImage statically allocated (like
m_waveformImageScaled
is). I hope you don't mind. 😃