simplify code responsible for adding items with 'a' more

master
Andrzej Rybczak 17 years ago
parent 68b724d9de
commit 7a85a15ff2
  1. 8
      src/mpdpp.cpp
  2. 1
      src/mpdpp.h
  3. 18
      src/ncmpcpp.cpp

@ -563,6 +563,14 @@ int Connection::AddSong(const Song &s)
return !s.Empty() ? (AddSong((!s.isFromDB() ? "file://" : "") + (s.Localized() ? locale_to_utf_cpy(s.GetFile()) : s.GetFile()))) : -1;
}
void Connection::Add(const std::string &path) const
{
if (!isConnected)
return;
mpd_sendAddCommand(itsConnection, path.c_str());
mpd_finishCommand(itsConnection);
}
bool Connection::AddRandomSongs(size_t number)
{
if (!isConnected && !number)

@ -153,6 +153,7 @@ namespace MPD
int AddSong(const std::string &); // returns id of added song
int AddSong(const Song &); // returns id of added song
bool AddRandomSongs(size_t);
void Add(const std::string &path) const;
void Delete(int) const;
void DeleteID(int) const;
void Delete(const std::string &, int) const;

@ -1061,20 +1061,14 @@ int main(int argc, char *argv[])
UnlockStatusbar();
if (!path.empty())
{
SongList list;
Mpd.GetDirectoryRecursive(path, list);
if (!list.empty())
myPlaylist->Add(list, 0);
else
{
if (myScreen == myPlaylistEditor)
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
else
Mpd.AddSong(path);
}
if (myScreen == myPlaylistEditor)
{
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
myPlaylistEditor->Content->Clear(0); // make it refetch content of playlist
FreeSongList(list);
}
else
Mpd.Add(path);
UpdateStatusImmediately = 1;
}
}
else if (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))

Loading…
Cancel
Save