browser: support operations on m3u playlists not created by mpd
This commit is contained in:
@@ -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:
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ void Display::Items(const MPD::Item &item, void *, Menu<MPD::Item> *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<MPD::Item> *menu)
|
||||
Display::SongsInColumns(*item.song, 0, reinterpret_cast<Menu<MPD::Song> *>(menu));
|
||||
return;
|
||||
case MPD::itPlaylist:
|
||||
*menu << Config.browser_playlist_prefix << item.name;
|
||||
*menu << Config.browser_playlist_prefix << ExtractTopName(item.name);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -212,7 +212,7 @@ std::string FindSharedDir(Menu<MPD::Song> *);
|
||||
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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user