Clean track lists view when removing a track list
This commit is contained in:
@@ -165,6 +165,7 @@
|
|||||||
|
|
||||||
<!--Explore:TrackLists-->
|
<!--Explore:TrackLists-->
|
||||||
|
|
||||||
|
|
||||||
<!--Explore:Search-->
|
<!--Explore:Search-->
|
||||||
<message id="Lms.Explore.Search.search-placeholder">搜索中...</message>
|
<message id="Lms.Explore.Search.search-placeholder">搜索中...</message>
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ handleContentsPathChange(Wt::WStackedWidget* stack)
|
|||||||
{
|
{
|
||||||
IdxArtists = 0,
|
IdxArtists = 0,
|
||||||
IdxArtist,
|
IdxArtist,
|
||||||
IdxTracklists,
|
IdxTrackLists,
|
||||||
IdxTracklist,
|
IdxTrackList,
|
||||||
IdxReleases,
|
IdxReleases,
|
||||||
IdxRelease,
|
IdxRelease,
|
||||||
IdxSearch,
|
IdxSearch,
|
||||||
@@ -64,8 +64,8 @@ handleContentsPathChange(Wt::WStackedWidget* stack)
|
|||||||
{
|
{
|
||||||
{ "/artists", IdxArtists },
|
{ "/artists", IdxArtists },
|
||||||
{ "/artist", IdxArtist },
|
{ "/artist", IdxArtist },
|
||||||
{ "/tracklists", IdxTracklists },
|
{ "/tracklists", IdxTrackLists },
|
||||||
{ "/tracklist", IdxTracklist },
|
{ "/tracklist", IdxTrackList },
|
||||||
{ "/releases", IdxReleases },
|
{ "/releases", IdxReleases },
|
||||||
{ "/release", IdxRelease },
|
{ "/release", IdxRelease },
|
||||||
{ "/search", IdxSearch },
|
{ "/search", IdxSearch },
|
||||||
@@ -103,14 +103,18 @@ Explore::Explore(Filters* filters)
|
|||||||
artist->tracksAction.connect(this, &Explore::handleTracksAction);
|
artist->tracksAction.connect(this, &Explore::handleTracksAction);
|
||||||
contentsStack->addWidget(std::move(artist));
|
contentsStack->addWidget(std::move(artist));
|
||||||
|
|
||||||
auto tracklists {std::make_unique<TrackLists>(*_filters)};
|
auto trackLists {std::make_unique<TrackLists>(*_filters)};
|
||||||
tracklists->trackListAction.connect(this, &Explore::handleTrackListAction);
|
TrackLists* trackListsPtr {trackLists.get()};
|
||||||
contentsStack->addWidget(std::move(tracklists));
|
trackLists->trackListAction.connect(this, &Explore::handleTrackListAction);
|
||||||
|
contentsStack->addWidget(std::move(trackLists));
|
||||||
|
|
||||||
auto tracklist {std::make_unique<TrackList>(*_filters)};
|
auto trackList {std::make_unique<TrackList>(*_filters)};
|
||||||
tracklist->trackListAction.connect(this, &Explore::handleTrackListAction);
|
TrackList* trackListPtr {trackList.get()};
|
||||||
tracklist->tracksAction.connect(this, &Explore::handleTracksAction);
|
trackList->trackListAction.connect(this, &Explore::handleTrackListAction);
|
||||||
contentsStack->addWidget(std::move(tracklist));
|
trackList->tracksAction.connect(this, &Explore::handleTracksAction);
|
||||||
|
contentsStack->addWidget(std::move(trackList));
|
||||||
|
|
||||||
|
trackListPtr->trackListDeleted.connect(trackListsPtr, &TrackLists::onTrackListDeleted);
|
||||||
|
|
||||||
auto releases = std::make_unique<Releases>(*_filters);
|
auto releases = std::make_unique<Releases>(*_filters);
|
||||||
releases->releasesAction.connect(this, &Explore::handleReleasesAction);
|
releases->releasesAction.connect(this, &Explore::handleReleasesAction);
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ namespace UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
trackListDeleted.emit(*trackListId);
|
||||||
LmsApp->setInternalPath("/tracklists", true);
|
LmsApp->setInternalPath("/tracklists", true);
|
||||||
|
|
||||||
LmsApp->getModalManager().dispose(modalPtr);
|
LmsApp->getModalManager().dispose(modalPtr);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace UserInterface
|
|||||||
PlayQueueActionTrackListSignal trackListAction;
|
PlayQueueActionTrackListSignal trackListAction;
|
||||||
PlayQueueActionTrackSignal tracksAction;
|
PlayQueueActionTrackSignal tracksAction;
|
||||||
|
|
||||||
|
Wt::Signal<Database::TrackListId> trackListDeleted;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshView();
|
void refreshView();
|
||||||
void addSome();
|
void addSome();
|
||||||
|
|||||||
@@ -78,10 +78,23 @@ namespace UserInterface
|
|||||||
refreshView();
|
refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackLists::onTrackListDeleted(Database::TrackListId trackListId)
|
||||||
|
{
|
||||||
|
auto itTrackList {_trackListWidgets.find(trackListId)};
|
||||||
|
if (itTrackList == std::end(_trackListWidgets))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_container->remove(*itTrackList->second);
|
||||||
|
_trackListWidgets.erase(itTrackList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackLists::refreshView()
|
TrackLists::refreshView()
|
||||||
{
|
{
|
||||||
_container->clear();
|
_container->clear();
|
||||||
|
_trackListWidgets.clear();
|
||||||
addSome();
|
addSome();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +138,9 @@ namespace UserInterface
|
|||||||
|
|
||||||
WTemplate* entry {_container->addNew<Template>(Wt::WString::tr("Lms.Explore.TrackLists.template.entry"))};
|
WTemplate* entry {_container->addNew<Template>(Wt::WString::tr("Lms.Explore.TrackLists.template.entry"))};
|
||||||
entry->bindWidget("name", LmsApplication::createTrackListAnchor(trackList));
|
entry->bindWidget("name", LmsApplication::createTrackListAnchor(trackList));
|
||||||
|
|
||||||
|
assert(_trackListWidgets.find(trackListId) == std::cend(_trackListWidgets));
|
||||||
|
_trackListWidgets.emplace(trackListId, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
#include <Wt/WTemplate.h>
|
#include <Wt/WTemplate.h>
|
||||||
|
|
||||||
#include "services/database/Object.hpp"
|
#include "services/database/Object.hpp"
|
||||||
|
#include "services/database/TrackListId.hpp"
|
||||||
#include "services/database/Types.hpp"
|
#include "services/database/Types.hpp"
|
||||||
|
|
||||||
#include "common/Template.hpp"
|
#include "common/Template.hpp"
|
||||||
@@ -44,6 +46,8 @@ namespace UserInterface
|
|||||||
|
|
||||||
PlayQueueActionTrackListSignal trackListAction;
|
PlayQueueActionTrackListSignal trackListAction;
|
||||||
|
|
||||||
|
void onTrackListDeleted(Database::TrackListId trackListId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Mode
|
enum class Mode
|
||||||
{
|
{
|
||||||
@@ -62,6 +66,7 @@ namespace UserInterface
|
|||||||
Filters& _filters;
|
Filters& _filters;
|
||||||
Wt::WWidget* _currentActiveItem {};
|
Wt::WWidget* _currentActiveItem {};
|
||||||
InfiniteScrollingContainer* _container {};
|
InfiniteScrollingContainer* _container {};
|
||||||
|
std::unordered_map<Database::TrackListId, Wt::WWidget*> _trackListWidgets;
|
||||||
};
|
};
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user