PlaylistList (wxPanel* parent, ContentStore* content_store)
: _sizer (new wxBoxSizer(wxVERTICAL))
, _content_store (content_store)
PlaylistList (wxPanel* parent, ContentStore* content_store)
: _sizer (new wxBoxSizer(wxVERTICAL))
, _content_store (content_store)
{
auto label = new wxStaticText (parent, wxID_ANY, wxEmptyString);
label->SetLabelMarkup (_("<b>Playlists</b>"));
{
auto label = new wxStaticText (parent, wxID_ANY, wxEmptyString);
label->SetLabelMarkup (_("<b>Playlists</b>"));
_list->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, bind(&PlaylistList::selection_changed, this));
_new->Bind (wxEVT_BUTTON, bind(&PlaylistList::new_playlist, this));
_delete->Bind (wxEVT_BUTTON, bind(&PlaylistList::delete_playlist, this));
_list->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, bind(&PlaylistList::selection_changed, this));
_new->Bind (wxEVT_BUTTON, bind(&PlaylistList::new_playlist, this));
_delete->Bind (wxEVT_BUTTON, bind(&PlaylistList::delete_playlist, this));
shared_ptr<SignalSPL> spl (new SignalSPL(wx_to_std(_("New Playlist"))));
add_playlist_to_model (spl);
add_playlist_to_view (spl);
_list->SetItemState (_list->GetItemCount() - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
shared_ptr<SignalSPL> spl (new SignalSPL(wx_to_std(_("New Playlist"))));
add_playlist_to_model (spl);
add_playlist_to_view (spl);
_list->SetItemState (_list->GetItemCount() - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
- boost::filesystem::remove (*dir / (_playlists[selected]->id() + ".xml"));
- _list->DeleteItem (selected);
- _playlists.erase (_playlists.begin() + selected);
+ boost::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml"));
+ _list->DeleteItem(*index);
+ _playlists.erase(_playlists.begin() + *index);
_down->Bind (wxEVT_BUTTON, bind(&PlaylistContent::down_clicked, this));
_add->Bind (wxEVT_BUTTON, bind(&PlaylistContent::add_clicked, this));
_remove->Bind (wxEVT_BUTTON, bind(&PlaylistContent::remove_clicked, this));
_down->Bind (wxEVT_BUTTON, bind(&PlaylistContent::down_clicked, this));
_add->Bind (wxEVT_BUTTON, bind(&PlaylistContent::add_clicked, this));
_remove->Bind (wxEVT_BUTTON, bind(&PlaylistContent::remove_clicked, this));
- auto tmp = (*_playlist)[s];
- (*_playlist)[s] = (*_playlist)[s-1];
- (*_playlist)[s-1] = tmp;
+ _playlist->swap(s, s - 1);
set_item (s - 1, (*_playlist)[s-1]);
set_item (s, (*_playlist)[s]);
set_item (s - 1, (*_playlist)[s-1]);
set_item (s, (*_playlist)[s]);
- auto tmp = (*_playlist)[s];
- (*_playlist)[s] = (*_playlist)[s+1];
- (*_playlist)[s+1] = tmp;
+ _playlist->swap(s, s + 1);
set_item (s + 1, (*_playlist)[s+1]);
set_item (s, (*_playlist)[s]);
set_item (s + 1, (*_playlist)[s+1]);
set_item (s, (*_playlist)[s]);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
- auto dir = Config::instance()->player_playlist_directory();
- if (!dir) {
- error_dialog (this, _("No playlist folder is specified in preferences. Please set one and then try again."));
- return;
+ if (auto dir = Config::instance()->player_playlist_directory()) {
+ playlist->write(*dir / (playlist->id() + ".xml"));