simplify code responsible for adding items with 'a' more
This commit is contained in:
@@ -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;
|
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)
|
bool Connection::AddRandomSongs(size_t number)
|
||||||
{
|
{
|
||||||
if (!isConnected && !number)
|
if (!isConnected && !number)
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ namespace MPD
|
|||||||
int AddSong(const std::string &); // returns id of added song
|
int AddSong(const std::string &); // returns id of added song
|
||||||
int AddSong(const Song &); // returns id of added song
|
int AddSong(const Song &); // returns id of added song
|
||||||
bool AddRandomSongs(size_t);
|
bool AddRandomSongs(size_t);
|
||||||
|
void Add(const std::string &path) const;
|
||||||
void Delete(int) const;
|
void Delete(int) const;
|
||||||
void DeleteID(int) const;
|
void DeleteID(int) const;
|
||||||
void Delete(const std::string &, int) const;
|
void Delete(const std::string &, int) const;
|
||||||
|
|||||||
@@ -1061,20 +1061,14 @@ int main(int argc, char *argv[])
|
|||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
{
|
{
|
||||||
SongList list;
|
if (myScreen == myPlaylistEditor)
|
||||||
Mpd.GetDirectoryRecursive(path, list);
|
|
||||||
if (!list.empty())
|
|
||||||
myPlaylist->Add(list, 0);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (myScreen == myPlaylistEditor)
|
|
||||||
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
|
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
|
||||||
else
|
|
||||||
Mpd.AddSong(path);
|
|
||||||
}
|
|
||||||
if (myScreen == myPlaylistEditor)
|
|
||||||
myPlaylistEditor->Content->Clear(0); // make it refetch content of playlist
|
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))
|
else if (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
||||||
|
|||||||
Reference in New Issue
Block a user