add playlist renaming support

This commit is contained in:
unK
2008-09-06 13:55:35 +02:00
parent 7e5b023d2a
commit c9263b8396
3 changed files with 25 additions and 2 deletions

View File

@@ -302,6 +302,15 @@ void MPDConnection::Move(const string &path, int from, int to) const
}
}
void MPDConnection::Rename(const string &from, const string &to) const
{
if (isConnected)
{
mpd_sendRenameCommand(itsConnection, from.c_str(), to.c_str());
mpd_finishCommand(itsConnection);
}
}
void MPDConnection::GetPlaylistChanges(long long id, SongList &v) const
{
if (isConnected)

View File

@@ -150,6 +150,7 @@ class MPDConnection
void AddToPlaylist(const string &, const Song &) const;
void AddToPlaylist(const string &, const string &) const;
void Move(const string &, int, int) const;
void Rename(const string &, const string &) const;
void StartSearch(bool) const;
void StartFieldSearch(mpd_TagItems);

View File

@@ -57,10 +57,10 @@
#ifdef HAVE_TAGLIB_H
const string tag_screen = "Tag editor";
const string tag_screen_keydesc = "Edit song's tags\n";
const string tag_screen_keydesc = "Edit song's tags/playlist's name\n";
#else
const string tag_screen = "Tag info";
const string tag_screen_keydesc = "Show song's tags\n";
const string tag_screen_keydesc = "Show song's tags/edit playlist's name\n";
#endif
ncmpcpp_config Config;
@@ -1977,6 +1977,19 @@ int main(int argc, char *argv[])
else
ShowMessage("Cannot read file!");
}
else if (wCurrent == mPlaylistList)
{
LOCK_STATUSBAR;
wFooter->WriteXY(0, Config.statusbar_visibility, "[.b]Playlist:[/b] ", 1);
string new_name = wFooter->GetString(mPlaylistList->GetOption());
UNLOCK_STATUSBAR;
if (!new_name.empty() && new_name != mPlaylistList->GetOption())
{
Mpd->Rename(mPlaylistList->GetOption(), new_name);
ShowMessage("Playlist '" + mPlaylistList->GetOption() + "' renamed to '" + new_name + "'");
mPlaylistList->Clear(0);
}
}
}
else if (Keypressed(input, Key.GoToContainingDir))
{