-
-
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
Track menu: enable Lock BPM action if any selected track BPM is unlocked #12385
Conversation
There's probably a smarter solution, but it does the job 🤷 |
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.
Except the code duplication issue, it's fine for me.
src/widget/wtrackmenu.cpp
Outdated
bool WTrackMenu::isAnyTrackBpmUnlocked() const { | ||
if (m_pTrackModel) { | ||
const int column = | ||
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK); | ||
for (const auto& trackIndex : m_trackIndexList) { | ||
QModelIndex bpmLockedIndex = | ||
trackIndex.sibling(trackIndex.row(), column); | ||
if (!bpmLockedIndex.data().toBool()) { | ||
return true; | ||
} | ||
} | ||
} else { | ||
if (m_pTrack && !m_pTrack->isBpmLocked()) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
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.
bool WTrackMenu::isAnyTrackBpmUnlocked() const { | |
if (m_pTrackModel) { | |
const int column = | |
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK); | |
for (const auto& trackIndex : m_trackIndexList) { | |
QModelIndex bpmLockedIndex = | |
trackIndex.sibling(trackIndex.row(), column); | |
if (!bpmLockedIndex.data().toBool()) { | |
return true; | |
} | |
} | |
} else { | |
if (m_pTrack && !m_pTrack->isBpmLocked()) { | |
return true; | |
} | |
} | |
return false; | |
} | |
void WTrackMenu::accumulateBpmLockStates(bool* anyBpmLocked, bool* anyBpmNotLocked) const { | |
VERIFY_OR_DEBUG_ASSERT(anyBpmLocked && anyBpmNotLocked) { | |
return; | |
} | |
*anyBpmLocked = false; | |
*anyBpmNotLocked = false; | |
if (m_pTrackModel) { | |
const int column = | |
m_pTrackModel->fieldIndex(LIBRARYTABLE_BPM_LOCK); | |
for (const auto& trackIndex : m_trackIndexList) { | |
QModelIndex bpmLockedIndex = | |
trackIndex.sibling(trackIndex.row(), column); | |
if (bpmLockedIndex.data().toBool()) { | |
*anyBpmLocked = true; | |
} else { | |
*anyBpmNotLocked = true; | |
} | |
} | |
} else { | |
if (m_pTrack) { | |
if (m_pTrack->isBpmLocked()) { | |
*anyBpmLocked = true; | |
} else { | |
*anyBpmNotLocked = true; | |
} | |
} | |
} | |
} |
Otherwise it's a lot of code duplication, and this code would be also executed twice.
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.
Yeah, something like, I was just too lazy last night ; )
Co-authored-by: JoergAtGithub <64457745+JoergAtGithub@users.noreply.github.com>
8687782
to
c24cbc1
Compare
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.
Code LGTM now! Works as expected on local Windows11 build. Thank you!
BPM > Lock was not enabled if any of the selected track is locked.