Cleaned up sorting.

This commit is contained in:
emb 2015-07-29 07:58:54 -05:00
parent 2cc15babf9
commit bb3c88e411
5 changed files with 11 additions and 23 deletions

View File

@ -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);

View File

@ -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_;

View File

@ -354,7 +354,5 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
metaDB_.injectMetadata(info);
info->sortItems();
return true;
}

View File

@ -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;

View File

@ -585,7 +585,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
}
}
collection->sortItems();
return collection;
}