CategoryListView widgets can now requery themselves automatically using

visibility events, instead of relying on their parent. This fixes bugs
related to "JumpTo".
This commit is contained in:
casey langen 2020-10-21 11:36:21 -07:00
parent 14c73d9dee
commit 13d8b3b6c4
5 changed files with 18 additions and 14 deletions

View File

@ -228,15 +228,6 @@ void BrowseLayout::ScrollTo(const std::string& fieldType, int64_t fieldId) {
this->categoryList->SetFrameTitle(getTitleForCategory(fieldType));
}
void BrowseLayout::OnVisibilityChanged(bool visible) {
LayoutBase::OnVisibilityChanged(visible);
if (visible) {
this->categoryList->Requery(
this->categoryList->GetSelectedId());
}
}
void BrowseLayout::OnIndexerProgress(int count) {
this->Post(message::IndexerProgress);
}
@ -370,6 +361,7 @@ bool BrowseLayout::ProcessPlaylistOperation(const std::string& key) {
this->categoryList->Requery(this->categoryList->GetFilter(), id);
});
}
return true;
}
else if (Hotkeys::Is(Hotkeys::BrowsePlaylistsDelete, key)) {
if (this->GetFocus() == this->categoryList) {
@ -382,6 +374,7 @@ bool BrowseLayout::ProcessPlaylistOperation(const std::string& key) {
});
}
}
return true;
}
}

View File

@ -58,7 +58,6 @@ namespace musik {
virtual ~BrowseLayout();
virtual void OnVisibilityChanged(bool visible) override;
virtual bool KeyPress(const std::string& key) override;
virtual void ProcessMessage(musik::core::runtime::IMessage &message) override;

View File

@ -334,8 +334,8 @@ static void handleJumpTo(
IMessageQueue& messageQueue,
TrackPtr track)
{
int64_t type;
int64_t id;
int64_t type = -1LL;
int64_t id = -1LL;
if (index == 0) {
type = cube::message::category::Album;
@ -350,8 +350,10 @@ static void handleJumpTo(
id = track->GetInt64(library::constants::Track::GENRE_ID);
}
messageQueue.Broadcast(runtime::Message::Create(
nullptr, cube::message::JumpToCategory, type, id));
if (type != -1LL && id != -1LL) {
messageQueue.Broadcast(runtime::Message::Create(
nullptr, cube::message::JumpToCategory, type, id));
}
}
static void showAddCategorySelectionToPlaylistOverlay(

View File

@ -92,6 +92,14 @@ CategoryListView::~CategoryListView() {
delete adapter;
}
void CategoryListView::OnVisibilityChanged(bool visible) {
ListWindow::OnVisibilityChanged(visible);
if (visible && !this->activeQuery) {
this->Requery(this->GetSelectedId());
}
}
void CategoryListView::RequeryWithField(
const std::string& fieldName,
const std::string& filter,

View File

@ -83,6 +83,8 @@ namespace musik {
std::string GetFieldName();
void SetFieldName(const std::string& fieldName);
virtual void OnVisibilityChanged(bool visible) override;
protected:
virtual cursespp::IScrollAdapter& GetScrollAdapter();
virtual bool OnEntryContextMenu(size_t index);