diff --git a/src/browser.cpp b/src/browser.cpp index 99adb815..c409dba5 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -552,7 +552,7 @@ std::string Browser::ItemToString(const MPD::Item &item, void *) { if (item.song) return "[..]"; - return "[" + ExtractTopDirectory(item.name) + "]"; + return "[" + ExtractTopName(item.name) + "]"; } case MPD::itSong: { @@ -563,7 +563,7 @@ std::string Browser::ItemToString(const MPD::Item &item, void *) } case MPD::itPlaylist: { - return Config.browser_playlist_prefix.Str() + item.name; + return Config.browser_playlist_prefix.Str() + ExtractTopName(item.name); } default: { diff --git a/src/display.cpp b/src/display.cpp index f0407c04..3735f9c2 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -387,7 +387,7 @@ void Display::Items(const MPD::Item &item, void *, Menu *menu) *menu << "[..]"; return; } - *menu << "[" << ExtractTopDirectory(item.name) << "]"; + *menu << "[" << ExtractTopName(item.name) << "]"; return; } case MPD::itSong: @@ -397,7 +397,7 @@ void Display::Items(const MPD::Item &item, void *, Menu *menu) Display::SongsInColumns(*item.song, 0, reinterpret_cast *>(menu)); return; case MPD::itPlaylist: - *menu << Config.browser_playlist_prefix << item.name; + *menu << Config.browser_playlist_prefix << ExtractTopName(item.name); return; default: return; diff --git a/src/helpers.cpp b/src/helpers.cpp index 56a5a412..8c29e6f8 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -250,7 +250,7 @@ bool CaseInsensitiveSorting::operator()(const MPD::Item &a, const MPD::Item &b) switch (a.type) { case MPD::itDirectory: - return cmp(ExtractTopDirectory(a.name), ExtractTopDirectory(b.name)) < 0; + return cmp(ExtractTopName(a.name), ExtractTopName(b.name)) < 0; case MPD::itPlaylist: return cmp(a.name, b.name) < 0; case MPD::itSong: @@ -369,7 +369,7 @@ std::string GetLineValue(std::string &line, char a, char b, bool once) return result; } -std::string ExtractTopDirectory(const std::string &s) +std::string ExtractTopName(const std::string &s) { size_t slash = s.rfind("/"); return slash != std::string::npos ? s.substr(++slash) : s; diff --git a/src/helpers.h b/src/helpers.h index 81615bf4..fc9d20a9 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -212,7 +212,7 @@ std::string FindSharedDir(Menu *); std::string FindSharedDir(const MPD::SongList &); #endif // HAVE_TAGLIB_H std::string FindSharedDir(const std::string &, const std::string &); -std::string ExtractTopDirectory(const std::string &); +std::string ExtractTopName(const std::string &); std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 55968b39..837f1cb9 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -659,7 +659,7 @@ int main(int argc, char *argv[]) } } else if ( - (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->Main()->Current().type == itPlaylist) + (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->CurrentDir() == "/" && myBrowser->Main()->Current().type == itPlaylist) || (myScreen->ActiveWindow() == myPlaylistEditor->Playlists) ) { @@ -691,7 +691,7 @@ int main(int argc, char *argv[]) myPlaylistEditor->Playlists->Clear(); // make playlists list update itself } # ifndef WIN32 - else if (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->Main()->Current().type != itPlaylist) + else if (myScreen == myBrowser && !myBrowser->Main()->Empty()) { if (!myBrowser->isLocal()) CHECK_MPD_MUSIC_DIR; @@ -713,7 +713,7 @@ int main(int argc, char *argv[]) std::string name = item.type == itSong ? item.song->GetName() : item.name; LockStatusbar(); - Statusbar() << "Delete " << (item.type == itSong ? "file" : "directory") << " \"" << Shorten(TO_WSTRING(name), COLS-30) << "\" ? [" << fmtBold << 'y' << fmtBoldEnd << '/' << fmtBold << 'n' << fmtBoldEnd << "] "; + Statusbar() << "Delete " << (item.type == itSong ? "file" : item.type == itDirectory ? "directory" : "playlist") << " \"" << Shorten(TO_WSTRING(name), COLS-30) << "\" ? [" << fmtBold << 'y' << fmtBoldEnd << '/' << fmtBold << 'n' << fmtBoldEnd << "] "; wFooter->Refresh(); int answer = 0; do diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index a2099c6d..c66cea00 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -879,7 +879,7 @@ void TagEditor::LocateSong(const MPD::Song &s) Dirs->Reset(); // go to the first pos, which is "." (music dir root) // highlight directory we need and get files from it - std::string dir = ExtractTopDirectory(s.GetDirectory()); + std::string dir = ExtractTopName(s.GetDirectory()); for (size_t i = 0; i < Dirs->Size(); ++i) { if ((*Dirs)[i].first == dir)