Skip to content
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

WTrackTableView cleanup #2675

Merged
merged 3 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void WTrackMenu::updateMenus() {
const auto trackPointers = getTrackPointers();

// Gray out some stuff if multiple songs were selected.
bool oneSongSelected = trackPointers.size() == 1;
const bool singleTrackSelected = trackPointers.size() == 1;

if (featureIsEnabled(Feature::LoadTo)) {
int iNumDecks = m_pNumDecks->get();
Expand All @@ -416,7 +416,7 @@ void WTrackMenu::updateMenus() {
ConfigKey(deckGroup, "play")) > 0.0;
bool loadTrackIntoPlayingDeck = m_pConfig->getValue<bool>(
ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck"));
bool deckEnabled = (!deckPlaying || loadTrackIntoPlayingDeck) && oneSongSelected;
bool deckEnabled = (!deckPlaying || loadTrackIntoPlayingDeck) && singleTrackSelected;
QAction* pAction = new QAction(tr("Deck %1").arg(i), this);
pAction->setEnabled(deckEnabled);
m_pDeckMenu->addAction(pAction);
Expand All @@ -432,7 +432,7 @@ void WTrackMenu::updateMenus() {
QString samplerGroup = PlayerManager::groupForSampler(i - 1);
bool samplerPlaying = ControlObject::get(
ConfigKey(samplerGroup, "play")) > 0.0;
bool samplerEnabled = !samplerPlaying && oneSongSelected;
bool samplerEnabled = !samplerPlaying && singleTrackSelected;
QAction* pAction = new QAction(tr("Sampler %1").arg(i), m_pSamplerMenu);
pAction->setEnabled(samplerEnabled);
m_pSamplerMenu->addAction(pAction);
Expand Down Expand Up @@ -467,18 +467,14 @@ void WTrackMenu::updateMenus() {
}

if (featureIsEnabled(Feature::Metadata)) {
m_pImportMetadataFromMusicBrainzAct->setEnabled(oneSongSelected);
m_pImportMetadataFromMusicBrainzAct->setEnabled(singleTrackSelected);

// We load a single track to get the necessary context for the cover (we use
// last to be consistent with selectionChanged above).
TrackPointer last = trackPointers.last();
CoverInfo info;
info.source = last->getCoverInfo().source;
info.type = last->getCoverInfo().type;
info.hash = last->getCoverHash();
info.trackLocation = last->getCoverInfoWithLocation().trackLocation;
info.coverLocation = last->getCoverInfoWithLocation().coverLocation;
m_pCoverMenu->setCoverArt(info);
TrackPointer pTrack = trackPointers.last();

m_pCoverMenu->setCoverArt(
pTrack->getCoverInfoWithLocation());
}

if (featureIsEnabled(Feature::Reset)) {
Expand Down Expand Up @@ -558,7 +554,7 @@ void WTrackMenu::updateMenus() {
}

if (featureIsEnabled(Feature::Properties)) {
m_pPropertiesAct->setEnabled(oneSongSelected);
m_pPropertiesAct->setEnabled(singleTrackSelected);
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ void WTrackTableView::loadTrackModel(QAbstractItemModel *model) {
//using address of track model as key
}

// The "coverLocation" and "hash" column numbers are required very often
// by slotLoadCoverArt(). As this value will not change when the model
// still the same, we must avoid doing hundreds of "fieldIndex" calls
// when it is completely unnecessary...


setVisible(false);

// Save the previous track model's header state
Expand Down