MCPcopy Create free account
hub / github.com/YACReader/yacreader / comic_pages_sort

Function comic_pages_sort

common/comic.cpp:1064–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062}
1063
1064void comic_pages_sort(QList<QString> &pageNames, YACReaderPageSortingMode sortingMode)
1065{
1066 switch (sortingMode) {
1067 case YACReaderNumericalSorting:
1068 std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI);
1069 break;
1070
1071 case YACReaderHeuristicSorting: {
1072 std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI);
1073
1074 // This heuristic tries to find spreads named like 1011.jpg, which means page 10 and 11 toghether in a single image file
1075 // if the issue has more than 1000 pages lets not use this heuristic to avoid false positives.
1076 // Alternativelly the heuristic could be improved but I don't think it's worth the effort.
1077 if (pageNames.size() >= 1000) {
1078 return;
1079 }
1080
1081 QList<QString> singlePageNames;
1082 QList<QString> doublePageNames;
1083
1084 get_double_pages(pageNames, singlePageNames, doublePageNames);
1085
1086 if (doublePageNames.length() > 0) {
1087 pageNames = merge_pages(singlePageNames, doublePageNames);
1088 }
1089 } break;
1090
1091 case YACReaderAlphabeticalSorting:
1092 std::sort(pageNames.begin(), pageNames.end());
1093 break;
1094 }
1095}

Callers 1

processMethod · 0.85

Calls 2

get_double_pagesFunction · 0.85
merge_pagesFunction · 0.85

Tested by

no test coverage detected