mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-27 10:15:05 +01:00
Cleaned up sorting.
This commit is contained in:
parent
2cc15babf9
commit
bb3c88e411
@ -30,6 +30,7 @@ CollectionInfo::CollectionInfo(std::string name,
|
||||
, metadataType(metadataType)
|
||||
, metadataPath_(metadataPath)
|
||||
, extensions_(extensions)
|
||||
, menusort(true)
|
||||
{
|
||||
}
|
||||
|
||||
@ -85,9 +86,13 @@ bool CollectionInfo::hasSubcollections()
|
||||
|
||||
bool CollectionInfo::itemIsLess(Item *lhs, Item *rhs)
|
||||
{
|
||||
if(lhs->leaf && !rhs->leaf) return true;
|
||||
if(!lhs->leaf && rhs->leaf) return false;
|
||||
if(!lhs->collectionInfo->menusort && lhs->leaf && rhs->leaf) return false;
|
||||
return lhs->lowercaseFullTitle() < rhs->lowercaseFullTitle();
|
||||
}
|
||||
|
||||
|
||||
void CollectionInfo::sortItems()
|
||||
{
|
||||
std::sort(items.begin(), items.end(), itemIsLess);
|
||||
|
||||
@ -35,7 +35,7 @@ public:
|
||||
std::string metadataType;
|
||||
std::string launcher;
|
||||
std::vector<Item *> items;
|
||||
|
||||
bool menusort;
|
||||
private:
|
||||
std::vector<CollectionInfo *> subcollections_;
|
||||
std::string metadataPath_;
|
||||
|
||||
@ -354,7 +354,5 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
|
||||
metaDB_.injectMetadata(info);
|
||||
|
||||
info->sortItems();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,17 +85,10 @@ bool MenuParser::buildTextMenu(CollectionInfo *collection, bool sort)
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(collection->items.begin(), collection->items.end(), VectorSort);
|
||||
|
||||
// todo: sorting should occur within the collection itself, not externally
|
||||
if(sort)
|
||||
{
|
||||
// sort the menu if requested
|
||||
std::sort( menuItems.begin(), menuItems.end(), VectorSort);
|
||||
}
|
||||
|
||||
//todo: sorting
|
||||
collection->menusort = sort;
|
||||
collection->items.insert(collection->items.begin(), menuItems.begin(), menuItems.end());
|
||||
collection->sortItems();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -147,17 +140,9 @@ bool MenuParser::buildLegacyXmlMenu(CollectionInfo *collection, bool sort)
|
||||
|
||||
menuItems.push_back(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::sort( collection->items.begin(), collection->items.end(), VectorSort);
|
||||
|
||||
// todo: sorting should occur within the collection itself, not externally
|
||||
if(sort)
|
||||
{
|
||||
// sort the menu if requested
|
||||
std::sort( menuItems.begin(), menuItems.end(), VectorSort);
|
||||
}
|
||||
|
||||
collection->menusort = sort;
|
||||
collection->items.insert(collection->items.begin(), menuItems.begin(), menuItems.end());
|
||||
|
||||
retVal = true;
|
||||
|
||||
@ -585,7 +585,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
collection->sortItems();
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user