mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-17 04:08:53 +01:00
Playlist save support
This commit is contained in:
parent
d1a45e650e
commit
cdba6f5df7
@ -42,29 +42,6 @@ CollectionInfo::~CollectionInfo()
|
|||||||
{
|
{
|
||||||
// remove items from the subcollections so their destructors do not
|
// remove items from the subcollections so their destructors do not
|
||||||
// delete the items since the parent collection will delete them.
|
// delete the items since the parent collection will delete them.
|
||||||
if(saveRequest)
|
|
||||||
{
|
|
||||||
std::string file = Utils::combinePath(Configuration::absolutePath, "collections", name, "playlists/favorites.txt");
|
|
||||||
Logger::write(Logger::ZONE_INFO, "Collection", "Saving " + file);
|
|
||||||
|
|
||||||
std::ofstream filestream;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
filestream.open(file.c_str());
|
|
||||||
std::vector<Item *> *saveitems = playlists["favorites"];
|
|
||||||
for(std::vector<Item *>::iterator it = saveitems->begin(); it != saveitems->end(); it++)
|
|
||||||
{
|
|
||||||
filestream << (*it)->name << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
filestream.close();
|
|
||||||
}
|
|
||||||
catch(std::exception &)
|
|
||||||
{
|
|
||||||
Logger::write(Logger::ZONE_ERROR, "Collection", "Save failed: " + file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<CollectionInfo *>::iterator subit;
|
std::vector<CollectionInfo *>::iterator subit;
|
||||||
for (subit = subcollections_.begin(); subit != subcollections_.end(); subit++)
|
for (subit = subcollections_.begin(); subit != subcollections_.end(); subit++)
|
||||||
{
|
{
|
||||||
@ -94,6 +71,36 @@ CollectionInfo::~CollectionInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CollectionInfo::Save()
|
||||||
|
{
|
||||||
|
bool retval = true;
|
||||||
|
if(saveRequest)
|
||||||
|
{
|
||||||
|
std::string file = Utils::combinePath(Configuration::absolutePath, "collections", name, "playlists/favorites.txt");
|
||||||
|
Logger::write(Logger::ZONE_INFO, "Collection", "Saving " + file);
|
||||||
|
|
||||||
|
std::ofstream filestream;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
filestream.open(file.c_str());
|
||||||
|
std::vector<Item *> *saveitems = playlists["favorites"];
|
||||||
|
for(std::vector<Item *>::iterator it = saveitems->begin(); it != saveitems->end(); it++)
|
||||||
|
{
|
||||||
|
filestream << (*it)->name << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
filestream.close();
|
||||||
|
}
|
||||||
|
catch(std::exception &)
|
||||||
|
{
|
||||||
|
Logger::write(Logger::ZONE_ERROR, "Collection", "Save failed: " + file);
|
||||||
|
retval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CollectionInfo::settingsPath() const
|
std::string CollectionInfo::settingsPath() const
|
||||||
{
|
{
|
||||||
return Utils::combinePath(Configuration::absolutePath, "collections", name);
|
return Utils::combinePath(Configuration::absolutePath, "collections", name);
|
||||||
|
|||||||
@ -27,6 +27,7 @@ public:
|
|||||||
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
|
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
|
||||||
virtual ~CollectionInfo();
|
virtual ~CollectionInfo();
|
||||||
std::string settingsPath() const;
|
std::string settingsPath() const;
|
||||||
|
bool Save();
|
||||||
void sortItems();
|
void sortItems();
|
||||||
void addSubcollection(CollectionInfo *info);
|
void addSubcollection(CollectionInfo *info);
|
||||||
bool hasSubcollections();
|
bool hasSubcollections();
|
||||||
|
|||||||
@ -90,6 +90,19 @@ Page::~Page()
|
|||||||
delete selectSoundChunk_;
|
delete selectSoundChunk_;
|
||||||
selectSoundChunk_ = NULL;
|
selectSoundChunk_ = NULL;
|
||||||
}
|
}
|
||||||
|
CollectionVector_T::iterator itc = collections_.begin();
|
||||||
|
|
||||||
|
while(itc != collections_.end())
|
||||||
|
{
|
||||||
|
itc->collection->Save();
|
||||||
|
|
||||||
|
if(itc->collection)
|
||||||
|
{
|
||||||
|
delete itc->collection;
|
||||||
|
}
|
||||||
|
collections_.erase(itc);
|
||||||
|
itc = collections_.begin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -554,6 +567,7 @@ bool Page::popCollection()
|
|||||||
void Page::nextPlaylist()
|
void Page::nextPlaylist()
|
||||||
{
|
{
|
||||||
MenuInfo_S &info = collections_.back();
|
MenuInfo_S &info = collections_.back();
|
||||||
|
info.collection->Save();
|
||||||
unsigned int numlists = info.collection->playlists.size();
|
unsigned int numlists = info.collection->playlists.size();
|
||||||
|
|
||||||
for(unsigned int i = 0; i <= numlists; ++i)
|
for(unsigned int i = 0; i <= numlists; ++i)
|
||||||
@ -619,7 +633,11 @@ void Page::update(float dt)
|
|||||||
std::list<MenuInfo_S>::iterator next = del;
|
std::list<MenuInfo_S>::iterator next = del;
|
||||||
++next;
|
++next;
|
||||||
|
|
||||||
if(info.collection) delete info.collection;
|
if(info.collection)
|
||||||
|
{
|
||||||
|
info.collection->Save();
|
||||||
|
delete info.collection;
|
||||||
|
}
|
||||||
deleteCollections_.erase(del);
|
deleteCollections_.erase(del);
|
||||||
del = next;
|
del = next;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -389,7 +389,6 @@ void RetroFE::run()
|
|||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user