From e5d82dc868ba8cab6d02530c9959dd6786566ef2 Mon Sep 17 00:00:00 2001 From: casey langen Date: Mon, 12 Feb 2018 08:10:38 -0800 Subject: [PATCH] A couple small bug fixes in the directory browser. --- src/musikcube/app/layout/DirectoryLayout.cpp | 34 +++++++++++--------- src/musikcube/app/model/DirectoryAdapter.cpp | 5 +-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/musikcube/app/layout/DirectoryLayout.cpp b/src/musikcube/app/layout/DirectoryLayout.cpp index 617748c8b..6c4ef5f72 100644 --- a/src/musikcube/app/layout/DirectoryLayout.cpp +++ b/src/musikcube/app/layout/DirectoryLayout.cpp @@ -114,7 +114,7 @@ void DirectoryLayout::SetDirectory(const std::string& directory) { this->rootDirectory = directory; this->adapter->SetRootDirectory(directory); this->directoryList->SetSelectedIndex(0); - this->Refresh(); + this->Refresh(true); } void DirectoryLayout::OnVisibilityChanged(bool visible) { @@ -126,25 +126,29 @@ void DirectoryLayout::OnVisibilityChanged(bool visible) { void DirectoryLayout::RequeryTrackList(ListWindow *view) { size_t selected = this->directoryList->GetSelectedIndex(); - if (selected != ListWindow::NO_SELECTION) { - if (selected == 0 && this->adapter->GetLeafAt(0) == "..") { - return; - } + std::string fullPath = ""; - std::string fullPath = this->adapter->GetFullPathAt(selected); + if (selected == 0 && this->adapter->GetLeafAt(0) == "..") { + return; + } + else if (selected == ListWindow::NO_SELECTION) { + fullPath = this->rootDirectory; /* no sub directories */ + } + else { + fullPath = this->adapter->GetFullPathAt(selected); + } - if (fullPath.size()) { - fullPath = NormalizeDir(fullPath); + if (fullPath.size()) { + fullPath = NormalizeDir(fullPath); - auto query = std::shared_ptr( - new DirectoryTrackListQuery(this->library, fullPath)); + auto query = std::shared_ptr( + new DirectoryTrackListQuery(this->library, fullPath)); - auto hash = query->GetQueryHash(); + auto hash = query->GetQueryHash(); - if (hash != this->queryHash) { - this->queryHash = hash; - this->trackList->Requery(query); - } + if (hash != this->queryHash) { + this->queryHash = hash; + this->trackList->Requery(query); } } } diff --git a/src/musikcube/app/model/DirectoryAdapter.cpp b/src/musikcube/app/model/DirectoryAdapter.cpp index 1de03219f..4ebaa6de5 100755 --- a/src/musikcube/app/model/DirectoryAdapter.cpp +++ b/src/musikcube/app/model/DirectoryAdapter.cpp @@ -35,7 +35,7 @@ #include "stdafx.h" #include - +#include #include #include @@ -241,5 +241,6 @@ IScrollAdapter::EntryPtr DirectoryAdapter::GetEntry(cursespp::ScrollableWindow* --index; } - return IScrollAdapter::EntryPtr(new SingleLineEntry(this->subdirs[index])); + auto text = text::Ellipsize(this->subdirs[index], this->GetWidth()); + return IScrollAdapter::EntryPtr(new SingleLineEntry(text)); }