added more options for sorting pages

This commit is contained in:
Luis Ángel San Martín 2015-11-28 17:05:24 +01:00
parent 7b271a1c03
commit d151ccf9e4

View File

@ -15,9 +15,14 @@
#include "QsLog.h" #include "QsLog.h"
enum YACReaderPageSortingMode
{
YACReaderNumericalSorting,
YACReaderHeuristicSorting,
YACReaderAlphabeticalSorting
};
void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sortingMode);
void comic_pages_sort(QList<QString> & pageNames, bool fixDoublePagesSorting);
@ -518,8 +523,8 @@ void FileComic::process()
_cfi=0; _cfi=0;
//TODO, add a setting for fixing bad named double page files, so the user can have control over it. //TODO, add a setting for choosing the type of page sorting used.
comic_pages_sort(_fileNames, true); comic_pages_sort(_fileNames, YACReaderHeuristicSorting);
if(_firstPage == -1) if(_firstPage == -1)
_firstPage = bm->getLastPage(); _firstPage = bm->getLastPage();
@ -967,12 +972,18 @@ QList<QString> merge_pages(QList<QString> & singlePageNames, QList<QString> & do
} }
void comic_pages_sort(QList<QString> & pageNames, bool fixDoublePagesSorting) void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sortingMode)
{
switch(sortingMode)
{
case YACReaderNumericalSorting:
std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI);
break;
case YACReaderHeuristicSorting:
{ {
std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI); std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI);
if(fixDoublePagesSorting)
{
QList<QString> singlePageNames; QList<QString> singlePageNames;
QList<QString> doublePageNames; QList<QString> doublePageNames;
@ -982,6 +993,13 @@ void comic_pages_sort(QList<QString> & pageNames, bool fixDoublePagesSorting)
{ {
pageNames = merge_pages(singlePageNames, doublePageNames); pageNames = merge_pages(singlePageNames, doublePageNames);
} }
break;
}
case YACReaderAlphabeticalSorting:
std::sort(pageNames.begin(), pageNames.end());
break;
} }
} }